summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
commite8a196082586bb68e0bf254a8f6f4b8f39071f32 (patch)
treeb03dbbd1b5be6092ed5e9bcb3806aa2d4938bba3 /src
parentdd2f7ce46df53f2c377c02d1bf4df8adcf092072 (diff)
Imported Upstream version 2.3.3
Diffstat (limited to 'src')
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp92
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h18
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp97
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h41
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp14
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h14
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp9
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h6
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp10
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h4
-rw-r--r--src/backend/bookshelfmodel/distributionitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/distributionitem.h10
-rw-r--r--src/backend/bookshelfmodel/item.cpp3
-rw-r--r--src/backend/bookshelfmodel/item.h26
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/languageitem.h4
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h10
-rw-r--r--src/backend/btmoduletreeitem.cpp431
-rw-r--r--src/backend/btmoduletreeitem.h243
-rw-r--r--src/backend/config/cbtconfig.cpp442
-rw-r--r--src/backend/cswordmodulesearch.cpp102
-rw-r--r--src/backend/cswordmodulesearch.h118
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp282
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h160
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp58
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h66
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h28
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp254
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h76
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp1328
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h636
-rw-r--r--src/backend/filters/bt_gbfhtml.cpp436
-rw-r--r--src/backend/filters/bt_gbfhtml.h43
-rw-r--r--src/backend/filters/bt_osishtml.cpp1117
-rw-r--r--src/backend/filters/bt_osishtml.h88
-rw-r--r--src/backend/filters/bt_plainhtml.cpp100
-rw-r--r--src/backend/filters/bt_plainhtml.h18
-rw-r--r--src/backend/filters/bt_thmlhtml.cpp646
-rw-r--r--src/backend/filters/bt_thmlhtml.h46
-rw-r--r--src/backend/filters/bt_thmlplain.cpp380
-rw-r--r--src/backend/filters/bt_thmlplain.h12
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp84
-rw-r--r--src/backend/filters/osismorphsegmentation.h16
-rw-r--r--src/backend/keys/cswordkey.cpp237
-rw-r--r--src/backend/keys/cswordkey.h147
-rw-r--r--src/backend/keys/cswordldkey.cpp100
-rw-r--r--src/backend/keys/cswordldkey.h102
-rw-r--r--src/backend/keys/cswordtreekey.cpp94
-rw-r--r--src/backend/keys/cswordtreekey.h94
-rw-r--r--src/backend/keys/cswordversekey.cpp461
-rw-r--r--src/backend/keys/cswordversekey.h140
-rw-r--r--src/backend/managers/btstringmgr.cpp206
-rw-r--r--src/backend/managers/btstringmgr.h50
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp265
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h92
-rw-r--r--src/backend/managers/clanguagemgr.cpp960
-rw-r--r--src/backend/managers/clanguagemgr.h234
-rw-r--r--src/backend/managers/creferencemanager.cpp666
-rw-r--r--src/backend/managers/creferencemanager.h154
-rw-r--r--src/backend/managers/cswordbackend.cpp842
-rw-r--r--src/backend/managers/cswordbackend.h414
-rw-r--r--src/backend/rendering/cbookdisplay.cpp160
-rw-r--r--src/backend/rendering/cbookdisplay.h32
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp62
-rw-r--r--src/backend/rendering/cchapterdisplay.h16
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp268
-rw-r--r--src/backend/rendering/cdisplayrendering.h18
-rw-r--r--src/backend/rendering/centrydisplay.cpp62
-rw-r--r--src/backend/rendering/centrydisplay.h16
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp362
-rw-r--r--src/backend/rendering/chtmlexportrendering.h62
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp38
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h32
-rw-r--r--src/backend/rendering/ctextrendering.cpp382
-rw-r--r--src/backend/rendering/ctextrendering.h118
-rw-r--r--src/bibletime.cpp374
-rw-r--r--src/bibletime.h497
-rw-r--r--src/bibletime_dbus.cpp276
-rw-r--r--src/bibletime_dbus_adaptor.cpp61
-rw-r--r--src/bibletime_dbus_adaptor.h159
-rw-r--r--src/bibletime_init.cpp714
-rw-r--r--src/bibletime_slots.cpp733
-rw-r--r--src/bibletimeapp.cpp17
-rw-r--r--src/bibletimeapp.h8
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp145
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h86
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp88
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h76
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp84
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h35
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp237
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h24
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp282
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h115
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp188
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h29
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp203
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h67
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp241
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h43
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp340
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp281
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h83
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp432
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.h105
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp625
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.h107
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp380
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp320
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h53
-rw-r--r--src/frontend/btaboutmoduledialog.cpp13
-rw-r--r--src/frontend/btaboutmoduledialog.h11
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp287
-rw-r--r--src/frontend/btbookshelfdockwidget.h43
-rw-r--r--src/frontend/cdragdrop.cpp33
-rw-r--r--src/frontend/cdragdrop.h100
-rw-r--r--src/frontend/cdragdropmgr.cpp326
-rw-r--r--src/frontend/cdragdropmgr.h224
-rw-r--r--src/frontend/cexportmanager.cpp844
-rw-r--r--src/frontend/cexportmanager.h112
-rw-r--r--src/frontend/cinfodisplay.cpp744
-rw-r--r--src/frontend/cinfodisplay.h64
-rw-r--r--src/frontend/cinputdialog.cpp112
-rw-r--r--src/frontend/cinputdialog.h30
-rw-r--r--src/frontend/cmdiarea.cpp363
-rw-r--r--src/frontend/cmdiarea.h158
-rw-r--r--src/frontend/cmodulechooserdialog.cpp177
-rw-r--r--src/frontend/cmodulechooserdialog.h147
-rw-r--r--src/frontend/cmoduleindexdialog.cpp128
-rw-r--r--src/frontend/cmoduleindexdialog.h56
-rw-r--r--src/frontend/cprinter.cpp185
-rw-r--r--src/frontend/cprinter.h38
-rw-r--r--src/frontend/crossrefrendering.cpp111
-rw-r--r--src/frontend/crossrefrendering.h23
-rw-r--r--src/frontend/display/btcolorwidget.cpp68
-rw-r--r--src/frontend/display/btcolorwidget.h31
-rw-r--r--src/frontend/display/btfontsizewidget.cpp51
-rw-r--r--src/frontend/display/btfontsizewidget.h29
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp113
-rw-r--r--src/frontend/display/bthtmlfindtext.h29
-rw-r--r--src/frontend/display/bthtmljsobject.cpp224
-rw-r--r--src/frontend/display/bthtmljsobject.h82
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp479
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h147
-rw-r--r--src/frontend/display/cdisplay.cpp137
-rw-r--r--src/frontend/display/cdisplay.h268
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp404
-rw-r--r--src/frontend/display/chtmlwritedisplay.h148
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp139
-rw-r--r--src/frontend/display/cplainwritedisplay.h112
-rw-r--r--src/frontend/display/creaddisplay.cpp116
-rw-r--r--src/frontend/display/creaddisplay.h78
-rw-r--r--src/frontend/display/cwritedisplay.h46
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp200
-rw-r--r--src/frontend/displaywindow/btactioncollection.h33
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp78
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h39
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp624
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h208
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp186
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h90
-rw-r--r--src/frontend/displaywindow/cbuttons.cpp230
-rw-r--r--src/frontend/displaywindow/cbuttons.h93
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp216
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h70
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp694
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h251
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp52
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h15
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp202
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h88
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp520
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h178
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp151
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.h82
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.cpp306
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.h106
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp209
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h120
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp259
-rw-r--r--src/frontend/displaywindow/creadwindow.h92
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp202
-rw-r--r--src/frontend/displaywindow/cwritewindow.h76
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp378
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.h21
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp170
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.h60
-rw-r--r--src/frontend/keychooser/bthistory.cpp165
-rw-r--r--src/frontend/keychooser/bthistory.h97
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp408
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h100
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp233
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h94
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp48
-rw-r--r--src/frontend/keychooser/ckeychooser.h152
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp510
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h258
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp227
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h94
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp18
-rw-r--r--src/frontend/keychooser/cscrollbutton.h2
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp114
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h82
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp142
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h92
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp51
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h31
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp112
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h78
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp362
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h126
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp194
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.h45
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.cpp198
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.h61
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp21
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.h53
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.cpp244
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.h39
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.cpp1308
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.h194
-rw-r--r--src/frontend/mainindex/bookshelf/actionenum.h16
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.cpp7
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.h9
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.cpp3
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.h37
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.cpp108
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.h19
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.cpp1044
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.h310
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp58
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h31
-rw-r--r--src/frontend/mainindex/btbookshelfview.cpp36
-rw-r--r--src/frontend/mainindex/btbookshelfview.h2
-rw-r--r--src/frontend/profile/cprofile.cpp666
-rw-r--r--src/frontend/profile/cprofile.h174
-rw-r--r--src/frontend/profile/cprofilemgr.cpp146
-rw-r--r--src/frontend/profile/cprofilemgr.h70
-rw-r--r--src/frontend/profile/cprofilewindow.cpp64
-rw-r--r--src/frontend/profile/cprofilewindow.h178
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp82
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h45
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp188
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h65
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp67
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h15
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp403
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h102
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp15
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h47
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp770
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h221
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp1093
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h250
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp41
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h23
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp418
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h186
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp407
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h111
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp383
-rw-r--r--src/frontend/searchdialog/csearchdialog.h182
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp37
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h23
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp376
-rw-r--r--src/frontend/searchdialog/csearchresultview.h142
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp119
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h53
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp577
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h99
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp422
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h99
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp137
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h40
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp282
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h37
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp428
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.h74
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.cpp451
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.h59
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp16
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h12
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp704
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h95
-rw-r--r--src/main.cpp176
-rw-r--r--src/tests/backend/config/cbtconfig_test.cpp37
-rw-r--r--src/tests/bibletime_test.cpp5
-rw-r--r--src/tests/bibletime_test.h17
-rw-r--r--src/util/cpointers.cpp30
-rw-r--r--src/util/cpointers.h144
-rw-r--r--src/util/cresmgr.cpp950
-rw-r--r--src/util/cresmgr.h972
-rw-r--r--src/util/ctoolclass.cpp372
-rw-r--r--src/util/ctoolclass.h110
-rw-r--r--src/util/dialogutil.cpp81
-rw-r--r--src/util/dialogutil.h7
-rw-r--r--src/util/directoryutil.cpp534
-rw-r--r--src/util/directoryutil.h160
-rw-r--r--src/util/migrationutil.cpp124
-rw-r--r--src/util/migrationutil.h36
303 files changed, 28303 insertions, 29164 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 6764a88..99f83ba 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -17,8 +17,7 @@
#include "util/directoryutil.h"
BtBookshelfModel::BtBookshelfModel(QObject *parent)
- : QAbstractListModel(parent)
-{
+ : QAbstractListModel(parent) {
// Intentionally empty
}
@@ -41,7 +40,7 @@ QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
case ModuleNameRole: // Qt::DisplayRole
return m_data.at(row)->name();
case ModuleIconRole: // Qt::DecorationRole
- return categoryIcon(m_data.at(row)->category());
+ return moduleIcon(m_data.at(row));
case ModulePointerRole:
return qVariantFromValue((void*) m_data.at(row));
default:
@@ -50,19 +49,58 @@ QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
}
QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
+ int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal &&
- section == 0)
- {
+ section == 0) {
return tr("Module");
}
return QVariant();
}
-QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category)
-{
+QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
+ typedef util::filesystem::DirectoryUtil DU;
+
+ /// \todo Make CSwordModuleInfo::isLocked() const and remove const_cast:
+ CSwordModuleInfo *module(const_cast<CSwordModuleInfo*>(m));
+
+ CSwordModuleInfo::Category cat(module->category());
+ switch (cat) {
+ case CSwordModuleInfo::Bibles:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::bible::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::bible::icon_unlocked);
+ }
+ case CSwordModuleInfo::Commentaries:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::commentary::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::commentary::icon_unlocked);
+ }
+ case CSwordModuleInfo::Lexicons:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::lexicon::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::lexicon::icon_unlocked);
+ }
+ case CSwordModuleInfo::Books:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::book::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::book::icon_unlocked);
+ }
+ case CSwordModuleInfo::Cult:
+ case CSwordModuleInfo::Images:
+ case CSwordModuleInfo::DailyDevotional:
+ case CSwordModuleInfo::Glossary:
+ case CSwordModuleInfo::UnknownCategory:
+ default:
+ return categoryIcon(cat);
+ }
+}
+
+QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category) {
typedef util::filesystem::DirectoryUtil DU;
switch (category) {
@@ -89,8 +127,7 @@ QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category)
}
QString BtBookshelfModel::categoryName(
- const CSwordModuleInfo::Category &category)
-{
+ const CSwordModuleInfo::Category &category) {
switch (category) {
case CSwordModuleInfo::Bibles:
return tr("Bibles");
@@ -114,13 +151,17 @@ QString BtBookshelfModel::categoryName(
}
QString BtBookshelfModel::languageName(
- const CLanguageMgr::Language *language)
-{
+ const CLanguageMgr::Language *language) {
return language->translatedName();
}
-void BtBookshelfModel::clear() {
+void BtBookshelfModel::clear(bool destroy) {
+ if (m_data.size() <= 0) return;
+
beginRemoveRows(QModelIndex(), 0, m_data.size() - 1);
+ if (destroy) {
+ qDeleteAll(m_data);
+ }
m_data.clear();
endRemoveRows();
}
@@ -152,27 +193,40 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
beginInsertRows(QModelIndex(), m_data.size(),
m_data.size() + newModules.size() - 1);
+#if QT_VERSION >= 0x040500
m_data.append(newModules);
+#else
+ Q_FOREACH(CSwordModuleInfo *module, newModules) {
+ m_data.append(module);
+ }
+#endif
endInsertRows();
}
-void BtBookshelfModel::removeModule(CSwordModuleInfo * const module) {
+void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
+ bool destroy)
+{
const int index(m_data.indexOf(module));
if (index == -1) return;
beginRemoveRows(QModelIndex(), index, index);
m_data.removeAt(index);
endRemoveRows();
+ if (destroy) delete module;
}
-void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules) {
- removeModules(modules.toSet());
+void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules,
+ bool destroy)
+{
+ removeModules(modules.toSet(), destroy);
}
-void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules) {
+void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules,
+ bool destroy)
+{
// This is inefficient, since signals are emitted for each removed module:
Q_FOREACH(CSwordModuleInfo *module, modules) {
- removeModule(module);
+ removeModule(module, destroy);
}
}
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index c268d2c..01fc260 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -18,7 +18,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
class BtBookshelfModel: public QAbstractListModel {
- Q_OBJECT
+ Q_OBJECT
public:
enum ModuleRole {
ModuleNameRole = Qt::DisplayRole,
@@ -39,21 +39,25 @@ class BtBookshelfModel: public QAbstractListModel {
inline CSwordModuleInfo *module(const QModelIndex &index) const {
return (CSwordModuleInfo *)
- data(index, BtBookshelfModel::ModulePointerRole)
- .value<void *>();
+ data(index, BtBookshelfModel::ModulePointerRole)
+ .value<void *>();
}
+ static QIcon moduleIcon(const CSwordModuleInfo *module);
static QIcon categoryIcon(const CSwordModuleInfo::Category &category);
static QString categoryName(const CSwordModuleInfo::Category &category);
static QString languageName(const CLanguageMgr::Language *language);
- void clear();
+ void clear(bool destroy = false);
void addModule(CSwordModuleInfo * const module);
void addModules(const QSet<CSwordModuleInfo *> &modules);
void addModules(const QList<CSwordModuleInfo *> &modules);
- void removeModule(CSwordModuleInfo * const module);
- void removeModules(const QSet<CSwordModuleInfo *> &modules);
- void removeModules(const QList<CSwordModuleInfo *> &modules);
+ void removeModule(CSwordModuleInfo * const module,
+ bool destroy = false);
+ void removeModules(const QSet<CSwordModuleInfo *> &modules,
+ bool destroy = false);
+ void removeModules(const QList<CSwordModuleInfo *> &modules,
+ bool destroy = false);
CSwordModuleInfo* getModule(const QString &name) const;
inline const QList<CSwordModuleInfo *> &modules() const {
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 47526e9..8e457e7 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -22,13 +22,18 @@
using namespace BookshelfModel;
BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
- : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_checkable(false), m_defaultChecked(false)
-{
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_checkable(false), m_defaultChecked(false) {
m_groupingOrder.push_back(GROUP_CATEGORY);
m_groupingOrder.push_back(GROUP_LANGUAGE);
}
+BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_groupingOrder(g), m_checkable(false), m_defaultChecked(false) {
+ // Intentionally empty
+}
+
BtBookshelfTreeModel::~BtBookshelfTreeModel() {
delete m_rootItem;
}
@@ -46,15 +51,15 @@ bool BtBookshelfTreeModel::hasChildren(const QModelIndex &parent) const {
}
QModelIndex BtBookshelfTreeModel::index(int row, int column,
- const QModelIndex &parent) const
-{
+ const QModelIndex &parent) const {
if (!hasIndex(row, column, parent)) return QModelIndex();
Item *parentItem(getItem(parent));
Item *childItem(parentItem->childAt(row));
if (childItem != 0) {
return createIndex(row, column, childItem);
- } else {
+ }
+ else {
return QModelIndex();
}
}
@@ -107,8 +112,7 @@ QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
const QVariant &value,
- int role)
-{
+ int role) {
typedef QPair<Item *, QModelIndex> IP;
if (role == Qt::CheckStateRole) {
@@ -164,9 +168,8 @@ Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex &index) const {
}
QVariant BtBookshelfTreeModel::headerData(int section,
- Qt::Orientation orientation,
- int role) const
-{
+ Qt::Orientation orientation,
+ int role) const {
if (orientation == Qt::Horizontal) {
return m_sourceModel->headerData(section, orientation, role);
}
@@ -177,9 +180,9 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
if (m_sourceModel == sourceModel) return;
if (m_sourceModel != 0) {
- disconnect(this, SLOT(moduleInserted(QModelIndex,int,int)));
- disconnect(this, SLOT(moduleRemoved(QModelIndex,int,int)));
- disconnect(this, SLOT(moduleDataChanged(QModelIndex,QModelIndex)));
+ disconnect(this, SLOT(moduleInserted(QModelIndex, int, int)));
+ disconnect(this, SLOT(moduleRemoved(QModelIndex, int, int)));
+ disconnect(this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
delete m_rootItem;
m_modules.clear();
@@ -190,10 +193,10 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
m_sourceModel = sourceModel;
if (sourceModel != 0) {
- connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(moduleRemoved(QModelIndex,int,int)));
- connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
- this, SLOT(moduleInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),
+ this, SLOT(moduleRemoved(QModelIndex, int, int)));
+ connect(sourceModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
+ this, SLOT(moduleInserted(QModelIndex, int, int)));
connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
@@ -202,7 +205,8 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
addModule(module, m_defaultChecked);
}
- } else {
+ }
+ else {
for (int i(0); i < sourceModel->rowCount(); i++) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
@@ -239,7 +243,8 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
addModule(module, checked.contains(module));
}
- } else {
+ }
+ else {
for (int i(0); i < m_sourceModel->rowCount(); i++) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
@@ -273,7 +278,8 @@ void BtBookshelfTreeModel::setCheckable(bool checkable) {
queue.append(childIndex);
}
}
- } while (!queue.isEmpty());
+ }
+ while (!queue.isEmpty());
}
}
@@ -306,8 +312,7 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
QModelIndex parentIndex,
Grouping &intermediateGrouping,
- bool checked)
-{
+ bool checked) {
Q_ASSERT(module != 0);
if (!intermediateGrouping.empty()) {
@@ -325,7 +330,8 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
}
intermediateGrouping.pop_front();
addModule(module, newIndex, intermediateGrouping, checked);
- } else {
+ }
+ else {
Item *parentItem(getItem(parentIndex));
ModuleItem *newItem(new ModuleItem(module));
newItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
@@ -376,7 +382,8 @@ Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
Item *item(static_cast<Item*>(index.internalPointer()));
Q_ASSERT(item != 0);
return item;
- } else {
+ }
+ else {
return m_rootItem;
}
}
@@ -395,10 +402,12 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
haveCheckedChildren = true;
haveUncheckedChildren = true;
break;
- } else if (state == Qt::Checked) {
+ }
+ else if (state == Qt::Checked) {
haveCheckedChildren = true;
if (haveUncheckedChildren) break;
- } else if (state == Qt::Unchecked) {
+ }
+ else if (state == Qt::Unchecked) {
haveUncheckedChildren = true;
if (haveCheckedChildren) break;
}
@@ -408,10 +417,12 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
if (haveCheckedChildren) {
if (haveUncheckedChildren) {
newState = Qt::PartiallyChecked;
- } else {
+ }
+ else {
newState = Qt::Checked;
}
- } else {
+ }
+ else {
newState = Qt::Unchecked;
}
if (newState == oldState) break;
@@ -422,8 +433,7 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
}
void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight)
-{
+ const QModelIndex &bottomRight) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -444,8 +454,7 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
}
void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
- int end)
-{
+ int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -459,8 +468,7 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
}
void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
- int end)
-{
+ int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -472,3 +480,22 @@ void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
removeModule(module);
}
}
+
+QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o) {
+ os << o.size();
+ Q_FOREACH(BtBookshelfTreeModel::Group g, o) {
+ os << (int) g;
+ }
+ return os;
+}
+
+QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o) {
+ int s;
+ is >> s;
+ for (int i(0); i < s; i++) {
+ int g;
+ is >> g;
+ o.append((BtBookshelfTreeModel::Group) g);
+ }
+ return is;
+}
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 0a84ac3..84293e1 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -20,34 +20,37 @@
#include "backend/bookshelfmodel/item.h"
namespace BookshelfModel {
- class ModuleItem;
+class ModuleItem;
}
class CSwordModuleInfo;
+class QDataStream;
class BtBookshelfTreeModel: public QAbstractItemModel {
- Q_OBJECT
+ Q_OBJECT
+ Q_ENUMS(Group)
- typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
public:
enum ModuleRole {
CheckStateRole = BtBookshelfModel::UserRole,
UserRole = BtBookshelfModel::UserRole + 100
};
- enum Group { GROUP_CATEGORY, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
+ enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
+ BtBookshelfTreeModel(const Grouping &grouping, QObject *parent = 0);
virtual ~BtBookshelfTreeModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual bool hasChildren(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex parent(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
@@ -57,15 +60,23 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
int role);
void setSourceModel(QAbstractListModel *sourceModel);
- inline QAbstractListModel *sourceModel() const { return m_sourceModel; }
+ inline QAbstractListModel *sourceModel() const {
+ return m_sourceModel;
+ }
void setGroupingOrder(const Grouping &groupingOrder);
- inline Grouping groupingOrder() const { return m_groupingOrder; }
+ inline Grouping groupingOrder() const {
+ return m_groupingOrder;
+ }
void setCheckable(bool checkable);
- inline bool checkable() const { return m_checkable; }
+ inline bool checkable() const {
+ return m_checkable;
+ }
inline void setDefaultChecked(bool defaultChecked) {
m_defaultChecked = defaultChecked;
}
- inline bool defaultChecked() const { return m_defaultChecked; }
+ inline bool defaultChecked() const {
+ return m_defaultChecked;
+ }
QList<CSwordModuleInfo*> checkedModules() const;
@@ -80,8 +91,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
template <class T>
QModelIndex getGroup(CSwordModuleInfo *module,
- QModelIndex parentIndex)
- {
+ QModelIndex parentIndex) {
BookshelfModel::Item *parentItem(getItem(parentIndex));
int groupIndex;
T *groupItem(parentItem->getGroupItem<T>(module, &groupIndex));
@@ -111,4 +121,9 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
bool m_defaultChecked;
};
+QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
+QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o);
+
+Q_DECLARE_METATYPE(BtBookshelfTreeModel::Grouping);
+
#endif // BTBOOKSHELFTREEMODEL_H
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
index 4d9cfd6..184bd39 100644
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
@@ -13,9 +13,8 @@
#include "backend/bookshelfmodel/btcheckstatefilterproxymodel.h"
BtCheckStateFilterProxyModel::BtCheckStateFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true), m_showChecked(true),
- m_showUnchecked(false), m_showPartiallyChecked(true)
-{
+ : QSortFilterProxyModel(parent), m_enabled(true), m_showChecked(true),
+ m_showUnchecked(false), m_showPartiallyChecked(true) {
setFilterRole(Qt::CheckStateRole);
}
@@ -48,8 +47,7 @@ void BtCheckStateFilterProxyModel::setShowPartiallyChecked(bool show) {
}
bool BtCheckStateFilterProxyModel::filterAcceptsRow(int row,
- const QModelIndex &parent) const
-{
+ const QModelIndex &parent) const {
typedef Qt::CheckState CS;
if (!m_enabled) return true;
@@ -62,9 +60,11 @@ bool BtCheckStateFilterProxyModel::filterAcceptsRow(int row,
state == Qt::PartiallyChecked);
if (state == Qt::Unchecked) {
return m_showUnchecked;
- } else if (state == Qt::Checked) {
+ }
+ else if (state == Qt::Checked) {
return m_showChecked;
- } else {
+ }
+ else {
return m_showPartiallyChecked;
}
}
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
index b2081f1..78d324d 100644
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
@@ -16,18 +16,24 @@
#include <QSortFilterProxyModel>
class BtCheckStateFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
+ Q_OBJECT
public:
BtCheckStateFilterProxyModel(QObject *parent = 0);
virtual ~BtCheckStateFilterProxyModel();
- inline bool enabled() const { return m_enabled; }
+ inline bool enabled() const {
+ return m_enabled;
+ }
void setEnabled(bool enable);
- inline bool showChecked() const { return m_showChecked; }
+ inline bool showChecked() const {
+ return m_showChecked;
+ }
void setShowChecked(bool show);
- inline bool showUnchecked() const { return m_showUnchecked; }
+ inline bool showUnchecked() const {
+ return m_showUnchecked;
+ }
void setShowUnchecked(bool show);
inline bool showPartiallyChecked() const {
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
index f416175..31b93e1 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
@@ -13,8 +13,7 @@
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true)
-{
+ : QSortFilterProxyModel(parent), m_enabled(true) {
setFilterCaseSensitivity(Qt::CaseInsensitive);
}
@@ -23,8 +22,7 @@ BtModuleNameFilterProxyModel::~BtModuleNameFilterProxyModel() {
}
bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
- const QModelIndex &p) const
-{
+ const QModelIndex &p) const {
if (!m_enabled) return true;
const QAbstractItemModel *m(sourceModel());
@@ -34,7 +32,8 @@ bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
return QSortFilterProxyModel::filterAcceptsRow(row, p);
- } else {
+ }
+ else {
for (int i(0); i < numChildren; i++) {
if (filterAcceptsRow(i, itemIndex)) return true;
}
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
index dd6f652..e4499be 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
@@ -16,12 +16,14 @@
#include <QSortFilterProxyModel>
class BtModuleNameFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
+ Q_OBJECT
public:
BtModuleNameFilterProxyModel(QObject *parent = 0);
virtual ~BtModuleNameFilterProxyModel();
- inline bool enabled() const { return m_enabled; }
+ inline bool enabled() const {
+ return m_enabled;
+ }
void setEnabled(bool enable);
virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 0d4b853..3ce6e88 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -15,9 +15,15 @@
namespace BookshelfModel {
CategoryItem::CategoryItem(CSwordModuleInfo *module)
- : Item(ITEM_CATEGORY), m_category(module->category())
-{
+ : Item(ITEM_CATEGORY), m_category(module->category()) {
// Intentionally empty
}
+bool CategoryItem::operator<(const Item &other) const {
+ if (other.type() != ITEM_CATEGORY) {
+ return ITEM_CATEGORY < other.type();
+ }
+ return m_category < static_cast<const CategoryItem &>(other).m_category;
+}
+
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 3cf7996..40820a2 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -22,7 +22,7 @@
namespace BookshelfModel {
class CategoryItem: public Item {
- Q_DECLARE_TR_FUNCTIONS(CategoryItem);
+ Q_DECLARE_TR_FUNCTIONS(CategoryItem);
public:
static const Item::Type GROUP_TYPE = Item::ITEM_CATEGORY;
@@ -45,6 +45,8 @@ class CategoryItem: public Item {
return module->category() == m_category;
}
+ bool operator<(const Item &other) const;
+
protected:
CSwordModuleInfo::Category m_category;
};
diff --git a/src/backend/bookshelfmodel/distributionitem.cpp b/src/backend/bookshelfmodel/distributionitem.cpp
index 411e236..4ae81c5 100644
--- a/src/backend/bookshelfmodel/distributionitem.cpp
+++ b/src/backend/bookshelfmodel/distributionitem.cpp
@@ -15,8 +15,7 @@
namespace BookshelfModel {
DistributionItem::DistributionItem(CSwordModuleInfo *module)
- : Item(ITEM_DISTRIBUTION)
-{
+ : Item(ITEM_DISTRIBUTION) {
m_distribution = module->config(CSwordModuleInfo::DistributionSource);
}
diff --git a/src/backend/bookshelfmodel/distributionitem.h b/src/backend/bookshelfmodel/distributionitem.h
index ac3912d..44ae591 100644
--- a/src/backend/bookshelfmodel/distributionitem.h
+++ b/src/backend/bookshelfmodel/distributionitem.h
@@ -25,13 +25,17 @@ class DistributionItem: public Item {
DistributionItem(CSwordModuleInfo *module);
- inline QString distribution() const { return m_distribution; }
+ inline QString distribution() const {
+ return m_distribution;
+ }
- inline QString name() const { return m_distribution; }
+ inline QString name() const {
+ return m_distribution;
+ }
inline bool fitFor(CSwordModuleInfo *module) {
return module->config(CSwordModuleInfo::DistributionSource)
- == m_distribution;
+ == m_distribution;
}
protected:
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 22bed91..8556274 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -19,8 +19,7 @@
namespace BookshelfModel {
Item::Item(Type type)
- : m_type(type), m_parent(0), m_checkState(Qt::Unchecked)
-{
+ : m_type(type), m_parent(0), m_checkState(Qt::Unchecked) {
// Intentionally empty
}
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index cb2e6d9..b24b503 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -38,18 +38,24 @@ class Item {
/**
\brief Returns the type of this item.
*/
- inline Type type() const { return m_type; }
+ inline Type type() const {
+ return m_type;
+ }
/**
\brief Returns a pointer to the parent item of this item.
\retval 0 if this item has no parent.
*/
- inline Item *parent() const { return m_parent; }
+ inline Item *parent() const {
+ return m_parent;
+ }
/**
\brief Returns the list of child items of this node.
*/
- inline const QList<Item*> &children() const { return m_children; }
+ inline const QList<Item*> &children() const {
+ return m_children;
+ }
/**
\brief Returns a pointer to the child item at the given index.
@@ -111,17 +117,23 @@ class Item {
/**
\brief Returns the visible name of the item.
*/
- inline virtual QString name() const { return QString::null; }
+ inline virtual QString name() const {
+ return QString::null;
+ }
/**
\brief Returns the visible icon of the item.
*/
- inline virtual QIcon icon() const { return QIcon(); }
+ inline virtual QIcon icon() const {
+ return QIcon();
+ }
/**
\brief Returns the check state of this item.
*/
- inline const Qt::CheckState checkState() const { return m_checkState; }
+ inline const Qt::CheckState checkState() const {
+ return m_checkState;
+ }
/**
\brief Sets the check state of this item.
@@ -145,7 +157,7 @@ class Item {
/**
\brief Comparsion operator used sorting child items.
*/
- bool operator<(const Item &other) const;
+ virtual bool operator<(const Item &other) const;
protected:
inline void setParent(Item *parent) {
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 6c2af30..6758178 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -15,8 +15,7 @@
namespace BookshelfModel {
LanguageItem::LanguageItem(CSwordModuleInfo *module)
- : Item(ITEM_LANGUAGE), m_language(module->language())
-{
+ : Item(ITEM_LANGUAGE), m_language(module->language()) {
// Intentionally empty
}
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index 3b329f1..262ca65 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -27,7 +27,9 @@ class LanguageItem: public Item {
LanguageItem(CSwordModuleInfo *module);
- inline const CLanguageMgr::Language *language() const { return m_language; }
+ inline const CLanguageMgr::Language *language() const {
+ return m_language;
+ }
inline QString name() const {
return BtBookshelfModel::languageName(m_language);
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index 6a543bc..8d02111 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -17,8 +17,7 @@
namespace BookshelfModel {
ModuleItem::ModuleItem(CSwordModuleInfo *module)
- : Item(ITEM_MODULE), m_moduleInfo(module)
-{
+ : Item(ITEM_MODULE), m_moduleInfo(module) {
Q_ASSERT(module != 0);
}
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 7bafc1f..40ecc79 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -24,12 +24,16 @@ class ModuleItem: public Item {
public:
ModuleItem(CSwordModuleInfo *module);
- CSwordModuleInfo *moduleInfo() const { return m_moduleInfo; }
+ CSwordModuleInfo *moduleInfo() const {
+ return m_moduleInfo;
+ }
- inline QString name() const { return m_moduleInfo->name(); }
+ inline QString name() const {
+ return m_moduleInfo->name();
+ }
inline QIcon icon() const {
- return BtBookshelfModel::categoryIcon(m_moduleInfo->category());
+ return BtBookshelfModel::moduleIcon(m_moduleInfo);
}
protected:
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index 275c841..d11ecbd 100644
--- a/src/backend/btmoduletreeitem.cpp
+++ b/src/backend/btmoduletreeitem.cpp
@@ -24,19 +24,19 @@
//This ctor creates the root item and the tree.
BTModuleTreeItem::BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules)
- : m_moduleInfo(0),
- m_firstChild(0),
- m_next(0),
- m_type(BTModuleTreeItem::Root),
- m_category(CSwordModuleInfo::UnknownCategory)
-{
- if (modules) {
- m_originalModuleList = *modules;
- } else {
- m_originalModuleList = CPointers::backend()->moduleList();
- }
- //populate the tree with groups/modules
- create_tree(filters, grouping);
+ : m_moduleInfo(0),
+ m_firstChild(0),
+ m_next(0),
+ m_type(BTModuleTreeItem::Root),
+ m_category(CSwordModuleInfo::UnknownCategory) {
+ if (modules) {
+ m_originalModuleList = *modules;
+ }
+ else {
+ m_originalModuleList = CPointers::backend()->moduleList();
+ }
+ //populate the tree with groups/modules
+ create_tree(filters, grouping);
}
/**
@@ -44,229 +44,222 @@ BTModuleTreeItem::BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters, BT
* parent, the previous firstChild will be the next sibling of this.
*/
BTModuleTreeItem::BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo* info, CSwordModuleInfo::Category category)
- : m_moduleInfo(info),
- m_text(text),
- m_firstChild(0),
- m_next(0),
- m_type(type),
- m_category(category)
-{
- if (info) {
- m_text = info->name();
- m_type = BTModuleTreeItem::Module;
- }
- BTModuleTreeItem* tmp = parentItem->m_firstChild;
- parentItem->m_firstChild = this;
- if (tmp) this->m_next = tmp;
+ : m_moduleInfo(info),
+ m_text(text),
+ m_firstChild(0),
+ m_next(0),
+ m_type(type),
+ m_category(category) {
+ if (info) {
+ m_text = info->name();
+ m_type = BTModuleTreeItem::Module;
+ }
+ BTModuleTreeItem* tmp = parentItem->m_firstChild;
+ parentItem->m_firstChild = this;
+ if (tmp) this->m_next = tmp;
}
-BTModuleTreeItem::~BTModuleTreeItem()
-{
- // this works recursively
- foreach(BTModuleTreeItem* i, children()) {
- delete i;
- }
+BTModuleTreeItem::~BTModuleTreeItem() {
+ // this works recursively
+ foreach(BTModuleTreeItem* i, children()) {
+ delete i;
+ }
}
-QList<BTModuleTreeItem*> BTModuleTreeItem::children() const
-{
- //qDebug("BTModuleTreeItem::children");
- QList<BTModuleTreeItem*> childList;
+QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
+ //qDebug("BTModuleTreeItem::children");
+ QList<BTModuleTreeItem*> childList;
if (m_firstChild) {
- BTModuleTreeItem* child = m_firstChild;
- while (child) {
- //qDebug() << "child:" << child->text();
- childList.append(child);
- child = child->m_next;
- }
- }
- return childList;
+ BTModuleTreeItem* child = m_firstChild;
+ while (child) {
+ //qDebug() << "child:" << child->text();
+ childList.append(child);
+ child = child->m_next;
+ }
+ }
+ return childList;
}
//TODO
-QString BTModuleTreeItem::iconName() const
-{
- if (m_type == Category) {
- switch ( m_category) {
- case CSwordModuleInfo::Bibles:
- return CResMgr::categories::bibles::icon;
- break;
- case CSwordModuleInfo::Commentaries:
- return CResMgr::categories::commentaries::icon;
- break;
- case CSwordModuleInfo::Books:
- return CResMgr::categories::books::icon;
- break;
- case CSwordModuleInfo::Cult:
- return CResMgr::categories::cults::icon;
- break;
- case CSwordModuleInfo::Images:
- return CResMgr::categories::images::icon;
- break;
- case CSwordModuleInfo::DailyDevotional:
- return CResMgr::categories::dailydevotional::icon;
- break;
- case CSwordModuleInfo::Lexicons:
- return CResMgr::categories::lexicons::icon;
- break;
- case CSwordModuleInfo::Glossary:
- return CResMgr::categories::glossary::icon;
- break;
- default: break;
- }
- }
- else if (m_type == Module) {
- return CToolClass::getIconNameForModule(m_moduleInfo);
- }
- else if (m_type == Language) {
- //TODO: don't hardcode here
- return "flag.svg";
- }
-
- return QString::null;
+QString BTModuleTreeItem::iconName() const {
+ if (m_type == Category) {
+ switch ( m_category) {
+ case CSwordModuleInfo::Bibles:
+ return CResMgr::categories::bibles::icon;
+ break;
+ case CSwordModuleInfo::Commentaries:
+ return CResMgr::categories::commentaries::icon;
+ break;
+ case CSwordModuleInfo::Books:
+ return CResMgr::categories::books::icon;
+ break;
+ case CSwordModuleInfo::Cult:
+ return CResMgr::categories::cults::icon;
+ break;
+ case CSwordModuleInfo::Images:
+ return CResMgr::categories::images::icon;
+ break;
+ case CSwordModuleInfo::DailyDevotional:
+ return CResMgr::categories::dailydevotional::icon;
+ break;
+ case CSwordModuleInfo::Lexicons:
+ return CResMgr::categories::lexicons::icon;
+ break;
+ case CSwordModuleInfo::Glossary:
+ return CResMgr::categories::glossary::icon;
+ break;
+ default:
+ break;
+ }
+ }
+ else if (m_type == Module) {
+ return CToolClass::getIconNameForModule(m_moduleInfo);
+ }
+ else if (m_type == Language) {
+ //TODO: don't hardcode here
+ return "flag.svg";
+ }
+
+ return QString::null;
}
-void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping)
-{
- qDebug("BTModuleTreeItem::create_tree");
- static bool map_initialized = false;
- static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
- if (!map_initialized) {
- CategoryNamesMap.insert(CSwordModuleInfo::Commentaries, QObject::tr("Commentaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Cult, QObject::tr("Cults/Unorthodox"));
- CategoryNamesMap.insert(CSwordModuleInfo::Images, QObject::tr("Maps and Images"));
- CategoryNamesMap.insert(CSwordModuleInfo::DailyDevotional, QObject::tr("Daily Devotionals"));
- CategoryNamesMap.insert(CSwordModuleInfo::Lexicons, QObject::tr("Lexicons and Dictionaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Bibles, QObject::tr("Bibles"));
- CategoryNamesMap.insert(CSwordModuleInfo::Glossary, QObject::tr("Glossaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Books, QObject::tr("Books"));
-
- map_initialized = true;
- }
-
- //QList<CSwordModuleInfo*> originalInfoList = CPointers::backend()->moduleList();
-
- foreach (CSwordModuleInfo* info, m_originalModuleList) {
- bool included;
- included = true;
- foreach (BTModuleTreeItem::Filter* f, filters) {
- if (!f->filter(info)) {
- included = false;
- break;
- }
- }
- if (included) {
- //qDebug() << "a module will be included: " << info->name();
-
- BTModuleTreeItem* parentGroupForModule = this;
- BTModuleTreeItem* parentGroupForLanguage = this;
- BTModuleTreeItem* parentGroupForCategory = this;
-
- //the order of if(grouping...) clauses is important
- if (grouping == BTModuleTreeItem::LangMod || grouping == BTModuleTreeItem::LangCatMod) {
- BTModuleTreeItem* langItem = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
-
- if (grouping == BTModuleTreeItem::LangMod)
- parentGroupForModule = langItem;
- else
- parentGroupForCategory = langItem;
- }
-
- if (grouping == BTModuleTreeItem::CatMod || grouping == BTModuleTreeItem::CatLangMod) {
- BTModuleTreeItem* catItem = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
-
- if (grouping == BTModuleTreeItem::CatMod)
- parentGroupForModule = catItem;
- else
- parentGroupForLanguage = catItem;
- }
-
- if (grouping == BTModuleTreeItem::CatLangMod) {
- // category is there already, create language and make it the parent for the module
- parentGroupForModule = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
- }
-
- if (grouping == BTModuleTreeItem::LangCatMod) {
- //language is there already, create category and make it the parent for the module
- parentGroupForModule = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
- }
-
- // the parent group for module has been set above, now just add the module to it
- new BTModuleTreeItem(parentGroupForModule, QString::null, BTModuleTreeItem::Module, info);
-
- } // end: if (included)
- }
-
- // Finally sort the items
- sort_children(this);
+void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping) {
+ qDebug("BTModuleTreeItem::create_tree");
+ static bool map_initialized = false;
+ static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
+ if (!map_initialized) {
+ CategoryNamesMap.insert(CSwordModuleInfo::Commentaries, QObject::tr("Commentaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Cult, QObject::tr("Cults/Unorthodox"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Images, QObject::tr("Maps and Images"));
+ CategoryNamesMap.insert(CSwordModuleInfo::DailyDevotional, QObject::tr("Daily Devotionals"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Lexicons, QObject::tr("Lexicons and Dictionaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Bibles, QObject::tr("Bibles"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Glossary, QObject::tr("Glossaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Books, QObject::tr("Books"));
+
+ map_initialized = true;
+ }
+
+ //QList<CSwordModuleInfo*> originalInfoList = CPointers::backend()->moduleList();
+
+ foreach (CSwordModuleInfo* info, m_originalModuleList) {
+ bool included;
+ included = true;
+ foreach (BTModuleTreeItem::Filter* f, filters) {
+ if (!f->filter(info)) {
+ included = false;
+ break;
+ }
+ }
+ if (included) {
+ //qDebug() << "a module will be included: " << info->name();
+
+ BTModuleTreeItem* parentGroupForModule = this;
+ BTModuleTreeItem* parentGroupForLanguage = this;
+ BTModuleTreeItem* parentGroupForCategory = this;
+
+ //the order of if(grouping...) clauses is important
+ if (grouping == BTModuleTreeItem::LangMod || grouping == BTModuleTreeItem::LangCatMod) {
+ BTModuleTreeItem* langItem = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
+
+ if (grouping == BTModuleTreeItem::LangMod)
+ parentGroupForModule = langItem;
+ else
+ parentGroupForCategory = langItem;
+ }
+
+ if (grouping == BTModuleTreeItem::CatMod || grouping == BTModuleTreeItem::CatLangMod) {
+ BTModuleTreeItem* catItem = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
+
+ if (grouping == BTModuleTreeItem::CatMod)
+ parentGroupForModule = catItem;
+ else
+ parentGroupForLanguage = catItem;
+ }
+
+ if (grouping == BTModuleTreeItem::CatLangMod) {
+ // category is there already, create language and make it the parent for the module
+ parentGroupForModule = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
+ }
+
+ if (grouping == BTModuleTreeItem::LangCatMod) {
+ //language is there already, create category and make it the parent for the module
+ parentGroupForModule = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
+ }
+
+ // the parent group for module has been set above, now just add the module to it
+ new BTModuleTreeItem(parentGroupForModule, QString::null, BTModuleTreeItem::Module, info);
+
+ } // end: if (included)
+ }
+
+ // Finally sort the items
+ sort_children(this);
}
BTModuleTreeItem* BTModuleTreeItem::create_parent_item(
- BTModuleTreeItem* parentGroup,
- const QString& itemText,
- BTModuleTreeItem::Type type,
- CSwordModuleInfo::Category category)
-{
- BTModuleTreeItem* item = 0;
- foreach(BTModuleTreeItem* it, parentGroup->children()) {
- if (it->text() == itemText) {
- item = it;
- break;
- }
- }
- if (!item)
- item = new BTModuleTreeItem(parentGroup, itemText, type, 0, category);
-
- return item;
+ BTModuleTreeItem* parentGroup,
+ const QString& itemText,
+ BTModuleTreeItem::Type type,
+ CSwordModuleInfo::Category category) {
+ BTModuleTreeItem* item = 0;
+ foreach(BTModuleTreeItem* it, parentGroup->children()) {
+ if (it->text() == itemText) {
+ item = it;
+ break;
+ }
+ }
+ if (!item)
+ item = new BTModuleTreeItem(parentGroup, itemText, type, 0, category);
+
+ return item;
}
-void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent)
-{
- //qDebug("BTModuleTreeItem::sort_children");
-
- // sort each child recursively depth-first
- foreach(BTModuleTreeItem* item, parent->children()) {
- sort_children(item);
- }
-
- QList<BTModuleTreeItem*> items = parent->children();
- if (items.size() > 0) {
- // Sort the list of the children according to each item's text
- qSort(items.begin(), items.end(), BTModuleTreeItem::localeAwareLessThan);
- //put the children back to tree in sorted order
- BTModuleTreeItem* first = items.at(0);
- BTModuleTreeItem* prev = first;
- foreach (BTModuleTreeItem* item2, items) {
- prev->m_next = item2;
- prev = item2;
- }
- prev->m_next = 0;
- parent->m_firstChild = first; // attach the partial tree to the parent
- }
+void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent) {
+ //qDebug("BTModuleTreeItem::sort_children");
+
+ // sort each child recursively depth-first
+ foreach(BTModuleTreeItem* item, parent->children()) {
+ sort_children(item);
+ }
+
+ QList<BTModuleTreeItem*> items = parent->children();
+ if (items.size() > 0) {
+ // Sort the list of the children according to each item's text
+ qSort(items.begin(), items.end(), BTModuleTreeItem::localeAwareLessThan);
+ //put the children back to tree in sorted order
+ BTModuleTreeItem* first = items.at(0);
+ BTModuleTreeItem* prev = first;
+ foreach (BTModuleTreeItem* item2, items) {
+ prev->m_next = item2;
+ prev = item2;
+ }
+ prev->m_next = 0;
+ parent->m_firstChild = first; // attach the partial tree to the parent
+ }
}
-bool BTModuleTreeItem::localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second)
-{
- static bool map_initialized = false;
- static QMap<QString, int> CategoryNameValueMap;
- if (!map_initialized) {
- //this is the sorting order for categories
- CategoryNameValueMap.insert(QObject::tr("Bibles"), 1);
- CategoryNameValueMap.insert(QObject::tr("Commentaries"), 2);
- CategoryNameValueMap.insert(QObject::tr("Books"), 3);
- CategoryNameValueMap.insert(QObject::tr("Lexicons and Dictionaries"), 4);
- CategoryNameValueMap.insert(QObject::tr("Glossaries"), 5);
- CategoryNameValueMap.insert(QObject::tr("Daily Devotionals"), 6);
- CategoryNameValueMap.insert(QObject::tr("Maps and Images"), 7);
- CategoryNameValueMap.insert(QObject::tr("Cults/Unorthodox"), 8);
- map_initialized = true;
- }
-
- //Categories are always in the same order, not alphabetically
- if (first->type() == BTModuleTreeItem::Category) {
- return (CategoryNameValueMap.value(first->text()) < CategoryNameValueMap.value(second->text()));
- }
- return (QString::localeAwareCompare(first->text(), second->text()) < 0 );
+bool BTModuleTreeItem::localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second) {
+ static bool map_initialized = false;
+ static QMap<QString, int> CategoryNameValueMap;
+ if (!map_initialized) {
+ //this is the sorting order for categories
+ CategoryNameValueMap.insert(QObject::tr("Bibles"), 1);
+ CategoryNameValueMap.insert(QObject::tr("Commentaries"), 2);
+ CategoryNameValueMap.insert(QObject::tr("Books"), 3);
+ CategoryNameValueMap.insert(QObject::tr("Lexicons and Dictionaries"), 4);
+ CategoryNameValueMap.insert(QObject::tr("Glossaries"), 5);
+ CategoryNameValueMap.insert(QObject::tr("Daily Devotionals"), 6);
+ CategoryNameValueMap.insert(QObject::tr("Maps and Images"), 7);
+ CategoryNameValueMap.insert(QObject::tr("Cults/Unorthodox"), 8);
+ map_initialized = true;
+ }
+
+ //Categories are always in the same order, not alphabetically
+ if (first->type() == BTModuleTreeItem::Category) {
+ return (CategoryNameValueMap.value(first->text()) < CategoryNameValueMap.value(second->text()));
+ }
+ return (QString::localeAwareCompare(first->text(), second->text()) < 0 );
}
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index abdfdb7..b159c6f 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -40,127 +40,134 @@ Example:
if (item->type() == BTModuleTreeItem::Category) prepare_category_item(widgetItem, item);
...
}
-
+
@author The BibleTime team <info@bibletime.info>
*/
-class BTModuleTreeItem
-{
-public:
-
- /**
- * A filter which is given to the root constructor. It filters some modules
- * out from the tree. If it returns true when the filter() is called the module will be added,
- * if it returns false the module will be left out.
- *
- * If you want for example to get only unindexed modules in the list you should
- * write a class (possibly a small inner class inside the calling class) which
- * inherits Filter and write the operator() function which returns true if the
- * module is unindexed and false if it's indexed.
- *
- * It's also possible to do arbitrary tasks to modules by using more complex subclasses.
- *
- * The filters will be applied in the order in which they are in the list.
- * A module will be filtered out if even one filter rejects it and testing
- * will stop with the first negative.
- *
- * Example:
- * QList<BTModuleTreeItem::Filter*> filters;
- * MyFilter filter; BTModuleTreeItem::HiddenOff hideFilter;
- * filters.append(&hideFilter); filters.append(&filter);
- * BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
- */
- struct Filter {
- virtual bool filter(CSwordModuleInfo*) = 0;
- inline virtual ~Filter() {};
- };
-
- /**
- * One example of a filter which can be used with any view. If the module has been
- * set "hidden" it will be filtered out.
- */
- struct HiddenOff : public Filter {
- inline bool filter(CSwordModuleInfo* mi) { return !mi->isHidden(); }
- inline virtual ~HiddenOff() {};
- };
-
- /**
- * Type of the item: root item, category (Bibles, Commentaries etc.), language or module.
- */
- enum Type {Root, Category, Language, Module};
-
- /**
- * Tells how to group the modules. For example:
- * CatLangMod: first category, second language, third module. Mod: don't use
- * Category or Language at all, Module is toplevel and tree is flat.
- */
- enum Grouping {CatLangMod, CatMod, LangCatMod, LangMod, Mod};
-
-
- /**
- * This constructor creates a root item. Create it for example with scoped_ptr or in stack.
- * The root item is populated with the item tree.
- * The constructor takes a list of filters (see Filter), grouping indicator (see Grouping)
- * and optionally the module list from which the tree is constructed
- * (by default CPointers::backend()->moduleList() is used).
- */
- BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters,
- BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules = 0);
-
- /** When the root item is deleted the whole tree is deleted. */
- ~BTModuleTreeItem();
-
- /**
- * Returns the item type.
- */
- inline BTModuleTreeItem::Type type() const {return m_type;}
- /**
- * Returns the item text (category name, language name or module name).
- */
- inline QString text() const {return m_text;}
- /**
- * Returns the path to the icon which is appropriate for this type of item, or QString::null.
- */
- QString iconName() const;
- /**
- * If the type is Module returns a pointer to the corresponding CSwordModuleInfo object,
- * otherwise returns 0.
- */
- inline CSwordModuleInfo* moduleInfo() const {return m_moduleInfo;}
- /**
- * Returns a list of the direct children of this item.
- */
- QList<BTModuleTreeItem*> children() const;
-
- /**
- * For alphabetical sorting which uses text(). See QString::localeAwareCompare().
- * Categories will always be in the same order regardless of the i18n.
- */
- static bool localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second);
-
-
-private:
- /**
- * Private constructor which sets the members.
- */
- BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, Type type, CSwordModuleInfo* info=0, CSwordModuleInfo::Category category=CSwordModuleInfo::UnknownCategory);
- /** Default ctor is private because it is not to be called.*/
- BTModuleTreeItem();
-
- /** Creates the tree under this root item (called only from root ctor). */
- void create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping);
- /** Sorts recursively the children of of the given item. */
- void sort_children(BTModuleTreeItem* parent);
- /** Helper function for creating a group item while creating the tree. */
- BTModuleTreeItem* create_parent_item(BTModuleTreeItem* parent, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo::Category category=CSwordModuleInfo::UnknownCategory);
-
- CSwordModuleInfo* m_moduleInfo;
- QString m_text;
- BTModuleTreeItem* m_firstChild;
- BTModuleTreeItem* m_next;
- Type m_type;
- CSwordModuleInfo::Category m_category;
- QList<CSwordModuleInfo*> m_originalModuleList;
+class BTModuleTreeItem {
+ public:
+
+ /**
+ * A filter which is given to the root constructor. It filters some modules
+ * out from the tree. If it returns true when the filter() is called the module will be added,
+ * if it returns false the module will be left out.
+ *
+ * If you want for example to get only unindexed modules in the list you should
+ * write a class (possibly a small inner class inside the calling class) which
+ * inherits Filter and write the operator() function which returns true if the
+ * module is unindexed and false if it's indexed.
+ *
+ * It's also possible to do arbitrary tasks to modules by using more complex subclasses.
+ *
+ * The filters will be applied in the order in which they are in the list.
+ * A module will be filtered out if even one filter rejects it and testing
+ * will stop with the first negative.
+ *
+ * Example:
+ * QList<BTModuleTreeItem::Filter*> filters;
+ * MyFilter filter; BTModuleTreeItem::HiddenOff hideFilter;
+ * filters.append(&hideFilter); filters.append(&filter);
+ * BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
+ */
+ struct Filter {
+ virtual bool filter(CSwordModuleInfo*) = 0;
+ inline virtual ~Filter() {};
+ };
+
+ /**
+ * One example of a filter which can be used with any view. If the module has been
+ * set "hidden" it will be filtered out.
+ */
+ struct HiddenOff : public Filter {
+ inline bool filter(CSwordModuleInfo* mi) {
+ return !mi->isHidden();
+ }
+ inline virtual ~HiddenOff() {};
+ };
+
+ /**
+ * Type of the item: root item, category (Bibles, Commentaries etc.), language or module.
+ */
+ enum Type {Root, Category, Language, Module};
+
+ /**
+ * Tells how to group the modules. For example:
+ * CatLangMod: first category, second language, third module. Mod: don't use
+ * Category or Language at all, Module is toplevel and tree is flat.
+ */
+ enum Grouping {CatLangMod, CatMod, LangCatMod, LangMod, Mod};
+
+
+ /**
+ * This constructor creates a root item. Create it for example with scoped_ptr or in stack.
+ * The root item is populated with the item tree.
+ * The constructor takes a list of filters (see Filter), grouping indicator (see Grouping)
+ * and optionally the module list from which the tree is constructed
+ * (by default CPointers::backend()->moduleList() is used).
+ */
+ BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters,
+ BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules = 0);
+
+ /** When the root item is deleted the whole tree is deleted. */
+ ~BTModuleTreeItem();
+
+ /**
+ * Returns the item type.
+ */
+ inline BTModuleTreeItem::Type type() const {
+ return m_type;
+ }
+ /**
+ * Returns the item text (category name, language name or module name).
+ */
+ inline QString text() const {
+ return m_text;
+ }
+ /**
+ * Returns the path to the icon which is appropriate for this type of item, or QString::null.
+ */
+ QString iconName() const;
+ /**
+ * If the type is Module returns a pointer to the corresponding CSwordModuleInfo object,
+ * otherwise returns 0.
+ */
+ inline CSwordModuleInfo* moduleInfo() const {
+ return m_moduleInfo;
+ }
+ /**
+ * Returns a list of the direct children of this item.
+ */
+ QList<BTModuleTreeItem*> children() const;
+
+ /**
+ * For alphabetical sorting which uses text(). See QString::localeAwareCompare().
+ * Categories will always be in the same order regardless of the i18n.
+ */
+ static bool localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second);
+
+
+ private:
+ /**
+ * Private constructor which sets the members.
+ */
+ BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, Type type, CSwordModuleInfo* info = 0, CSwordModuleInfo::Category category = CSwordModuleInfo::UnknownCategory);
+ /** Default ctor is private because it is not to be called.*/
+ BTModuleTreeItem();
+
+ /** Creates the tree under this root item (called only from root ctor). */
+ void create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping);
+ /** Sorts recursively the children of of the given item. */
+ void sort_children(BTModuleTreeItem* parent);
+ /** Helper function for creating a group item while creating the tree. */
+ BTModuleTreeItem* create_parent_item(BTModuleTreeItem* parent, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo::Category category = CSwordModuleInfo::UnknownCategory);
+
+ CSwordModuleInfo* m_moduleInfo;
+ QString m_text;
+ BTModuleTreeItem* m_firstChild;
+ BTModuleTreeItem* m_next;
+ Type m_type;
+ CSwordModuleInfo::Category m_category;
+ QList<CSwordModuleInfo*> m_originalModuleList;
};
#endif
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index 9dff6c1..db62863 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -37,10 +37,14 @@ FontCacheMap m_fontCache;
QString getKey(const strings ID) {
switch (ID) {
- case bibletimeVersion: return "bibletimeVersion";
- case language: return "language";
- case displayStyle: return "displayStyle";
- case bookshelfCurrentItem: return "bookshelfCurrentItem";
+ case bibletimeVersion:
+ return "bibletimeVersion";
+ case language:
+ return "language";
+ case displayStyle:
+ return "displayStyle";
+ case bookshelfCurrentItem:
+ return "bookshelfCurrentItem";
}
Q_ASSERT(false);
return QString::null;
@@ -48,14 +52,22 @@ QString getKey(const strings ID) {
QString getKey(const modules ID) {
switch (ID) {
- case standardBible: return "standardBible";
- case standardCommentary: return "standardCommentary";
- case standardLexicon: return "standardLexicon";
- case standardDailyDevotional: return "standardDailyDevotional";
- case standardHebrewStrongsLexicon: return "standardHebrewLexicon";
- case standardGreekStrongsLexicon: return "standardGreekLexicon";
- case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon";
- case standardGreekMorphLexicon: return "standardGreekMorphLexicon";
+ case standardBible:
+ return "standardBible";
+ case standardCommentary:
+ return "standardCommentary";
+ case standardLexicon:
+ return "standardLexicon";
+ case standardDailyDevotional:
+ return "standardDailyDevotional";
+ case standardHebrewStrongsLexicon:
+ return "standardHebrewLexicon";
+ case standardGreekStrongsLexicon:
+ return "standardGreekLexicon";
+ case standardHebrewMorphLexicon:
+ return "standardHebrewMorphLexicon";
+ case standardGreekMorphLexicon:
+ return "standardGreekMorphLexicon";
}
Q_ASSERT(false);
return QString::null;
@@ -63,27 +75,43 @@ QString getKey(const modules ID) {
QString getKey(const bools ID) {
switch (ID) {
- case firstSearchDialog: return "firstSearchDialog";
- case readOldBookmarks: return "readOldBookmarks";
-
- case toolbar: return "toolbar";
- case mainIndex: return "mainIndex";
- case infoDisplay: return "infoDisplay";
-
- case autoTileVertical: return "autoTileVertical";
- case autoTileHorizontal: return "autoTileHorizontal";
- case autoCascade: return "autoCascade";
-
- case lineBreaks: return "lineBreaks";
- case verseNumbers: return "verseNumbers";
-
- case logo: return "logo";
- case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices";
- case crashedLastTime: return "crashedLastTime";
- case crashedTwoTimes: return "crashedTwoTimes";
-
- case bookshelfShowHidden: return "bookshelfShowHidden";
- case allowNetworkConnection: return "allowNetworkConnection";
+ case firstSearchDialog:
+ return "firstSearchDialog";
+ case readOldBookmarks:
+ return "readOldBookmarks";
+
+ case toolbar:
+ return "toolbar";
+ case mainIndex:
+ return "mainIndex";
+ case infoDisplay:
+ return "infoDisplay";
+
+ case autoTileVertical:
+ return "autoTileVertical";
+ case autoTileHorizontal:
+ return "autoTileHorizontal";
+ case autoCascade:
+ return "autoCascade";
+
+ case lineBreaks:
+ return "lineBreaks";
+ case verseNumbers:
+ return "verseNumbers";
+
+ case logo:
+ return "logo";
+ case autoDeleteOrphanedIndices:
+ return "autoDeleteOrphanedIndices";
+ case crashedLastTime:
+ return "crashedLastTime";
+ case crashedTwoTimes:
+ return "crashedTwoTimes";
+
+ case bookshelfShowHidden:
+ return "bookshelfShowHidden";
+ case allowNetworkConnection:
+ return "allowNetworkConnection";
}
Q_ASSERT(false);
return false;
@@ -91,36 +119,66 @@ QString getKey(const bools ID) {
QString getKey(const ints ID) {
switch (ID) {
- case footnotes: return "footnotes";
- case strongNumbers: return "strongNumbers";
- case headings: return "headings";
- case morphTags: return "morphTags";
- case lemmas: return "lemmas";
- case hebrewPoints: return "hebrewPoints";
- case hebrewCantillation: return "hebrewCantillation";
- case greekAccents: return "greekAccents";
- case textualVariants: return "textualVariants";
- case scriptureReferences: return "scriptureReferences";
- case morphSegmentation: return "morphSegmentation";
- case bookshelfContentsX: return "bookshelfContentsX";
- case bookshelfContentsY: return "bookshelfContentsY";
- case magDelay: return "magDelay";
- case bookshelfGrouping: return "bookshelfGrouping";
- case mainindexActiveTab: return "mainindexActiveTab";
- case searchDialogWidth: return "searchDialogWidth";
- case searchDialogHeight: return "searchDialogHeight";
- case searchDialogX: return "searchDialogX";
- case searchDialogY: return "searchDialogY";
- case searchType: return "searchType";
- case installPathIndex: return "installPathIndex";
- case bookshelfPosX: return "bookshelfPosX";
- case bookshelfPosY: return "bookshelfPosY";
- case bookshelfHeight: return "bookshelfHeight";
- case bookshelfWidth: return "bookshelfWidth";
- case configDialogPosX: return "configDialogPosX";
- case configDialogPosY: return "configDialogPosY";
- case configDialogHeight: return "configDialogHeight";
- case configDialogWidth: return "configDialogWidth";
+ case footnotes:
+ return "footnotes";
+ case strongNumbers:
+ return "strongNumbers";
+ case headings:
+ return "headings";
+ case morphTags:
+ return "morphTags";
+ case lemmas:
+ return "lemmas";
+ case hebrewPoints:
+ return "hebrewPoints";
+ case hebrewCantillation:
+ return "hebrewCantillation";
+ case greekAccents:
+ return "greekAccents";
+ case textualVariants:
+ return "textualVariants";
+ case scriptureReferences:
+ return "scriptureReferences";
+ case morphSegmentation:
+ return "morphSegmentation";
+ case bookshelfContentsX:
+ return "bookshelfContentsX";
+ case bookshelfContentsY:
+ return "bookshelfContentsY";
+ case magDelay:
+ return "magDelay";
+ case bookshelfGrouping:
+ return "bookshelfGrouping";
+ case mainindexActiveTab:
+ return "mainindexActiveTab";
+ case searchDialogWidth:
+ return "searchDialogWidth";
+ case searchDialogHeight:
+ return "searchDialogHeight";
+ case searchDialogX:
+ return "searchDialogX";
+ case searchDialogY:
+ return "searchDialogY";
+ case searchType:
+ return "searchType";
+ case installPathIndex:
+ return "installPathIndex";
+ case bookshelfPosX:
+ return "bookshelfPosX";
+ case bookshelfPosY:
+ return "bookshelfPosY";
+ case bookshelfHeight:
+ return "bookshelfHeight";
+ case bookshelfWidth:
+ return "bookshelfWidth";
+ case configDialogPosX:
+ return "configDialogPosX";
+ case configDialogPosY:
+ return "configDialogPosY";
+ case configDialogHeight:
+ return "configDialogHeight";
+ case configDialogWidth:
+ return "configDialogWidth";
}
Q_ASSERT(false);
return QString::null;
@@ -128,10 +186,14 @@ QString getKey(const ints ID) {
QString getKey(const intLists ID) {
switch (ID) {
- case leftPaneSplitterSizes: return "leftPaneSplitterSizes";
- case mainSplitterSizes: return "mainSplitterSizes";
- case searchMainSplitterSizes: return "searchMainSplitterSizes";
- case searchResultSplitterSizes: return "searchResultSplitterSizes";
+ case leftPaneSplitterSizes:
+ return "leftPaneSplitterSizes";
+ case mainSplitterSizes:
+ return "mainSplitterSizes";
+ case searchMainSplitterSizes:
+ return "searchMainSplitterSizes";
+ case searchResultSplitterSizes:
+ return "searchResultSplitterSizes";
}
Q_ASSERT(false);
return QString::null;
@@ -139,11 +201,16 @@ QString getKey(const intLists ID) {
QString getKey(const stringLists ID) {
switch (ID) {
- case searchCompletionTexts: return "searchCompletionTexts";
- case searchTexts: return "searchTexts";
- case searchModulesHistory: return "searchModulesHistory";
- case bookshelfOpenGroups: return "bookshelfOpenGroups";
- case hiddenModules: return "hiddenModules";
+ case searchCompletionTexts:
+ return "searchCompletionTexts";
+ case searchTexts:
+ return "searchTexts";
+ case searchModulesHistory:
+ return "searchModulesHistory";
+ case bookshelfOpenGroups:
+ return "bookshelfOpenGroups";
+ case hiddenModules:
+ return "hiddenModules";
}
Q_ASSERT(false);
return QString::null;
@@ -151,7 +218,8 @@ QString getKey(const stringLists ID) {
QString getKey(const stringMaps ID) {
switch (ID) {
- case searchScopes: return "SearchScopes";
+ case searchScopes:
+ return "SearchScopes";
};
Q_ASSERT(false);
return QString::null;
@@ -184,10 +252,14 @@ QList<int> StringToIntList(const QString intListString) {
QString getDefault(const strings ID) {
switch (ID) {
- case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION
- case language: return QLocale::system().name();
- case displayStyle: return CDisplayTemplateMgr::defaultTemplate();
- case bookshelfCurrentItem: return QString();
+ case bibletimeVersion:
+ return "0.0"; // main() will realize this and set the value to VERSION
+ case language:
+ return QLocale::system().name();
+ case displayStyle:
+ return CDisplayTemplateMgr::defaultTemplate();
+ case bookshelfCurrentItem:
+ return QString();
}
return QString::null;
}
@@ -195,15 +267,23 @@ QString getDefault(const strings ID) {
QString getDefault(const modules ID) {
// CSwordBackend *b = CPointers::backend();
switch (ID) {
- case standardBible: return "KJV";
- case standardCommentary: return "MHC";
- case standardLexicon: return "ISBE";
- case standardDailyDevotional: return ""; // No default
-
- case standardHebrewStrongsLexicon: return "StrongsHebrew";
- case standardGreekStrongsLexicon: return "StrongsGreek";
- case standardHebrewMorphLexicon: return "StrongsHebrew";
- case standardGreekMorphLexicon: return "StrongsGreek";
+ case standardBible:
+ return "KJV";
+ case standardCommentary:
+ return "MHC";
+ case standardLexicon:
+ return "ISBE";
+ case standardDailyDevotional:
+ return ""; // No default
+
+ case standardHebrewStrongsLexicon:
+ return "StrongsHebrew";
+ case standardGreekStrongsLexicon:
+ return "StrongsGreek";
+ case standardHebrewMorphLexicon:
+ return "StrongsHebrew";
+ case standardGreekMorphLexicon:
+ return "StrongsGreek";
}
return QString::null;
@@ -211,62 +291,108 @@ QString getDefault(const modules ID) {
bool getDefault(const bools ID) {
switch (ID) {
- case firstSearchDialog: return true;
- case readOldBookmarks: return false;
-
- case toolbar: return true;
- case mainIndex: return true;
- case infoDisplay: return true;
-
- case autoTileVertical: return true;
- case autoTileHorizontal: return false;
- case autoCascade: return false;
-
- case lineBreaks: return false;
- case verseNumbers: return true;
-
- case logo: return true;
- case autoDeleteOrphanedIndices: return true;
- case crashedLastTime: return false;
- case crashedTwoTimes: return false;
- case bookshelfShowHidden: return false;
- case allowNetworkConnection: return false;
+ case firstSearchDialog:
+ return true;
+ case readOldBookmarks:
+ return false;
+
+ case toolbar:
+ return true;
+ case mainIndex:
+ return true;
+ case infoDisplay:
+ return true;
+
+ case autoTileVertical:
+ return true;
+ case autoTileHorizontal:
+ return false;
+ case autoCascade:
+ return false;
+
+ case lineBreaks:
+ return false;
+ case verseNumbers:
+ return true;
+
+ case logo:
+ return true;
+ case autoDeleteOrphanedIndices:
+ return true;
+ case crashedLastTime:
+ return false;
+ case crashedTwoTimes:
+ return false;
+ case bookshelfShowHidden:
+ return false;
+ case allowNetworkConnection:
+ return false;
}
return false;
}
int getDefault(const ints ID) {
switch (ID) {
- case footnotes: return int(true);
- case strongNumbers: return int(true);
- case headings: return int(true);
- case morphTags: return int(true);
- case lemmas: return int(true);
- case hebrewPoints: return int(true);
- case hebrewCantillation: return int(true);
- case greekAccents: return int(true);
- case textualVariants: return int(false);
- case scriptureReferences: return int(true);
- case morphSegmentation: return int(true);
- case bookshelfContentsX: return 0;
- case bookshelfContentsY: return 0;
- case magDelay: return 400;
- case bookshelfGrouping: return BTModuleTreeItem::CatLangMod;
- case searchDialogWidth: return 200;
- case searchDialogHeight: return 400;
- case searchDialogX: return 200;
- case searchDialogY: return 200;
- case searchType: return Search::BtSearchOptionsArea::AndType;
- case mainindexActiveTab: return 0;
- case installPathIndex: return 0;
- case bookshelfPosX: return 1;
- case bookshelfPosY: return 1;
- case bookshelfHeight: return 1;
- case bookshelfWidth: return 1;
- case configDialogPosX: return 1;
- case configDialogPosY: return 1;
- case configDialogHeight: return 1;
- case configDialogWidth: return 1;
+ case footnotes:
+ return int(true);
+ case strongNumbers:
+ return int(true);
+ case headings:
+ return int(true);
+ case morphTags:
+ return int(true);
+ case lemmas:
+ return int(true);
+ case hebrewPoints:
+ return int(true);
+ case hebrewCantillation:
+ return int(true);
+ case greekAccents:
+ return int(true);
+ case textualVariants:
+ return int(false);
+ case scriptureReferences:
+ return int(true);
+ case morphSegmentation:
+ return int(true);
+ case bookshelfContentsX:
+ return 0;
+ case bookshelfContentsY:
+ return 0;
+ case magDelay:
+ return 400;
+ case bookshelfGrouping:
+ return BTModuleTreeItem::CatLangMod;
+ case searchDialogWidth:
+ return 200;
+ case searchDialogHeight:
+ return 400;
+ case searchDialogX:
+ return 200;
+ case searchDialogY:
+ return 200;
+ case searchType:
+ return Search::BtSearchOptionsArea::AndType;
+ case mainindexActiveTab:
+ return 0;
+ case installPathIndex:
+ return 0;
+ case bookshelfPosX:
+ return 1;
+ case bookshelfPosY:
+ return 1;
+ case bookshelfHeight:
+ return 1;
+ case bookshelfWidth:
+ return 1;
+ case configDialogPosX:
+ return 1;
+ case configDialogPosY:
+ return 1;
+ case configDialogHeight:
+ return 1;
+ case configDialogWidth:
+ return 1;
}
return 0;
}
@@ -288,10 +414,14 @@ QStringList getDefault(const stringLists ID) {
list.append(QString::null);
return list;
}
- case searchCompletionTexts: return QStringList();
- case bookshelfOpenGroups: return QStringList();
- case hiddenModules: return QStringList();
- case searchModulesHistory: return QStringList();
+ case searchCompletionTexts:
+ return QStringList();
+ case bookshelfOpenGroups:
+ return QStringList();
+ case hiddenModules:
+ return QStringList();
+ case searchModulesHistory:
+ return QStringList();
}
return QStringList();
}
@@ -349,8 +479,8 @@ QString get(const strings ID) {
CSwordModuleInfo *get(const modules ID) {
getConfig()->beginGroup("modules");
CSwordModuleInfo *result(CPointers::backend()->findModuleByName(
- getConfig()->value(getKey(ID), getDefault(ID)).toString()
- ));
+ getConfig()->value(getKey(ID), getDefault(ID)).toString()
+ ));
getConfig()->endGroup();
return result;
}
@@ -372,9 +502,9 @@ int get(const ints ID) {
QList<int> get(const intLists ID) {
getConfig()->beginGroup("intlists");
QList<int> result(StringToIntList(
- getConfig()->value(getKey(ID), IntListToString(getDefault(ID)))
- .toString()
- ));
+ getConfig()->value(getKey(ID), IntListToString(getDefault(ID)))
+ .toString()
+ ));
getConfig()->endGroup();
return result;
}
@@ -382,8 +512,8 @@ QList<int> get(const intLists ID) {
QStringList get(const stringLists ID) {
getConfig()->beginGroup("stringlists");
QStringList result(
- getConfig()->value(getKey(ID), getDefault(ID)).toStringList()
- );
+ getConfig()->value(getKey(ID), getDefault(ID)).toStringList()
+ );
getConfig()->endGroup();
return result;
}
@@ -414,9 +544,11 @@ StringMap get(const stringMaps ID) {
map[key] = data; // Set the new data
}
}
- default: break;
+ default:
+ break;
}
- } else {
+ }
+ else {
map = getDefault(ID);
}
getConfig()->endGroup();
@@ -438,7 +570,8 @@ FontSettingsPair get(const CLanguageMgr::Language * const language) {
QFont font;
if (settings.first) {
font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString());
- } else {
+ }
+ else {
font = getDefault(language);
}
settings.second = font;
@@ -539,8 +672,7 @@ void set(const stringMaps ID, const StringMap value) {
}
void set(const CLanguageMgr::Language * const language,
- const FontSettingsPair& value)
-{
+ const FontSettingsPair& value) {
getConfig()->beginGroup("fonts");
getConfig()->setValue(getKey(language), value.second.toString());
getConfig()->endGroup();
@@ -579,8 +711,7 @@ CSwordBackend::FilterOptions getFilterOptionDefaults() {
}
void setupAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
+ BtActionCollection * const actionCollection) {
qDebug("CBTConfig::setupAccelSettings begin");
QString groupName;
switch (type) {
@@ -618,8 +749,7 @@ void setupAccelSettings(const keys type,
}
void saveAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
+ BtActionCollection * const actionCollection) {
qDebug("CBTConfig::saveAccelSettings begin");
QString groupName;
switch (type) {
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index f57a87a..220cac9 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -23,101 +23,99 @@
CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
CSwordModuleSearch::CSwordModuleSearch()
- : m_searchedText(QString::null),
- m_searchOptions(0),
- m_foundItems(false)
-{
- searcher = this;
+ : m_searchedText(QString::null),
+ m_searchOptions(0),
+ m_foundItems(false) {
+ searcher = this;
}
CSwordModuleSearch::~CSwordModuleSearch() {
- searcher = 0;
+ searcher = 0;
}
/** This function sets the modules which should be searched. */
void CSwordModuleSearch::setModules( const QList<CSwordModuleInfo*>& list ) {
- m_moduleList = list;
+ m_moduleList = list;
}
/** Starts the search for the search text. */
bool CSwordModuleSearch::startSearch() {
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- m_foundItems = false;
+ backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
+ m_foundItems = false;
- bool foundItems = false;
+ bool foundItems = false;
- // for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
+ // for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
- if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
- foundItems = true;
- }
- }
+ for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
+ if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
+ foundItems = true;
+ }
+ }
- m_foundItems = foundItems;
+ m_foundItems = foundItems;
- //m_finishedSig.activate();
- emit finished();
- return true;
+ //m_finishedSig.activate();
+ emit finished();
+ return true;
}
/** Sets the text which should be search in the modules. */
void CSwordModuleSearch::setSearchedText( const QString& text ) {
- m_searchedText = text;
+ m_searchedText = text;
}
/** Sets the search scope. */
void CSwordModuleSearch::setSearchScope( const sword::ListKey& scope ) {
- m_searchScope.copyFrom( scope );
-
- if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
- //reset the scope
- resetSearchScope();
-
- //disable searching with a scope!
- // if (m_searchOptions | useScope) {
- // qWarning("using the scope!");
- //set back the scope flag
- // }
- }
+ m_searchScope.copyFrom( scope );
+
+ if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
+ //reset the scope
+ resetSearchScope();
+
+ //disable searching with a scope!
+ // if (m_searchOptions | useScope) {
+ // qWarning("using the scope!");
+ //set back the scope flag
+ // }
+ }
}
/** Sets the search scope back. */
void CSwordModuleSearch::resetSearchScope() {
- m_searchScope.ClearList();
+ m_searchScope.ClearList();
}
/** Returns true if in the last search the searcher found items, if no items were found return false. */
bool CSwordModuleSearch::foundItems() const {
- return m_foundItems;
+ return m_foundItems;
}
/** Returns a copy of the used search scope. */
const sword::ListKey& CSwordModuleSearch::searchScope() const {
- return m_searchScope;
+ return m_searchScope;
}
void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member ) {
- //m_finishedSig.connect(receiver, member);
- QObject::connect(this, SIGNAL(finished()), receiver, member);
+ //m_finishedSig.connect(receiver, member);
+ QObject::connect(this, SIGNAL(finished()), receiver, member);
}
/** Should be called when the search finished. */
void CSwordModuleSearch::searchFinished() {
- //m_finishedSig.activate();
- emit finished();
+ //m_finishedSig.activate();
+ emit finished();
}
-bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules )
-{
- bool hasIndices = true;
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
- if (!(*it)->hasIndex()) {
- hasIndices = false;
- break;
- }
- }
- return hasIndices;
+bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules ) {
+ bool hasIndices = true;
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for ( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
+ if (!(*it)->hasIndex()) {
+ hasIndices = false;
+ break;
+ }
+ }
+ return hasIndices;
}
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index 7ba6a6f..cc0c8c1 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -34,65 +34,65 @@ class CSwordModuleInfo;
*/
class CSwordModuleSearch: public QObject, CPointers {
- Q_OBJECT
-
-public:
- CSwordModuleSearch();
- /**
- * The destructor of this class. It cleans uop memory before it's deleted.
- */
- virtual ~CSwordModuleSearch();
- /**
- * Sets the text which should be search in the modules.
- */
- void setSearchedText( const QString& );
- /**
- * Starts the search for the search text.
- */
- bool startSearch();
- /**
- * This function sets the modules which should be searched.
- */
- void setModules( const QList<CSwordModuleInfo*>& );
- /**
- * Sets the search scope.
- */
- void setSearchScope( const sword::ListKey& scope );
- /**
- * Sets the seaech scope back.
- */
- void resetSearchScope();
- /**
- * @return "true" if in the last search the searcher found items, if no items were found return "false"
- */
- bool foundItems() const;
- /**
- * Returns a copy of the used search scope.
- */
- const sword::ListKey& searchScope() const;
-
- void connectFinished( QObject * receiver, const char * member );
- void searchFinished();
-
- /**
- * Returns true if all of the specified modules have indices already built.
- */
- bool modulesHaveIndices( const QList<CSwordModuleInfo*>& );
-
-protected:
- QString m_searchedText;
- sword::ListKey m_searchScope;
- QList<CSwordModuleInfo*> m_moduleList;
-
- int m_searchOptions;
-
- bool m_foundItems;
-
-signals:
- void finished();
-
-private:
- static CSwordModuleSearch* searcher;
+ Q_OBJECT
+
+ public:
+ CSwordModuleSearch();
+ /**
+ * The destructor of this class. It cleans uop memory before it's deleted.
+ */
+ virtual ~CSwordModuleSearch();
+ /**
+ * Sets the text which should be search in the modules.
+ */
+ void setSearchedText( const QString& );
+ /**
+ * Starts the search for the search text.
+ */
+ bool startSearch();
+ /**
+ * This function sets the modules which should be searched.
+ */
+ void setModules( const QList<CSwordModuleInfo*>& );
+ /**
+ * Sets the search scope.
+ */
+ void setSearchScope( const sword::ListKey& scope );
+ /**
+ * Sets the seaech scope back.
+ */
+ void resetSearchScope();
+ /**
+ * @return "true" if in the last search the searcher found items, if no items were found return "false"
+ */
+ bool foundItems() const;
+ /**
+ * Returns a copy of the used search scope.
+ */
+ const sword::ListKey& searchScope() const;
+
+ void connectFinished( QObject * receiver, const char * member );
+ void searchFinished();
+
+ /**
+ * Returns true if all of the specified modules have indices already built.
+ */
+ bool modulesHaveIndices( const QList<CSwordModuleInfo*>& );
+
+ protected:
+ QString m_searchedText;
+ sword::ListKey m_searchScope;
+ QList<CSwordModuleInfo*> m_moduleList;
+
+ int m_searchOptions;
+
+ bool m_foundItems;
+
+ signals:
+ void finished();
+
+ private:
+ static CSwordModuleSearch* searcher;
};
#endif
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index a7b89ba..f00a580 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -22,204 +22,204 @@
CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0),
-m_cachedLocale("unknown"),
-m_hasOT(-1),
-m_hasNT(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0),
+ m_cachedLocale("unknown"),
+ m_hasOT(-1),
+ m_hasNT(-1) {}
CSwordBibleModuleInfo::CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ) :
-CSwordModuleInfo(m),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0) {
- if (m.m_bookList) {
- m_bookList = new QStringList();
- *m_bookList = *m.m_bookList;
- }
-
- m_hasOT = m.m_hasOT;
- m_hasNT = m.m_hasNT;
- m_cachedLocale = m.m_cachedLocale;
+ CSwordModuleInfo(m),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0) {
+ if (m.m_bookList) {
+ m_bookList = new QStringList();
+ *m_bookList = *m.m_bookList;
+ }
+
+ m_hasOT = m.m_hasOT;
+ m_hasNT = m.m_hasNT;
+ m_cachedLocale = m.m_cachedLocale;
}
CSwordModuleInfo* CSwordBibleModuleInfo::clone() {
- return new CSwordBibleModuleInfo(*this);
+ return new CSwordBibleModuleInfo(*this);
}
CSwordBibleModuleInfo::~CSwordBibleModuleInfo() {
- delete m_bookList;
+ delete m_bookList;
}
void CSwordBibleModuleInfo::initBounds() {
- if (m_hasOT == -1) {
- m_hasOT = hasTestament(OldTestament);
- }
-
- if (m_hasNT == -1) {
- m_hasNT = hasTestament(NewTestament);
- }
-
- if (m_hasOT) {
- m_lowerBound.key("Genesis 1:1");
- }
- else {
- m_lowerBound.key("Matthew 1:1");
- }
-
- if (!m_hasNT) {
- m_upperBound.key("Malachi 4:6");
- }
- else {
- m_upperBound.key("Revelation of John 22:21");
- }
+ if (m_hasOT == -1) {
+ m_hasOT = hasTestament(OldTestament);
+ }
+
+ if (m_hasNT == -1) {
+ m_hasNT = hasTestament(NewTestament);
+ }
+
+ if (m_hasOT) {
+ m_lowerBound.key("Genesis 1:1");
+ }
+ else {
+ m_lowerBound.key("Matthew 1:1");
+ }
+
+ if (!m_hasNT) {
+ m_upperBound.key("Malachi 4:6");
+ }
+ else {
+ m_upperBound.key("Revelation of John 22:21");
+ }
}
/** Returns the books available in this module */
QStringList* CSwordBibleModuleInfo::books() {
- if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
- delete m_bookList;
- m_bookList = 0;
- }
-
- if (!m_bookList) {
- m_bookList = new QStringList();
-
- initBounds();
- int min = 0;
- int max = 1;
-
- //find out if we have ot and nt, only ot or only nt
-
- if (m_hasOT>0 && m_hasNT>0) { //both
- min = 0;
- max = 1;
- }
- else if (m_hasOT>0 && !m_hasNT) { //only OT
- min = 0;
- max = 0;
- }
- else if (!m_hasOT && m_hasNT>0) { //only NT
- min = 1;
- max = 1;
- }
- else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
- qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
- min = 0;
- max = -1;
- }
-
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
-
- for (key->Testament(min+1); !key->Error() && (key->Testament()-1) <= max; key->Book(key->Book()+1)) {
- m_bookList->append( QString::fromUtf8(key->getBookName()) );
- }
-
- m_cachedLocale = backend()->booknameLanguage();
- }
-
- return m_bookList;
+ if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
+ delete m_bookList;
+ m_bookList = 0;
+ }
+
+ if (!m_bookList) {
+ m_bookList = new QStringList();
+
+ initBounds();
+ int min = 0;
+ int max = 1;
+
+ //find out if we have ot and nt, only ot or only nt
+
+ if (m_hasOT > 0 && m_hasNT > 0) { //both
+ min = 0;
+ max = 1;
+ }
+ else if (m_hasOT > 0 && !m_hasNT) { //only OT
+ min = 0;
+ max = 0;
+ }
+ else if (!m_hasOT && m_hasNT > 0) { //only NT
+ min = 1;
+ max = 1;
+ }
+ else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
+ qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
+ min = 0;
+ max = -1;
+ }
+
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
+
+ for (key->Testament(min + 1); !key->Error() && (key->Testament() - 1) <= max; key->Book(key->Book() + 1)) {
+ m_bookList->append( QString::fromUtf8(key->getBookName()) );
+ }
+
+ m_cachedLocale = backend()->booknameLanguage();
+ }
+
+ return m_bookList;
}
/** Returns the number of chapters for the given book. */
unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) {
- int result = 0;
+ int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- (*key) = sword::MAXCHAPTER;
- result = key->Chapter();
+ // works for old and new versions
+ key->Book(book);
+ (*key) = sword::MAXCHAPTER;
+ result = key->Chapter();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::chapterCount(const QString& book) {
- return chapterCount( bookNumber(book) );
+ return chapterCount( bookNumber(book) );
}
/** Returns the number of verses for the given chapter. */
unsigned int CSwordBibleModuleInfo::verseCount( const unsigned int book, const unsigned int chapter ) {
- unsigned int result = 0;
+ unsigned int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- key->Chapter(chapter);
- (*key) = sword::MAXVERSE;
- result = key->Verse();
+ // works for old and new versions
+ key->Book(book);
+ key->Chapter(chapter);
+ (*key) = sword::MAXVERSE;
+ result = key->Verse();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsigned int chapter ) {
- return verseCount( bookNumber(book), chapter );
+ return verseCount( bookNumber(book), chapter );
}
unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) {
- unsigned int bookNumber = 0;
+ unsigned int bookNumber = 0;
- //find out if we have ot and nt, only ot or only nt
- initBounds();
+ //find out if we have ot and nt, only ot or only nt
+ initBounds();
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- key->setBookName(book.toUtf8().constData());
+ key->setBookName(book.toUtf8().constData());
- bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
+ bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
- return bookNumber;
+ return bookNumber;
}
/** Returns true if his module has the text of desired type of testament */
bool CSwordBibleModuleInfo::hasTestament( CSwordBibleModuleInfo::Testament type ) {
- if (m_hasOT == -1 || m_hasNT == -1) {
- const bool oldStatus = module()->getSkipConsecutiveLinks();
- module()->setSkipConsecutiveLinks(true);
+ if (m_hasOT == -1 || m_hasNT == -1) {
+ const bool oldStatus = module()->getSkipConsecutiveLinks();
+ module()->setSkipConsecutiveLinks(true);
- *module() = sword::TOP; //position to first entry
- sword::VerseKey key( module()->KeyText() );
+ *module() = sword::TOP; //position to first entry
+ sword::VerseKey key( module()->KeyText() );
- if (key.Testament() == 1) { // OT && NT
- m_hasOT = 1;
- }
- else if (key.Testament() == 2) { //no OT
- m_hasOT = 0;
- }
+ if (key.Testament() == 1) { // OT && NT
+ m_hasOT = 1;
+ }
+ else if (key.Testament() == 2) { //no OT
+ m_hasOT = 0;
+ }
- *module() = sword::BOTTOM;
- key = module()->KeyText();
+ *module() = sword::BOTTOM;
+ key = module()->KeyText();
- if (key.Testament() == 1) { // only OT, no NT
- m_hasNT = 0;
- }
- else if (key.Testament() == 2) { //has NT
- m_hasNT = 1;
- }
+ if (key.Testament() == 1) { // only OT, no NT
+ m_hasNT = 0;
+ }
+ else if (key.Testament() == 2) { //has NT
+ m_hasNT = 1;
+ }
- module()->setSkipConsecutiveLinks(oldStatus);
- }
+ module()->setSkipConsecutiveLinks(oldStatus);
+ }
- switch (type) {
+ switch (type) {
- case OldTestament:
- return m_hasOT>0;
+ case OldTestament:
+ return m_hasOT > 0;
- case NewTestament:
- return m_hasNT>0;
+ case NewTestament:
+ return m_hasNT > 0;
- default:
- return false;
- }
+ default:
+ return false;
+ }
}
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index c25eb37..10d05bb 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -26,101 +26,101 @@
class CSwordBibleModuleInfo : public CSwordModuleInfo {
-public:
- enum Testament {
- OldTestament = 1,
- NewTestament = 2
- };
+ public:
+ enum Testament {
+ OldTestament = 1,
+ NewTestament = 2
+ };
- /**
- * The constructor of this class
- */
- CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /** The copy constructor for this Bible module.
- */
- CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
- /**
- * The destructor of this class
- */
- ~CSwordBibleModuleInfo();
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The number book we should use
- * @param chapter The chapter we should use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The name of the book we use
- * @param chapter The number of the chapter we use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- * @return The number of chapters for the given book
- */
- virtual unsigned int chapterCount( const unsigned int book );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- */
- virtual unsigned int chapterCount( const QString& book );
- /** Return all book of this module.
- * @return A QStringList containing the books which are available in this module.
- */
- virtual QStringList* books();
- /**
- * Reimplementation, Returns the type
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * @return the book number, values starting with 1; 0 if not found
- */
- unsigned int bookNumber(const QString &book);
- /**
- * Returns true if his module has the text of desired type of testament
- */
- bool hasTestament( CSwordBibleModuleInfo::Testament );
- /** Reimplementation to clone this object. */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns the key which represents the lower bound of this module.
- */
- inline const CSwordVerseKey& lowerBound();
- /**
- * Returns the key which represents the upper bound of this module.
- */
- inline const CSwordVerseKey& upperBound();
+ /**
+ * The constructor of this class
+ */
+ CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /** The copy constructor for this Bible module.
+ */
+ CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
+ /**
+ * The destructor of this class
+ */
+ ~CSwordBibleModuleInfo();
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The number book we should use
+ * @param chapter The chapter we should use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The name of the book we use
+ * @param chapter The number of the chapter we use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ * @return The number of chapters for the given book
+ */
+ virtual unsigned int chapterCount( const unsigned int book );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ */
+ virtual unsigned int chapterCount( const QString& book );
+ /** Return all book of this module.
+ * @return A QStringList containing the books which are available in this module.
+ */
+ virtual QStringList* books();
+ /**
+ * Reimplementation, Returns the type
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * @return the book number, values starting with 1; 0 if not found
+ */
+ unsigned int bookNumber(const QString &book);
+ /**
+ * Returns true if his module has the text of desired type of testament
+ */
+ bool hasTestament( CSwordBibleModuleInfo::Testament );
+ /** Reimplementation to clone this object. */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns the key which represents the lower bound of this module.
+ */
+ inline const CSwordVerseKey& lowerBound();
+ /**
+ * Returns the key which represents the upper bound of this module.
+ */
+ inline const CSwordVerseKey& upperBound();
-private:
- void initBounds();
+ private:
+ void initBounds();
- CSwordVerseKey m_lowerBound;
- CSwordVerseKey m_upperBound;
+ CSwordVerseKey m_lowerBound;
+ CSwordVerseKey m_upperBound;
- QStringList* m_bookList; //This booklist is cached
- QString m_cachedLocale;
- short int m_hasOT;
- short int m_hasNT;
+ QStringList* m_bookList; //This booklist is cached
+ QString m_cachedLocale;
+ short int m_hasOT;
+ short int m_hasNT;
};
inline CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const {
- return CSwordModuleInfo::Bible;
+ return CSwordModuleInfo::Bible;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::lowerBound() {
- initBounds();
- return m_lowerBound;
+ initBounds();
+ return m_lowerBound;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::upperBound() {
- initBounds();
- return m_upperBound;
+ initBounds();
+ return m_upperBound;
}
#endif
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index 0a8c1e6..b67015b 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -16,53 +16,53 @@
#include <treekey.h>
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_depth(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_depth(-1) {}
CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module )
-: CSwordModuleInfo(module) {
- m_depth = module.m_depth;
+ : CSwordModuleInfo(module) {
+ m_depth = module.m_depth;
}
CSwordBookModuleInfo::~CSwordBookModuleInfo() {}
int CSwordBookModuleInfo::depth() {
- if (m_depth == -1) {
- sword::TreeKeyIdx* key = tree();
+ if (m_depth == -1) {
+ sword::TreeKeyIdx* key = tree();
- if (key) {
- key->root();
- computeDepth(key, 0);
- }
- }
+ if (key) {
+ key->root();
+ computeDepth(key, 0);
+ }
+ }
- return m_depth;
+ return m_depth;
}
void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) {
- std::string savedKey;
- // savedKey = key->getFullName(); //sword 1.5.8
- savedKey = key->getText();
+ std::string savedKey;
+ // savedKey = key->getFullName(); //sword 1.5.8
+ savedKey = key->getText();
- if (level > m_depth) {
- m_depth = level;
- }
+ if (level > m_depth) {
+ m_depth = level;
+ }
- if (key->hasChildren()) {
- key->firstChild();
- computeDepth(key, level+1);
+ if (key->hasChildren()) {
+ key->firstChild();
+ computeDepth(key, level + 1);
- key->setText( savedKey.c_str() );//return to the initial value
- }
+ key->setText( savedKey.c_str() );//return to the initial value
+ }
- if (key->nextSibling()) {
- computeDepth(key, level);
- }
+ if (key->nextSibling()) {
+ computeDepth(key, level);
+ }
}
/** Returns a treekey filled with the structure of this module */
sword::TreeKeyIdx* CSwordBookModuleInfo::tree() const {
- sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*)*(module()));
- Q_ASSERT(treeKey);
- return treeKey;
+ sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*) * (module()));
+ Q_ASSERT(treeKey);
+ return treeKey;
}
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index f471d61..cd18efc 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -21,43 +21,43 @@
class CSwordBookModuleInfo : public CSwordModuleInfo {
-public:
- /** Constructor.
- * @param module The module which belongs to this object
- * @param backend The parent backend for this book module.
- */
- CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
- /** Copy constructor.
- * Copy constructor to copy the passed parameter.
- * @param module The module which should be copied.
- */
- CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
- /** Destructor.
- */
- ~CSwordBookModuleInfo();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the maximal depth of sections and subsections.
- */
- int depth();
- /**
- * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
- */
- sword::TreeKeyIdx* tree() const;
+ public:
+ /** Constructor.
+ * @param module The module which belongs to this object
+ * @param backend The parent backend for this book module.
+ */
+ CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
+ /** Copy constructor.
+ * Copy constructor to copy the passed parameter.
+ * @param module The module which should be copied.
+ */
+ CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
+ /** Destructor.
+ */
+ ~CSwordBookModuleInfo();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the maximal depth of sections and subsections.
+ */
+ int depth();
+ /**
+ * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
+ */
+ sword::TreeKeyIdx* tree() const;
-private:
- /**
- * A recursive helper function to help computng the module depth!
- */
- void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
- int m_depth;
+ private:
+ /**
+ * A recursive helper function to help computng the module depth!
+ */
+ void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
+ int m_depth;
};
inline CSwordBookModuleInfo::ModuleType CSwordBookModuleInfo::type() const {
- return CSwordModuleInfo::GenericBook;
+ return CSwordModuleInfo::GenericBook;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index b09e2f3..bb19a23 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -10,23 +10,23 @@
#include "cswordcommentarymoduleinfo.h"
CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
-: CSwordBibleModuleInfo(module, usedBackend) {}
+ : CSwordBibleModuleInfo(module, usedBackend) {}
CSwordCommentaryModuleInfo::~CSwordCommentaryModuleInfo() {}
/** No descriptions */
CSwordModuleInfo* CSwordCommentaryModuleInfo::clone() {
- return new CSwordCommentaryModuleInfo(*this);
+ return new CSwordCommentaryModuleInfo(*this);
}
/** Returns true if this module may be written by the write display windows. */
bool CSwordCommentaryModuleInfo::isWritable() const {
- // qWarning(module()->getConfigEntry("ModDrv"));
- //a module is only writable if it's a RawFiles module with writable returning true
+ // qWarning(module()->getConfigEntry("ModDrv"));
+ //a module is only writable if it's a RawFiles module with writable returning true
- if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
- return true;
- };
+ if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
+ return true;
+ };
- return false;
+ return false;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index 7ebf23f..eb9db83 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -21,23 +21,23 @@
class CSwordCommentaryModuleInfo : public CSwordBibleModuleInfo {
-public:
- CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
- ~CSwordCommentaryModuleInfo();
- /** Reimplementation to return the commentary type.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /** Reimplementation to clone the current object.
- */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns true if this module may be written by the write display windows.
- */
- virtual bool isWritable() const;
+ public:
+ CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ ~CSwordCommentaryModuleInfo();
+ /** Reimplementation to return the commentary type.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /** Reimplementation to clone the current object.
+ */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ virtual bool isWritable() const;
};
inline CSwordModuleInfo::ModuleType CSwordCommentaryModuleInfo::type() const {
- return CSwordModuleInfo::Commentary;
+ return CSwordModuleInfo::Commentary;
}
#endif
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index c84cd07..28874b6 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -25,151 +25,151 @@
#define CACHE_FORMAT "2"
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) {
- m_entryList = 0;
+ m_entryList = 0;
}
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ) : CSwordModuleInfo(m) {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
- if (m.m_entryList) {
- m_entryList = new QStringList();
- *m_entryList = *m.m_entryList;//copy list items
- }
+ if (m.m_entryList) {
+ m_entryList = new QStringList();
+ *m_entryList = *m.m_entryList;//copy list items
+ }
}
CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
}
/** Returns the entries of the module. */
QStringList* CSwordLexiconModuleInfo::entries() {
- if (!module()) {
- return 0;
- }
-
- sword::SWModule* my_module = module();
- bool is_unicode = isUnicode();
-
- if (!m_entryList) {
- m_entryList = new QStringList();
- bool read = false;
-
- //Check for buggy modules! They will not be loaded any more.
-
- if ( name() == QString("ZhEnglish")) {
- qWarning("Module ZhEnglish is buggy and will not be loaded.");
- return m_entryList;
- }
-
- if ( name() == QString("EReo_en")) {
- qWarning("Module EReo_en is buggy and will not be loaded.");
- return m_entryList;
- }
-
- QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
- QFile f1(
- QString(dir)
- .append("/")
- .append(name())
- );
-
- if ( f1.open( QIODevice::ReadOnly ) ) {
- QDataStream s( &f1 );
- QString mod_ver, prog_ver;
- s >> mod_ver;
- s >> prog_ver;
-
- if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
- s >> *m_entryList;
- read = true;
- }
-
- f1.close();
- // qWarning("read entries %d",m_entryList->count());
- }
-
- // Q_ASSERT(read);
- // Q_ASSERT(m_entryList->count());
- if (!read || !m_entryList->count()) {
- my_module->setSkipConsecutiveLinks(true);
- (*my_module) = sword::TOP;
- snap(); //snap to top entry
-
- // qWarning("Reading in module" );
- int i = 0;
-
- do {
- if ( is_unicode ) {
- m_entryList->append(QString::fromUtf8(my_module->KeyText()));
- // qWarning("Entry: %s", my_module->KeyText() );
- }
- else { //for latin1 modules use fromLatin1 because of speed
- // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
- QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
- m_entryList->append(codec->toUnicode(my_module->KeyText()));
- }
-
- (*my_module)++;
- i++;
- }
- while ( !my_module->Error() );
-
- // qWarning("Reading finished. Module has %d entries.", i );
-
- (*my_module) = sword::TOP; //back to the first entry
-
- my_module->setSkipConsecutiveLinks(false);
-
- if (m_entryList->count()) {
- m_entryList->first().simplified();
-
- if (m_entryList->first().trimmed().isEmpty()) {
- m_entryList->erase( m_entryList->begin() );
- }
-
- //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
- // qWarning("sorting");
- // QStringList::iterator start(m_entryList->begin());
- // QStringList::iterator end(m_entryList->end());
- // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
- // m_entryList->sort(); //make sure the module is sorted by utf-8
- }
-
- qWarning("Writing cache file.");
-
- if (m_entryList->count()) {
- //create cache
- QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
- //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
- QFile f2( QString(dir).append("/").append(name()) );
-
-
- if (f2.open( QIODevice::WriteOnly )) {
- QDataStream s( &f2 );
- s << config(CSwordModuleInfo::ModuleVersion); //store module version
- s << QString(CACHE_FORMAT); //store BT version -- format may change
- s << *m_entryList;
- f2.close();
- }
- }
- }
- }
-
- return m_entryList;
+ if (!module()) {
+ return 0;
+ }
+
+ sword::SWModule* my_module = module();
+ bool is_unicode = isUnicode();
+
+ if (!m_entryList) {
+ m_entryList = new QStringList();
+ bool read = false;
+
+ //Check for buggy modules! They will not be loaded any more.
+
+ if ( name() == QString("ZhEnglish")) {
+ qWarning("Module ZhEnglish is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ if ( name() == QString("EReo_en")) {
+ qWarning("Module EReo_en is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
+ QFile f1(
+ QString(dir)
+ .append("/")
+ .append(name())
+ );
+
+ if ( f1.open( QIODevice::ReadOnly ) ) {
+ QDataStream s( &f1 );
+ QString mod_ver, prog_ver;
+ s >> mod_ver;
+ s >> prog_ver;
+
+ if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
+ s >> *m_entryList;
+ read = true;
+ }
+
+ f1.close();
+ // qWarning("read entries %d",m_entryList->count());
+ }
+
+ // Q_ASSERT(read);
+ // Q_ASSERT(m_entryList->count());
+ if (!read || !m_entryList->count()) {
+ my_module->setSkipConsecutiveLinks(true);
+ (*my_module) = sword::TOP;
+ snap(); //snap to top entry
+
+ // qWarning("Reading in module" );
+ int i = 0;
+
+ do {
+ if ( is_unicode ) {
+ m_entryList->append(QString::fromUtf8(my_module->KeyText()));
+ // qWarning("Entry: %s", my_module->KeyText() );
+ }
+ else { //for latin1 modules use fromLatin1 because of speed
+ // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
+ QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
+ m_entryList->append(codec->toUnicode(my_module->KeyText()));
+ }
+
+ (*my_module)++;
+ i++;
+ }
+ while ( !my_module->Error() );
+
+ // qWarning("Reading finished. Module has %d entries.", i );
+
+ (*my_module) = sword::TOP; //back to the first entry
+
+ my_module->setSkipConsecutiveLinks(false);
+
+ if (m_entryList->count()) {
+ m_entryList->first().simplified();
+
+ if (m_entryList->first().trimmed().isEmpty()) {
+ m_entryList->erase( m_entryList->begin() );
+ }
+
+ //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
+ // qWarning("sorting");
+ // QStringList::iterator start(m_entryList->begin());
+ // QStringList::iterator end(m_entryList->end());
+ // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
+ // m_entryList->sort(); //make sure the module is sorted by utf-8
+ }
+
+ qWarning("Writing cache file.");
+
+ if (m_entryList->count()) {
+ //create cache
+ QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
+ //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
+ QFile f2( QString(dir).append("/").append(name()) );
+
+
+ if (f2.open( QIODevice::WriteOnly )) {
+ QDataStream s( &f2 );
+ s << config(CSwordModuleInfo::ModuleVersion); //store module version
+ s << QString(CACHE_FORMAT); //store BT version -- format may change
+ s << *m_entryList;
+ f2.close();
+ }
+ }
+ }
+ }
+
+ return m_entryList;
}
/** Jumps to the closest entry in the module. */
bool CSwordLexiconModuleInfo::snap() {
- if(module()->getRawEntry()) { // Snap to the current entry
- return true;
- }
+ if (module()->getRawEntry()) { // Snap to the current entry
+ return true;
+ }
- return false;
+ return false;
}
/** No descriptions */
CSwordModuleInfo* CSwordLexiconModuleInfo::clone() {
- return new CSwordLexiconModuleInfo(*this);
+ return new CSwordLexiconModuleInfo(*this);
}
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index 13f72e4..e5a5535 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -24,48 +24,48 @@
class CSwordLexiconModuleInfo : public CSwordModuleInfo {
-public:
- /**
- * The standard constructor fot this object.
- * A default constructor doesn't exist. Use this one.
- */
- CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /**
- * The copy constructor
- */
- CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordLexiconModuleInfo();
- /**
- * Returns the entries of the module.
- * This function returns the entries of the modules represented by this object.
- * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
- * If the function is called again, the cached list is returned so we have a major speed improvement.
- * @return The list of lexicon entries
- */
- QStringList* entries();
- /**
- * Reimplementation, to return the right type for this lexicon.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Jumps to the closest entry in the module.
- */
- bool snap();
+ public:
+ /**
+ * The standard constructor fot this object.
+ * A default constructor doesn't exist. Use this one.
+ */
+ CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /**
+ * The copy constructor
+ */
+ CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordLexiconModuleInfo();
+ /**
+ * Returns the entries of the module.
+ * This function returns the entries of the modules represented by this object.
+ * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
+ * If the function is called again, the cached list is returned so we have a major speed improvement.
+ * @return The list of lexicon entries
+ */
+ QStringList* entries();
+ /**
+ * Reimplementation, to return the right type for this lexicon.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Jumps to the closest entry in the module.
+ */
+ bool snap();
-private:
- /**
- * This is the list which caches the entres of the module.
- */
- QStringList* m_entryList;
+ private:
+ /**
+ * This is the list which caches the entres of the module.
+ */
+ QStringList* m_entryList;
};
inline CSwordModuleInfo::ModuleType CSwordLexiconModuleInfo::type() const {
- return CSwordModuleInfo::Lexicon;
+ return CSwordModuleInfo::Lexicon;
}
#endif
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index c76f5ef..5861a2b 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -53,96 +53,96 @@
//Increment this, if the index format changes
//Then indices on the user's systems will be rebuilt
-const unsigned int INDEX_VERSION = 6;
+const unsigned int INDEX_VERSION = 7;
//Maximum index entry size, 1MiB for now
//Lucene default is too small
-const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024*1024;
+const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024 * 1024;
CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * const usedBackend) {
- m_module = module;
- Q_ASSERT(module);
-
- m_hidden = false;
- m_cancelIndexing = false;
- m_searchResult.ClearList();
- m_backend = usedBackend ? usedBackend : CPointers::backend();
- m_dataCache.name = module ? QString(module->Name()) : QString::null;
- m_dataCache.isUnicode = module ? module->isUnicode() : false;
- m_dataCache.category = UnknownCategory;
- m_dataCache.language = 0;
- m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
-
- if (backend()) {
- if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
- qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
- name().toUtf8().constData(), (const char *)minimumSwordVersion());
- }
- }
-}
-
-CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject(){
- m_module = m.m_module;
- m_backend = m.m_backend;
- m_dataCache = m.m_dataCache;
- m_searchResult = m.m_searchResult;
- m_hidden = m.m_hidden;
- m_cancelIndexing = m.m_cancelIndexing;
+ m_module = module;
+ Q_ASSERT(module);
+
+ m_hidden = false;
+ m_cancelIndexing = false;
+ m_searchResult.ClearList();
+ m_backend = usedBackend ? usedBackend : CPointers::backend();
+ m_dataCache.name = module ? QString(module->Name()) : QString::null;
+ m_dataCache.isUnicode = module ? module->isUnicode() : false;
+ m_dataCache.category = UnknownCategory;
+ m_dataCache.language = 0;
+ m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
+
+ if (backend()) {
+ if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
+ qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
+ name().toUtf8().constData(), (const char *)minimumSwordVersion());
+ }
+ }
+}
+
+CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject() {
+ m_module = m.m_module;
+ m_backend = m.m_backend;
+ m_dataCache = m.m_dataCache;
+ m_searchResult = m.m_searchResult;
+ m_hidden = m.m_hidden;
+ m_cancelIndexing = m.m_cancelIndexing;
}
/** No descriptions */
CSwordModuleInfo *CSwordModuleInfo::clone() {
- return new CSwordModuleInfo(*this);
+ return new CSwordModuleInfo(*this);
}
CSwordModuleInfo::~CSwordModuleInfo() {
- m_searchResult.ClearList();
- m_module = 0; //the Sword module object is deleted by the backend
+ m_searchResult.ClearList();
+ m_module = 0; //the Sword module object is deleted by the backend
}
/** Sets the unlock key of the modules and writes the key into the cofig file.*/
bool CSwordModuleInfo::unlock(const QString & unlockKey) {
- if (!isEncrypted()) {
- return false;
- }
+ if (!isEncrypted()) {
+ return false;
+ }
- CBTConfig::setModuleEncryptionKey(name(), unlockKey);
- backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
- //TODO: write to Sword config as well
+ CBTConfig::setModuleEncryptionKey(name(), unlockKey);
+ backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
+ //TODO: write to Sword config as well
- return true;
+ return true;
}
/** This function returns true if this module is locked, otherwise return false. */
bool CSwordModuleInfo::isLocked() {
- //still works, but the cipherkey is stored in CBTConfig.
- //Works because it is set in sword on program startup.
+ //still works, but the cipherkey is stored in CBTConfig.
+ //Works because it is set in sword on program startup.
- if (isEncrypted()) {
- if (unlockKeyIsValid()) {
- return false;
- }
- return true;
- }
- return false;
+ if (isEncrypted()) {
+ if (unlockKeyIsValid()) {
+ return false;
+ }
+ return true;
+ }
+ return false;
}
/** This functions returns true if this module is encrypted (locked or unlocked). */
bool CSwordModuleInfo::isEncrypted() const {
- /**
- * If we have the CipherKey entry the module
- * is encrypted but not necessarily locked
- */
+ /**
+ * If we have the CipherKey entry the module
+ * is encrypted but not necessarily locked
+ */
- //This code is still right, though we do no longer write to the module config files any more
- sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
- sword::ConfigEntMap::iterator it = config.find("CipherKey");
+ //This code is still right, though we do no longer write to the module config files any more
+ sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
+ sword::ConfigEntMap::iterator it = config.find("CipherKey");
- if (it != config.end()) {
- return true;
- }
+ if (it != config.end()) {
+ return true;
+ }
- return false;
+ return false;
}
/** This function makes an estimate if a module was properly unlocked.
@@ -154,757 +154,773 @@ bool CSwordModuleInfo::isEncrypted() const {
*/
bool CSwordModuleInfo::unlockKeyIsValid() {
- (*m_module) = sword::TOP;
+ (*m_module) = sword::TOP;
- // This needs to use ::fromLatin1 because if the text is still locked,
- // a lot of garbage will show up. It will also work with properly decrypted
- // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
- // and therefore contain no control (nonprintable) characters, which are all <127.
- QString test = isUnicode()
- ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
- : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
+ // This needs to use ::fromLatin1 because if the text is still locked,
+ // a lot of garbage will show up. It will also work with properly decrypted
+ // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
+ // and therefore contain no control (nonprintable) characters, which are all <127.
+ QString test = isUnicode()
+ ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
+ : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
- if (test.isEmpty()) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
+ if (test.isEmpty()) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
- for (int i = 0; i <= test.length() && i < 100; i++) {
- if ( !test[i].isPrint() && !test[i].isNull() ) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
- }
+ for (int i = 0; i <= test.length() && i < 100; i++) {
+ if ( !test[i].isPrint() && !test[i].isNull() ) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
+ }
- qDebug() << "Unlock key of module" << name() << "is valid";
- return true;
+ qDebug() << "Unlock key of module" << name() << "is valid";
+ return true;
}
QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
- return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
+ return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
- return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
+ return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
}
QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for now returns the location of the main index
- return getModuleBaseIndexLocation() + QString("/standard");
+ return getModuleBaseIndexLocation() + QString("/standard");
}
bool CSwordModuleInfo::hasIndex() {
- //this will return true only
- //if the index exists and has correct version information for both index and module
- QDir d;
- if (!d.exists( getModuleStandardIndexLocation() )) {
- return false;
- }
-
- //first check if the index version and module version are ok
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
-
- if (hasVersion()) {
- if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
- return false;
- }
- }
- if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
- qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
- return false;
- }
-
- //then check if the index is there
- return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
-}
-
+ //this will return true only
+ //if the index exists and has correct version information for both index and module
+ QDir d;
+ if (!d.exists( getModuleStandardIndexLocation() )) {
+ return false;
+ }
+
+ //first check if the index version and module version are ok
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+
+ if (hasVersion()) {
+ if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
+ return false;
+ }
+ }
+ if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
+ qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
+ return false;
+ }
+
+ //then check if the index is there
+ return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
+}
+
+// HELPER Method: this dumps all current EntryAttributes of a module
+//#include <iostream>
+//void dumpEntryAttributes(sword::SWModule *module) {
+// std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+// sword::AttributeTypeList::iterator i1;
+// sword::AttributeList::iterator i2;
+// sword::AttributeValue::iterator i3;
+// for (i1 = module->getEntryAttributes().begin(); i1 != module->getEntryAttributes().end(); i1++) {
+// std::cout << "[ " << i1->first << " ]\n";
+// for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
+// std::cout << "\t[ " << i2->first << " ]\n";
+// for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
+// std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+// }
+// }
+// }
+// std::cout << std::endl;
+//}
void CSwordModuleInfo::buildIndex() {
- m_cancelIndexing = false;
-
- try
- {
- //Without this we don't get strongs, lemmas, etc
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- //make sure we reset all important filter options which influcence the plain filters.
- backend()->setOption( CSwordModuleInfo::strongNumbers, false );
- backend()->setOption( CSwordModuleInfo::morphTags, false );
- backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
- backend()->setOption( CSwordModuleInfo::footnotes, false );
- backend()->setOption( CSwordModuleInfo::headings, false );
- backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
- backend()->setOption( CSwordModuleInfo::redLetterWords, false );
-
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
- QString index = getModuleStandardIndexLocation();
-
- QDir dir("/");
- dir.mkpath( getGlobalBaseIndexLocation() );
- dir.mkpath( getModuleBaseIndexLocation() );
- dir.mkpath( getModuleStandardIndexLocation() );
-
- if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
- if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
- lucene::index::IndexReader::unlock(index.toAscii().constData());
- }
- }
-
- boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
- writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
- writer->setUseCompoundFile(true); //merge segments into a single file
- writer->setMinMergeDocs(1000);
-
- *m_module = sword::TOP;
- unsigned long verseLowIndex = m_module->Index();
- *m_module = sword::BOTTOM;
- unsigned long verseHighIndex = m_module->Index();
-
- //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
- unsigned long verseIndex = verseLowIndex + 1;
- unsigned long verseSpan = verseHighIndex - verseLowIndex;
-
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex = 0;
- verseLowIndex = 0;
- verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
- }
-
- emit indexingProgress(0);
-
- sword::SWKey* key = m_module->getKey();
- //VerseKey for bibles
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
-
- if (vk) {
- // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
- vk->setLocale("en_US");
- //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
- vk->Headings(1);
- }
-
- //holds UTF-8 data and is faster than QString.
- QByteArray textBuffer;
-
- // we start with the first module entry, key is automatically updated
- // because key is a pointer to the modules key
- m_module->setSkipConsecutiveLinks(true);
-
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
-
- for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
-
- //If it is a sword-heading, store in buffer and index later in Verse X:1
- if (vk) {
- if (vk->Verse() == 0) {
- textBuffer.append( m_module->StripText() );
- continue;
- }
- }
-
- boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
-
- //index the key
- lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
- // index the main text
- //at this point we have to make sure we disabled the strongs and the other options
- //so the plain filters won't include the numbers somehow.
- lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- textBuffer.resize(0); //clean up
-
- // index attributes
- sword::AttributeList::iterator attListI;
- sword::AttributeValue::iterator attValueI;
- // Footnotes
- for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
- attListI != m_module->getEntryAttributes()["Footnote"].end();
- attListI++) {
- lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attListI
-
- // Headings
- for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
- attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
- attValueI++) {
- lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attValueI
-
- // Strongs/Morphs
- for (attListI = m_module->getEntryAttributes()["Word"].begin();
- attListI != m_module->getEntryAttributes()["Word"].end();
- attListI++) {
- // for each attribute
- if (attListI->second["LemmaClass"] == "strong") {
- lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
- }
- if (attListI->second.find("Morph") != attListI->second.end()) {
- lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- }
- } // for attListI
-
- writer->addDocument(doc.get());
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex++;
- }
- else{
- verseIndex = m_module->Index();
- }
-
- if (verseIndex % 200 == 0) {
- int indexingProgressValue;
- if (verseSpan == 0) { //prevent division by zero
- //m_indexingProgress.setValue( QVariant(0) );
- indexingProgressValue = 0;
- } else {
- //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
- indexingProgressValue = (int)((100*(verseIndex-verseLowIndex)) / (verseSpan));
- }
- //m_indexingProgress.activate();
- emit indexingProgress(indexingProgressValue);
- }
- }
-
- if (!m_cancelIndexing)
- {
- writer->optimize();
- }
- writer->close();
-
- if (m_cancelIndexing){
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
- else
- {
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
- if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
- module_config.setValue("index-version", INDEX_VERSION );
- }
- }
- catch(...)
- {
- qWarning("CLucene exception occurred while indexing");
- QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
+ m_cancelIndexing = false;
+
+ try {
+ //Without this we don't get strongs, lemmas, etc
+ backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
+ //make sure we reset all important filter options which influcence the plain filters.
+ // turn on these options, they are needed for the EntryAttributes population
+ backend()->setOption( CSwordModuleInfo::strongNumbers, true );
+ backend()->setOption( CSwordModuleInfo::morphTags, true );
+ backend()->setOption( CSwordModuleInfo::footnotes, true );
+ backend()->setOption( CSwordModuleInfo::headings, true );
+ // we don't want the following in the text, the do not carry searchable information
+ backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
+ backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
+ backend()->setOption( CSwordModuleInfo::redLetterWords, false );
+
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
+ QString index = getModuleStandardIndexLocation();
+
+ QDir dir("/");
+ dir.mkpath( getGlobalBaseIndexLocation() );
+ dir.mkpath( getModuleBaseIndexLocation() );
+ dir.mkpath( getModuleStandardIndexLocation() );
+
+ if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
+ if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
+ lucene::index::IndexReader::unlock(index.toAscii().constData());
+ }
+ }
+
+ boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
+ writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
+ writer->setUseCompoundFile(true); //merge segments into a single file
+ writer->setMinMergeDocs(1000);
+
+ *m_module = sword::TOP;
+ unsigned long verseLowIndex = m_module->Index();
+ *m_module = sword::BOTTOM;
+ unsigned long verseHighIndex = m_module->Index();
+
+ //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
+ unsigned long verseIndex = verseLowIndex + 1;
+ unsigned long verseSpan = verseHighIndex - verseLowIndex;
+
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex = 0;
+ verseLowIndex = 0;
+ verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
+ }
+
+ emit indexingProgress(0);
+
+ sword::SWKey* key = m_module->getKey();
+ //VerseKey for bibles
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
+
+ if (vk) {
+ // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
+ vk->setLocale("en_US");
+ //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
+ vk->Headings(1);
+ }
+
+ //holds UTF-8 data and is faster than QString.
+ QByteArray textBuffer;
+
+ // we start with the first module entry, key is automatically updated
+ // because key is a pointer to the modules key
+ m_module->setSkipConsecutiveLinks(true);
+
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+
+ for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
+
+ // Also index Chapter 0 and Verse 0, because they might have information in the entry attributes
+ // We used to just put their content into the textBuffer and continue to the next verse, but
+ // with entry attributes this doesn't work any more.
+ // Hits in the search dialog will show up as 1:1 (instead of 0)
+
+ boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
+
+ //index the key
+ lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
+
+ //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
+
+ // index the main text
+ //at this point we have to make sure we disabled the strongs and the other options
+ //so the plain filters won't include the numbers somehow.
+ lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ textBuffer.resize(0); //clean up
+
+ // index attributes
+ sword::AttributeList::iterator attListI;
+ sword::AttributeValue::iterator attValueI;
+ // Footnotes
+ for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
+ attListI != m_module->getEntryAttributes()["Footnote"].end();
+ attListI++) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attListI
+
+ // Headings
+ for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
+ attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
+ attValueI++) {
+ lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attValueI
+
+ // Strongs/Morphs
+ for (attListI = m_module->getEntryAttributes()["Word"].begin();
+ attListI != m_module->getEntryAttributes()["Word"].end();
+ attListI++) {
+ // for each attribute
+ if (attListI->second["LemmaClass"] == "strong") {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
+ }
+ if (attListI->second.find("Morph") != attListI->second.end()) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ }
+ } // for attListI
+
+ writer->addDocument(doc.get());
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex++;
+ }
+ else {
+ verseIndex = m_module->Index();
+ }
+
+ if (verseIndex % 200 == 0) {
+ int indexingProgressValue;
+ if (verseSpan == 0) { //prevent division by zero
+ //m_indexingProgress.setValue( QVariant(0) );
+ indexingProgressValue = 0;
+ }
+ else {
+ //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
+ indexingProgressValue = (int)((100 * (verseIndex - verseLowIndex)) / (verseSpan));
+ }
+ //m_indexingProgress.activate();
+ emit indexingProgress(indexingProgressValue);
+ }
+ }
+
+ if (!m_cancelIndexing) {
+ writer->optimize();
+ }
+ writer->close();
+
+ if (m_cancelIndexing) {
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
+ else {
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+ if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
+ module_config.setValue("index-version", INDEX_VERSION );
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred while indexing");
+ QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
}
void CSwordModuleInfo::deleteIndexForModule( QString name ) {
- util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
+ util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
unsigned long CSwordModuleInfo::indexSize() const {
- return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
}
bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey& scope) {
- char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- // work around Swords thread insafety for Bibles and Commentaries
- boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
- sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
- QList<sword::VerseKey*> list;
+ // work around Swords thread insafety for Bibles and Commentaries
+ boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
+ sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
+ QList<sword::VerseKey*> list;
- if (s) {
- m_module->SetKey(*s);
- }
+ if (s) {
+ m_module->SetKey(*s);
+ }
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
- try {
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
- lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
- lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
- boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
+ try {
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
+ lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
+ lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
+ boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
- boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
+ boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
- const bool useScope = (scope.Count() > 0);
+ const bool useScope = (scope.Count() > 0);
// const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary);
- lucene::document::Document* doc = 0;
- boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
+ lucene::document::Document* doc = 0;
+ boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
- for (int i = 0; i < h->length(); ++i) {
- doc = &h->doc(i);
- lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
+ for (int i = 0; i < h->length(); ++i) {
+ doc = &h->doc(i);
+ lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
- swKey->setText(utfBuffer);
+ swKey->setText(utfBuffer);
- // limit results based on scope
- //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
- if (useScope) {
- for (int j = 0; j < scope.Count(); j++) {
- sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
- if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
- m_searchResult.add(*swKey);
- }
- }
- } else { // no scope, give me all buffers
- m_searchResult.add(*swKey);
- }
- }
- }
- catch (...) {
- qWarning("CLucene exception occurred");
- QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
- return false;
- }
+ // limit results based on scope
+ //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
+ if (useScope) {
+ for (int j = 0; j < scope.Count(); j++) {
+ sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
+ if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ else { // no scope, give me all buffers
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred");
+ QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ return false;
+ }
- qDeleteAll(list);
- list.clear();
+ qDeleteAll(list);
+ list.clear();
- return (m_searchResult.Count() > 0);
+ return (m_searchResult.Count() > 0);
}
/** Returns the last search result for this module. */
sword::ListKey & CSwordModuleInfo::searchResult(const sword::ListKey * newResult) {
- if (newResult) {
- m_searchResult.copyFrom(*newResult);
- }
+ if (newResult) {
+ m_searchResult.copyFrom(*newResult);
+ }
- return m_searchResult;
+ return m_searchResult;
}
/** Clears the last search result. */
void CSwordModuleInfo::clearSearchResult() {
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
}
/** Returns the required Sword version for this module. Returns -1 if no special Sword version is required. */
sword::SWVersion CSwordModuleInfo::minimumSwordVersion() {
- return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
+ return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
}
QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) const {
- switch (entry) {
+ switch (entry) {
- case AboutInformation:
- return getFormattedConfigEntry("About");
+ case AboutInformation:
+ return getFormattedConfigEntry("About");
- case CipherKey: {
- if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
- return QString(m_module->getConfigEntry("CipherKey"));
- }
- else {
- return CBTConfig::getModuleEncryptionKey(name());
- }
- }
+ case CipherKey: {
+ if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
+ return QString(m_module->getConfigEntry("CipherKey"));
+ }
+ else {
+ return CBTConfig::getModuleEncryptionKey(name());
+ }
+ }
- case AbsoluteDataPath: {
- QString path( getSimpleConfigEntry("AbsoluteDataPath") );
- path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
- //make sure we have a trailing slash!
+ case AbsoluteDataPath: {
+ QString path( getSimpleConfigEntry("AbsoluteDataPath") );
+ path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
+ //make sure we have a trailing slash!
- if (path.right(1) != "/") {
- path.append('/');
- }
+ if (path.right(1) != "/") {
+ path.append('/');
+ }
- return path;
- }
+ return path;
+ }
- case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
- QString path(getSimpleConfigEntry("DataPath"));
+ case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
+ QString path(getSimpleConfigEntry("DataPath"));
- if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
- int pos = path.lastIndexOf("/"); //last slash in the string
+ if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
+ int pos = path.lastIndexOf("/"); //last slash in the string
- if (pos != -1) {
- path = path.left(pos + 1); //include the slash
- }
- }
+ if (pos != -1) {
+ path = path.left(pos + 1); //include the slash
+ }
+ }
- return path;
- }
+ return path;
+ }
- case Description:
- return getFormattedConfigEntry("Description");
+ case Description:
+ return getFormattedConfigEntry("Description");
- case ModuleVersion: {
- QString version(getSimpleConfigEntry("Version"));
+ case ModuleVersion: {
+ QString version(getSimpleConfigEntry("Version"));
- if (version.isEmpty()) {
- version = "1.0";
- }
+ if (version.isEmpty()) {
+ version = "1.0";
+ }
- return version;
- }
+ return version;
+ }
- case MinimumSwordVersion: {
- const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
- return !minimumVersion.isEmpty()? minimumVersion : QString("0.0");
- }
+ case MinimumSwordVersion: {
+ const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
+ return !minimumVersion.isEmpty() ? minimumVersion : QString("0.0");
+ }
- case TextDir: {
- const QString dir(getSimpleConfigEntry("Direction"));
- return !dir.isEmpty()? dir : QString("LtoR");
- }
+ case TextDir: {
+ const QString dir(getSimpleConfigEntry("Direction"));
+ return !dir.isEmpty() ? dir : QString("LtoR");
+ }
- case DisplayLevel: {
- const QString level(getSimpleConfigEntry("DisplayLevel"));
- return !level.isEmpty()? level : QString("1");
- }
+ case DisplayLevel: {
+ const QString level(getSimpleConfigEntry("DisplayLevel"));
+ return !level.isEmpty() ? level : QString("1");
+ }
- case GlossaryFrom: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryFrom: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryFrom"));
+ const QString lang(getSimpleConfigEntry("GlossaryFrom"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case GlossaryTo: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryTo: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryTo"));
+ const QString lang(getSimpleConfigEntry("GlossaryTo"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case Markup: {
- const QString markup(getSimpleConfigEntry("SourceType"));
- return !markup.isEmpty()? markup : QString("Unknown");
- }
+ case Markup: {
+ const QString markup(getSimpleConfigEntry("SourceType"));
+ return !markup.isEmpty() ? markup : QString("Unknown");
+ }
- case DistributionLicense:
- return getSimpleConfigEntry("DistributionLicense");
+ case DistributionLicense:
+ return getSimpleConfigEntry("DistributionLicense");
- case DistributionSource:
- return getSimpleConfigEntry("DistributionSource");
+ case DistributionSource:
+ return getSimpleConfigEntry("DistributionSource");
- case DistributionNotes:
- return getSimpleConfigEntry("DistributionNotes");
+ case DistributionNotes:
+ return getSimpleConfigEntry("DistributionNotes");
- case TextSource:
- return getSimpleConfigEntry("TextSource");
+ case TextSource:
+ return getSimpleConfigEntry("TextSource");
- case CopyrightNotes:
- return getSimpleConfigEntry("CopyrightNotes");
+ case CopyrightNotes:
+ return getSimpleConfigEntry("CopyrightNotes");
- case CopyrightHolder:
- return getSimpleConfigEntry("CopyrightHolder");
+ case CopyrightHolder:
+ return getSimpleConfigEntry("CopyrightHolder");
- case CopyrightDate:
- return getSimpleConfigEntry("CopyrightDate");
+ case CopyrightDate:
+ return getSimpleConfigEntry("CopyrightDate");
- case CopyrightContactName:
- return getSimpleConfigEntry("CopyrightContactName");
+ case CopyrightContactName:
+ return getSimpleConfigEntry("CopyrightContactName");
- case CopyrightContactAddress:
- return getSimpleConfigEntry("CopyrightContactAddress");
+ case CopyrightContactAddress:
+ return getSimpleConfigEntry("CopyrightContactAddress");
- case CopyrightContactEmail:
- return getSimpleConfigEntry("CopyrightContactEmail");
+ case CopyrightContactEmail:
+ return getSimpleConfigEntry("CopyrightContactEmail");
- default:
- return QString::null;
- }
+ default:
+ return QString::null;
+ }
}
/** Returns true if the module supports the feature given as parameter. */
bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const {
- switch (feature) {
+ switch (feature) {
- // case StrongsNumbers:
- // return m_module->getConfig().has("Feature", "StrongsNumber");
+ // case StrongsNumbers:
+ // return m_module->getConfig().has("Feature", "StrongsNumber");
- case GreekDef:
- return m_module->getConfig().has("Feature", "GreekDef");
+ case GreekDef:
+ return m_module->getConfig().has("Feature", "GreekDef");
- case HebrewDef:
- return m_module->getConfig().has("Feature", "HebrewDef");
+ case HebrewDef:
+ return m_module->getConfig().has("Feature", "HebrewDef");
- case GreekParse:
- return m_module->getConfig().has("Feature", "GreekParse");
+ case GreekParse:
+ return m_module->getConfig().has("Feature", "GreekParse");
- case HebrewParse:
- return m_module->getConfig().has("Feature", "HebrewParse");
- }
+ case HebrewParse:
+ return m_module->getConfig().has("Feature", "HebrewParse");
+ }
- return false;
+ return false;
}
bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const {
- //BAD workaround to see if the filter is GBF, OSIS or ThML!
- const QString name = backend()->configOptionName(option);
+ //BAD workaround to see if the filter is GBF, OSIS or ThML!
+ const QString name = backend()->configOptionName(option);
- if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the text direction of the module's text., */
CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() {
- if (config(TextDir) == "RtoL") {
- return CSwordModuleInfo::RightToLeft;
- }
- else {
- return CSwordModuleInfo::LeftToRight;
- }
+ if (config(TextDir) == "RtoL") {
+ return CSwordModuleInfo::RightToLeft;
+ }
+ else {
+ return CSwordModuleInfo::LeftToRight;
+ }
}
/** Writes the new text at the given position into the module. This does only work for writable modules. */
void CSwordModuleInfo::write(CSwordKey * key, const QString & newText) {
- module()->KeyText(key->key().toUtf8().constData());
+ module()->KeyText(key->key().toUtf8().constData());
- //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
- module()->setEntry(isUnicode()? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
+ //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
+ module()->setEntry(isUnicode() ? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
}
/** Deletes the current entry and removes it from the module. */
bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
- module()->KeyText(isUnicode()? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
+ module()->KeyText(isUnicode() ? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
- if (module()) {
- module()->deleteEntry();
- return true;
- }
+ if (module()) {
+ module()->deleteEntry();
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */
CSwordModuleInfo::Category CSwordModuleInfo::category() const {
- //qDebug("CSwordModuleInfo::category");
- if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
- const QString cat(m_module->getConfigEntry("Category"));
- //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
-
- if (cat == "Cults / Unorthodox / Questionable Material") {
- m_dataCache.category = Cult;
- }
- else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
- m_dataCache.category = DailyDevotional;
- }
- else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
- m_dataCache.category = Glossary;
- }
- else if (cat == "Images" || cat == "Maps") {
- m_dataCache.category = Images;
- }
- else if (type() == Commentary) {
- m_dataCache.category = Commentaries;
- }
- else if (type() == Bible) {
- m_dataCache.category = Bibles;
- }
- else if (type() == Lexicon) {
- m_dataCache.category = Lexicons;
- }
- else if (type() == GenericBook) {
- m_dataCache.category = Books;
- }
- }
- //qDebug() << "assigned category: " << m_dataCache.category;
- return m_dataCache.category;
+ //qDebug("CSwordModuleInfo::category");
+ if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
+ const QString cat(m_module->getConfigEntry("Category"));
+ //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
+
+ if (cat == "Cults / Unorthodox / Questionable Material") {
+ m_dataCache.category = Cult;
+ }
+ else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
+ m_dataCache.category = DailyDevotional;
+ }
+ else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
+ m_dataCache.category = Glossary;
+ }
+ else if (cat == "Images" || cat == "Maps") {
+ m_dataCache.category = Images;
+ }
+ else if (type() == Commentary) {
+ m_dataCache.category = Commentaries;
+ }
+ else if (type() == Bible) {
+ m_dataCache.category = Bibles;
+ }
+ else if (type() == Lexicon) {
+ m_dataCache.category = Lexicons;
+ }
+ else if (type() == GenericBook) {
+ m_dataCache.category = Books;
+ }
+ }
+ //qDebug() << "assigned category: " << m_dataCache.category;
+ return m_dataCache.category;
}
/** Returns the display object for this module. */
Rendering::CEntryDisplay * CSwordModuleInfo::getDisplay() const {
- return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
+ return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
}
QString CSwordModuleInfo::aboutText() const {
- QString text;
- text += "<table>";
+ QString text;
+ text += "<table>";
- text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
- .arg(tr("Version"))
- .arg(hasVersion()? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
+ .arg(tr("Version"))
+ .arg(hasVersion() ? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Markup"))
- .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty()? QString(m_module->
- getConfigEntry("SourceType")) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Markup"))
+ .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty() ? QString(m_module->
+ getConfigEntry("SourceType")) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Location"))
- .arg(config(CSwordModuleInfo::AbsoluteDataPath));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Location"))
+ .arg(config(CSwordModuleInfo::AbsoluteDataPath));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Language"))
- .arg(language()->translatedName());
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Language"))
+ .arg(language()->translatedName());
- if (m_module->getConfigEntry("Category"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Category"))
- .arg(m_module->getConfigEntry("Category"));
+ if (m_module->getConfigEntry("Category"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Category"))
+ .arg(m_module->getConfigEntry("Category"));
- if (m_module->getConfigEntry("LCSH"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("LCSH"))
- .arg(m_module->getConfigEntry("LCSH"));
+ if (m_module->getConfigEntry("LCSH"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("LCSH"))
+ .arg(m_module->getConfigEntry("LCSH"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Writable"))
- .arg(isWritable()? tr("yes") : tr("no"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Writable"))
+ .arg(isWritable() ? tr("yes") : tr("no"));
- if (isEncrypted())
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Unlock key"))
- .arg(config(CSwordModuleInfo::CipherKey));
+ if (isEncrypted())
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Unlock key"))
+ .arg(config(CSwordModuleInfo::CipherKey));
- QString options;
+ QString options;
- unsigned int opts;
+ unsigned int opts;
- for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
- if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
- if (!options.isEmpty()) {
- options += QString::fromLatin1(", ");
- }
+ for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
+ if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
+ if (!options.isEmpty()) {
+ options += QString::fromLatin1(", ");
+ }
- options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
- }
- }
+ options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
+ }
+ }
- if (!options.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Features"))
- .arg(options);
- }
+ if (!options.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Features"))
+ .arg(options);
+ }
- text += "</table><hr>";
+ text += "</table><hr>";
- if (category() == Cult) //clearly say the module contains cult/questionable materials
- text += QString("<br/><b>%1</b><br/><br/>")
- .arg(tr("Take care, this work contains cult / questionable material!"));
+ if (category() == Cult) //clearly say the module contains cult/questionable materials
+ text += QString("<br/><b>%1</b><br/><br/>")
+ .arg(tr("Take care, this work contains cult / questionable material!"));
- text += QString("<b>%1:</b><br>%2</font>")
- .arg(tr("About"))
- .arg(config(AboutInformation));
+ text += QString("<b>%1:</b><br>%2</font>")
+ .arg(tr("About"))
+ .arg(config(AboutInformation));
- typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
+ typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
- ListConfigEntry entries;
+ ListConfigEntry entries;
- entries.append(DistributionLicense);
+ entries.append(DistributionLicense);
- entries.append(DistributionSource);
+ entries.append(DistributionSource);
- entries.append(DistributionNotes);
+ entries.append(DistributionNotes);
- entries.append(TextSource);
+ entries.append(TextSource);
- entries.append(CopyrightNotes);
+ entries.append(CopyrightNotes);
- entries.append(CopyrightHolder);
+ entries.append(CopyrightHolder);
- entries.append(CopyrightDate);
+ entries.append(CopyrightDate);
- entries.append(CopyrightContactName);
+ entries.append(CopyrightContactName);
- entries.append(CopyrightContactAddress);
+ entries.append(CopyrightContactAddress);
- entries.append(CopyrightContactEmail);
+ entries.append(CopyrightContactEmail);
- typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
+ typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
- MapConfigEntry entryMap;
+ MapConfigEntry entryMap;
- entryMap[DistributionLicense] = tr("Distribution license");
+ entryMap[DistributionLicense] = tr("Distribution license");
- entryMap[DistributionSource] = tr("Distribution source");
+ entryMap[DistributionSource] = tr("Distribution source");
- entryMap[DistributionNotes] = tr("Distribution notes");
+ entryMap[DistributionNotes] = tr("Distribution notes");
- entryMap[TextSource] = tr("Text source");
+ entryMap[TextSource] = tr("Text source");
- entryMap[CopyrightNotes] = tr("Copyright notes");
+ entryMap[CopyrightNotes] = tr("Copyright notes");
- entryMap[CopyrightHolder] = tr("Copyright holder");
+ entryMap[CopyrightHolder] = tr("Copyright holder");
- entryMap[CopyrightDate] = tr("Copyright date");
+ entryMap[CopyrightDate] = tr("Copyright date");
- entryMap[CopyrightContactName] = tr("Copyright contact name");
+ entryMap[CopyrightContactName] = tr("Copyright contact name");
- entryMap[CopyrightContactAddress] = tr("Copyright contact address");
+ entryMap[CopyrightContactAddress] = tr("Copyright contact address");
- entryMap[CopyrightContactEmail] = tr("Copyright contact email");
+ entryMap[CopyrightContactEmail] = tr("Copyright contact email");
- text += ("<hr><table>");
+ text += ("<hr><table>");
- for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
- QString t( config(*it) );
+ for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
+ QString t( config(*it) );
- if (!t.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(entryMap[*it])
- .arg(config(*it));
- }
+ if (!t.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(entryMap[*it])
+ .arg(config(*it));
+ }
- }
+ }
- text += "</table></font>";
+ text += "</table></font>";
- return text;
+ return text;
}
/** Returns the language of the module. */
const CLanguageMgr::Language* CSwordModuleInfo::language() const {
- if (!m_dataCache.language) {
- if (module()) {
- if (category() == Glossary) {
- //special handling for glossaries, we use the "from language" as language for the module
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
- }
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
- }
- }
+ if (!m_dataCache.language) {
+ if (module()) {
+ if (category() == Glossary) {
+ //special handling for glossaries, we use the "from language" as language for the module
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
+ }
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
+ }
+ }
- return m_dataCache.language;
+ return m_dataCache.language;
}
@@ -912,44 +928,42 @@ const CLanguageMgr::Language* CSwordModuleInfo::language() const {
\fn CSwordModuleInfo::getSimpleConfigEntry(char* name)
*/
QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
- QString ret = isUnicode()
- ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
- : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
+ QString ret = isUnicode()
+ ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
+ : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
- return ret.isEmpty() ? QString::null : ret;
+ return ret.isEmpty() ? QString::null : ret;
}
QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
- sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
- sword::RTFHTML RTF_Filter;
- RTF_Filter.processText(RTF_Buffer, 0, 0);
- QString ret = isUnicode()
- ? QString::fromUtf8(RTF_Buffer.c_str())
- : QString::fromLatin1(RTF_Buffer.c_str());
-
- return ret.isEmpty() ? QString::null : ret;
-}
-
-void CSwordModuleInfo::setHidden(bool hidden)
-{
- //qDebug("CSwordModuleInfo::setHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hidden && !hiddenModules.contains(this->name())) {
- hiddenModules.append(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
- if (!hidden && hiddenModules.contains(this->name()) ) {
- hiddenModules.removeAll(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
-}
-
-bool CSwordModuleInfo::isHidden() const
-{
- //qDebug("CSwordModuleInfo::isHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hiddenModules.contains(this->name())) {
- return true;
- }
- return false;
+ sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
+ sword::RTFHTML RTF_Filter;
+ RTF_Filter.processText(RTF_Buffer, 0, 0);
+ QString ret = isUnicode()
+ ? QString::fromUtf8(RTF_Buffer.c_str())
+ : QString::fromLatin1(RTF_Buffer.c_str());
+
+ return ret.isEmpty() ? QString::null : ret;
+}
+
+void CSwordModuleInfo::setHidden(bool hidden) {
+ //qDebug("CSwordModuleInfo::setHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hidden && !hiddenModules.contains(this->name())) {
+ hiddenModules.append(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+ if (!hidden && hiddenModules.contains(this->name()) ) {
+ hiddenModules.removeAll(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+}
+
+bool CSwordModuleInfo::isHidden() const {
+ //qDebug("CSwordModuleInfo::isHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hiddenModules.contains(this->name())) {
+ return true;
+ }
+ return false;
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index 0f612f9..ba4b8f6 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -28,7 +28,7 @@ class CSwordKey;
namespace Rendering {
- class CEntryDisplay;
+class CEntryDisplay;
}
/**
@@ -40,329 +40,331 @@ namespace Rendering {
* @version $Id: cswordmoduleinfo.h,v 1.83 2007/02/04 23:12:32 joachim Exp $
*/
-class CSwordModuleInfo: public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * These are the options which could be supported by modules and by this backend.
- * It's used in @ref CSwordBackend::setOption.
- */
- enum FilterTypes {
- footnotes, /**< Footnotes embedded in the module's text */
- strongNumbers, /**< strong numbers, usually in the text for the info display */
- headings, /**< additional section headings */
- morphTags, /**< morphology */
- lemmas, /**< lemma tags */
- hebrewPoints,/**< Hebrew vowel points */
- hebrewCantillation, /**<Hewbrew caantillation points */
- greekAccents, /**< Greek accents may be switched on and off */
- scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
- redLetterWords, /**< Jesus words in red, color is template specific */
- textualVariants, /**< variants */
- morphSegmentation, /**< morph word segmentation, supported by OSIS */
- filterTypesMIN = footnotes, /**< first entry of this enum */
- filterTypesMAX = morphSegmentation /**< last item in this enum */
- // transliteration /* The following are handled in a special way */
- };
- /** The text direction of a module */
- enum TextDirection { /* The text direction of the modules's text */
- LeftToRight, /**< Left to right text direction, the default setting */
- RightToLeft /**< Right to left text directin, e.g. for hebrew */
- };
- /** The module type.
- */
- enum ModuleType {
- Bible, /**< Bible module */
- Commentary, /**< Commentary module */
- Lexicon, /**< Lexicon module */
- GenericBook, /**< Generic book module */
- Unknown /**< Fall back type for unknown modules */
- };
- /**
- * This enum is used to give
- * back an error code after unlocking the module
- * BibleTime stores the unlock key not in the module's config file but in BibleTime's
- * configuration file.
- */
- enum UnlockErrorCode {
- noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
- wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
- notLocked, /**< The module was not locked so it can't be unlocked */
- noPermission /**< The key was not written to config because we have no permissions */
- };
- enum ConfigEntry {
- AboutInformation, /**< The about information of a module which is stored in the config file*/
- AbsoluteDataPath, /**< The absolute data path stored in the config object */
- CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
- DataPath, /**< The relative path. See AbsoluteDataPath*/
- Description, /**< The module description stored in the config file */
- ModuleVersion, /**< The module's version.*/
- MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
- TextDir, /**< The text direction */
- DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
- GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
- GlossaryTo, /**< lamguages to which the glossary maps to */
- DistributionLicense,
- DistributionSource,
- DistributionNotes,
- TextSource,
- CopyrightNotes,
- CopyrightHolder,
- CopyrightDate,
- CopyrightContactName,
- CopyrightContactAddress,
- CopyrightContactEmail,
- Markup /**< The markup of this module */
- };
- enum Feature {
- //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
- GreekDef,
- HebrewDef,
- GreekParse,
- HebrewParse,
- featureMin = GreekDef,
- featureMax = HebrewParse
- };
- enum Category {
- UnknownCategory = 0, /**< The category wasn't set or has an unknwon value */
- Bibles,
- Commentaries,
- Books,
- Lexicons,
- Glossary,
- DailyDevotional,
- Images,
- Cult /**< The module is a cult / sect / questionable module */
- };
-
- /**
- * Returns the base directory for search indices
- */
- static QString getGlobalBaseIndexLocation();
- /**
- * Removes search index for this module, even if the module is not there any more
- */
- static void deleteIndexForModule( QString name );
-
-
- /**
- * Returns the config entry which is pecified by the parameter.
- */
- QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
-
- CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
- /** Copy constructor to copy the passed parameter.
- * @param m The module to be copied
- */
- CSwordModuleInfo( const CSwordModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordModuleInfo();
-
- /**
- * Returns the module object so all objects can access the original Sword module.
- */
- sword::SWModule* module() const;
- /**
- * Sets the unlock key of the modules and writes the key into the cofig file.
- * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
- */
- bool unlock( const QString& unlockKey );
- /**
- * Returns the display object for this module. Normally every module should have a Display object.
- * Please don't use module()->Display() because this function does return the Sword display and does
- * render the text, too.
- * This function performs some casts to return the correct display. If it returns 0 there's no valid
- * display object.
- */
- Rendering::CEntryDisplay* getDisplay() const;
- /**
- * This function does return true if the data files of the module are encrypted by the module author
- * (the on who made the module) no matter if it's locked or not.
- * @return True if this module is encryped
- */
- bool isEncrypted() const;
- /**
- * This function returns true if this module is locked (encrypted + correct cipher key),
- * otherwise return false.
- * @return True if this module is locked, i.e. encrypted but without a key set
- */
- bool isLocked();
-
- bool unlockKeyIsValid();
-
- /** The module version.
- * @return true if this module has a version number and false if it doesn't have one.
- */
- inline bool hasVersion() const;
-
- /**
- * Returns true if the module's index has been built.
- */
- virtual bool hasIndex();
- /**
- * Returns the path to this module's index base dir
- */
- virtual QString getModuleBaseIndexLocation() const;
- /**
- * Returns the path to this module's standard index
- */
- virtual QString getModuleStandardIndexLocation() const;
- /**
- * Builds a search index for this module
- */
- virtual void buildIndex();
- /**
- * Returns index size
- */
- virtual unsigned long indexSize() const;
- /**
- * Returns true if something was found, otherwise return false.
- * This function uses CLucene to perform and index based search. It also
- * overwrites the variable containing the last search result.
- */
- virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
- /**
- * Returns the last search result for this module.
- * The last result is cleared by @ref search
- */
- virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
- /**
- * Clears the last search result.
- * This does immediately clean the last search result,
- * no matter if search is in progress or not.
- */
- void clearSearchResult();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the required Sword version for this module.
- * Returns -1 if no special Sword version is required.
- */
- sword::SWVersion minimumSwordVersion();
- /**
- * Returns the name of the module.
- * @return The name of this module.
- */
- QString name() const;
- /**
- * Snaps to the closest entry in the module if the current key is
- * not present in the data files.
- */
- virtual bool snap() {
- return false;
- };
-
- bool has( const CSwordModuleInfo::Feature ) const;
- bool has( const CSwordModuleInfo::FilterTypes ) const;
- /**
- * Returns the text direction of the module's text.,
- */
- virtual CSwordModuleInfo::TextDirection textDirection();
- /**
- * Writes the new text at the given position into the module. This does only work for writabe modules.
- */
- virtual void write( CSwordKey* key, const QString& newText );
- /**
- * Deletes the current entry and removes it from the module.
- */
- bool deleteEntry( CSwordKey* const key );
- /**
- * Returns the language of the module.
- */
- const CLanguageMgr::Language* language() const;
- /**
- * Returns true if this module may be written by the write display windows.
- */
- inline virtual bool isWritable() const;
- /**
- * Returns true if this module is hidden (not to be shown with other modules in certain views).
- */
- bool isHidden() const;
-
- void setHidden(bool hidden);
-
- /**
- * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
- */
- CSwordModuleInfo::Category category() const;
- /**
- * The about text which belongs to this module.
- */
- QString aboutText() const;
- /**
- * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
- * Protected because it should not be used outside of the CSword*ModuleInfo classes.
- */
- inline bool isUnicode() const {
- return m_dataCache.isUnicode;
- }
-
-public slots:
- inline void cancelIndexing() { m_cancelIndexing = true; };
-
-protected:
- friend class CSwordBackend;
-
- inline CSwordBackend* backend() const {
- return m_backend;
- }
-
- inline void backend( CSwordBackend* newBackend ) {
- if (newBackend) {
- m_backend = newBackend;
- }
- }
-
- QString getSimpleConfigEntry(const QString& name) const;
- QString getFormattedConfigEntry(const QString& name) const;
-
-signals:
- void indexingFinished();
- void indexingProgress(int);
-
-private:
- sword::SWModule* m_module;
- sword::ListKey m_searchResult;
-
- mutable struct DataCache {
- DataCache() {
- language = 0;
- }
-
- QString name;
- bool isUnicode;
- CSwordModuleInfo::Category category;
- const CLanguageMgr::Language* language;
- bool hasVersion;
- }
-
- m_dataCache;
-
- CSwordBackend* m_backend;
-
- bool m_hidden;
-
- bool m_cancelIndexing;
+class CSwordModuleInfo: public QObject {
+ Q_OBJECT
+
+ public:
+ /**
+ * These are the options which could be supported by modules and by this backend.
+ * It's used in @ref CSwordBackend::setOption.
+ */
+ enum FilterTypes {
+ footnotes, /**< Footnotes embedded in the module's text */
+ strongNumbers, /**< strong numbers, usually in the text for the info display */
+ headings, /**< additional section headings */
+ morphTags, /**< morphology */
+ lemmas, /**< lemma tags */
+ hebrewPoints,/**< Hebrew vowel points */
+ hebrewCantillation, /**<Hewbrew caantillation points */
+ greekAccents, /**< Greek accents may be switched on and off */
+ scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
+ redLetterWords, /**< Jesus words in red, color is template specific */
+ textualVariants, /**< variants */
+ morphSegmentation, /**< morph word segmentation, supported by OSIS */
+ filterTypesMIN = footnotes, /**< first entry of this enum */
+ filterTypesMAX = morphSegmentation /**< last item in this enum */
+ // transliteration /* The following are handled in a special way */
+ };
+ /** The text direction of a module */
+ enum TextDirection { /* The text direction of the modules's text */
+ LeftToRight, /**< Left to right text direction, the default setting */
+ RightToLeft /**< Right to left text directin, e.g. for hebrew */
+ };
+ /** The module type.
+ */
+ enum ModuleType {
+ Bible, /**< Bible module */
+ Commentary, /**< Commentary module */
+ Lexicon, /**< Lexicon module */
+ GenericBook, /**< Generic book module */
+ Unknown /**< Fall back type for unknown modules */
+ };
+ /**
+ * This enum is used to give
+ * back an error code after unlocking the module
+ * BibleTime stores the unlock key not in the module's config file but in BibleTime's
+ * configuration file.
+ */
+ enum UnlockErrorCode {
+ noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
+ wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
+ notLocked, /**< The module was not locked so it can't be unlocked */
+ noPermission /**< The key was not written to config because we have no permissions */
+ };
+ enum ConfigEntry {
+ AboutInformation, /**< The about information of a module which is stored in the config file*/
+ AbsoluteDataPath, /**< The absolute data path stored in the config object */
+ CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
+ DataPath, /**< The relative path. See AbsoluteDataPath*/
+ Description, /**< The module description stored in the config file */
+ ModuleVersion, /**< The module's version.*/
+ MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
+ TextDir, /**< The text direction */
+ DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
+ GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
+ GlossaryTo, /**< lamguages to which the glossary maps to */
+ DistributionLicense,
+ DistributionSource,
+ DistributionNotes,
+ TextSource,
+ CopyrightNotes,
+ CopyrightHolder,
+ CopyrightDate,
+ CopyrightContactName,
+ CopyrightContactAddress,
+ CopyrightContactEmail,
+ Markup /**< The markup of this module */
+ };
+ enum Feature {
+ //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
+ GreekDef,
+ HebrewDef,
+ GreekParse,
+ HebrewParse,
+ featureMin = GreekDef,
+ featureMax = HebrewParse
+ };
+ enum Category {
+ Bibles,
+ Commentaries,
+ Books,
+ Lexicons,
+ Glossary,
+ DailyDevotional,
+ Images,
+ Cult, /**< The module is a cult / sect / questionable module */
+ UnknownCategory /**< The category wasn't set or has an unknown value */
+ };
+
+ /**
+ * Returns the base directory for search indices
+ */
+ static QString getGlobalBaseIndexLocation();
+ /**
+ * Removes search index for this module, even if the module is not there any more
+ */
+ static void deleteIndexForModule( QString name );
+
+
+ /**
+ * Returns the config entry which is pecified by the parameter.
+ */
+ QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
+
+ CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
+ /** Copy constructor to copy the passed parameter.
+ * @param m The module to be copied
+ */
+ CSwordModuleInfo( const CSwordModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordModuleInfo();
+
+ /**
+ * Returns the module object so all objects can access the original Sword module.
+ */
+ sword::SWModule* module() const;
+ /**
+ * Sets the unlock key of the modules and writes the key into the cofig file.
+ * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
+ */
+ bool unlock( const QString& unlockKey );
+ /**
+ * Returns the display object for this module. Normally every module should have a Display object.
+ * Please don't use module()->Display() because this function does return the Sword display and does
+ * render the text, too.
+ * This function performs some casts to return the correct display. If it returns 0 there's no valid
+ * display object.
+ */
+ Rendering::CEntryDisplay* getDisplay() const;
+ /**
+ * This function does return true if the data files of the module are encrypted by the module author
+ * (the on who made the module) no matter if it's locked or not.
+ * @return True if this module is encryped
+ */
+ bool isEncrypted() const;
+ /**
+ * This function returns true if this module is locked (encrypted + correct cipher key),
+ * otherwise return false.
+ * \todo Make CSwordModuleInfo::isLocked() const.
+ * @return True if this module is locked, i.e. encrypted but without a key set
+ */
+ bool isLocked();
+
+ bool unlockKeyIsValid();
+
+ /** The module version.
+ * @return true if this module has a version number and false if it doesn't have one.
+ */
+ inline bool hasVersion() const;
+
+ /**
+ * Returns true if the module's index has been built.
+ */
+ virtual bool hasIndex();
+ /**
+ * Returns the path to this module's index base dir
+ */
+ virtual QString getModuleBaseIndexLocation() const;
+ /**
+ * Returns the path to this module's standard index
+ */
+ virtual QString getModuleStandardIndexLocation() const;
+ /**
+ * Builds a search index for this module
+ */
+ virtual void buildIndex();
+ /**
+ * Returns index size
+ */
+ virtual unsigned long indexSize() const;
+ /**
+ * Returns true if something was found, otherwise return false.
+ * This function uses CLucene to perform and index based search. It also
+ * overwrites the variable containing the last search result.
+ */
+ virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
+ /**
+ * Returns the last search result for this module.
+ * The last result is cleared by @ref search
+ */
+ virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
+ /**
+ * Clears the last search result.
+ * This does immediately clean the last search result,
+ * no matter if search is in progress or not.
+ */
+ void clearSearchResult();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the required Sword version for this module.
+ * Returns -1 if no special Sword version is required.
+ */
+ sword::SWVersion minimumSwordVersion();
+ /**
+ * Returns the name of the module.
+ * @return The name of this module.
+ */
+ QString name() const;
+ /**
+ * Snaps to the closest entry in the module if the current key is
+ * not present in the data files.
+ */
+ virtual bool snap() {
+ return false;
+ };
+
+ bool has( const CSwordModuleInfo::Feature ) const;
+ bool has( const CSwordModuleInfo::FilterTypes ) const;
+ /**
+ * Returns the text direction of the module's text.,
+ */
+ virtual CSwordModuleInfo::TextDirection textDirection();
+ /**
+ * Writes the new text at the given position into the module. This does only work for writabe modules.
+ */
+ virtual void write( CSwordKey* key, const QString& newText );
+ /**
+ * Deletes the current entry and removes it from the module.
+ */
+ bool deleteEntry( CSwordKey* const key );
+ /**
+ * Returns the language of the module.
+ */
+ const CLanguageMgr::Language* language() const;
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ inline virtual bool isWritable() const;
+ /**
+ * Returns true if this module is hidden (not to be shown with other modules in certain views).
+ */
+ bool isHidden() const;
+
+ void setHidden(bool hidden);
+
+ /**
+ * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
+ */
+ CSwordModuleInfo::Category category() const;
+ /**
+ * The about text which belongs to this module.
+ */
+ QString aboutText() const;
+ /**
+ * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
+ * Protected because it should not be used outside of the CSword*ModuleInfo classes.
+ */
+ inline bool isUnicode() const {
+ return m_dataCache.isUnicode;
+ }
+
+ public slots:
+ inline void cancelIndexing() {
+ m_cancelIndexing = true;
+ };
+
+ protected:
+ friend class CSwordBackend;
+
+ inline CSwordBackend* backend() const {
+ return m_backend;
+ }
+
+ inline void backend( CSwordBackend* newBackend ) {
+ if (newBackend) {
+ m_backend = newBackend;
+ }
+ }
+
+ QString getSimpleConfigEntry(const QString& name) const;
+ QString getFormattedConfigEntry(const QString& name) const;
+
+ signals:
+ void indexingFinished();
+ void indexingProgress(int);
+
+ private:
+ sword::SWModule* m_module;
+ sword::ListKey m_searchResult;
+
+ mutable struct DataCache {
+ DataCache() {
+ language = 0;
+ }
+
+ QString name;
+ bool isUnicode;
+ CSwordModuleInfo::Category category;
+ const CLanguageMgr::Language* language;
+ bool hasVersion;
+ }
+
+ m_dataCache;
+
+ CSwordBackend* m_backend;
+
+ bool m_hidden;
+
+ bool m_cancelIndexing;
};
inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
- return CSwordModuleInfo::Unknown;
+ return CSwordModuleInfo::Unknown;
}
inline sword::SWModule* CSwordModuleInfo::module() const {
- return m_module;
+ return m_module;
}
inline bool CSwordModuleInfo::hasVersion() const {
- return m_dataCache.hasVersion;
+ return m_dataCache.hasVersion;
}
@@ -371,12 +373,12 @@ inline bool CSwordModuleInfo::hasVersion() const {
* The Sword library takes care of the duplicate names: _n is added after each duplicate.
*/
inline QString CSwordModuleInfo::name() const {
- return m_dataCache.name;
+ return m_dataCache.name;
}
/** Returns true if this module may be written by the write display windows. */
inline bool CSwordModuleInfo::isWritable() const {
- return false;
+ return false;
}
//#include "util/cpointers.h"
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/bt_gbfhtml.cpp
index 0627cee..6580bcd 100644
--- a/src/backend/filters/bt_gbfhtml.cpp
+++ b/src/backend/filters/bt_gbfhtml.cpp
@@ -25,272 +25,272 @@
Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
- setEscapeStringCaseSensitive(true);
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setEscapeStringCaseSensitive(true);
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- removeTokenSubstitute("Rf");
- // addTokenSubstitute("RB", "<span>"); //start of a footnote with embedded text
+ removeTokenSubstitute("Rf");
+ // addTokenSubstitute("RB", "<span>"); //start of a footnote with embedded text
- addTokenSubstitute("FI", "<span class=\"italic\">"); // italics begin
- addTokenSubstitute("Fi", "</span>");
+ addTokenSubstitute("FI", "<span class=\"italic\">"); // italics begin
+ addTokenSubstitute("Fi", "</span>");
- addTokenSubstitute("FB", "<span class=\"bold\">"); // bold begin
- addTokenSubstitute("Fb", "</span>");
+ addTokenSubstitute("FB", "<span class=\"bold\">"); // bold begin
+ addTokenSubstitute("Fb", "</span>");
- addTokenSubstitute("FR", "<span class=\"jesuswords\">");
- addTokenSubstitute("Fr", "</span>");
+ addTokenSubstitute("FR", "<span class=\"jesuswords\">");
+ addTokenSubstitute("Fr", "</span>");
- addTokenSubstitute("FU", "<u>"); // underline begin
- addTokenSubstitute("Fu", "</u>");
+ addTokenSubstitute("FU", "<u>"); // underline begin
+ addTokenSubstitute("Fu", "</u>");
- addTokenSubstitute("FO", "<span class=\"quotation\">"); // Old Testament quote begin
- addTokenSubstitute("Fo", "</span>");
+ addTokenSubstitute("FO", "<span class=\"quotation\">"); // Old Testament quote begin
+ addTokenSubstitute("Fo", "</span>");
- addTokenSubstitute("FS", "<span class=\"sup\">"); // Superscript begin// Subscript begin
- addTokenSubstitute("Fs", "</span>");
+ addTokenSubstitute("FS", "<span class=\"sup\">"); // Superscript begin// Subscript begin
+ addTokenSubstitute("Fs", "</span>");
- addTokenSubstitute("FV", "<span class=\"sub\">"); // Subscript begin
- addTokenSubstitute("Fv", "</span>");
+ addTokenSubstitute("FV", "<span class=\"sub\">"); // Subscript begin
+ addTokenSubstitute("Fv", "</span>");
- addTokenSubstitute("TT", "<div class=\"booktitle\">");
- addTokenSubstitute("Tt", "</div>");
+ addTokenSubstitute("TT", "<div class=\"booktitle\">");
+ addTokenSubstitute("Tt", "</div>");
- addTokenSubstitute("TS", "<div class=\"sectiontitle\">");
- addTokenSubstitute("Ts", "</div>");
+ addTokenSubstitute("TS", "<div class=\"sectiontitle\">");
+ addTokenSubstitute("Ts", "</div>");
- //addTokenSubstitute("PP", "<span class=\"poetry\">"); // poetry begin
- //addTokenSubstitute("Pp", "</span>");
+ //addTokenSubstitute("PP", "<span class=\"poetry\">"); // poetry begin
+ //addTokenSubstitute("Pp", "</span>");
- addTokenSubstitute("Fn", "</font>"); // font end
- addTokenSubstitute("CL", "<br/>"); // new line
- addTokenSubstitute("CM", "<br/>"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
+ addTokenSubstitute("Fn", "</font>"); // font end
+ addTokenSubstitute("CL", "<br/>"); // new line
+ addTokenSubstitute("CM", "<br/>"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
- addTokenSubstitute("CG", "&gt;"); // literal greater-than sign
- addTokenSubstitute("CT", "&lt;"); // literal less-than sign
+ addTokenSubstitute("CG", "&gt;"); // literal greater-than sign
+ addTokenSubstitute("CT", "&lt;"); // literal less-than sign
- addTokenSubstitute("JR", "<span class=\"right\">"); // right align begin
- addTokenSubstitute("JC", "<span class=\"center\">"); // center align begin
- addTokenSubstitute("JL", "</span>"); // align end
+ addTokenSubstitute("JR", "<span class=\"right\">"); // right align begin
+ addTokenSubstitute("JC", "<span class=\"center\">"); // center align begin
+ addTokenSubstitute("JL", "</span>"); // align end
}
/** No descriptions */
char Filters::BT_GBFHTML::processText(sword::SWBuf& buf, const sword::SWKey * key, const sword::SWModule * module) {
- GBFHTML::processText(buf, key, module);
+ GBFHTML::processText(buf, key, module);
- if (!module->isProcessEntryAttributes()) {
- return 1; //no processing should be done, may happen in a search
- }
+ if (!module->isProcessEntryAttributes()) {
+ return 1; //no processing should be done, may happen in a search
+ }
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
- if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::morphTags) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
- return 1; //WARNING: Return alread here
- }
+ if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::morphTags) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
+ return 1; //WARNING: Return alread here
+ }
- //Am Anfang<WH07225> schuf<WH01254><WTH8804> Gott<WH0430> Himmel<WH08064> und<WT> Erde<WH0776>.
- //A simple word<WT> means: No entry for this word "word"
- QString result;
+ //Am Anfang<WH07225> schuf<WH01254><WTH8804> Gott<WH0430> Himmel<WH08064> und<WT> Erde<WH0776>.
+ //A simple word<WT> means: No entry for this word "word"
+ QString result;
- QString t = QString::fromUtf8(buf.c_str());
+ QString t = QString::fromUtf8(buf.c_str());
- QRegExp tag("([.,;:]?<W[HGT][^>]*>\\s*)+");
+ QRegExp tag("([.,;:]?<W[HGT][^>]*>\\s*)+");
- QStringList list;
+ QStringList list;
- int lastMatchEnd = 0;
+ int lastMatchEnd = 0;
- int pos = tag.indexIn(t,0);
+ int pos = tag.indexIn(t, 0);
- if (pos == -1) { //no strong or morph code found in this text
- return 1; //WARNING: Return already here
- }
+ if (pos == -1) { //no strong or morph code found in this text
+ return 1; //WARNING: Return already here
+ }
- //split the text into parts which end with the GBF tag marker for strongs/lemmas
- while (pos != -1) {
- list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd));
+ //split the text into parts which end with the GBF tag marker for strongs/lemmas
+ while (pos != -1) {
+ list.append(t.mid(lastMatchEnd, pos + tag.matchedLength() - lastMatchEnd));
- lastMatchEnd = pos + tag.matchedLength();
- pos = tag.indexIn(t, pos + tag.matchedLength());
- }
+ lastMatchEnd = pos + tag.matchedLength();
+ pos = tag.indexIn(t, pos + tag.matchedLength());
+ }
- //append the trailing text to the list.
- if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
- list.append(t.right(t.length() - lastMatchEnd));
- }
+ //append the trailing text to the list.
+ if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
+ list.append(t.right(t.length() - lastMatchEnd));
+ }
- //list is now a list of words with 1-n Strongs at the end, which belong to this word.
-
- //now create the necessary HTML in list entries and concat them to the result
- tag = QRegExp("<W([HGT])([^>]*)>");
- tag.setMinimal(true);
+ //list is now a list of words with 1-n Strongs at the end, which belong to this word.
- for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
- QString e = (*it); //current entry to process
- //qWarning(e.latin1());
-
- //check if there is a word to which the strongs info belongs to.
- //If yes, wrap that word with the strongs info
- //If not, leave out the strongs info, because it can't be tight to a text
- //Comparing the first char with < is not enough, because the tokenReplace is done already
- //so there might be html tags already.
- const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(2) != "<W");
+ //now create the necessary HTML in list entries and concat them to the result
+ tag = QRegExp("<W([HGT])([^>]*)>");
+ tag.setMinimal(true);
- if (!textPresent) {
- result += (*it);
- continue;
- }
+ for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
+ QString e = (*it); //current entry to process
+ //qWarning(e.latin1());
- int pos = tag.indexIn(e, 0); //try to find a strong number marker
- bool insertedTag = false;
- bool hasLemmaAttr = false;
- bool hasMorphAttr = false;
+ //check if there is a word to which the strongs info belongs to.
+ //If yes, wrap that word with the strongs info
+ //If not, leave out the strongs info, because it can't be tight to a text
+ //Comparing the first char with < is not enough, because the tokenReplace is done already
+ //so there might be html tags already.
+ const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(2) != "<W");
- QString value = QString::null;
- int tagAttributeStart = -1;
+ if (!textPresent) {
+ result += (*it);
+ continue;
+ }
- while (pos != -1) { //work on all strong/lemma tags in this section, should be between 1-3 loops
- const bool isMorph = (tag.cap(1) == "T");
- value = isMorph ? tag.cap(2) : tag.cap(2).prepend( tag.cap(1) );
+ int pos = tag.indexIn(e, 0); //try to find a strong number marker
+ bool insertedTag = false;
+ bool hasLemmaAttr = false;
+ bool hasMorphAttr = false;
- if (value.isEmpty()) {
- break;
- }
+ QString value = QString::null;
+ int tagAttributeStart = -1;
- //insert the span
- if (!insertedTag) { //we have to insert a new tag end and beginning, i.e. our first loop
- e.replace(pos, tag.matchedLength(), "</span>");
- pos += 7;
+ while (pos != -1) { //work on all strong/lemma tags in this section, should be between 1-3 loops
+ const bool isMorph = (tag.cap(1) == "T");
+ value = isMorph ? tag.cap(2) : tag.cap(2).prepend( tag.cap(1) );
- //skip blanks, commas, dots and stuff at the beginning, it doesn't belong to the morph code
- QString rep("<span ");
- rep.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\">");
+ if (value.isEmpty()) {
+ break;
+ }
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
+ //insert the span
+ if (!insertedTag) { //we have to insert a new tag end and beginning, i.e. our first loop
+ e.replace(pos, tag.matchedLength(), "</span>");
+ pos += 7;
- int startPos = 0;
- QChar c = e[startPos];
+ //skip blanks, commas, dots and stuff at the beginning, it doesn't belong to the morph code
+ QString rep("<span ");
+ rep.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\">");
- while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
- ++startPos;
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
- c = e[startPos];
- }
+ int startPos = 0;
+ QChar c = e[startPos];
- e.insert( startPos, rep );
- tagAttributeStart = startPos + 6; //to point to the start of the attributes
- pos += rep.length();
- }
- else { //add the attribute to the existing tag
- e.remove(pos, tag.matchedLength());
-
- if (tagAttributeStart == -1) {
- continue; //nothing valid found
- }
-
- if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
- //search the existing attribute start
- QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
- attrRegExp.setMinimal(true);
- const int foundPos = e.indexOf(attrRegExp, tagAttributeStart);
-
- if (foundPos != -1) {
- e.insert(foundPos + attrRegExp.matchedLength(), QString("|").append(value));
- pos += value.length() + 1;
-
- hasLemmaAttr = !isMorph;
- hasMorphAttr = isMorph;
- }
- }
- else { //attribute was not yet inserted
- QString attr = QString(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
-
- e.insert(tagAttributeStart, attr);
- pos += attr.length();
-
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
- }
-
- //tagAttributeStart remains the same
- }
-
- insertedTag = true;
- pos = tag.indexIn(e, pos);
- }
-
- result += e;
- }
-
- if (list.count()) {
- buf = (const char*)result.toUtf8().constData();
- }
-
- return 1;
+ while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
+ ++startPos;
+
+ c = e[startPos];
+ }
+
+ e.insert( startPos, rep );
+ tagAttributeStart = startPos + 6; //to point to the start of the attributes
+ pos += rep.length();
+ }
+ else { //add the attribute to the existing tag
+ e.remove(pos, tag.matchedLength());
+
+ if (tagAttributeStart == -1) {
+ continue; //nothing valid found
+ }
+
+ if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
+ //search the existing attribute start
+ QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
+ attrRegExp.setMinimal(true);
+ const int foundPos = e.indexOf(attrRegExp, tagAttributeStart);
+
+ if (foundPos != -1) {
+ e.insert(foundPos + attrRegExp.matchedLength(), QString("|").append(value));
+ pos += value.length() + 1;
+
+ hasLemmaAttr = !isMorph;
+ hasMorphAttr = isMorph;
+ }
+ }
+ else { //attribute was not yet inserted
+ QString attr = QString(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
+
+ e.insert(tagAttributeStart, attr);
+ pos += attr.length();
+
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
+ }
+
+ //tagAttributeStart remains the same
+ }
+
+ insertedTag = true;
+ pos = tag.indexIn(e, pos);
+ }
+
+ result += e;
+ }
+
+ if (list.count()) {
+ buf = (const char*)result.toUtf8().constData();
+ }
+
+ return 1;
}
bool Filters::BT_GBFHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- if (!substituteToken(buf, token)) { //more than a simple replace
- const unsigned int tokenLength = strlen(token);
- unsigned long i;
- sword::SWBuf value;
-
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
-
- if ( !strncmp(token, "WG", 2)
- || !strncmp(token, "WH", 2)
- || !strncmp(token, "WT", 2) ) {
- buf.append('<');
- buf.append(token);
- buf.append('>');
- }
- else if (!strncmp(token, "RB", 2)) {
- myUserData->hasFootnotePreTag = true;
- buf.append("<span class=\"footnotepre\">");
- }
- else if (!strncmp(token, "RF", 2)) {
- //we use several append calls because appendFormatted slows down filtering, which should be fast
-
- if (myUserData->hasFootnotePreTag) {
- // qWarning("inserted footnotepre end");
- buf.append("</span>");
- myUserData->hasFootnotePreTag = false;
- }
-
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
- buf.append("\">*</span> ");
-
- userData->suspendTextPassThru = true;
- }
- else if (!strncmp(token, "Rf", 2)) { //end of footnote
- userData->suspendTextPassThru = false;
- }
- else if (!strncmp(token, "FN", 2)) { //the end </font> tag is inserted in addTokenSubsitute
- buf.append("<font face=\"");
-
- for (i = 2; i < tokenLength; i++) {
- if(token[i] != '\"') {
- buf.append( token[i] );
- }
- }
-
- buf.append("\">");
- }
- else if (!strncmp(token, "CA", 2)) { // ASCII value
- buf.append( (char)atoi(&token[2]) );
- }
- else {
- return GBFHTML::handleToken(buf, token, userData);
- }
- }
-
- return true;
+ if (!substituteToken(buf, token)) { //more than a simple replace
+ const unsigned int tokenLength = strlen(token);
+ unsigned long i;
+ sword::SWBuf value;
+
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
+
+ if ( !strncmp(token, "WG", 2)
+ || !strncmp(token, "WH", 2)
+ || !strncmp(token, "WT", 2) ) {
+ buf.append('<');
+ buf.append(token);
+ buf.append('>');
+ }
+ else if (!strncmp(token, "RB", 2)) {
+ myUserData->hasFootnotePreTag = true;
+ buf.append("<span class=\"footnotepre\">");
+ }
+ else if (!strncmp(token, "RF", 2)) {
+ //we use several append calls because appendFormatted slows down filtering, which should be fast
+
+ if (myUserData->hasFootnotePreTag) {
+ // qWarning("inserted footnotepre end");
+ buf.append("</span>");
+ myUserData->hasFootnotePreTag = false;
+ }
+
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
+ buf.append("\">*</span> ");
+
+ userData->suspendTextPassThru = true;
+ }
+ else if (!strncmp(token, "Rf", 2)) { //end of footnote
+ userData->suspendTextPassThru = false;
+ }
+ else if (!strncmp(token, "FN", 2)) { //the end </font> tag is inserted in addTokenSubsitute
+ buf.append("<font face=\"");
+
+ for (i = 2; i < tokenLength; i++) {
+ if (token[i] != '\"') {
+ buf.append( token[i] );
+ }
+ }
+
+ buf.append("\">");
+ }
+ else if (!strncmp(token, "CA", 2)) { // ASCII value
+ buf.append( (char)atoi(&token[2]) );
+ }
+ else {
+ return GBFHTML::handleToken(buf, token, userData);
+ }
+ }
+
+ return true;
}
diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h
index b9118aa..ad23653 100644
--- a/src/backend/filters/bt_gbfhtml.h
+++ b/src/backend/filters/bt_gbfhtml.h
@@ -20,35 +20,34 @@
namespace Filters {
- /** GBF to HTML filter,
- * This filter converts GBF Text into HTML
- */
+/** GBF to HTML filter,
+* This filter converts GBF Text into HTML
+*/
-class BT_GBFHTML : public sword::GBFHTML/*, protected CFilterTool */
- {
+class BT_GBFHTML : public sword::GBFHTML { /*, protected CFilterTool */
-protected:
+ protected:
-class BT_UserData : public sword::GBFHTML::MyUserData {
+ class BT_UserData : public sword::GBFHTML::MyUserData {
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::GBFHTML::MyUserData(module, key) {
- swordFootnote = 1;
- hasFootnotePreTag = false;
- }
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::GBFHTML::MyUserData(module, key) {
+ swordFootnote = 1;
+ hasFootnotePreTag = false;
+ }
- short unsigned int swordFootnote;
- };
+ short unsigned int swordFootnote;
+ };
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
-public:
- BT_GBFHTML();
- virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
- };
+ public:
+ BT_GBFHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
+};
}
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp
index 8ee0b40..9026a94 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/bt_osishtml.cpp
@@ -28,590 +28,571 @@
Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- addTokenSubstitute("inscription", "<span class=\"inscription\">");
- addTokenSubstitute("/inscription","</span>");
+ addTokenSubstitute("inscription", "<span class=\"inscription\">");
+ addTokenSubstitute("/inscription", "</span>");
- addTokenSubstitute("mentioned", "<span class=\"mentioned\">");
- addTokenSubstitute("/mentioned", "</span>");
+ addTokenSubstitute("mentioned", "<span class=\"mentioned\">");
+ addTokenSubstitute("/mentioned", "</span>");
// addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">");
// addTokenSubstitute("/divineName", "</span></span>");
- //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
+ //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
// addTokenSubstitute("/seg", "</span>");
- // OSIS tables
- addTokenSubstitute("table", "<table>");
- addTokenSubstitute("/table", "</table>");
- addTokenSubstitute("row", "<tr>");
- addTokenSubstitute("/row", "</tr>");
- addTokenSubstitute("cell", "<td>");
- addTokenSubstitute("/cell", "</td>");
+ // OSIS tables
+ addTokenSubstitute("table", "<table>");
+ addTokenSubstitute("/table", "</table>");
+ addTokenSubstitute("row", "<tr>");
+ addTokenSubstitute("/row", "</tr>");
+ addTokenSubstitute("cell", "<td>");
+ addTokenSubstitute("/cell", "</td>");
}
bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- // manually process if it wasn't a simple substitution
-
- if (!substituteToken(buf, token)) {
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack
-
- sword::XMLTag tag(token);
- // qWarning("found %s", token);
- const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false")));
-
- if (!tag.getName()) {
- return false;
- }
-
- // <div> tag
- if (!strcmp(tag.getName(), "div")) {
- //handle intro
-
- if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
- sword::SWBuf type( tag.getAttribute("type") );
-
- if (type == "introduction") {
- buf.append("<div class=\"introduction\">");
- }
- else if (type == "chapter") {
- buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
- }
- else {
- buf.append("<div>");
- }
- }
- else if (tag.isEndTag()) { //end tag
- buf.append("</div>");
- }
- }
- else if (!strcmp(tag.getName(), "w")) {
- if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
- const char *attrib;
- const char *val;
-
- sword::XMLTag outTag("span");
- sword::SWBuf attrValue;
-
- if ((attrib = tag.getAttribute("xlit"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("xlit", val);
- }
-
- if ((attrib = tag.getAttribute("gloss"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("gloss", val);
- }
-
- if ((attrib = tag.getAttribute("lemma"))) {
- char splitChar = '|';
- const int countSplit1 = tag.getAttributePartCount("lemma", '|');
- const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
- int count = 0;
-
- if (countSplit1 > countSplit2) { //| split char
- splitChar = '|'; //TODO: not allowed, remove soon
- count = countSplit1;
- }
- else {
- splitChar = ' ';
- count = countSplit2;
- }
-
- int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
- attrValue = "";
-
- do {
- if (attrValue.length()) {
- attrValue.append( '|' );
- }
-
- attrib = tag.getAttribute("lemma", i, splitChar);
-
- if (i < 0) { // to handle our -1 condition
- i = 0;
- }
-
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
-
- attrValue.append(val);
- }
- while (++i < count);
-
- if (attrValue.length()) {
- outTag.setAttribute("lemma", attrValue.c_str());
- }
- }
-
- if ((attrib = tag.getAttribute("morph"))) {
- char splitChar = '|';
- const int countSplit1 = tag.getAttributePartCount("morph", '|');
- const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
- int count = 0;
-
- if (countSplit1 > countSplit2) { //| split char
- splitChar = '|';
- count = countSplit1;
- }
- else {
- splitChar = ' ';
- count = countSplit2;
- }
-
- int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
-
- attrValue = "";
-
- do {
- if (attrValue.length()) {
- attrValue.append('|');
- }
-
- attrib = tag.getAttribute("morph", i, splitChar);
-
- if (i < 0) {
- i = 0; // to handle our -1 condition
- }
-
- val = strchr(attrib, ':');
-
- if (val) { //the prefix gives the modulename
- //check the prefix
- if (!strncmp("robinson:", attrib, 9)) { //robinson
- attrValue.append( "Robinson:" ); //work is not the same as Sword's module name
- attrValue.append( val+1 );
- }
- //strongs is handled by BibleTime
- /*else if (!strncmp("strongs", attrib, val-atrrib)) {
- attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
- }*/
- else {
- attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
- }
- }
- else { //no prefix given
- val = attrib;
- const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
- attrValue.append( skipFirst ? val+1 : val );
- }
- }
- while (++i < count);
-
- if (attrValue.length()) {
- outTag.setAttribute("morph", attrValue.c_str());
- }
- }
-
- if ((attrib = tag.getAttribute("POS"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("pos", val);
- }
-
- buf.append( outTag.toString() );
- }
- else if (tag.isEndTag()) { // end or empty <w> tag
- buf.append("</span>");
- }
- }
-
- // <note> tag
- else if (!strcmp(tag.getName(), "note")) {
- if (!tag.isEndTag()) { //start tag
- const sword::SWBuf type( tag.getAttribute("type") );
-
- if (type == "crossReference") { //note containing cross references
- myUserData->inCrossrefNote = true;
- myUserData->noteType = BT_UserData::CrossReference;
- myUserData->swordFootnote++; // cross refs count as notes, too
-
- /* //get the refList value of the right entry attribute
- AttributeList notes = myModule->getEntryAttributes()["Footnote"];
- bool foundNote = false;
-
- SWBuf id( tag.getAttribute("osisID") );
- SWBuf refList;
-
- for (AttributeList::iterator list_it = notes.begin(); (list_it != notes.end()) && !foundNote; ++list_it ) {
- for (AttributeValue::iterator val_it = list_it->second.begin(); (val_it != list_it->second.end()) && !foundNote; ++val_it ) {
- if ((val_it->first == "osisID") && (val_it->second == id)) {
- foundNote = true; //this break the loop
- refList = list_it->second["refList"];
- }
- }
- }
-
- if (refList.length()) {
- buf.append(" <span class=\"crossreference\" crossrefs=\"");
- buf.append(refList.c_str());
- buf.append("\"> ");
-
- myUserData->noteType = BT_UserData::CrossReference;
- }
- else {
- myUserData->noteType = BT_UserData::Unknown;
- }*/
-
- buf.append("<span class=\"crossreference\">");
- sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
- buf += myModule->RenderText(footnoteBody);
- }
-
- /* else if (type == "explanation") {
- }
- */
- else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) {
- /**
- * leave strong's markup notes out, in the future we'll probably have
- * different option filters to turn different note types on or off
- */
-
- myUserData->suspendTextPassThru = true;
- myUserData->noteType = BT_UserData::StrongsMarkup;
- }
-
- else {
- // qWarning("found note in %s", myUserData->key->getShortText());
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient
-
- const sword::SWBuf n = tag.getAttribute("n");
-
- buf.append("\">");
- buf.append( (n.length() > 0) ? n.c_str() : "*" );
- buf.append("</span> ");
-
- myUserData->noteType = BT_UserData::Footnote;
- myUserData->suspendTextPassThru = true;
- }
- }
- else { //if (tag.isEndTag()) {
- Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);
-
- if (myUserData->noteType == BT_UserData::CrossReference) {
- buf.append("</span> ");
+ // manually process if it wasn't a simple substitution
+
+ if (!substituteToken(buf, token)) {
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack
+
+ sword::XMLTag tag(token);
+ // qWarning("found %s", token);
+ const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false")));
+
+ if (!tag.getName()) {
+ return false;
+ }
+
+ // <div> tag
+ if (!strcmp(tag.getName(), "div")) {
+ //handle intro
+
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
+ sword::SWBuf type( tag.getAttribute("type") );
+
+ if (type == "introduction") {
+ buf.append("<div class=\"introduction\">");
+ }
+ else if (type == "chapter") {
+ buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
+ }
+ else {
+ buf.append("<div>");
+ }
+ }
+ else if (tag.isEndTag()) { //end tag
+ buf.append("</div>");
+ }
+ }
+ else if (!strcmp(tag.getName(), "w")) {
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
+ const char *attrib;
+ const char *val;
+
+ sword::XMLTag outTag("span");
+ sword::SWBuf attrValue;
+
+ if ((attrib = tag.getAttribute("xlit"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("xlit", val);
+ }
+
+ if ((attrib = tag.getAttribute("gloss"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("gloss", val);
+ }
+
+ if ((attrib = tag.getAttribute("lemma"))) {
+ char splitChar = '|';
+ const int countSplit1 = tag.getAttributePartCount("lemma", '|');
+ const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
+ int count = 0;
+
+ if (countSplit1 > countSplit2) { //| split char
+ splitChar = '|'; //TODO: not allowed, remove soon
+ count = countSplit1;
+ }
+ else {
+ splitChar = ' ';
+ count = countSplit2;
+ }
+
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ attrValue = "";
+
+ do {
+ if (attrValue.length()) {
+ attrValue.append( '|' );
+ }
+
+ attrib = tag.getAttribute("lemma", i, splitChar);
+
+ if (i < 0) { // to handle our -1 condition
+ i = 0;
+ }
+
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+
+ attrValue.append(val);
+ }
+ while (++i < count);
+
+ if (attrValue.length()) {
+ outTag.setAttribute("lemma", attrValue.c_str());
+ }
+ }
+
+ if ((attrib = tag.getAttribute("morph"))) {
+ char splitChar = '|';
+ const int countSplit1 = tag.getAttributePartCount("morph", '|');
+ const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
+ int count = 0;
+
+ if (countSplit1 > countSplit2) { //| split char
+ splitChar = '|';
+ count = countSplit1;
+ }
+ else {
+ splitChar = ' ';
+ count = countSplit2;
+ }
+
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+
+ attrValue = "";
+
+ do {
+ if (attrValue.length()) {
+ attrValue.append('|');
+ }
+
+ attrib = tag.getAttribute("morph", i, splitChar);
+
+ if (i < 0) {
+ i = 0; // to handle our -1 condition
+ }
+
+ val = strchr(attrib, ':');
+
+ if (val) { //the prefix gives the modulename
+ //check the prefix
+ if (!strncmp("robinson:", attrib, 9)) { //robinson
+ attrValue.append( "Robinson:" ); //work is not the same as Sword's module name
+ attrValue.append( val + 1 );
+ }
+ //strongs is handled by BibleTime
+ /*else if (!strncmp("strongs", attrib, val-atrrib)) {
+ attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
+ }*/
+ else {
+ attrValue.append( !strncmp(attrib, "x-", 2) ? attrib + 2 : attrib );
+ }
+ }
+ else { //no prefix given
+ val = attrib;
+ const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
+ attrValue.append( skipFirst ? val + 1 : val );
+ }
+ }
+ while (++i < count);
+
+ if (attrValue.length()) {
+ outTag.setAttribute("morph", attrValue.c_str());
+ }
+ }
+
+ if ((attrib = tag.getAttribute("POS"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("pos", val);
+ }
+
+ buf.append( outTag.toString() );
+ }
+ else if (tag.isEndTag()) { // end or empty <w> tag
+ buf.append("</span>");
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) { //start tag
+ const sword::SWBuf type( tag.getAttribute("type") );
+
+ if (type == "crossReference") { //note containing cross references
+ myUserData->inCrossrefNote = true;
+ myUserData->noteType = BT_UserData::CrossReference;
+
+ /*
+ * Do not count crossrefs as footnotes if they are displayed in the text. This will cause problems
+ * with footnote numbering when crossrefs are turned on/off.
+ * When accessing footnotes, crossrefs must be turned off in the filter so that they are not in the entry
+ * attributes of Sword.
+ *
+ * //myUserData->swordFootnote++; // cross refs count as notes, too
+ */
+
+ buf.append("<span class=\"crossreference\">");
+ sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
+ buf += myModule->RenderText(footnoteBody);
+ }
+
+ /* else if (type == "explanation") {
+ }
+ */
+ else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) {
+ /**
+ * leave strong's markup notes out, in the future we'll probably have
+ * different option filters to turn different note types on or off
+ */
+
+ myUserData->suspendTextPassThru = true;
+ myUserData->noteType = BT_UserData::StrongsMarkup;
+ }
+
+ else {
+ // qWarning("found note in %s", myUserData->key->getShortText());
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient
+
+ const sword::SWBuf n = tag.getAttribute("n");
+
+ buf.append("\">");
+ buf.append( (n.length() > 0) ? n.c_str() : "*" );
+ buf.append("</span> ");
+
+ myUserData->noteType = BT_UserData::Footnote;
+ myUserData->suspendTextPassThru = true;
+ }
+ }
+ else { //if (tag.isEndTag()) {
+ Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);
+
+ if (myUserData->noteType == BT_UserData::CrossReference) {
+ buf.append("</span> ");
// myUserData->suspendTextPassThru = false;
- myUserData->inCrossrefNote = false;
- }
-
- myUserData->noteType = BT_UserData::Unknown;
- myUserData->suspendTextPassThru = false;
- }
- }
- // The <p> paragraph tag is handled by OSISHTMLHref
- else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
- if (!tag.isEndTag() && !tag.isEmpty()) {
-
- renderReference(tag.getAttribute("osisRef"), buf, myModule, myUserData);
-
- }
- else if (tag.isEndTag()) {
- buf.append("</a>");
- }
- else { // empty reference marker
- // -- what should we do? nothing for now.
- }
- }
-
- // <l> is handled by OSISHTMLHref
- // <title>
- else if (!strcmp(tag.getName(), "title")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
- buf.append("<div class=\"sectiontitle\">");
- }
- else if (tag.isEndTag()) {
- buf.append("</div>");
- }
- else { // empty title marker
- // what to do? is this even valid?
- buf.append("<br/>");
- }
- }
-
- // <hi> highlighted text
- else if (!strcmp(tag.getName(), "hi")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "bold") {
- buf.append("<span class=\"bold\">");
- }
- else if (type == "illuminated") {
- buf.append("<span class=\"illuminated\">");
- }
- else if (type == "italic") {
- buf.append("<span class=\"italic\">");
- }
- else if (type == "line-through") {
- buf.append("<span class=\"line-through\">");
- }
- else if (type == "normal") {
- buf.append("<span class=\"normal\">");
- }
- else if (type == "small-caps") {
- buf.append("<span class=\"small-caps\">");
- }
- else if (type == "underline") {
- buf.append("<span class=\"underline\">");
- }
- else {
- buf.append("<span>"); //don't break markup, </span> is inserted later
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span>");
- }
- }
-
- //name
- else if (!strcmp(tag.getName(), "name")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "geographic") {
- buf.append("<span class=\"name\"><span class=\"geographic\">");
- }
- else if (type == "holiday") {
- buf.append("<span class=\"name\"><span class=\"holiday\">");
- }
- else if (type == "nonhuman") {
- buf.append("<span class=\"name\"><span class=\"nonhuman\">");
- }
- else if (type == "person") {
- buf.append("<span class=\"name\"><span class=\"person\">");
- }
- else if (type == "ritual") {
- buf.append("<span class=\"name\"><span class=\"ritual\">");
- }
- else {
- buf.append("<span class=\"name\"><span>");
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span></span> ");
- }
- }
- else if (!strcmp(tag.getName(), "transChange")) {
- sword::SWBuf type( tag.getAttribute("type") );
-
- if ( !type.length() ) {
- type = tag.getAttribute("changeType");
- }
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "added") {
- buf.append("<span class=\"transchange\" title=\"");
- buf.append(QObject::tr("Added text").toUtf8().constData());
- buf.append("\"><span class=\"added\">");
- }
- else if (type == "amplified") {
- buf.append("<span class=\"transchange\"><span class=\"amplified\">");
- }
- else if (type == "changed") {
- buf.append("<span class=\"transchange\"><span class=\"changed\">");
- }
- else if (type == "deleted") {
- buf.append("<span class=\"transchange\"><span class=\"deleted\">");
- }
- else if (type == "moved") {
- buf.append("<span class=\"transchange\"><span class=\"moved\">");
- }
- else if (type == "tenseChange") {
- buf.append("<span class=\"transchange\" title=\"");
- buf.append(QObject::tr("Verb tense changed").toUtf8().constData());
- buf.append("\"><span class=\"tenseChange\">");
- }
- else {
- buf.append("<span class=\"transchange\"><span>");
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span></span>");
- }
- }
- else if (!strcmp(tag.getName(), "p")) {
- if (tag.isEmpty()) {
- buf.append("<p/>");
- }
- }
-
- // <q> quote
- else if (!strcmp(tag.getName(), "q")) {
- sword::SWBuf type = tag.getAttribute("type");
- sword::SWBuf who = tag.getAttribute("who");
- const char *lev = tag.getAttribute("level");
- int level = (lev) ? atoi(lev) : 1;
- const char* quoteMarker = tag.getAttribute("marker");
-
- if ((!tag.isEndTag())) {
- myUserData->quote.who = who;
- if (quoteMarker) {
- buf.append(quoteMarker);
- }
- else if(osisQToTick) //alternate " and '
- buf.append((level % 2) ? '\"' : '\'');
-
- if (who == "Jesus") {
- buf.append("<span class=\"jesuswords\">");
- }
- }
- else if (tag.isEndTag()) {
- if (myUserData->quote.who == "Jesus") {
- buf.append("</span>");
- }
- if (quoteMarker) {
- buf.append(quoteMarker);
- }
- else if (osisQToTick) { //alternate " and '
- buf.append((level % 2) ? '\"' : '\'');
- }
-
- myUserData->quote.who = "";
- }
- }
-
- // abbr tag
- else if (!strcmp(tag.getName(), "abbr")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
- const sword::SWBuf expansion = tag.getAttribute("expansion");
-
- buf.append("<span class=\"abbreviation\" expansion=\"");
- buf.append(expansion);
- buf.append("\">");
- }
- else if (tag.isEndTag()) {
- buf.append("</span>");
- }
- }
-
- // <milestone> tag
- else if (!strcmp(tag.getName(), "milestone")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((type == "screen") || (type == "line")) {//line break
- buf.append("<br/>");
- userData->supressAdjacentWhitespace = true;
- }
- else if (type == "x-p") { //e.g. occurs in the KJV2006 module
- //buf.append("<br/>");
- const sword::SWBuf marker = tag.getAttribute("marker");
- if (marker.length() > 0) {
- buf.append(marker);
- }
- }
- }
- //seg tag
- else if (!strcmp(tag.getName(), "seg")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
-
- const sword::SWBuf type = tag.getAttribute("type");
-
- if (type == "morph") {//line break
- //This code is for WLC and MORPH (WHI)
- sword::XMLTag outTag("span");
- outTag.setAttribute("class", "morphSegmentation");
- const char* attrValue;
- //Transfer the values to the span
- //Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime?
- if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue);
- if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue);
- if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue);
-
- buf.append(outTag.toString());
- //buf.append("<span class=\"morphSegmentation\">");
- }
- else{
- buf.append("<span>");
- }
- }
- else { // seg end tag
- buf.append("</span>");
- }
- //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
- }
-
- //divine name, don't use simple tag replacing because it may have attributes
- else if (!strcmp(tag.getName(), "divineName")) {
- if (!tag.isEndTag()) {
- buf.append("<span class=\"name\"><span class=\"divine\">");
- }
- else { //all hi replacements are html spans
- buf.append("</span></span>");
- }
- }
-
- else { //all tokens handled by OSISHTMLHref will run through the filter now
- return sword::OSISHTMLHREF::handleToken(buf, token, userData);
- }
- }
-
- return false;
+ myUserData->inCrossrefNote = false;
+ }
+
+ myUserData->noteType = BT_UserData::Unknown;
+ myUserData->suspendTextPassThru = false;
+ }
+ }
+ // The <p> paragraph tag is handled by OSISHTMLHref
+ else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ renderReference(tag.getAttribute("osisRef"), buf, myModule, myUserData);
+
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</a>");
+ }
+ else { // empty reference marker
+ // -- what should we do? nothing for now.
+ }
+ }
+
+ // <l> is handled by OSISHTMLHref
+ // <title>
+ else if (!strcmp(tag.getName(), "title")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ buf.append("<div class=\"sectiontitle\">");
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</div>");
+ }
+ else { // empty title marker
+ // what to do? is this even valid?
+ buf.append("<br/>");
+ }
+ }
+
+ // <hi> highlighted text
+ else if (!strcmp(tag.getName(), "hi")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold") {
+ buf.append("<span class=\"bold\">");
+ }
+ else if (type == "illuminated") {
+ buf.append("<span class=\"illuminated\">");
+ }
+ else if (type == "italic") {
+ buf.append("<span class=\"italic\">");
+ }
+ else if (type == "line-through") {
+ buf.append("<span class=\"line-through\">");
+ }
+ else if (type == "normal") {
+ buf.append("<span class=\"normal\">");
+ }
+ else if (type == "small-caps") {
+ buf.append("<span class=\"small-caps\">");
+ }
+ else if (type == "underline") {
+ buf.append("<span class=\"underline\">");
+ }
+ else {
+ buf.append("<span>"); //don't break markup, </span> is inserted later
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span>");
+ }
+ }
+
+ //name
+ else if (!strcmp(tag.getName(), "name")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "geographic") {
+ buf.append("<span class=\"name\"><span class=\"geographic\">");
+ }
+ else if (type == "holiday") {
+ buf.append("<span class=\"name\"><span class=\"holiday\">");
+ }
+ else if (type == "nonhuman") {
+ buf.append("<span class=\"name\"><span class=\"nonhuman\">");
+ }
+ else if (type == "person") {
+ buf.append("<span class=\"name\"><span class=\"person\">");
+ }
+ else if (type == "ritual") {
+ buf.append("<span class=\"name\"><span class=\"ritual\">");
+ }
+ else {
+ buf.append("<span class=\"name\"><span>");
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span></span> ");
+ }
+ }
+ else if (!strcmp(tag.getName(), "transChange")) {
+ sword::SWBuf type( tag.getAttribute("type") );
+
+ if ( !type.length() ) {
+ type = tag.getAttribute("changeType");
+ }
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "added") {
+ buf.append("<span class=\"transchange\" title=\"");
+ buf.append(QObject::tr("Added text").toUtf8().constData());
+ buf.append("\"><span class=\"added\">");
+ }
+ else if (type == "amplified") {
+ buf.append("<span class=\"transchange\"><span class=\"amplified\">");
+ }
+ else if (type == "changed") {
+ buf.append("<span class=\"transchange\"><span class=\"changed\">");
+ }
+ else if (type == "deleted") {
+ buf.append("<span class=\"transchange\"><span class=\"deleted\">");
+ }
+ else if (type == "moved") {
+ buf.append("<span class=\"transchange\"><span class=\"moved\">");
+ }
+ else if (type == "tenseChange") {
+ buf.append("<span class=\"transchange\" title=\"");
+ buf.append(QObject::tr("Verb tense changed").toUtf8().constData());
+ buf.append("\"><span class=\"tenseChange\">");
+ }
+ else {
+ buf.append("<span class=\"transchange\"><span>");
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span></span>");
+ }
+ }
+ else if (!strcmp(tag.getName(), "p")) {
+ if (tag.isEmpty()) {
+ buf.append("<p/>");
+ }
+ }
+
+ // <q> quote
+ else if (!strcmp(tag.getName(), "q")) {
+ sword::SWBuf type = tag.getAttribute("type");
+ sword::SWBuf who = tag.getAttribute("who");
+ const char *lev = tag.getAttribute("level");
+ int level = (lev) ? atoi(lev) : 1;
+ const char* quoteMarker = tag.getAttribute("marker");
+
+ if ((!tag.isEndTag())) {
+ myUserData->quote.who = who;
+ if (quoteMarker) {
+ buf.append(quoteMarker);
+ }
+ else if (osisQToTick) //alternate " and '
+ buf.append((level % 2) ? '\"' : '\'');
+
+ if (who == "Jesus") {
+ buf.append("<span class=\"jesuswords\">");
+ }
+ }
+ else if (tag.isEndTag()) {
+ if (myUserData->quote.who == "Jesus") {
+ buf.append("</span>");
+ }
+ if (quoteMarker) {
+ buf.append(quoteMarker);
+ }
+ else if (osisQToTick) { //alternate " and '
+ buf.append((level % 2) ? '\"' : '\'');
+ }
+
+ myUserData->quote.who = "";
+ }
+ }
+
+ // abbr tag
+ else if (!strcmp(tag.getName(), "abbr")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ const sword::SWBuf expansion = tag.getAttribute("expansion");
+
+ buf.append("<span class=\"abbreviation\" expansion=\"");
+ buf.append(expansion);
+ buf.append("\">");
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</span>");
+ }
+ }
+
+ // <milestone> tag
+ else if (!strcmp(tag.getName(), "milestone")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((type == "screen") || (type == "line")) {//line break
+ buf.append("<br/>");
+ userData->supressAdjacentWhitespace = true;
+ }
+ else if (type == "x-p") { //e.g. occurs in the KJV2006 module
+ //buf.append("<br/>");
+ const sword::SWBuf marker = tag.getAttribute("marker");
+ if (marker.length() > 0) {
+ buf.append(marker);
+ }
+ }
+ }
+ //seg tag
+ else if (!strcmp(tag.getName(), "seg")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if (type == "morph") {//line break
+ //This code is for WLC and MORPH (WHI)
+ sword::XMLTag outTag("span");
+ outTag.setAttribute("class", "morphSegmentation");
+ const char* attrValue;
+ //Transfer the values to the span
+ //Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime?
+ if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue);
+ if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue);
+ if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue);
+
+ buf.append(outTag.toString());
+ //buf.append("<span class=\"morphSegmentation\">");
+ }
+ else {
+ buf.append("<span>");
+ }
+ }
+ else { // seg end tag
+ buf.append("</span>");
+ }
+ //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
+ }
+
+ //divine name, don't use simple tag replacing because it may have attributes
+ else if (!strcmp(tag.getName(), "divineName")) {
+ if (!tag.isEndTag()) {
+ buf.append("<span class=\"name\"><span class=\"divine\">");
+ }
+ else { //all hi replacements are html spans
+ buf.append("</span></span>");
+ }
+ }
+
+ else { //all tokens handled by OSISHTMLHref will run through the filter now
+ return sword::OSISHTMLHREF::handleToken(buf, token, userData);
+ }
+ }
+
+ return false;
}
void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData) {
- QString ref( osisRef );
- QString hrefRef( ref );
- //Q_ASSERT(!ref.isEmpty()); checked later
-
- if (!ref.isEmpty()) {
- //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
- //If the osisRef is something like "ModuleID:key comes here" then the
- // modulename is given, so we'll use that one
-
- CSwordModuleInfo* mod = CPointers::backend()->findSwordModuleByPointer(myModule);
- //Q_ASSERT(mod); checked later
- if (!mod || (mod->type() != CSwordModuleInfo::Bible
- && mod->type() != CSwordModuleInfo::Commentary)) {
-
- mod = CBTConfig::get( CBTConfig::standardBible );
- }
-
- // Q_ASSERT(mod); There's no necessarily a module or standard Bible
-
- //if the osisRef like "GerLut:key" contains a module, use that
- int pos = ref.indexOf(":");
-
- if ((pos >= 0) && ref.at(pos-1).isLetter() && ref.at(pos+1).isLetter()) {
- QString newModuleName = ref.left(pos);
- hrefRef = ref.mid(pos+1);
-
- if (CPointers::backend()->findModuleByName(newModuleName)) {
- mod = CPointers::backend()->findModuleByName(newModuleName);
- }
- }
-
- if (mod) {
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText());
- options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
- options.destinationLanguage = QString("en");
-
- buf.append("<a href=\"");
- buf.append( //create the hyperlink with key and mod
- CReferenceManager::encodeHyperlink(
- mod->name(),
- CReferenceManager::parseVerseReference(hrefRef, options),
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
- buf.append("\" crossrefs=\"");
- buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
- buf.append("\">");
- }
- // should we add something if there were no referenced module available?
- }
+ QString ref( osisRef );
+ QString hrefRef( ref );
+ //Q_ASSERT(!ref.isEmpty()); checked later
+
+ if (!ref.isEmpty()) {
+ //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
+ //If the osisRef is something like "ModuleID:key comes here" then the
+ // modulename is given, so we'll use that one
+
+ CSwordModuleInfo* mod = CPointers::backend()->findSwordModuleByPointer(myModule);
+ //Q_ASSERT(mod); checked later
+ if (!mod || (mod->type() != CSwordModuleInfo::Bible
+ && mod->type() != CSwordModuleInfo::Commentary)) {
+
+ mod = CBTConfig::get( CBTConfig::standardBible );
+ }
+
+ // Q_ASSERT(mod); There's no necessarily a module or standard Bible
+
+ //if the osisRef like "GerLut:key" contains a module, use that
+ int pos = ref.indexOf(":");
+
+ if ((pos >= 0) && ref.at(pos - 1).isLetter() && ref.at(pos + 1).isLetter()) {
+ QString newModuleName = ref.left(pos);
+ hrefRef = ref.mid(pos + 1);
+
+ if (CPointers::backend()->findModuleByName(newModuleName)) {
+ mod = CPointers::backend()->findModuleByName(newModuleName);
+ }
+ }
+
+ if (mod) {
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(myModule->Lang());
+ options.destinationLanguage = QString("en");
+
+ buf.append("<a href=\"");
+ buf.append( //create the hyperlink with key and mod
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ CReferenceManager::parseVerseReference(hrefRef, options),
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append("\">");
+ }
+ // should we add something if there were no referenced module available?
+ }
}
diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h
index 175ee4b..04b68ec 100644
--- a/src/backend/filters/bt_osishtml.h
+++ b/src/backend/filters/bt_osishtml.h
@@ -17,53 +17,53 @@
namespace Filters {
- /** BibleTime's OSIS to HTMl filter.
- * This filter works on OSIS tags and outputs HTML in the structure supported by BibleTime.
- */
+/** BibleTime's OSIS to HTMl filter.
+* This filter works on OSIS tags and outputs HTML in the structure supported by BibleTime.
+*/
class BT_OSISHTML : public sword::OSISHTMLHREF {
-protected:
-
-class BT_UserData : public sword::OSISHTMLHREF::MyUserData {
-
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSISHTMLHREF::MyUserData(module, key) {
- noteType = Unknown;
- swordFootnote = 1;
- inCrossrefNote = false;
- entryAttributes = module->getEntryAttributes();
- }
-
- unsigned short int swordFootnote;
- bool inCrossrefNote;
- sword::AttributeTypeList entryAttributes;
-
- enum NoteType {
- Unknown,
- Alternative,
- CrossReference,
- Footnote,
- StrongsMarkup
- } noteType;
-
- struct {
- sword::SWBuf who;
- }
-
- quote;
- };
-
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
-
-public:
- BT_OSISHTML();
- virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
-private:
- void renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData);
- };
+ protected:
+
+ class BT_UserData : public sword::OSISHTMLHREF::MyUserData {
+
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSISHTMLHREF::MyUserData(module, key) {
+ noteType = Unknown;
+ swordFootnote = 1;
+ inCrossrefNote = false;
+ entryAttributes = module->getEntryAttributes();
+ }
+
+ unsigned short int swordFootnote;
+ bool inCrossrefNote;
+ sword::AttributeTypeList entryAttributes;
+
+ enum NoteType {
+ Unknown,
+ Alternative,
+ CrossReference,
+ Footnote,
+ StrongsMarkup
+ } noteType;
+
+ struct {
+ sword::SWBuf who;
+ }
+
+ quote;
+ };
+
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
+
+ public:
+ BT_OSISHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ private:
+ void renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData);
+};
} //end of Filters namespace
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp
index 4ee98b4..d26d8ed 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/bt_plainhtml.cpp
@@ -14,59 +14,55 @@ Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() {
/** No descriptions */
char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
- int count = 0;
+ int count = 0;
- sword::SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph
- {
- text += "<P>";
- from++;
- continue;
- }
- //This is a special case: Newlines in the plaintext editor are stored as <br />, not as \n
- //we need to let them through
- else if ((*from == '<') && (from[1] == 'b') && (from[2] == 'r') && (from[3] == ' ') && (from[4] == '/') && (from[5] == '>')){
- text += "<br />";
- from += 5;
- continue;
- }
- else if ((*from == '\n')){ // only one new line
- text += "<BR>";
- continue;
- }
- else if (*from == '<') {
- text += "&lt;";
- continue;
- }
- else if (*from == '>') {
- text += "&gt;";
- continue;
- }
- else if (*from == '&'){
- text += "&amp;";
- continue;
- }
- else if (*from == '{') { //footnote start
+ sword::SWBuf orig = text;
+ const char *from = orig.c_str();
+ for (text = ""; *from; from++) {
+ if ((*from == '\n') && (from[1] == '\n')) { // two newlinea are a paragraph
+ text += "<P>";
+ from++;
+ continue;
+ }
+ //This is a special case: Newlines in the plaintext editor are stored as <br />, not as \n
+ //we need to let them through
+ else if ((*from == '<') && (from[1] == 'b') && (from[2] == 'r') && (from[3] == ' ') && (from[4] == '/') && (from[5] == '>')) {
+ text += "<br />";
+ from += 5;
+ continue;
+ }
+ else if ((*from == '\n')) { // only one new line
+ text += "<BR>";
+ continue;
+ }
+ else if (*from == '<') {
+ text += "&lt;";
+ continue;
+ }
+ else if (*from == '>') {
+ text += "&gt;";
+ continue;
+ }
+ else if (*from == '&') {
+ text += "&amp;";
+ continue;
+ }
+ else if (*from == '{') { //footnote start
text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict
- continue;
- }
- else if (*from == '}') //footnote end
- {
- text += ") </SMALL></FONT>";
- continue;
- }
- else if ((*from == ' ') && (count > 5000))
- {
- text += "<WBR>";
- count = 0;
- continue;
- }
+ continue;
+ }
+ else if (*from == '}') { //footnote end
+ text += ") </SMALL></FONT>";
+ continue;
+ }
+ else if ((*from == ' ') && (count > 5000)) {
+ text += "<WBR>";
+ count = 0;
+ continue;
+ }
- text += *from;
- count++;
- }
- return 0;
+ text += *from;
+ count++;
+ }
+ return 0;
}
diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h
index ce1ef36..0430e51 100644
--- a/src/backend/filters/bt_plainhtml.h
+++ b/src/backend/filters/bt_plainhtml.h
@@ -19,15 +19,15 @@ class SWModule;
namespace Filters {
- /** Plain to HTML filter,
- * This filter converts Plain Text into HTML
- */
-class BT_PLAINHTML : public sword::SWFilter{
-protected:
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
-public:
- BT_PLAINHTML();
- };
+/** Plain to HTML filter,
+* This filter converts Plain Text into HTML
+*/
+class BT_PLAINHTML : public sword::SWFilter {
+ protected:
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
+ public:
+ BT_PLAINHTML();
+};
}
#endif
diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/bt_thmlhtml.cpp
index a5f17d2..4ee333d 100644
--- a/src/backend/filters/bt_thmlhtml.cpp
+++ b/src/backend/filters/bt_thmlhtml.cpp
@@ -28,358 +28,358 @@
#include <QRegExp>
Filters::BT_ThMLHTML::BT_ThMLHTML() {
- setEscapeStringCaseSensitive(true);
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setEscapeStringCaseSensitive(true);
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- setTokenStart("<");
- setTokenEnd(">");
- setTokenCaseSensitive(true);
+ setTokenStart("<");
+ setTokenEnd(">");
+ setTokenCaseSensitive(true);
- addTokenSubstitute("/foreign", "</span>");
+ addTokenSubstitute("/foreign", "</span>");
- removeTokenSubstitute("note");
- removeTokenSubstitute("/note");
+ removeTokenSubstitute("note");
+ removeTokenSubstitute("/note");
}
char Filters::BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* key, const sword::SWModule* module) {
- sword::ThMLHTML::processText(buf, key, module);
+ sword::ThMLHTML::processText(buf, key, module);
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
- if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
- return 1;
- }
+ if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
+ return 1;
+ }
- QString result;
+ QString result;
- QString t = QString::fromUtf8(buf.c_str());
- QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+");
+ QString t = QString::fromUtf8(buf.c_str());
+ QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+");
- QStringList list;
- int lastMatchEnd = 0;
- int pos = tag.indexIn(t,0);
+ QStringList list;
+ int lastMatchEnd = 0;
+ int pos = tag.indexIn(t, 0);
- if (pos == -1) { //no strong or morph code found in this text
- return 1; //WARNING: Return alread here
- }
+ if (pos == -1) { //no strong or morph code found in this text
+ return 1; //WARNING: Return alread here
+ }
- while (pos != -1) {
- list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd));
-
- lastMatchEnd = pos+tag.matchedLength();
- pos = tag.indexIn(t,pos+tag.matchedLength());
- }
-
- if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
- list.append(t.right(t.length() - lastMatchEnd));
- }
-
- tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>");
+ while (pos != -1) {
+ list.append(t.mid(lastMatchEnd, pos + tag.matchedLength() - lastMatchEnd));
+
+ lastMatchEnd = pos + tag.matchedLength();
+ pos = tag.indexIn(t, pos + tag.matchedLength());
+ }
+
+ if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
+ list.append(t.right(t.length() - lastMatchEnd));
+ }
+
+ tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>");
- for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
- QString e( *it );
-
- const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(1) != "<");
+ for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
+ QString e( *it );
+
+ const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(1) != "<");
- if (!textPresent) {
- continue;
- }
+ if (!textPresent) {
+ continue;
+ }
- bool hasLemmaAttr = false;
- bool hasMorphAttr = false;
-
- int pos = tag.indexIn(e, 0);
- bool insertedTag = false;
- QString value;
- QString valueClass;
+ bool hasLemmaAttr = false;
+ bool hasMorphAttr = false;
+
+ int pos = tag.indexIn(e, 0);
+ bool insertedTag = false;
+ QString value;
+ QString valueClass;
- while (pos != -1) {
- bool isMorph = false;
- bool isStrongs = false;
- value = QString::null;
- valueClass = QString::null;
+ while (pos != -1) {
+ bool isMorph = false;
+ bool isStrongs = false;
+ value = QString::null;
+ valueClass = QString::null;
- // check 3 attribute/value pairs
+ // check 3 attribute/value pairs
- for (int i = 1; i < 6; i += 2) {
- if (i > 4)
- i++;
+ for (int i = 1; i < 6; i += 2) {
+ if (i > 4)
+ i++;
- if (tag.cap(i) == "type") {
- isMorph = (tag.cap(i+1) == "morph");
- isStrongs = (tag.cap(i+1) == "Strongs");
- }
- else if (tag.cap(i) == "value") {
- value = tag.cap(i+1);
- }
- else if (tag.cap(i) == "class") {
- valueClass = tag.cap(i+1);
- }
- }
+ if (tag.cap(i) == "type") {
+ isMorph = (tag.cap(i + 1) == "morph");
+ isStrongs = (tag.cap(i + 1) == "Strongs");
+ }
+ else if (tag.cap(i) == "value") {
+ value = tag.cap(i + 1);
+ }
+ else if (tag.cap(i) == "class") {
+ valueClass = tag.cap(i + 1);
+ }
+ }
- // prepend the class qualifier to the value
- if (!valueClass.isEmpty()) {
- value = valueClass + ":" + value;
- // value.append(":").append(value);
- }
+ // prepend the class qualifier to the value
+ if (!valueClass.isEmpty()) {
+ value = valueClass + ":" + value;
+ // value.append(":").append(value);
+ }
- if (value.isEmpty()) {
- break;
- }
+ if (value.isEmpty()) {
+ break;
+ }
- //insert the span
- if (!insertedTag) {
- e.replace(pos, tag.matchedLength(), "</span>");
- pos += 7;
+ //insert the span
+ if (!insertedTag) {
+ e.replace(pos, tag.matchedLength(), "</span>");
+ pos += 7;
- QString rep = QString("<span lemma=\"").append(value).append("\">");
- int startPos = 0;
- QChar c = e[startPos];
+ QString rep = QString("<span lemma=\"").append(value).append("\">");
+ int startPos = 0;
+ QChar c = e[startPos];
- while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
- ++startPos;
- c = e[startPos];
- }
+ while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
+ ++startPos;
+ c = e[startPos];
+ }
- hasLemmaAttr = isStrongs;
- hasMorphAttr = isMorph;
-
- e.insert( startPos, rep );
- pos += rep.length();
- }
- else { //add the attribute to the existing tag
- e.remove(pos, tag.matchedLength());
-
- if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
- //search the existing attribute start
- QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
- attrRegExp.setMinimal(true);
- const int foundAttrPos = e.indexOf(attrRegExp, pos);
-
- if (foundAttrPos != -1) {
- e.insert(foundAttrPos + attrRegExp.matchedLength(), QString("|").append(value));
- pos += value.length() + 1;
-
- hasLemmaAttr = !isMorph;
- hasMorphAttr = isMorph;
- }
- }
- else { //attribute was not yet inserted
- const int attrPos = e.indexOf(QRegExp("morph=|lemma="), 0);
-
- if (attrPos >= 0) {
- QString attr;
- attr.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
- e.insert(attrPos, attr);
-
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
-
- pos += attr.length();
- }
- }
- }
-
- insertedTag = true;
- pos = tag.indexIn(e, pos);
- }
-
- result.append( e );
- }
-
- if (list.count()) {
- buf = (const char*)result.toUtf8();
- }
-
- return 1;
+ hasLemmaAttr = isStrongs;
+ hasMorphAttr = isMorph;
+
+ e.insert( startPos, rep );
+ pos += rep.length();
+ }
+ else { //add the attribute to the existing tag
+ e.remove(pos, tag.matchedLength());
+
+ if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
+ //search the existing attribute start
+ QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
+ attrRegExp.setMinimal(true);
+ const int foundAttrPos = e.indexOf(attrRegExp, pos);
+
+ if (foundAttrPos != -1) {
+ e.insert(foundAttrPos + attrRegExp.matchedLength(), QString("|").append(value));
+ pos += value.length() + 1;
+
+ hasLemmaAttr = !isMorph;
+ hasMorphAttr = isMorph;
+ }
+ }
+ else { //attribute was not yet inserted
+ const int attrPos = e.indexOf(QRegExp("morph=|lemma="), 0);
+
+ if (attrPos >= 0) {
+ QString attr;
+ attr.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
+ e.insert(attrPos, attr);
+
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
+
+ pos += attr.length();
+ }
+ }
+ }
+
+ insertedTag = true;
+ pos = tag.indexIn(e, pos);
+ }
+
+ result.append( e );
+ }
+
+ if (list.count()) {
+ buf = (const char*)result.toUtf8();
+ }
+
+ return 1;
}
bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) {
- sword::XMLTag tag(token);
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
-
- if ( tag.getName() && !sword::stricmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font
-
- if (tag.getAttribute("lang")) {
- const char* abbrev = tag.getAttribute("lang");
- //const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) );
-
- buf.append("<span class=\"foreign\" lang=\"");
- buf.append(abbrev);
- buf.append("\">");
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs
-
- if (tag.getAttribute("type") && (!sword::stricmp(tag.getAttribute("type"), "morph") || !sword::stricmp(tag.getAttribute("type"), "Strongs") || !sword::stricmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong
- buf.append('<');
- buf.append(token);
- buf.append('>');
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "note")) { // <note> tag
-
- if (!tag.isEndTag() && !tag.isEmpty()) {
- //appending is faster than appendFormatted
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
- buf.append("\">*</span> ");
-
- myUserData->suspendTextPassThru = true;
- myUserData->inFootnoteTag = true;
- }
- else if (tag.isEndTag() && !tag.isEmpty()) { //end tag
- //buf += ")</span>";
- myUserData->suspendTextPassThru = false;
- myUserData->inFootnoteTag = false;
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "scripRef")) { // a scripRef
- //scrip refs which are embeded in footnotes may not be displayed!
-
- if (!myUserData->inFootnoteTag) {
- if (tag.isEndTag()) {
- if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>"
- buf.append("</a></span>");
-
- myUserData->inscriptRef = false;
- myUserData->suspendTextPassThru = false;
- }
- else { // like "<scripRef>John 3:16</scripRef>"
-
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
- //Q_ASSERT(mod); tested later
- if (mod) {
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
- options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
- options.destinationLanguage = QString("en");
-
- //it's ok to split the reference, because to descriptive text is given
- bool insertSemicolon = false;
- buf.append("<span class=\"crossreference\">");
- QStringList refs = QString::fromUtf8(myUserData->lastTextNode.c_str()).split(";");
- QString oldRef; //the previous reference to use as a base for the next refs
- for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) {
-
- if (! oldRef.isEmpty() ){
- options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
- }
- const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
-
- oldRef = completeRef; //use the parsed result as the base for the next ref.
-
- if (insertSemicolon) { //prepend a ref divider if we're after the first one
- buf.append("; ");
- }
-
- buf.append("<a href=\"");
- buf.append(
- CReferenceManager::encodeHyperlink(
- mod->name(),
- completeRef,
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
-
- buf.append("\" crossrefs=\"");
- buf.append((const char*)completeRef.toUtf8());
- buf.append("\">");
-
- buf.append((const char*)(*it).toUtf8());
-
- buf.append("</a>");
-
- insertSemicolon = true;
- }
- buf.append("</span>"); //crossref end
- }
-
- myUserData->suspendTextPassThru = false;
- }
- }
- else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value
- myUserData->inscriptRef = true;
- myUserData->suspendTextPassThru = false;
-
- const char* ref = tag.getAttribute("passage");
- Q_ASSERT(ref);
-
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
- //Q_ASSERT(mod); tested later
-
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText());
-
- options.sourceLanguage = myModule->Lang();
- options.destinationLanguage = QString("en");
-
- const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
-
- if (mod) {
- options.refDestinationModule = QString(mod->name());
- buf.append("<span class=\"crossreference\">");
- buf.append("<a href=\"");
- buf.append(
- CReferenceManager::encodeHyperlink(
- mod->name(),
- completeRef,
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
- buf.append("\" crossrefs=\"");
- buf.append((const char*)completeRef.toUtf8());
- buf.append("\">");
- }
- else {
- buf.append("<span><a>");
- }
- }
- else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
- myUserData->inscriptRef = false;
-
- // let's stop text from going to output, the text get's added in the -tag handler
- myUserData->suspendTextPassThru = true;
- }
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "div")) {
- if (tag.isEndTag()) {
- buf.append("</div>");
- }
- else if ( tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"),"sechead") ) {
- buf.append("<div class=\"sectiontitle\">");
- }
- else if (tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "title")) {
- buf.append("<div class=\"booktitle\">");
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "img") && tag.getAttribute("src")) {
- const char* value = tag.getAttribute("src");
-
- if (value[0] == '/') {
- value++; //strip the first /
- }
-
- buf.append("<img src=\"file:");
- buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
- buf.append('/');
- buf.append(value);
- buf.append("\" />");
- }
- else { // let unknown token pass thru
- return sword::ThMLHTML::handleToken(buf, token, userData);
- }
- }
-
- return true;
+ if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) {
+ sword::XMLTag tag(token);
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
+
+ if ( tag.getName() && !sword::stricmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font
+
+ if (tag.getAttribute("lang")) {
+ const char* abbrev = tag.getAttribute("lang");
+ //const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) );
+
+ buf.append("<span class=\"foreign\" lang=\"");
+ buf.append(abbrev);
+ buf.append("\">");
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs
+
+ if (tag.getAttribute("type") && (!sword::stricmp(tag.getAttribute("type"), "morph") || !sword::stricmp(tag.getAttribute("type"), "Strongs") || !sword::stricmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong
+ buf.append('<');
+ buf.append(token);
+ buf.append('>');
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "note")) { // <note> tag
+
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ //appending is faster than appendFormatted
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
+ buf.append("\">*</span> ");
+
+ myUserData->suspendTextPassThru = true;
+ myUserData->inFootnoteTag = true;
+ }
+ else if (tag.isEndTag() && !tag.isEmpty()) { //end tag
+ //buf += ")</span>";
+ myUserData->suspendTextPassThru = false;
+ myUserData->inFootnoteTag = false;
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "scripRef")) { // a scripRef
+ //scrip refs which are embeded in footnotes may not be displayed!
+
+ if (!myUserData->inFootnoteTag) {
+ if (tag.isEndTag()) {
+ if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>"
+ buf.append("</a></span>");
+
+ myUserData->inscriptRef = false;
+ myUserData->suspendTextPassThru = false;
+ }
+ else { // like "<scripRef>John 3:16</scripRef>"
+
+ CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ //Q_ASSERT(mod); tested later
+ if (mod) {
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(myModule->Lang());
+ options.destinationLanguage = QString("en");
+
+ //it's ok to split the reference, because to descriptive text is given
+ bool insertSemicolon = false;
+ buf.append("<span class=\"crossreference\">");
+ QStringList refs = QString::fromUtf8(myUserData->lastTextNode.c_str()).split(";");
+ QString oldRef; //the previous reference to use as a base for the next refs
+ for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) {
+
+ if (! oldRef.isEmpty() ) {
+ options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
+ }
+ const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
+
+ oldRef = completeRef; //use the parsed result as the base for the next ref.
+
+ if (insertSemicolon) { //prepend a ref divider if we're after the first one
+ buf.append("; ");
+ }
+
+ buf.append("<a href=\"");
+ buf.append(
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ completeRef,
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)completeRef.toUtf8());
+ buf.append("\">");
+
+ buf.append((const char*)(*it).toUtf8());
+
+ buf.append("</a>");
+
+ insertSemicolon = true;
+ }
+ buf.append("</span>"); //crossref end
+ }
+
+ myUserData->suspendTextPassThru = false;
+ }
+ }
+ else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value
+ myUserData->inscriptRef = true;
+ myUserData->suspendTextPassThru = false;
+
+ const char* ref = tag.getAttribute("passage");
+ Q_ASSERT(ref);
+
+ CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ //Q_ASSERT(mod); tested later
+
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+
+ options.sourceLanguage = myModule->Lang();
+ options.destinationLanguage = QString("en");
+
+ const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
+
+ if (mod) {
+ options.refDestinationModule = QString(mod->name());
+ buf.append("<span class=\"crossreference\">");
+ buf.append("<a href=\"");
+ buf.append(
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ completeRef,
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)completeRef.toUtf8());
+ buf.append("\">");
+ }
+ else {
+ buf.append("<span><a>");
+ }
+ }
+ else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
+ myUserData->inscriptRef = false;
+
+ // let's stop text from going to output, the text get's added in the -tag handler
+ myUserData->suspendTextPassThru = true;
+ }
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "div")) {
+ if (tag.isEndTag()) {
+ buf.append("</div>");
+ }
+ else if ( tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "sechead") ) {
+ buf.append("<div class=\"sectiontitle\">");
+ }
+ else if (tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "title")) {
+ buf.append("<div class=\"booktitle\">");
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "img") && tag.getAttribute("src")) {
+ const char* value = tag.getAttribute("src");
+
+ if (value[0] == '/') {
+ value++; //strip the first /
+ }
+
+ buf.append("<img src=\"file:");
+ buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
+ buf.append('/');
+ buf.append(value);
+ buf.append("\" />");
+ }
+ else { // let unknown token pass thru
+ return sword::ThMLHTML::handleToken(buf, token, userData);
+ }
+ }
+
+ return true;
}
diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h
index df20472..25b168c 100644
--- a/src/backend/filters/bt_thmlhtml.h
+++ b/src/backend/filters/bt_thmlhtml.h
@@ -16,37 +16,37 @@
namespace Filters {
- /** ThML to HTML filter.
- * This filter converts ThML text to HTML text
- */
+/** ThML to HTML filter.
+* This filter converts ThML text to HTML text
+*/
class BT_ThMLHTML : public sword::ThMLHTML {
-protected:
+ protected:
-class BT_UserData : public sword::ThMLHTML::MyUserData {
+ class BT_UserData : public sword::ThMLHTML::MyUserData {
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::ThMLHTML::MyUserData(module, key) {
- inscriptRef = false;
- swordFootnote = 1;
- inFootnoteTag = false;
- }
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::ThMLHTML::MyUserData(module, key) {
+ inscriptRef = false;
+ swordFootnote = 1;
+ inFootnoteTag = false;
+ }
- bool inscriptRef;
- bool inFootnoteTag;
- unsigned short int swordFootnote;
- };
+ bool inscriptRef;
+ bool inFootnoteTag;
+ unsigned short int swordFootnote;
+ };
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
-public:
- BT_ThMLHTML ();
- virtual bool handleToken(sword::SWBuf& buf, const char *token, sword::BasicFilterUserData *userData);
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule* = 0);
- };
+ public:
+ BT_ThMLHTML ();
+ virtual bool handleToken(sword::SWBuf& buf, const char *token, sword::BasicFilterUserData *userData);
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule* = 0);
+};
}
diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/bt_thmlplain.cpp
index e08afb7..2cd3cf9 100644
--- a/src/backend/filters/bt_thmlplain.cpp
+++ b/src/backend/filters/bt_thmlplain.cpp
@@ -18,204 +18,202 @@
Filters::BT_ThMLPlain::BT_ThMLPlain() {
}
-char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/)
-{
- char token[2048];
- int tokpos = 0;
- bool intoken = false;
- bool ampersand = false;
+char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
+ char token[2048];
+ int tokpos = 0;
+ bool intoken = false;
+ bool ampersand = false;
- const char *from;
- sword::SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if (*from == 10 || *from == 13)
- from++;
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- ampersand = false;
- continue;
- }
- else if (*from == '&') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- ampersand = true;
- continue;
- }
- if (*from == ';' && ampersand) {
- intoken = false;
- ampersand = false;
+ const char *from;
+ sword::SWBuf orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) {
+ if (*from == 10 || *from == 13)
+ from++;
+ if (*from == '<') {
+ intoken = true;
+ tokpos = 0;
+ token[0] = 0;
+ token[1] = 0;
+ token[2] = 0;
+ ampersand = false;
+ continue;
+ }
+ else if (*from == '&') {
+ intoken = true;
+ tokpos = 0;
+ token[0] = 0;
+ token[1] = 0;
+ token[2] = 0;
+ ampersand = true;
+ continue;
+ }
+ if (*from == ';' && ampersand) {
+ intoken = false;
+ ampersand = false;
- if (!strncmp("nbsp", token, 4)) text += " ";
- else if (!strncmp("quot", token, 4)) text += "\"";
- else if (!strncmp("amp", token, 3)) text += "&";
- else if (!strncmp("lt", token, 2)) text += "<";
- else if (!strncmp("gt", token, 2)) text += ">";
- else if (!strncmp("brvbar", token, 6)) text += "¦";
- else if (!strncmp("sect", token, 4)) text += "§";
- else if (!strncmp("copy", token, 4)) text += "©";
- else if (!strncmp("laquo", token, 5)) text += "«";
- else if (!strncmp("reg", token, 3)) text += "®";
- else if (!strncmp("acute", token, 5)) text += "´";
- else if (!strncmp("para", token, 4)) text += "¶";
- else if (!strncmp("raquo", token, 5)) text += "»";
+ if (!strncmp("nbsp", token, 4)) text += " ";
+ else if (!strncmp("quot", token, 4)) text += "\"";
+ else if (!strncmp("amp", token, 3)) text += "&";
+ else if (!strncmp("lt", token, 2)) text += "<";
+ else if (!strncmp("gt", token, 2)) text += ">";
+ else if (!strncmp("brvbar", token, 6)) text += "¦";
+ else if (!strncmp("sect", token, 4)) text += "§";
+ else if (!strncmp("copy", token, 4)) text += "©";
+ else if (!strncmp("laquo", token, 5)) text += "«";
+ else if (!strncmp("reg", token, 3)) text += "®";
+ else if (!strncmp("acute", token, 5)) text += "´";
+ else if (!strncmp("para", token, 4)) text += "¶";
+ else if (!strncmp("raquo", token, 5)) text += "»";
- else if (!strncmp("Aacute", token, 6)) text += "Á";
- else if (!strncmp("Agrave", token, 6)) text += "À";
- else if (!strncmp("Acirc", token, 5)) text += "Â";
- else if (!strncmp("Auml", token, 4)) text += "Ä";
- else if (!strncmp("Atilde", token, 6)) text += "Ã";
- else if (!strncmp("Aring", token, 5)) text += "Å";
- else if (!strncmp("aacute", token, 6)) text += "á";
- else if (!strncmp("agrave", token, 6)) text += "à";
- else if (!strncmp("acirc", token, 5)) text += "â";
- else if (!strncmp("auml", token, 4)) text += "ä";
- else if (!strncmp("atilde", token, 6)) text += "ã";
- else if (!strncmp("aring", token, 5)) text += "å";
- else if (!strncmp("Eacute", token, 6)) text += "É";
- else if (!strncmp("Egrave", token, 6)) text += "È";
- else if (!strncmp("Ecirc", token, 5)) text += "Ê";
- else if (!strncmp("Euml", token, 4)) text += "Ë";
- else if (!strncmp("eacute", token, 6)) text += "é";
- else if (!strncmp("egrave", token, 6)) text += "è";
- else if (!strncmp("ecirc", token, 5)) text += "ê";
- else if (!strncmp("euml", token, 4)) text += "ë";
- else if (!strncmp("Iacute", token, 6)) text += "Í";
- else if (!strncmp("Igrave", token, 6)) text += "Ì";
- else if (!strncmp("Icirc", token, 5)) text += "Î";
- else if (!strncmp("Iuml", token, 4)) text += "Ï";
- else if (!strncmp("iacute", token, 6)) text += "í";
- else if (!strncmp("igrave", token, 6)) text += "ì";
- else if (!strncmp("icirc", token, 5)) text += "î";
- else if (!strncmp("iuml", token, 4)) text += "ï";
- else if (!strncmp("Oacute", token, 6)) text += "Ó";
- else if (!strncmp("Ograve", token, 6)) text += "Ò";
- else if (!strncmp("Ocirc", token, 5)) text += "Ô";
- else if (!strncmp("Ouml", token, 4)) text += "Ö";
- else if (!strncmp("Otilde", token, 6)) text += "Õ";
- else if (!strncmp("oacute", token, 6)) text += "ó";
- else if (!strncmp("ograve", token, 6)) text += "ò";
- else if (!strncmp("ocirc", token, 5)) text += "ô";
- else if (!strncmp("ouml", token, 4)) text += "ö";
- else if (!strncmp("otilde", token, 6)) text += "õ";
- else if (!strncmp("Uacute", token, 6)) text += "Ú";
- else if (!strncmp("Ugrave", token, 6)) text += "Ù";
- else if (!strncmp("Ucirc", token, 5)) text += "Û";
- else if (!strncmp("Uuml", token, 4)) text += "Ü";
- else if (!strncmp("uacute", token, 6)) text += "ú";
- else if (!strncmp("ugrave", token, 6)) text += "ù";
- else if (!strncmp("ucirc", token, 5)) text += "û";
- else if (!strncmp("uuml", token, 4)) text += "ü";
- else if (!strncmp("Yacute", token, 6)) text += "Ý";
- else if (!strncmp("yacute", token, 6)) text += "ý";
- else if (!strncmp("yuml", token, 4)) text += "ÿ";
+ else if (!strncmp("Aacute", token, 6)) text += "Á";
+ else if (!strncmp("Agrave", token, 6)) text += "À";
+ else if (!strncmp("Acirc", token, 5)) text += "Â";
+ else if (!strncmp("Auml", token, 4)) text += "Ä";
+ else if (!strncmp("Atilde", token, 6)) text += "Ã";
+ else if (!strncmp("Aring", token, 5)) text += "Å";
+ else if (!strncmp("aacute", token, 6)) text += "á";
+ else if (!strncmp("agrave", token, 6)) text += "à";
+ else if (!strncmp("acirc", token, 5)) text += "â";
+ else if (!strncmp("auml", token, 4)) text += "ä";
+ else if (!strncmp("atilde", token, 6)) text += "ã";
+ else if (!strncmp("aring", token, 5)) text += "å";
+ else if (!strncmp("Eacute", token, 6)) text += "É";
+ else if (!strncmp("Egrave", token, 6)) text += "È";
+ else if (!strncmp("Ecirc", token, 5)) text += "Ê";
+ else if (!strncmp("Euml", token, 4)) text += "Ë";
+ else if (!strncmp("eacute", token, 6)) text += "é";
+ else if (!strncmp("egrave", token, 6)) text += "è";
+ else if (!strncmp("ecirc", token, 5)) text += "ê";
+ else if (!strncmp("euml", token, 4)) text += "ë";
+ else if (!strncmp("Iacute", token, 6)) text += "Í";
+ else if (!strncmp("Igrave", token, 6)) text += "Ì";
+ else if (!strncmp("Icirc", token, 5)) text += "Î";
+ else if (!strncmp("Iuml", token, 4)) text += "Ï";
+ else if (!strncmp("iacute", token, 6)) text += "í";
+ else if (!strncmp("igrave", token, 6)) text += "ì";
+ else if (!strncmp("icirc", token, 5)) text += "î";
+ else if (!strncmp("iuml", token, 4)) text += "ï";
+ else if (!strncmp("Oacute", token, 6)) text += "Ó";
+ else if (!strncmp("Ograve", token, 6)) text += "Ò";
+ else if (!strncmp("Ocirc", token, 5)) text += "Ô";
+ else if (!strncmp("Ouml", token, 4)) text += "Ö";
+ else if (!strncmp("Otilde", token, 6)) text += "Õ";
+ else if (!strncmp("oacute", token, 6)) text += "ó";
+ else if (!strncmp("ograve", token, 6)) text += "ò";
+ else if (!strncmp("ocirc", token, 5)) text += "ô";
+ else if (!strncmp("ouml", token, 4)) text += "ö";
+ else if (!strncmp("otilde", token, 6)) text += "õ";
+ else if (!strncmp("Uacute", token, 6)) text += "Ú";
+ else if (!strncmp("Ugrave", token, 6)) text += "Ù";
+ else if (!strncmp("Ucirc", token, 5)) text += "Û";
+ else if (!strncmp("Uuml", token, 4)) text += "Ü";
+ else if (!strncmp("uacute", token, 6)) text += "ú";
+ else if (!strncmp("ugrave", token, 6)) text += "ù";
+ else if (!strncmp("ucirc", token, 5)) text += "û";
+ else if (!strncmp("uuml", token, 4)) text += "ü";
+ else if (!strncmp("Yacute", token, 6)) text += "Ý";
+ else if (!strncmp("yacute", token, 6)) text += "ý";
+ else if (!strncmp("yuml", token, 4)) text += "ÿ";
- else if (!strncmp("deg", token, 3)) text += "°";
- else if (!strncmp("plusmn", token, 6)) text += "±";
- else if (!strncmp("sup2", token, 4)) text += "²";
- else if (!strncmp("sup3", token, 4)) text += "³";
- else if (!strncmp("sup1", token, 4)) text += "¹";
- else if (!strncmp("nbsp", token, 4)) text += "º";
- else if (!strncmp("pound", token, 5)) text += "£";
- else if (!strncmp("cent", token, 4)) text += "¢";
- else if (!strncmp("frac14", token, 6)) text += "¼";
- else if (!strncmp("frac12", token, 6)) text += "½";
- else if (!strncmp("frac34", token, 6)) text += "¾";
- else if (!strncmp("iquest", token, 6)) text += "¿";
- else if (!strncmp("iexcl", token, 5)) text += "¡";
- else if (!strncmp("ETH", token, 3)) text += "Ð";
- else if (!strncmp("eth", token, 3)) text += "ð";
- else if (!strncmp("THORN", token, 5)) text += "Þ";
- else if (!strncmp("thorn", token, 5)) text += "þ";
- else if (!strncmp("AElig", token, 5)) text += "Æ";
- else if (!strncmp("aelig", token, 5)) text += "æ";
- else if (!strncmp("Oslash", token, 6)) text += "Ø";
- else if (!strncmp("curren", token, 6)) text += "¤";
- else if (!strncmp("Ccedil", token, 6)) text += "Ç";
- else if (!strncmp("ccedil", token, 6)) text += "ç";
- else if (!strncmp("szlig", token, 5)) text += "ß";
- else if (!strncmp("Ntilde", token, 6)) text += "Ñ";
- else if (!strncmp("ntilde", token, 6)) text += "ñ";
- else if (!strncmp("yen", token, 3)) text += "¥";
- else if (!strncmp("not", token, 3)) text += "¬";
- else if (!strncmp("ordf", token, 4)) text += "ª";
- else if (!strncmp("uml", token, 3)) text += "¨";
- else if (!strncmp("shy", token, 3)) text += "­";
- else if (!strncmp("macr", token, 4)) text += "¯";
- else if (!strncmp("micro", token, 5)) text += "µ";
- else if (!strncmp("middot", token, 6)) text +="·";
- else if (!strncmp("cedil", token, 5)) text += "¸";
- else if (!strncmp("ordm", token, 4)) text += "º";
- else if (!strncmp("times", token, 5)) text += "×";
- else if (!strncmp("divide", token, 6)) text +="÷";
- else if (!strncmp("oslash", token, 6)) text +="ø";
- continue;
+ else if (!strncmp("deg", token, 3)) text += "°";
+ else if (!strncmp("plusmn", token, 6)) text += "±";
+ else if (!strncmp("sup2", token, 4)) text += "²";
+ else if (!strncmp("sup3", token, 4)) text += "³";
+ else if (!strncmp("sup1", token, 4)) text += "¹";
+ else if (!strncmp("nbsp", token, 4)) text += "º";
+ else if (!strncmp("pound", token, 5)) text += "£";
+ else if (!strncmp("cent", token, 4)) text += "¢";
+ else if (!strncmp("frac14", token, 6)) text += "¼";
+ else if (!strncmp("frac12", token, 6)) text += "½";
+ else if (!strncmp("frac34", token, 6)) text += "¾";
+ else if (!strncmp("iquest", token, 6)) text += "¿";
+ else if (!strncmp("iexcl", token, 5)) text += "¡";
+ else if (!strncmp("ETH", token, 3)) text += "Ð";
+ else if (!strncmp("eth", token, 3)) text += "ð";
+ else if (!strncmp("THORN", token, 5)) text += "Þ";
+ else if (!strncmp("thorn", token, 5)) text += "þ";
+ else if (!strncmp("AElig", token, 5)) text += "Æ";
+ else if (!strncmp("aelig", token, 5)) text += "æ";
+ else if (!strncmp("Oslash", token, 6)) text += "Ø";
+ else if (!strncmp("curren", token, 6)) text += "¤";
+ else if (!strncmp("Ccedil", token, 6)) text += "Ç";
+ else if (!strncmp("ccedil", token, 6)) text += "ç";
+ else if (!strncmp("szlig", token, 5)) text += "ß";
+ else if (!strncmp("Ntilde", token, 6)) text += "Ñ";
+ else if (!strncmp("ntilde", token, 6)) text += "ñ";
+ else if (!strncmp("yen", token, 3)) text += "¥";
+ else if (!strncmp("not", token, 3)) text += "¬";
+ else if (!strncmp("ordf", token, 4)) text += "ª";
+ else if (!strncmp("uml", token, 3)) text += "¨";
+ else if (!strncmp("shy", token, 3)) text += "­";
+ else if (!strncmp("macr", token, 4)) text += "¯";
+ else if (!strncmp("micro", token, 5)) text += "µ";
+ else if (!strncmp("middot", token, 6)) text += "·";
+ else if (!strncmp("cedil", token, 5)) text += "¸";
+ else if (!strncmp("ordm", token, 4)) text += "º";
+ else if (!strncmp("times", token, 5)) text += "×";
+ else if (!strncmp("divide", token, 6)) text += "÷";
+ else if (!strncmp("oslash", token, 6)) text += "ø";
+ continue;
- }
- else if (*from == '>' && !ampersand) {
- intoken = false;
- // process desired tokens
- if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) {
- text += ' ';
- text += '<';
- for (unsigned int i = 27; token[i] != '\"'; i++)
- text += token[i];
- text += '>';
- continue;
- }
- if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) {
- text += ' ';
- text += '(';
- for (unsigned int i = 25; token[i] != '\"'; i++)
- text += token[i];
- text += ')';
- continue;
- }
- if (!strncmp("note", token, 4)) {
- text += ' ';
- text += '(';
- }
- else if (!strncmp("br", token, 2))
- text += '\n';
- else if (!strncmp("/p", token, 2))
- text += '\n';
- else if (!strncmp("/note", token, 5)) {
- text += ')';
- text += ' ';
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else text += *from;
- }
+ }
+ else if (*from == '>' && !ampersand) {
+ intoken = false;
+ // process desired tokens
+ if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) {
+ text += ' ';
+ text += '<';
+ for (unsigned int i = 27; token[i] != '\"'; i++)
+ text += token[i];
+ text += '>';
+ continue;
+ }
+ if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) {
+ text += ' ';
+ text += '(';
+ for (unsigned int i = 25; token[i] != '\"'; i++)
+ text += token[i];
+ text += ')';
+ continue;
+ }
+ if (!strncmp("note", token, 4)) {
+ text += ' ';
+ text += '(';
+ }
+ else if (!strncmp("br", token, 2))
+ text += '\n';
+ else if (!strncmp("/p", token, 2))
+ text += '\n';
+ else if (!strncmp("/note", token, 5)) {
+ text += ')';
+ text += ' ';
+ }
+ continue;
+ }
+ if (intoken) {
+ if (tokpos < 2045)
+ token[tokpos++] = *from;
+ token[tokpos+2] = 0;
+ }
+ else text += *from;
+ }
- orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) { //loop to remove extra spaces
- if ((strchr(" \t\n\r", *from))) {
- while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
- from++;
- }
- text += " ";
- }
- else {
- text += *from;
- }
+ orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) { //loop to remove extra spaces
+ if ((strchr(" \t\n\r", *from))) {
+ while (*(from + 1) && (strchr(" \t\n\r", *(from + 1)))) {
+ from++;
+ }
+ text += " ";
+ }
+ else {
+ text += *from;
}
- text += (char)0;
+ }
+ text += (char)0;
- return 0;
+ return 0;
}
diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h
index 9d0a0c5..7ef82d6 100644
--- a/src/backend/filters/bt_thmlplain.h
+++ b/src/backend/filters/bt_thmlplain.h
@@ -15,13 +15,13 @@
namespace Filters {
- /** This filter converts ThML text to plain text
- */
+/** This filter converts ThML text to plain text
+*/
class BT_ThMLPlain : public sword::SWFilter {
-protected:
- virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
-public:
- BT_ThMLPlain();
+ protected:
+ virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
+ public:
+ BT_ThMLPlain();
};
}
diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
index 9ec00f7..26e7470 100644
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ b/src/backend/filters/osismorphsegmentation.cpp
@@ -19,65 +19,65 @@ const sword::SWBuf Filters::OSISMorphSegmentation::choices[3] = {"Off", "On", ""
const sword::StringList Filters::OSISMorphSegmentation::oValues(&choices[0], &choices[2]);
Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
- }
+ setOptionValue("Off");
+}
Filters::OSISMorphSegmentation::~OSISMorphSegmentation() {}
char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey */*key*/, const sword::SWModule */*module*/) {
- sword::SWBuf token;
- bool intoken = false;
- bool hide = false;
+ sword::SWBuf token;
+ bool intoken = false;
+ bool hide = false;
- sword::SWBuf orig( text );
- const char *from = orig.c_str();
+ sword::SWBuf orig( text );
+ const char *from = orig.c_str();
- sword::XMLTag tag;
+ sword::XMLTag tag;
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
- if (*from == '>') { // process tokens
- intoken = false;
+ if (*from == '>') { // process tokens
+ intoken = false;
- if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
- tag = token;
+ if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
+ tag = token;
- if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag
- hide = (option == 0); //only hide if option is Off
- }
+ if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag
+ hide = (option == 0); //only hide if option is Off
+ }
- if (hide) { //hides start and end tags as long as hide is set
+ if (hide) { //hides start and end tags as long as hide is set
- if (tag.isEndTag()) { //</seg>
- hide = false;
- }
+ if (tag.isEndTag()) { //</seg>
+ hide = false;
+ }
- continue; //leave out the current token
- }
- } //end of seg tag handling
+ continue; //leave out the current token
+ }
+ } //end of seg tag handling
- text.append('<');
- text.append(token);
- text.append('>');
+ text.append('<');
+ text.append(token);
+ text.append('>');
- // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
+ // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
- continue;
- } //end of intoken part
+ continue;
+ } //end of intoken part
- if (intoken) { //copy token
- token.append(*from);
- }
- else { //copy text which is not inside of a tag
- text.append(*from);
- }
- }
+ if (intoken) { //copy token
+ token.append(*from);
+ }
+ else { //copy text which is not inside of a tag
+ text.append(*from);
+ }
+ }
- return 0;
+ return 0;
}
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
index e419fe2..bc405f5 100644
--- a/src/backend/filters/osismorphsegmentation.h
+++ b/src/backend/filters/osismorphsegmentation.h
@@ -19,16 +19,16 @@ namespace Filters {
* @author Martin Gruner
*/
class OSISMorphSegmentation : public sword::SWOptionFilter {
- static const char oName[];
- static const char oTip[];
- static const sword::SWBuf choices[3];
- static const sword::StringList oValues;
+ static const char oName[];
+ static const char oTip[];
+ static const sword::SWBuf choices[3];
+ static const sword::StringList oValues;
-public:
- OSISMorphSegmentation();
- virtual ~OSISMorphSegmentation();
+ public:
+ OSISMorphSegmentation();
+ virtual ~OSISMorphSegmentation();
- virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
+ virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
};
}
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index acb6da9..546c55e 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -32,154 +32,147 @@
CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
CSwordKey::CSwordKey(const CSwordKey& k) {
- m_module = k.m_module;
+ m_module = k.m_module;
}
QString CSwordKey::rawText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ m_module->module()->getKey()->setText( rawKey() );
+ }
- if (key().isNull()) return QString::null;
+ if (key().isNull()) return QString::null;
- return QString::fromUtf8( m_module->module()->getRawEntry() );
+ return QString::fromUtf8( m_module->module()->getRawEntry() );
}
QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
- Q_ASSERT(m_module);
- if (!m_module) {
- return QString::null;
- }
-
- sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
-
- if (k) {
- char * keyBuffer = new char[strlen(rawKey()) + 1];
- strcpy(keyBuffer, rawKey());
- sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
-
- if (vk_mod) {
- vk_mod->Headings(1);
- }
-
- m_module->module()->getKey()->setText( keyBuffer );
-
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- m_module->snap();
- /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
- i.e. the module key contains this key (e.g. 0123 contains 123) */
-
- if ( sword::stricmp(m_module->module()->getKey()->getText(), keyBuffer)
- && !strstr(m_module->module()->getKey()->getText(), keyBuffer)
- ) {
- qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
- return QString::null;
- }
- }
- delete [] keyBuffer;
- }
-
- //Q_ASSERT(!key().isNull());
- if (!key().isNull()) { //we have valid text
- QString text = QString::fromUtf8( m_module->module()->RenderText() );
-
- // This is yucky, but if we want strong lexicon refs we have to do it here.
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- QString t(text);
- QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
- int pos = 0;
- while( (pos = rx.indexIn(t, pos)) != -1 ) {
- QString language = rx.cap(1);
- QString langcode = QString(language.at(0)); // "G" or "H"
- QString number = rx.cap(2);
- QString paddednumber = number.rightJustified(5, '0'); // Form 00123
-
- text.replace(
- QRegExp( QString(
- "(>[^<>]+)" // Avoid replacing inside tags
- "\\b(0*%1)\\b").arg(number) ), // And span around 0's
- QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
- .arg(langcode, paddednumber, language, paddednumber)
- );
- pos += rx.matchedLength();
- }
- }
-
- if (mode == HTMLEscaped) {
- //we have to encode all UTF-8 in HTML escapes
- // go though every character and write down the escaped HTML unicode entity
- // form is &#<decimal unicode value here>;
- QString ret;
- QChar c;
- const unsigned int length = text.length();
-
- for (unsigned int i = 0; i < length; ++i) {
- c = text.at(i);
-
- if (c.toLatin1()) { //normal latin1 character
- ret.append(c);
- }
- else {//unicode character, needs to be escaped
- ret.append("&#")
- .append(c.unicode())
- .append(";");
- }
- }
-
- return ret;
- }
- else {
- return text;
- }
- }
-
- return QString::null;
+ Q_ASSERT(m_module);
+
+ sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
+
+ if (k) {
+ sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
+
+ if (vk_mod) {
+ vk_mod->Headings(1);
+ }
+
+ m_module->module()->getKey()->setText( rawKey() );
+
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ m_module->snap();
+ /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
+ i.e. the module key contains this key (e.g. 0123 contains 123) */
+
+ if ( sword::stricmp(m_module->module()->getKey()->getText(), rawKey())
+ && !strstr(m_module->module()->getKey()->getText(), rawKey())
+ ) {
+ qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
+ return QString::null;
+ }
+ }
+ }
+
+ //Q_ASSERT(!key().isNull());
+ if (!key().isNull()) { //we have valid text
+ bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
+ QString text = QString::fromUtf8( m_module->module()->RenderText(0, -1, DoRender) );
+ if (!DoRender) return QString::null;
+
+ // This is yucky, but if we want strong lexicon refs we have to do it here.
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ QString t(text);
+ QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
+ int pos = 0;
+ while ( (pos = rx.indexIn(t, pos)) != -1 ) {
+ QString language = rx.cap(1);
+ QString langcode = QString(language.at(0)); // "G" or "H"
+ QString number = rx.cap(2);
+ QString paddednumber = number.rightJustified(5, '0'); // Form 00123
+
+ text.replace(
+ QRegExp( QString(
+ "(>[^<>]+)" // Avoid replacing inside tags
+ "\\b(0*%1)\\b").arg(number) ), // And span around 0's
+ QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
+ .arg(langcode, paddednumber, language, paddednumber)
+ );
+ pos += rx.matchedLength();
+ }
+ }
+
+ if (mode == HTMLEscaped) {
+ //we have to encode all UTF-8 in HTML escapes
+ // go though every character and write down the escaped HTML unicode entity
+ // form is &#<decimal unicode value here>;
+ QString ret;
+ QChar c;
+ const unsigned int length = text.length();
+
+ for (unsigned int i = 0; i < length; ++i) {
+ c = text.at(i);
+
+ if (c.toLatin1()) { //normal latin1 character
+ ret.append(c);
+ }
+ else {//unicode character, needs to be escaped
+ ret.append("&#")
+ .append(c.unicode())
+ .append(";");
+ }
+ }
+
+ return ret;
+ }
+ else {
+ return text;
+ }
+ }
+
+ return QString::null;
}
QString CSwordKey::strippedText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ char * buffer = new char[strlen(rawKey()) + 1];
+ strcpy(buffer, rawKey());
+ m_module->module()->getKey()->setText( buffer );
+ delete [] buffer;
+ }
- return QString::fromUtf8( m_module->module()->StripText() );
+ return QString::fromUtf8( m_module->module()->StripText() );
}
const QTextCodec* CSwordKey::cp1252Codec() {
- static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
- return codec;
+ static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
+ return codec;
}
/** This will create a proper key object from a given module */
CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) {
- if (!module) {
- return 0;
- }
+ if (!module) {
+ return 0;
+ }
- switch( module->type() ) {
+ switch ( module->type() ) {
- case CSwordModuleInfo::Bible://fall through
+ case CSwordModuleInfo::Bible://fall through
- case CSwordModuleInfo::Commentary:
- return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
+ case CSwordModuleInfo::Commentary:
+ return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
- case CSwordModuleInfo::Lexicon:
- return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
+ case CSwordModuleInfo::Lexicon:
+ return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
- case CSwordModuleInfo::GenericBook:
- return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
+ case CSwordModuleInfo::GenericBook:
+ return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
- default:
- return 0;
- }
+ default:
+ return 0;
+ }
}
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index e0e6300..af0075a 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -24,88 +24,89 @@ class QTextCodec;
class CSwordKey {
-protected:
- /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
- * @param module The module which belongs to this key, may be NULL
- */
- CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
- /** Copy constructor.
- */
- CSwordKey(const CSwordKey&); //copy constructor
+ protected:
+ /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
+ * @param module The module which belongs to this key, may be NULL
+ */
+ CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
+ /** Copy constructor.
+ */
+ CSwordKey(const CSwordKey&); //copy constructor
-public:
- enum TextRenderType {
- Normal = 0,
- HTMLEscaped
- };
- /** Destructor.
- * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
- */
- virtual ~CSwordKey() {};
+ public:
+ enum TextRenderType {
+ Normal = 0,
+ HTMLEscaped = 1,
+ ProcessEntryAttributesOnly = 2 // in this case, renderText() will not return text, but only cause EntryAttribute processing
+ };
+ /** Destructor.
+ * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
+ */
+ virtual ~CSwordKey() {};
- //pure virtual functions
- /** Returns the current key.
- * @return The current key which belongs to the current object.
- */
- virtual QString key() const = 0;
- /** Sets the current key. Sets the key using a utf8 enabled QString.
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const QString& key) = 0;
- /** Set the key using a utf8-decoded c-string
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const char* key) = 0;
- /** Clone this object. Clone this current object and return it.
- * @return A clone of the current object.
- */
- virtual CSwordKey* copy() const = 0;
+ //pure virtual functions
+ /** Returns the current key.
+ * @return The current key which belongs to the current object.
+ */
+ virtual QString key() const = 0;
+ /** Sets the current key. Sets the key using a utf8 enabled QString.
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const QString& key) = 0;
+ /** Set the key using a utf8-decoded c-string
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const char* key) = 0;
+ /** Clone this object. Clone this current object and return it.
+ * @return A clone of the current object.
+ */
+ virtual CSwordKey* copy() const = 0;
- //implemented functions
- /** Set/get the module. Set and get the module which belongs to this key.
- * @return The module which belongs to this key.
- */
- inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
- /** Returns the raw, unchanged text. Returns the text without any filter modifications,
- * just in the way it comes out of the module.
- */
- virtual QString rawText();
- /** Returns the rendered text. Returns the text of the current key after passign it through the
- * modules filters.
- */
- virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
- /** Stripped down text. Returns the text after removing all markup tags from it.
- */
- virtual QString strippedText();
- /**
- * This returns a new object of the right CSwordKey* implementation
- * (e.g. CSwordVerseKey or CSwordLDKey)
- * The type is determined by the type of the module.
- * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
- */
- static CSwordKey* createInstance(CSwordModuleInfo * const module);
+ //implemented functions
+ /** Set/get the module. Set and get the module which belongs to this key.
+ * @return The module which belongs to this key.
+ */
+ inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
+ /** Returns the raw, unchanged text. Returns the text without any filter modifications,
+ * just in the way it comes out of the module.
+ */
+ virtual QString rawText();
+ /** Returns the rendered text. Returns the text of the current key after passign it through the
+ * modules filters.
+ */
+ virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
+ /** Stripped down text. Returns the text after removing all markup tags from it.
+ */
+ virtual QString strippedText();
+ /**
+ * This returns a new object of the right CSwordKey* implementation
+ * (e.g. CSwordVerseKey or CSwordLDKey)
+ * The type is determined by the type of the module.
+ * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
+ */
+ static CSwordKey* createInstance(CSwordModuleInfo * const module);
-protected:
- /**
- * Returns the encoded key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const = 0;
- static const QTextCodec* cp1252Codec();
- CSwordModuleInfo* m_module; //module pointer used by all keys
+ protected:
+ /**
+ * Returns the encoded key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const = 0;
+ static const QTextCodec* cp1252Codec();
+ CSwordModuleInfo* m_module; //module pointer used by all keys
-private:
- /**
- * Disable the assignment operator
- */
- CSwordKey& operator= ( const CSwordKey & );
+ private:
+ /**
+ * Disable the assignment operator
+ */
+ CSwordKey& operator= ( const CSwordKey & );
};
inline CSwordModuleInfo* CSwordKey::module(CSwordModuleInfo* const newModule) {
- if (newModule) {
- m_module = newModule;
- }
- return m_module;
+ if (newModule) {
+ m_module = newModule;
+ }
+ return m_module;
}
#endif
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 3205827..4aa95cb 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -19,11 +19,11 @@
#include <QTextCodec>
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
- if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
- // *(m_module->module()) = TOP;
- }
+ if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
+ // *(m_module->module()) = TOP;
+ }
- SWKey::operator= (" ");
+ SWKey::operator= (" ");
}
/** No descriptions */
@@ -34,85 +34,87 @@ CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(
/** Clones this object by copying the members. */
CSwordLDKey* CSwordLDKey::copy() const {
- return new CSwordLDKey(*this);
+ return new CSwordLDKey(*this);
}
/** Sets the module of this key. */
CSwordModuleInfo* CSwordLDKey::module(CSwordModuleInfo* const newModule) {
- if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
- const QString oldKey = key();
- m_module = newModule;
- key(oldKey);
- }
+ if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
+ const QString oldKey = key();
+ m_module = newModule;
+ key(oldKey);
+ }
- return m_module;
+ return m_module;
}
QString CSwordLDKey::key() const {
- //return QString::fromUtf8((const char*)*this);
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return QString::fromUtf8((const char*)*this);
- } else {
- return cp1252Codec()->toUnicode((const char*)*this);
- }
+ //return QString::fromUtf8((const char*)*this);
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8((const char*)*this);
+ }
+ else {
+ return cp1252Codec()->toUnicode((const char*)*this);
+ }
}
const char * CSwordLDKey::rawKey() const {
- return (const char*)*this;
+ return (const char*)*this;
}
bool CSwordLDKey::key( const QString& newKey ) {
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
/** Sets the key of this instance */
bool CSwordLDKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- SWKey::operator = (newKey); //set the key
- m_module->module()->SetKey(this);
- m_module->snap();
- }
+ if (newKey) {
+ SWKey::operator = (newKey); //set the key
+ m_module->module()->SetKey(this);
+ m_module->snap();
+ }
- return !Error();
+ return !Error();
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::NextEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )++;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )++;
+ m_module->module()->setSkipConsecutiveLinks(false);
- key(m_module->module()->KeyText());
- SWKey::operator = (m_module->module()->KeyText());
+ key(m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::PreviousEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+ m_module->module()->setSkipConsecutiveLinks(false);
- SWKey::operator = (m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 0349597..1cb3382 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -49,59 +49,59 @@ class CSwordModuleInfo;
class CSwordLDKey : public CSwordKey, public sword::SWKey {
-public:
- /**
- * Constructor of CSwordLDKey
- */
- CSwordLDKey( CSwordModuleInfo* module );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const CSwordLDKey &k );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
- /**
- * Clones this object by copying the members.
- */
- virtual CSwordLDKey* copy() const;
- /**
- * Uses the parameter to returns the next entry afer this key.
- */
- CSwordLDKey* NextEntry( void );
- /**
- * Uses the parameter to returns the previous entry afer this key.
- */
- CSwordLDKey* PreviousEntry( void );
- /**
- * Sets the module of this key.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
- /**
- * Returns the current key as a QString
- */
- virtual QString key() const;
- /**
- * Set the current key using unicode decoded QString.
- */
- virtual bool key( const QString& newKey );
- /**
- * Set the current key from char*. To avoid encoding problems use key(QString) instead.
- */
- virtual bool key( const char* );
+ public:
+ /**
+ * Constructor of CSwordLDKey
+ */
+ CSwordLDKey( CSwordModuleInfo* module );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const CSwordLDKey &k );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
+ /**
+ * Clones this object by copying the members.
+ */
+ virtual CSwordLDKey* copy() const;
+ /**
+ * Uses the parameter to returns the next entry afer this key.
+ */
+ CSwordLDKey* NextEntry( void );
+ /**
+ * Uses the parameter to returns the previous entry afer this key.
+ */
+ CSwordLDKey* PreviousEntry( void );
+ /**
+ * Sets the module of this key.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
+ /**
+ * Returns the current key as a QString
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key using unicode decoded QString.
+ */
+ virtual bool key( const QString& newKey );
+ /**
+ * Set the current key from char*. To avoid encoding problems use key(QString) instead.
+ */
+ virtual bool key( const char* );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char* rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char* rawKey() const;
-private:
- /**
- * Disable assignment operator
- */
- CSwordLDKey& operator= (const CSwordLDKey& );
+ private:
+ /**
+ * Disable assignment operator
+ */
+ CSwordLDKey& operator= (const CSwordLDKey& );
};
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index 6e02806..e845bf6 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -19,75 +19,77 @@ CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyId
CSwordTreeKey::CSwordTreeKey( const TreeKeyIdx *k, CSwordModuleInfo* module ) : CSwordKey(module), TreeKeyIdx(*k) {}
CSwordTreeKey* CSwordTreeKey::copy() const {
- return new CSwordTreeKey(*this);
+ return new CSwordTreeKey(*this);
}
/** Sets the key of this instance */
QString CSwordTreeKey::key() const {
- //return getTextUnicode();
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getText());
- } else {
- return cp1252Codec()->toUnicode(getText());
- }
+ //return getTextUnicode();
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getText());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getText());
+ }
}
const char * CSwordTreeKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordTreeKey::key( const QString& newKey ) {
- //return key( newKey.toLocal8Bit().constData() );
- //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ //return key( newKey.toLocal8Bit().constData() );
+ //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
bool CSwordTreeKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- TreeKeyIdx::operator = (newKey);
- }
- else {
- root();
- }
+ if (newKey) {
+ TreeKeyIdx::operator = (newKey);
+ }
+ else {
+ root();
+ }
- return !Error();
+ return !Error();
}
-QString CSwordTreeKey::getLocalNameUnicode()
-{
- //return m_module->getTextCodec()->toUnicode(getLocalName());
- //Only UTF-8 and latin1 are legal Sword module encodings
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getLocalName());
- } else {
- return cp1252Codec()->toUnicode(getLocalName());
- }
+QString CSwordTreeKey::getLocalNameUnicode() {
+ //return m_module->getTextCodec()->toUnicode(getLocalName());
+ //Only UTF-8 and latin1 are legal Sword module encodings
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getLocalName());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getLocalName());
+ }
}
CSwordModuleInfo* CSwordTreeKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
- m_module = newModule;
+ if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
+ m_module = newModule;
- const QString oldKey = key();
+ const QString oldKey = key();
- CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
- copyFrom( *(newBook->tree()) );
+ CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
+ copyFrom( *(newBook->tree()) );
- key(oldKey); //try to restore our old key
+ key(oldKey); //try to restore our old key
- //set the key to the root node
- root();
- firstChild();
- }
+ //set the key to the root node
+ root();
+ firstChild();
+ }
- return m_module;
+ return m_module;
}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index 4114652..c0c9e45 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -25,55 +25,57 @@ class CSwordModuleInfo;
class CSwordTreeKey : public CSwordKey, public sword::TreeKeyIdx {
-public:
- /** Constructor of this CSwordKey implementation.
- * @param k The Sword tree key which belongs to this key
- * @param module The module which belongs to this key
- */
- CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
- /** Copy constructor.
- */
- CSwordTreeKey( const CSwordTreeKey& k );
- /** The module which belongs to this key.
- * @return The module.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
- /** Copy method.
- * @return A new copy of this object.
- */
- virtual CSwordTreeKey* copy() const;
+ public:
+ /** Constructor of this CSwordKey implementation.
+ * @param k The Sword tree key which belongs to this key
+ * @param module The module which belongs to this key
+ */
+ CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
+ /** Copy constructor.
+ */
+ CSwordTreeKey( const CSwordTreeKey& k );
+ /** The module which belongs to this key.
+ * @return The module.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
+ /** Copy method.
+ * @return A new copy of this object.
+ */
+ virtual CSwordTreeKey* copy() const;
- /**
- * Returns the TreeKeyIdx::getLocalKey value in unicode.
- * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
- * Use this instead of getLocalKey() to avoid encoding problems.
- */
- QString getLocalNameUnicode();
- /**
- * Returns the current key as unicode decoded QString.
- */
- virtual QString key() const;
- /**
- * Set the key. If the parameter is empty or null, the key will be set to "/"
- */
- virtual bool key( const QString& key );
- /**
- * Set the key from char* To avoid encoding problems use key(QString instead),
- * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
- */
- virtual bool key( const char* key );
+ /**
+ * Returns the TreeKeyIdx::getLocalKey value in unicode.
+ * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
+ * Use this instead of getLocalKey() to avoid encoding problems.
+ */
+ QString getLocalNameUnicode();
+ /**
+ * Returns the current key as unicode decoded QString.
+ */
+ virtual QString key() const;
+ /**
+ * Set the key. If the parameter is empty or null, the key will be set to "/"
+ */
+ virtual bool key( const QString& key );
+ /**
+ * Set the key from char* To avoid encoding problems use key(QString instead),
+ * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
+ */
+ virtual bool key( const char* key );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordTreeKey& operator= (const CSwordTreeKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordTreeKey& operator= (const CSwordTreeKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) {
+ return (*this);
+ };
};
#endif
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 8008a7f..01cfd31 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -19,14 +19,13 @@
#include <localemgr.h>
CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
- CSwordKey(module)
-{
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
- // Copy important settings like versification system
- copyFrom((sword::VerseKey*) bible->module()->getKey());
-
- key( bible->lowerBound().key() );
- }
+ CSwordKey(module) {
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
+ // Copy important settings like versification system
+ copyFrom((sword::VerseKey*) bible->module()->getKey());
+
+ key( bible->lowerBound().key() );
+ }
}
CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {}
@@ -35,258 +34,258 @@ CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const
/** Clones this object. */
CSwordKey* CSwordVerseKey::copy() const {
- return new CSwordVerseKey(*this);
+ return new CSwordVerseKey(*this);
}
/** Sets the module for this key */
CSwordModuleInfo* CSwordVerseKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
- m_module = newModule;
+ if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
+ m_module = newModule;
- //check if the module contains the key we present
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
+ //check if the module contains the key we present
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
- if (_compare(bible->lowerBound()) < 0) {
- key( bible->lowerBound() );
- }
+ if (_compare(bible->lowerBound()) < 0) {
+ key( bible->lowerBound() );
+ }
- if (_compare(bible->upperBound()) > 0) {
- key( bible->upperBound() );
- }
- }
+ if (_compare(bible->upperBound()) > 0) {
+ key( bible->upperBound() );
+ }
+ }
- return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
+ return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
- int min = 0;
- int max = 1;
-
- if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
- const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
- const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
-
- if (hasOT && hasNT) {
- min = 0;
- max = 1;
- }
- else if (hasOT && !hasNT) {
- min = 0;
- max = 0;
- }
- else if (!hasOT && hasNT) {
- min = 1;
- max = 1;
- }
- else if (!hasOT && !hasNT) {
- min = 0;
- max = -1; //no loop
- }
- }
-
- if (!newBook.isEmpty()) {
- setBookName(newBook.toUtf8().constData());
- }
-
- if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) {
- return QString::fromUtf8( getBookName() );
- }
-
- //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
- return QString::null;
+ int min = 0;
+ int max = 1;
+
+ if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
+ const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
+ const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
+
+ if (hasOT && hasNT) {
+ min = 0;
+ max = 1;
+ }
+ else if (hasOT && !hasNT) {
+ min = 0;
+ max = 0;
+ }
+ else if (!hasOT && hasNT) {
+ min = 1;
+ max = 1;
+ }
+ else if (!hasOT && !hasNT) {
+ min = 0;
+ max = -1; //no loop
+ }
+ }
+
+ if (!newBook.isEmpty()) {
+ setBookName(newBook.toUtf8().constData());
+ }
+
+ if ( (Testament() >= min + 1) && (Testament() <= max + 1) && (Book() <= BMAX[min]) ) {
+ return QString::fromUtf8( getBookName() );
+ }
+
+ //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
+ return QString::null;
}
/** Sets the key we use to the parameter. */
QString CSwordVerseKey::key() const {
- return QString::fromUtf8(getText());
+ return QString::fromUtf8(getText());
}
const char * CSwordVerseKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordVerseKey::key( const QString& newKey ) {
- return key( newKey.toUtf8().constData() );
+ return key( newKey.toUtf8().constData() );
}
bool CSwordVerseKey::key( const char* newKey ) {
- if (newKey && (strlen(newKey)>0) ) {
- VerseKey::operator = (newKey);
- }
- else if (newKey && !strlen(newKey)) {
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
-
- if ( bible ) {
- VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
- }
- }
-
- return !Error();
+ if (newKey && (strlen(newKey) > 0) ) {
+ VerseKey::operator = (newKey);
+ }
+ else if (newKey && !strlen(newKey)) {
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
+
+ if ( bible ) {
+ VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
+ }
+ }
+
+ return !Error();
}
bool CSwordVerseKey::next( const JumpType type ) {
- Error(); //clear Error status
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- const int currentTestament = Testament();
- const int currentBook = Book();
-
- if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
- return false;
- }
- else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
- Testament(currentTestament+1);
- Book(1);
- }
- else {
- Book(Book()+1);
- }
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()+1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
-
- //disable headings for next verse
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
- //don't use setKey(), that would create a new key without Headings set
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- (*(m_module->module()) )++;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );
- }
- else {
- // Verse(Verse()+1);
- //don't change the key, restore the module's position
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
- ret = false;
- break;
- }
-
- }
- else {
- Verse(Verse()+1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) { //we have no module, so take care of VerseKey::Error()
- return false;
- }
-
- return ret;
+ Error(); //clear Error status
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ const int currentTestament = Testament();
+ const int currentBook = Book();
+
+ if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
+ return false;
+ }
+ else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
+ Testament(currentTestament + 1);
+ Book(1);
+ }
+ else {
+ Book(Book() + 1);
+ }
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() + 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+
+ //disable headings for next verse
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+ //don't use setKey(), that would create a new key without Headings set
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ (*(m_module->module()) )++;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );
+ }
+ else {
+ // Verse(Verse()+1);
+ //don't change the key, restore the module's position
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+ ret = false;
+ break;
+ }
+
+ }
+ else {
+ Verse(Verse() + 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) { //we have no module, so take care of VerseKey::Error()
+ return false;
+ }
+
+ return ret;
}
bool CSwordVerseKey::previous( const JumpType type ) {
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
- return false;
- }
- else if ( (Book() == 1) && (Testament() == 2) ){ //Matthew
- Testament(1);
- Book(BMAX[0]);
- }
- else{
- Book( Book()-1 );
- }
-
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()-1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
-
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
- }
- else {
- ret = false;
- // Verse(Verse()-1);
- m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
- }
- }
- else {
- Verse(Verse()-1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) {
- return false;
- }
-
- return ret;
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
+ return false;
+ }
+ else if ( (Book() == 1) && (Testament() == 2) ) { //Matthew
+ Testament(1);
+ Book(BMAX[0]);
+ }
+ else {
+ Book( Book() - 1 );
+ }
+
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() - 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
+ }
+ else {
+ ret = false;
+ // Verse(Verse()-1);
+ m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
+ }
+ }
+ else {
+ Verse(Verse() - 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) {
+ return false;
+ }
+
+ return ret;
}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index e421b6c..0f286dc 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -44,79 +44,81 @@ class CSwordModuleInfo;
class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
-public:
- enum JumpType {
- UseBook,
- UseChapter,
- UseVerse
- };
+ public:
+ enum JumpType {
+ UseBook,
+ UseChapter,
+ UseVerse
+ };
- /**
- * Constructor of this class.
- *
- * This function will construct a versekey with the current module position
- * and it will setup the m_module members.
- *
- */
- CSwordVerseKey( CSwordModuleInfo* const module );
- /**
- * Copy constructor.
- */
- CSwordVerseKey( const CSwordVerseKey& k );
- /**
- * VerseKey based constructor.
- */
- CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
- /**
- * Clones this object.
- */
- virtual CSwordKey* copy() const;
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual QString key() const;
- /**
- * Set the current key.
- */
- virtual bool key( const QString& );
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual bool key( const char* key );
+ /**
+ * Constructor of this class.
+ *
+ * This function will construct a versekey with the current module position
+ * and it will setup the m_module members.
+ *
+ */
+ CSwordVerseKey( CSwordModuleInfo* const module );
+ /**
+ * Copy constructor.
+ */
+ CSwordVerseKey( const CSwordVerseKey& k );
+ /**
+ * VerseKey based constructor.
+ */
+ CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
+ /**
+ * Clones this object.
+ */
+ virtual CSwordKey* copy() const;
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key.
+ */
+ virtual bool key( const QString& );
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual bool key( const char* key );
- /**
- * Jumps to the next entry of the given type
- */
- bool next( const JumpType type );
- /**
- * Jumps to the previous entry of the given type
- */
- bool previous ( const JumpType type );
- /**
- * This functions returns the current book as localised text, not as book numer.
- *
- * Use "char Book()" to retrieve the book number of the current book.
- * @return The name of the current book
- */
- QString book(const QString& newBook = QString::null);
- /**
- * Sets the module for this key
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
+ /**
+ * Jumps to the next entry of the given type
+ */
+ bool next( const JumpType type );
+ /**
+ * Jumps to the previous entry of the given type
+ */
+ bool previous ( const JumpType type );
+ /**
+ * This functions returns the current book as localised text, not as book numer.
+ *
+ * Use "char Book()" to retrieve the book number of the current book.
+ * @return The name of the current book
+ */
+ QString book(const QString& newBook = QString::null);
+ /**
+ * Sets the module for this key
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordVerseKey& operator= (const CSwordVerseKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordVerseKey& operator= (const CSwordVerseKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) {
+ return (*this);
+ };
};
#endif
diff --git a/src/backend/managers/btstringmgr.cpp b/src/backend/managers/btstringmgr.cpp
index 9f57258..a4fe381 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -10,127 +10,127 @@
#include "btstringmgr.h"
char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const {
- const int max = (maxlen>0) ? maxlen : strlen(text);
+ const int max = (maxlen > 0) ? maxlen : strlen(text);
- if (isUtf8(text)) {
- strncpy(text, (const char*)QString::fromUtf8(text).toUpper().toUtf8(), max);
+ if (isUtf8(text)) {
+ strncpy(text, (const char*)QString::fromUtf8(text).toUpper().toUtf8(), max);
- return text;
- }
- else {
- char* ret = text;
+ return text;
+ }
+ else {
+ char* ret = text;
- while (*text) {
- *text = toupper(*text);
- text++;
- }
+ while (*text) {
+ *text = toupper(*text);
+ text++;
+ }
- return ret;
- }
+ return ret;
+ }
- return text;
+ return text;
}
char* BTStringMgr::upperLatin1(char* text, unsigned int /*max*/) const {
- char* ret = text;
+ char* ret = text;
- while (*text) {
- *text = toupper(*text);
- text++;
- }
+ while (*text) {
+ *text = toupper(*text);
+ text++;
+ }
- return ret;
+ return ret;
}
bool BTStringMgr::supportsUnicode() const {
- return true;
+ return true;
}
bool BTStringMgr::isUtf8(const char *buf) const {
- int i, n;
- register unsigned char c;
- bool gotone = false;
-
- #define F 0 /* character never appears in text */
- #define T 1 /* character appears in plain ASCII text */
- #define I 2 /* character appears in ISO-8859 text */
- #define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
-
- static const unsigned char text_chars[256] = {
- /* BEL BS HT LF FF CR */
- F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
- /* ESC */
- F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
- /* NEL */
- X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
- X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
- };
-
- /* *ulen = 0; */
-
- for (i = 0; (c = buf[i]); i++) {
- if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
- /*
- * Even if the whole file is valid UTF-8 sequences,
- * still reject it if it uses weird control characters.
- */
-
- if (text_chars[c] != T)
- return false;
-
- }
- else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */
- return false;
- }
- else { /* 11xxxxxx begins UTF-8 */
- int following;
-
- if ((c & 0x20) == 0) { /* 110xxxxx */
- following = 1;
- }
- else if ((c & 0x10) == 0) { /* 1110xxxx */
- following = 2;
- }
- else if ((c & 0x08) == 0) { /* 11110xxx */
- following = 3;
- }
- else if ((c & 0x04) == 0) { /* 111110xx */
- following = 4;
- }
- else if ((c & 0x02) == 0) { /* 1111110x */
- following = 5;
- }
- else
- return false;
-
- for (n = 0; n < following; n++) {
- i++;
-
- if (!(c = buf[i]))
- goto done;
-
- if ((c & 0x80) == 0 || (c & 0x40))
- return false;
- }
-
- gotone = true;
- }
- }
+ int i, n;
+ register unsigned char c;
+ bool gotone = false;
+
+#define F 0 /* character never appears in text */
+#define T 1 /* character appears in plain ASCII text */
+#define I 2 /* character appears in ISO-8859 text */
+#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
+
+ static const unsigned char text_chars[256] = {
+ /* BEL BS HT LF FF CR */
+ F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
+ /* ESC */
+ F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
+ /* NEL */
+ X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
+ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
+ };
+
+ /* *ulen = 0; */
+
+ for (i = 0; (c = buf[i]); i++) {
+ if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
+ /*
+ * Even if the whole file is valid UTF-8 sequences,
+ * still reject it if it uses weird control characters.
+ */
+
+ if (text_chars[c] != T)
+ return false;
+
+ }
+ else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */
+ return false;
+ }
+ else { /* 11xxxxxx begins UTF-8 */
+ int following;
+
+ if ((c & 0x20) == 0) { /* 110xxxxx */
+ following = 1;
+ }
+ else if ((c & 0x10) == 0) { /* 1110xxxx */
+ following = 2;
+ }
+ else if ((c & 0x08) == 0) { /* 11110xxx */
+ following = 3;
+ }
+ else if ((c & 0x04) == 0) { /* 111110xx */
+ following = 4;
+ }
+ else if ((c & 0x02) == 0) { /* 1111110x */
+ following = 5;
+ }
+ else
+ return false;
+
+ for (n = 0; n < following; n++) {
+ i++;
+
+ if (!(c = buf[i]))
+ goto done;
+
+ if ((c & 0x80) == 0 || (c & 0x40))
+ return false;
+ }
+
+ gotone = true;
+ }
+ }
done:
- return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
+ return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
}
#undef F
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index d202c7f..73b784d 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -23,31 +23,31 @@
class BTStringMgr : public sword::StringMgr {
-public:
- /** Converts the param to an upper case Utf8 string
- * @param The text encoded in utf8 which should be turned into an upper case string
- */
- virtual char *upperUTF8(char *text, unsigned int max = 0) const;
-
- /** Converts the param to an uppercase latin1 string
- * @param The text encoded in latin1 which should be turned into an upper case string
- */
- virtual char *upperLatin1(char *text, unsigned int max = 0) const;
-
-protected:
- /** Enable Unicode support.
- * Reimplementation to show unicode support.
- */
- virtual bool supportsUnicode() const;
-
- /** CODE TAKEN FROM KDELIBS 3.2, which is licensed under the LGPL 2.
- *
- * This code was taken from KStringHandler, which is part of the KDE libraries.
- *
- * This function checks whether a string is utf8 or not.
- * It was taken from kdelibs so we do not depend on KDE 3.2.
- */
- bool isUtf8(const char *buf) const;
+ public:
+ /** Converts the param to an upper case Utf8 string
+ * @param The text encoded in utf8 which should be turned into an upper case string
+ */
+ virtual char *upperUTF8(char *text, unsigned int max = 0) const;
+
+ /** Converts the param to an uppercase latin1 string
+ * @param The text encoded in latin1 which should be turned into an upper case string
+ */
+ virtual char *upperLatin1(char *text, unsigned int max = 0) const;
+
+ protected:
+ /** Enable Unicode support.
+ * Reimplementation to show unicode support.
+ */
+ virtual bool supportsUnicode() const;
+
+ /** CODE TAKEN FROM KDELIBS 3.2, which is licensed under the LGPL 2.
+ *
+ * This code was taken from KStringHandler, which is part of the KDE libraries.
+ *
+ * This function checks whether a string is utf8 or not.
+ * It was taken from kdelibs so we do not depend on KDE 3.2.
+ */
+ bool isUtf8(const char *buf) const;
};
#endif
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index 6ddd6b7..4722734 100644
--- a/src/backend/managers/cdisplaytemplatemgr.cpp
+++ b/src/backend/managers/cdisplaytemplatemgr.cpp
@@ -23,148 +23,145 @@
#include <QDebug>
CDisplayTemplateMgr::CDisplayTemplateMgr() {
- loadTemplates();
+ loadTemplates();
}
CDisplayTemplateMgr::~CDisplayTemplateMgr() {
}
-const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings )
-{
- qDebug() << "CDisplayTemplateMgr::fillTemplate";
-
- const QString templateName = m_templateMap.contains(name) ? name : defaultTemplate();
-
- QString displayTypeString;
-
- if (!settings.pageCSS_ID.isEmpty()) {
- displayTypeString = settings.pageCSS_ID;
- }
- else {
- if (settings.modules.count()) {
- switch (settings.modules.first()->type()) {
-
- case CSwordModuleInfo::Bible:
- displayTypeString = "bible";
- break;
-
- case CSwordModuleInfo::GenericBook:
- displayTypeString = "book";
- break;
-
- case CSwordModuleInfo::Commentary:
- case CSwordModuleInfo::Lexicon:
- default:
- displayTypeString = "singleentry";
- break;
- };
- }
- else { //use bible as default type if no modules are set
- displayTypeString = "bible";
- };
- }
-
- QString newContent = content;
- const int moduleCount = settings.modules.count();
-
- if (moduleCount >= 2) {
- //create header for the modules
- qDebug("There were more than 1 module, create headers");
- QString header;
-
- QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
-
- for (QList<CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
- header.append("<th style=\"width:")
- .append(QString::number(int( 100.0 / (float)moduleCount )))
- .append("%;\">")
- .append((*it)->name())
- .append("</th>");
- }
-
- newContent = QString("<table><tr>")
- .append(header)
- .append("</tr>")
- .append(content)
- .append("</table>");
- }
-
- QString langCSS;
- CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
-
- qDebug() << "langMap length:" << langMap.count();
- qDebug("loop through langMap");
- foreach(const CLanguageMgr::Language* lang, langMap) {
- //const CLanguageMgr::Language* lang = *it;
- //qDebug() << "foreach, lang: ";
- //qDebug() << lang;
-
- //if (lang->isValid() && CBTConfig::get(lang).first) {
- if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) {
- const QFont f = CBTConfig::get(lang).second;
-
- //don't use important, because it would reset the title formatting, etc. to the setup font
- QString css("{ ");
- css.append("font-family:").append(f.family())/*.append(" !important")*/;
- css.append("; font-size:").append(QString::number(f.pointSize())).append("pt /*!important*/");
- css.append("; font-weight:").append(f.bold() ? "bold" : "normal /*!important*/");
- css.append("; font-style:").append(f.italic() ? "italic" : "normal /*!important*/");
- css.append("; }\n");
-
- langCSS +=
- QString("\n*[lang=%1] %2")
- .arg(lang->abbrev())
- .arg(css);
- }
- }
-
- //at first append the font standard settings for all languages without configured font
- // Create a dummy language (the langmap may be empty)
- CLanguageMgr::Language lang_v(QString("en"), QString("English"), QString());
- CLanguageMgr::Language* lang = &lang_v;
-
- if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) {
- const QFont standardFont = CBTConfig::getDefault(lang); //we just need a dummy lang param
- langCSS.prepend(
- QString("\n#content {font-family:%1; font-size:%2pt; font-weight:%3; font-style: %4;}\n")
- .arg(standardFont.family())
- .arg(standardFont.pointSize())
- .arg(standardFont.bold() ? "bold" : "normal")
- .arg(standardFont.italic() ? "italic" : "normal")
- );
- }
+const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings ) {
+ qDebug() << "CDisplayTemplateMgr::fillTemplate";
+
+ const QString templateName = m_templateMap.contains(name) ? name : defaultTemplate();
+
+ QString displayTypeString;
+
+ if (!settings.pageCSS_ID.isEmpty()) {
+ displayTypeString = settings.pageCSS_ID;
+ }
+ else {
+ if (settings.modules.count()) {
+ switch (settings.modules.first()->type()) {
+
+ case CSwordModuleInfo::Bible:
+ displayTypeString = "bible";
+ break;
+
+ case CSwordModuleInfo::GenericBook:
+ displayTypeString = "book";
+ break;
+
+ case CSwordModuleInfo::Commentary:
+ case CSwordModuleInfo::Lexicon:
+ default:
+ displayTypeString = "singleentry";
+ break;
+ };
+ }
+ else { //use bible as default type if no modules are set
+ displayTypeString = "bible";
+ };
+ }
+
+ QString newContent = content;
+ const int moduleCount = settings.modules.count();
+
+ if (moduleCount >= 2) {
+ //create header for the modules
+ qDebug("There were more than 1 module, create headers");
+ QString header;
+
+ QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
+
+ for (QList<CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
+ header.append("<th style=\"width:")
+ .append(QString::number(int( 100.0 / (float)moduleCount )))
+ .append("%;\">")
+ .append((*it)->name())
+ .append("</th>");
+ }
+
+ newContent = QString("<table><tr>")
+ .append(header)
+ .append("</tr>")
+ .append(content)
+ .append("</table>");
+ }
+
+ QString langCSS;
+ CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
+
+ qDebug() << "langMap length:" << langMap.count();
+ qDebug("loop through langMap");
+ foreach(const CLanguageMgr::Language* lang, langMap) {
+ //const CLanguageMgr::Language* lang = *it;
+ //qDebug() << "foreach, lang: ";
+ //qDebug() << lang;
+
+ //if (lang->isValid() && CBTConfig::get(lang).first) {
+ if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) {
+ const QFont f = CBTConfig::get(lang).second;
+
+ //don't use important, because it would reset the title formatting, etc. to the setup font
+ QString css("{ ");
+ css.append("font-family:").append(f.family())/*.append(" !important")*/;
+ css.append("; font-size:").append(QString::number(f.pointSize())).append("pt /*!important*/");
+ css.append("; font-weight:").append(f.bold() ? "bold" : "normal /*!important*/");
+ css.append("; font-style:").append(f.italic() ? "italic" : "normal /*!important*/");
+ css.append("; }\n");
+
+ langCSS +=
+ QString("\n*[lang=%1] %2")
+ .arg(lang->abbrev())
+ .arg(css);
+ }
+ }
+
+ //at first append the font standard settings for all languages without configured font
+ // Create a dummy language (the langmap may be empty)
+ CLanguageMgr::Language lang_v(QString("en"), QString("English"), QString());
+ CLanguageMgr::Language* lang = &lang_v;
+
+ if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) {
+ const QFont standardFont = CBTConfig::getDefault(lang); //we just need a dummy lang param
+ langCSS.prepend(
+ QString("\n#content {font-family:%1; font-size:%2pt; font-weight:%3; font-style: %4;}\n")
+ .arg(standardFont.family())
+ .arg(standardFont.pointSize())
+ .arg(standardFont.bold() ? "bold" : "normal")
+ .arg(standardFont.italic() ? "italic" : "normal")
+ );
+ }
// qWarning("Outputing unformated text");
- const QString t = QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy
- .replace("#TITLE#", settings.title)
- .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev)
- .replace("#DISPLAYTYPE#", displayTypeString)
- .replace("#LANG_CSS#", langCSS)
- .replace("#PAGE_DIRECTION#", settings.pageDirection)
- .replace("#CONTENT#", newContent);
-
- return t;
+ const QString t = QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy
+ .replace("#TITLE#", settings.title)
+ .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev)
+ .replace("#DISPLAYTYPE#", displayTypeString)
+ .replace("#LANG_CSS#", langCSS)
+ .replace("#PAGE_DIRECTION#", settings.pageDirection)
+ .replace("#CONTENT#", newContent);
+
+ return t;
}
void CDisplayTemplateMgr::loadTemplates() {
- QStringList files;
- foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl")))
- {
- files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
- foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl")))
- {
- files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
-
- foreach (QString file, files) {
- QFile f(file);
- if (f.exists() && f.open( QIODevice::ReadOnly )) {
- QString fileContent = QTextStream( &f ).readAll();
-
- if (!fileContent.isEmpty()) {
- m_templateMap[ QFileInfo(file).fileName() ] = fileContent;
- }
- }
- }
+ QStringList files;
+ foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
+ }
+ foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
+ }
+
+ foreach (QString file, files) {
+ QFile f(file);
+ if (f.exists() && f.open( QIODevice::ReadOnly )) {
+ QString fileContent = QTextStream( &f ).readAll();
+
+ if (!fileContent.isEmpty()) {
+ m_templateMap[ QFileInfo(file).fileName() ] = fileContent;
+ }
+ }
+ }
}
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index c791e16..d048ecd 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -25,54 +25,54 @@ class CSwordModuleInfo;
class CDisplayTemplateMgr {
-public:
- /** Settings which are used to fill the content into the template.
- */
-
- struct Settings {
- /** Constructor. Constructs the new settings object. The default values are empty.
- */
- Settings() {
- title = QString::null;
- langAbbrev = QString::null;
- pageCSS_ID = QString::null;
- pageDirection = QString("ltr");
+ public:
+ /** Settings which are used to fill the content into the template.
+ */
+
+ struct Settings {
+ /** Constructor. Constructs the new settings object. The default values are empty.
+ */
+ Settings() {
+ title = QString::null;
+ langAbbrev = QString::null;
+ pageCSS_ID = QString::null;
+ pageDirection = QString("ltr");
+ };
+
+ QList<CSwordModuleInfo*> modules; /**< the list of modules */
+ QString title; /**< the title which is used for the new processed HTML page */
+ QString langAbbrev; /**< the language for the HTML page. */
+ QString pageDirection; /**< the language for the HTML page. */
+ QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */
};
- QList<CSwordModuleInfo*> modules; /**< the list of modules */
- QString title; /**< the title which is used for the new processed HTML page */
- QString langAbbrev; /**< the language for the HTML page. */
- QString pageDirection; /**< the language for the HTML page. */
- QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */
- };
-
- /** Available templates.
- * @return The list of templates, which are available.
- */
- inline const QStringList availableTemplates();
- /** Fill template. Fill rendered content into the template given by the name.
- * @param name The name of the template
- * @param content The content which should be filled into the template
- * @param settings The settings which are used to process the templating process
- * @return The full HTML template HTML code including the CSS data.
- */
- const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
- /** Default template.
- * @return The i18n'ed name of the default template
- */
- inline static const QString defaultTemplate();
-
-protected:
- friend class CPointers;
- /** Display template manager constructor. Protected to just allow CPointers to create objects. */
- CDisplayTemplateMgr();
- /** Destructor. */
- ~CDisplayTemplateMgr();
- /** Does the actual work of loading templates from disk */
- void loadTemplates();
-
-private:
- QMap<QString, QString> m_templateMap;
+ /** Available templates.
+ * @return The list of templates, which are available.
+ */
+ inline const QStringList availableTemplates();
+ /** Fill template. Fill rendered content into the template given by the name.
+ * @param name The name of the template
+ * @param content The content which should be filled into the template
+ * @param settings The settings which are used to process the templating process
+ * @return The full HTML template HTML code including the CSS data.
+ */
+ const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
+ /** Default template.
+ * @return The i18n'ed name of the default template
+ */
+ inline static const QString defaultTemplate();
+
+ protected:
+ friend class CPointers;
+ /** Display template manager constructor. Protected to just allow CPointers to create objects. */
+ CDisplayTemplateMgr();
+ /** Destructor. */
+ ~CDisplayTemplateMgr();
+ /** Does the actual work of loading templates from disk */
+ void loadTemplates();
+
+ private:
+ QMap<QString, QString> m_templateMap;
};
inline const QString CDisplayTemplateMgr::defaultTemplate() {
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index 4dcc411..e7245e5 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -20,17 +20,17 @@
CLanguageMgr::Language::Language() {}
CLanguageMgr::Language::Language(const Language& l) {
- m_abbrev = l.m_abbrev;
- m_englishName = l.m_englishName;
- m_translatedName = l.m_translatedName;
- m_altAbbrevs = l.m_altAbbrevs;
+ m_abbrev = l.m_abbrev;
+ m_englishName = l.m_englishName;
+ m_translatedName = l.m_translatedName;
+ m_altAbbrevs = l.m_altAbbrevs;
}
CLanguageMgr::Language::Language( const QString& abbrev, const QString& name, const QString& translatedName, const QStringList& altAbbrevs ) {
- m_abbrev = abbrev;
- m_englishName = name;
- m_translatedName = translatedName;
- m_altAbbrevs = altAbbrevs;
+ m_abbrev = abbrev;
+ m_englishName = name;
+ m_translatedName = translatedName;
+ m_altAbbrevs = altAbbrevs;
}
CLanguageMgr::Language::~Language() {
@@ -41,506 +41,506 @@ CLanguageMgr::Language::~Language() {
/******************** CLanguageMgr ******************/
/****************************************************/
CLanguageMgr::CLanguageMgr() : m_langMap() {
- m_availableModulesCache.moduleCount = 0;
- init();
+ m_availableModulesCache.moduleCount = 0;
+ init();
}
CLanguageMgr::~CLanguageMgr() {
- qDeleteAll(m_cleanupLangPtrs);
- m_cleanupLangPtrs.clear();
- qDeleteAll(m_langList);
- m_langList.clear();
+ qDeleteAll(m_cleanupLangPtrs);
+ m_cleanupLangPtrs.clear();
+ qDeleteAll(m_langList);
+ m_langList.clear();
}
const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() {
- QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();
+ QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();
- if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
- m_availableModulesCache.availableLanguages.clear();
- m_availableModulesCache.moduleCount = mods.count();
+ if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
+ m_availableModulesCache.availableLanguages.clear();
+ m_availableModulesCache.moduleCount = mods.count();
- //collect the languages abbrevs of all modules
- QStringList abbrevs;
+ //collect the languages abbrevs of all modules
+ QStringList abbrevs;
- foreach (const CSwordModuleInfo* mod, mods) {
- if (!abbrevs.contains(mod->module()->Lang())){
- abbrevs.append(mod->module()->Lang());
- }
- }
+ foreach (const CSwordModuleInfo* mod, mods) {
+ if (!abbrevs.contains(mod->module()->Lang())) {
+ abbrevs.append(mod->module()->Lang());
+ }
+ }
- //now create a map of available langs
- foreach ( QString abbrev, abbrevs ) {
- const Language* const lang = languageForAbbrev(abbrev);
+ //now create a map of available langs
+ foreach ( QString abbrev, abbrevs ) {
+ const Language* const lang = languageForAbbrev(abbrev);
- if (lang->isValid()) {
- m_availableModulesCache.availableLanguages.insert( abbrev, lang );
- }
- else { //invalid lang used by a module, create a new language using the abbrev
- Language* newLang = new Language(abbrev, abbrev, abbrev);
- m_cleanupLangPtrs.append(newLang);
- m_availableModulesCache.availableLanguages.insert( abbrev, newLang );
- }
- }
- }
- return m_availableModulesCache.availableLanguages;
+ if (lang->isValid()) {
+ m_availableModulesCache.availableLanguages.insert( abbrev, lang );
+ }
+ else { //invalid lang used by a module, create a new language using the abbrev
+ Language* newLang = new Language(abbrev, abbrev, abbrev);
+ m_cleanupLangPtrs.append(newLang);
+ m_availableModulesCache.availableLanguages.insert( abbrev, newLang );
+ }
+ }
+ }
+ return m_availableModulesCache.availableLanguages;
}
const CLanguageMgr::Language* CLanguageMgr::languageForAbbrev( const QString& abbrev ) const {
- LangMapIterator it = m_langMap.find(abbrev);
- if (it != m_langMap.constEnd()) return *it; //Language is already here
-
- //try to search in the alternative abbrevs
- foreach (const Language* lang, m_langList ) {
- if (lang->alternativeAbbrevs().contains(abbrev)) return lang;
- }
-
- // Invalid lang used by a modules, create a new language using the abbrev
- Language* newLang = new Language(abbrev, abbrev, abbrev); //return a language which holds the valid abbrev
- m_cleanupLangPtrs.append(newLang);
+ LangMapIterator it = m_langMap.find(abbrev);
+ if (it != m_langMap.constEnd()) return *it; //Language is already here
- return newLang;
+ //try to search in the alternative abbrevs
+ foreach (const Language* lang, m_langList ) {
+ if (lang->alternativeAbbrevs().contains(abbrev)) return lang;
+ }
+
+ // Invalid lang used by a modules, create a new language using the abbrev
+ Language* newLang = new Language(abbrev, abbrev, abbrev); //return a language which holds the valid abbrev
+ m_cleanupLangPtrs.append(newLang);
+
+ return newLang;
}
const CLanguageMgr::Language* CLanguageMgr::languageForName( const QString& name ) const {
- foreach ( const Language* lang, m_langList ) {
- if (lang->name() == name) return lang;
- }
- return &m_defaultLanguage;//invalid language
+ foreach ( const Language* lang, m_langList ) {
+ if (lang->name() == name) return lang;
+ }
+ return &m_defaultLanguage;//invalid language
}
const CLanguageMgr::Language* CLanguageMgr::languageForTranslatedName( const QString& name ) const {
- foreach ( const Language* lang, m_langList ) {
- if (lang->translatedName() == name) return lang;
- }
- return &m_defaultLanguage; //invalid language
+ foreach ( const Language* lang, m_langList ) {
+ if (lang->translatedName() == name) return lang;
+ }
+ return &m_defaultLanguage; //invalid language
}
void CLanguageMgr::init() {
- // The main() sets string literal codec to utf8:
- // QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
- // The language names include escape sequences \uxxxx
+ // The main() sets string literal codec to utf8:
+ // QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ // The language names include escape sequences \uxxxx
- //if we've already inserted all items we do not proceed
- if (m_langMap.count() > 0) return;
+ //if we've already inserted all items we do not proceed
+ if (m_langMap.count() > 0) return;
- // Developers: It's easy to get a list of used language codes from all modules:
- // Refresh all sources; go to .sword/InstallMgr/; run:
- // grep -R -hs Lang= *|cut -c 6-|sort|uniq
- // Don't remove unused languages from the source code unless you know it won't be used
- // anymore.in any module ever.
+ // Developers: It's easy to get a list of used language codes from all modules:
+ // Refresh all sources; go to .sword/InstallMgr/; run:
+ // grep -R -hs Lang= *|cut -c 6-|sort|uniq
+ // Don't remove unused languages from the source code unless you know it won't be used
+ // anymore.in any module ever.
- /*:
- The string "Names of languages" doesn't actually need translation.
- It is put here to help translators notice this help text.
- -------
- The names of the languages should follow the conventions of your
- language. You can write the names with a capital first letter even if your language
- uses non-capitalized language names (they look better with capital
- first letter when they are listed).
- -------
- To find the names of all languages from internet try searching for
- "names of languages in language_x" but in your own language, e.g.
- "kielten nimet suomeksi" in Finnish or "names of languages in english"
- in English.
- -------
- You can find the language codes and names by googling for the standards
- mentioned below.
- -------
- Preference order for locale codes are:
- -------
- ISO 639-1 -------
- ISO 639-2 -------
- ISO 639-3
- -------
- x-E-XXX form is deprecated and no modules in repositories use it.
- If you find a module with x-E-XXX language, update the module.
- */
- QObject::tr("Names of languages", "No need to translate - see the longer comment (If there is no longer comment, it doesn't work yet :)) ------ ");
- // m_langList.append( new Language("aa", "Afar", QObject::tr("Afar")) );
- // m_langList.append( new Language("ab", "Abkhazian", QObject::tr("Abkhazian")) );
- // m_langList.append( new Language("ae", "Avestan", QObject::tr("Avestan")) );
- //: Language name af
- m_langList.append( new Language("af", "Afrikaans", QObject::tr("Afrikaans")) );
- // m_langList.append( new Language("am", "Amharic", QObject::tr("Amharic")) );
- //: Language name amu
- m_langList.append( new Language("amu", "Amuzgo, Guerrero", QObject::tr("Amuzgo, Guerrero")) );
- //: Language name ang
- m_langList.append( new Language("ang", "English, Old (ca.450-1100)", QObject::tr("English, Old (ca.450-1100)")) );
- //: Language name ar
- m_langList.append( new Language("ar", "Arabic", QObject::tr("Arabic")) );
- // m_langList.append( new Language("as", "Assamese", QObject::tr("Assamese")) );
- //: Language name az
- m_langList.append( new Language("az", "Azerbaijani", QObject::tr("Azerbaijani")) );
- //: Language name azb
- m_langList.append( new Language("azb", "Azerbaijani, South", QObject::tr("Azerbaijani, South")) );
- // m_langList.append( new Language("ba", "Bashkir", QObject::tr("Bashkir")) );
- //: Language name bar
- m_langList.append( new Language("bar", "Bavarian", QObject::tr("Bavarian")) );
- //: Language name be
- m_langList.append( new Language("be", "Belarusian", QObject::tr("Belarusian")) );
- //: Language name bg
- m_langList.append( new Language("bg", "Bulgarian", QObject::tr("Bulgarian")) );
- // m_langList.append( new Language("bh", "Bihari", QObject::tr("Bihari")) );
- // m_langList.append( new Language("bi", "Bislama", QObject::tr("Bislama")) );
- // m_langList.append( new Language("bn", "Bengali", QObject::tr("Bengali")) );
- // m_langList.append( new Language("bo", "Tibetan", QObject::tr("Tibetan")) );
- //: Language name br
- m_langList.append( new Language("br", "Breton", QObject::tr("Breton")) );
- //: Language name bs
- m_langList.append( new Language("bs", "Bosnian", QObject::tr("Bosnian")) );
- //: Language name ca
- m_langList.append( new Language("ca", "Catalan", QObject::tr("Catalan")) );
- // m_langList.append( new Language("ce", "Chechen", QObject::tr("Chechen")) );
- //: Language name cco
- m_langList.append( new Language("cco", "Chinantec, Comaltepec", QObject::tr("Chinantec, Comaltepec")) );
- //: Language name ceb
- m_langList.append( new Language("ceb", "Cebuano", QObject::tr("Cebuano")) );
- //: Language name ch
- m_langList.append( new Language("ch", "Chamorro", QObject::tr("Chamorro")) );
- //: Language name chd
- m_langList.append( new Language("chd", "Chontal, Highland Oaxaca", QObject::tr("Chontal, Highland Oaxaca")) );
- //: Language name chq
- m_langList.append( new Language("chq", "Chinantec, Quiotepec", QObject::tr("Chinantec, Quiotepec")) );
- //: Language name chz
- m_langList.append( new Language("chz", "Chinantec, Ozumac\u00edn", QObject::tr("Chinantec, Ozumac\u00edn")) );
- // m_langList.append( new Language("co", "Corsican", QObject::tr("Corsican")) );
- //: Language name ckw
- m_langList.append( new Language("ckw", "Cakchiquel, Western", QObject::tr("Cakchiquel, Western")) );
- //: Language name cnl
- m_langList.append( new Language("cnl", "Chinantec, Lalana", QObject::tr("Chinantec, Lalana")) );
- //: Language name cnt
- m_langList.append( new Language("cnt", "Chinantec, Tepetotutla", QObject::tr("Chinantec, Tepetotutla")) );
- //: Language name cop
- m_langList.append( new Language("cop", "Coptic", QObject::tr("Coptic")) );
- //: Language name cs
- m_langList.append( new Language("cs", "Czech", QObject::tr("Czech")) );
- //: Language name cso
- m_langList.append( new Language("cso", "Chinantec, Sochiapan", QObject::tr("Chinantec, Sochiapan")) );
- //: Language name cti
- m_langList.append( new Language("cti", "Chol, Tila", QObject::tr("Chol, Tila")) );
- //: Language name ctp
- m_langList.append( new Language("ctp", "Chatino, Western Highland", QObject::tr("Chatino, Western Highland")) );
- //: Language name cu
- m_langList.append( new Language("cu", "Church Slavic", QObject::tr("Church Slavic")) );
- // m_langList.append( new Language("cv", "Chuvash", QObject::tr("Chuvash")) );
- //: Language name cy
- m_langList.append( new Language("cy", "Welsh", QObject::tr("Welsh")) );
- //: Language name da
- m_langList.append( new Language("da", "Danish", QObject::tr("Danish")) );
- //: Language name de
- m_langList.append( new Language("de", "German", QObject::tr("German")) );
- //: Language name dug
- m_langList.append( new Language("dug", "Duruma", QObject::tr("Duruma")) );
- // m_langList.append( new Language("dz", "Dzongkha", QObject::tr("Dzongkha")) );
- //: Language name el
- m_langList.append( new Language("el", "Greek, Modern (1453-)", QObject::tr("Greek, Modern (1453-)"), makeStringList("gre;ell")) );
- //: Language name en
- m_langList.append( new Language("en", "English", QObject::tr("English")) );
- //: Language name en_US
- m_langList.append( new Language("en_US","American English", QObject::tr("American English")) );
- //: Language name enm
- m_langList.append( new Language("enm", "English, Middle (1100-1500)", QObject::tr("English, Middle (1100-1500)")) );
- //: Language name eo
- m_langList.append( new Language("eo", "Esperanto", QObject::tr("Esperanto")) );
- //: Language name es
- m_langList.append( new Language("es", "Spanish", QObject::tr("Spanish")) );
- //: Language name et
- m_langList.append( new Language("et", "Estonian", QObject::tr("Estonian")) );
- //: Language name eu
- m_langList.append( new Language("eu", "Basque", QObject::tr("Basque")) );
- //: Language name fa
- m_langList.append( new Language("fa", "Persian", QObject::tr("Persian")) );
- //: Language name fi
- m_langList.append( new Language("fi", "Finnish", QObject::tr("Finnish")) );
- // m_langList.append( new Language("fj", "Fijian", QObject::tr("Fijian")) );
- // m_langList.append( new Language("fo", "Faroese", QObject::tr("Faroese")) );
- //: Language name fr
- m_langList.append( new Language("fr", "French", QObject::tr("French")) );
- //: Language name fy
- m_langList.append( new Language("fy", "Frisian", QObject::tr("Frisian")) );
- //: Language name ga
- m_langList.append( new Language("ga", "Irish", QObject::tr("Irish")) );
- //: Language name gd
- m_langList.append( new Language("gd", "Gaelic (Scots)", QObject::tr("Gaelic (Scots)")) );
- //: Language name gez
- m_langList.append( new Language("gez", "Geez", QObject::tr("Geez")) );
- // m_langList.append( new Language("gl", "Gallegan", QObject::tr("Gallegan")) );
- // m_langList.append( new Language("gn", "Guarani", QObject::tr("Guarani")) );
- // m_langList.append( new Language("gn", "Gujarati", QObject::tr("Gujarati")) );
- //: Language name got
- m_langList.append( new Language("got", "Gothic", QObject::tr("Gothic")) );
- //: Language name gv
- m_langList.append( new Language("gv", "Manx", QObject::tr("Manx")) );
- //: Language name grc
- m_langList.append( new Language("grc", "Greek, Ancient (to 1453)", QObject::tr("Greek, Ancient (to 1453)")) );
- //: Language name he
- m_langList.append( new Language("he", "Hebrew", QObject::tr("Hebrew")) );
- //: Language name hau
- m_langList.append( new Language("hau", "Hausa", QObject::tr("Hausa")) );
- //: Language name haw
- m_langList.append( new Language("haw", "Hawaiian", QObject::tr("Hawaiian")) );
- //: Language name hi
- m_langList.append( new Language("hi", "Hindi", QObject::tr("Hindi")) );
- // m_langList.append( new Language("ho", "Hiri Motu", QObject::tr("Hiri Motu")) );
- //: Language name hr
- m_langList.append( new Language("hr", "Croatian", QObject::tr("Croatian")) );
- //: Language name ht
- m_langList.append( new Language("ht", "Haitian Creole", QObject::tr("Haitian Creole")) );
- //: Language name hu
- m_langList.append( new Language("hu", "Hungarian", QObject::tr("Hungarian")) );
- //: Language name huv
- m_langList.append( new Language("huv", "Huave, San Mateo Del Mar", QObject::tr("Huave, San Mateo Del Mar")) );
- //: Language name hy
- m_langList.append( new Language("hy", "Armenian", QObject::tr("Armenian")) );
- // m_langList.append( new Language("hz", "Herero", QObject::tr("Herero")) );
- // m_langList.append( new Language("ia", "Interlingua", QObject::tr("Interlingua")) );
- //: Language name id
- m_langList.append( new Language("id", "Indonesian", QObject::tr("Indonesian")) );
- // m_langList.append( new Language("ie", "Interlingue", QObject::tr("Interlingue")) );
- // m_langList.append( new Language("ik", "Inupiaq", QObject::tr("Inupiaq")) );
- //: Language name is
- m_langList.append( new Language("is", "Icelandic", QObject::tr("Icelandic")) );
- //: Language name it
- m_langList.append( new Language("it", "Italian", QObject::tr("Italian")) );
- //: Language name itz
- m_langList.append( new Language("itz", "Itz\u00e1", QObject::tr("Itz\u00e1")) );
- //: Language name ixl
- m_langList.append( new Language("ixl", "Ixil, San Juan Cotzal", QObject::tr("Ixil, San Juan Cotzal")) );
- // m_langList.append( new Language("iu", "Inuktitut", QObject::tr("Inuktitut")) );
- //: Language name ja
- m_langList.append( new Language("ja", "Japanese", QObject::tr("Japanese")) );
- //: Language name jac
- m_langList.append( new Language("jac", "Jacalteco, Eastern", QObject::tr("Jacalteco, Eastern")) );
- //: Language name jvn
- m_langList.append( new Language("jvn", "Javanese, Caribbean", QObject::tr("Javanese, Caribbean")) );
- //: Language name ka
- m_langList.append( new Language("ka", "Georgian", QObject::tr("Georgian")) );
- //: Language name kek
- m_langList.append( new Language("kek", "Kekch\u00ed", QObject::tr("Kekch\u00ed", "kek")) );
- // m_langList.append( new Language("ki", "Kikuyu", QObject::tr("Kikuyu")) );
- // m_langList.append( new Language("kj", "Kuanyama", QObject::tr("Kuanyama")) );
- // m_langList.append( new Language("kk", "Kazakh", QObject::tr("Kazakh")) );
- // m_langList.append( new Language("kl", "Kalaallisut", QObject::tr("Kalaallisut")) );
- // m_langList.append( new Language("km", "Khmer", QObject::tr("Khmer")) );
- // m_langList.append( new Language("kn", "Kannada", QObject::tr("Kannada")) );
- //: Language name ko
- m_langList.append( new Language("ko", "Korean", QObject::tr("Korean")) );
- // m_langList.append( new Language("ks", "Kashmiri", QObject::tr("Kashmiri")) );
- //: Language name ku
- m_langList.append( new Language("ku", "Kurdish", QObject::tr("Kurdish")) );
- // m_langList.append( new Language("kv", "Komi", QObject::tr("Komi")) );
- // m_langList.append( new Language("kw", "Cornish", QObject::tr("Cornish")) );
- //: Language name ky
- m_langList.append( new Language("ky", "Kirghiz", QObject::tr("Kirghiz")) );
- //: Language name la
- m_langList.append( new Language("la", "Latin", QObject::tr("Latin")) );
- //: Language name lac
- m_langList.append( new Language("lac", "Lacandon", QObject::tr("Lacandon")) );
- // m_langList.append( new Language("lb", "Letzeburgesch", QObject::tr("Letzeburgesch")) );
- //: Language name lmo
- m_langList.append( new Language("lmo", "Lombard", QObject::tr("Lombard")) );
- // m_langList.append( new Language("ln", "Lingala", QObject::tr("Lingala")) );
- // m_langList.append( new Language("lo", "Lao", QObject::tr("Lao")) );
- //: Language name lt
- m_langList.append( new Language("lt", "Lithuanian", QObject::tr("Lithuanian")) );
- //: Language name lv
- m_langList.append( new Language("lv", "Latvian", QObject::tr("Latvian")) );
- //: Language name mg
- m_langList.append( new Language("mg", "Malagasy", QObject::tr("Malagasy")) );
- // m_langList.append( new Language("mh", "Marshall", QObject::tr("Marshall")) );
- //: Language name mi
- m_langList.append( new Language("mi", "Maori", QObject::tr("Maori")) );
- //: Language name mir
- m_langList.append( new Language("mir", "Mixe, Isthmus", QObject::tr("Mixe, Isthmus")) );
- //: Language name miz
- m_langList.append( new Language("miz", "Mixtec, Coatzospan", QObject::tr("Mixtec, Coatzospan")) );
- //: Language name mk
- m_langList.append( new Language("mk", "Macedonian", QObject::tr("Macedonian")) );
- //: Language name mks
- m_langList.append( new Language("mks", "Mixtec, Silacayoapan", QObject::tr("Mixtec, Silacayoapan")) );
- // m_langList.append( new Language("ml", "Malayalam", QObject::tr("Malayalam")) );
- // m_langList.append( new Language("mn", "Mongolian", QObject::tr("Mongolian")) );
- // m_langList.append( new Language("mo", "Moldavian", QObject::tr("Moldavian")) );
- //: Language name mos
- m_langList.append( new Language("mos", "More", QObject::tr("More")) );
- // m_langList.append( new Language("mr", "Marathi", QObject::tr("Marathi")) );
- //: Language name ms
- m_langList.append( new Language("ms", "Malay", QObject::tr("Malay")) );
- //: Language name mt
- m_langList.append( new Language("mt", "Maltese", QObject::tr("Maltese")) );
- //: Language name mul (meaning that the work has multiple languages)
- m_langList.append( new Language("mul", "(Multiple languages)", QObject::tr("(Multiple languages)")) );
- //: Language name mvc
- m_langList.append( new Language("mvc", "Mam, Central", QObject::tr("Mam, Central")) );
- //: Language name mvj
- m_langList.append( new Language("mvj", "Mam, Todos Santos Cuchumat\u00e1n", QObject::tr("Mam, Todos Santos Cuchumat\u00e1n")) );
- //: Language name mxq
- m_langList.append( new Language("mxq", "Mixe, Juquila", QObject::tr("Mixe, Juquila")) );
- //: Language name mxt
- m_langList.append( new Language("mxt", "Mixtec, Jamiltepec", QObject::tr("Mixtec, Jamiltepec")) );
- //: Language name my
- m_langList.append( new Language("my", "Burmese", QObject::tr("Burmese")) );
- // m_langList.append( new Language("na", "Nauru", QObject::tr("Nauru")) );
- //: Language name nb
- m_langList.append( new Language("nb", "Norwegian Bokm\u00e5l", QObject::tr("Norwegian Bokm\u00e5l")) );
- //: Language name ncl
- m_langList.append( new Language("ncl", "Nahuatl, Michoac\u00e1n", QObject::tr("Nahuatl, Michoac\u00e1n")) );
- // m_langList.append( new Language("nd", "Ndebele, North", QObject::tr("Ndebele, North")) );
- //: Language name nds
- m_langList.append( new Language("nds", "Low German; Low Saxon", QObject::tr("Low German; Low Saxon")) );
- //: Language name ne
- m_langList.append( new Language("ne", "Nepali", QObject::tr("Nepali")) );
- //: Language name ngu
- m_langList.append( new Language("ngu", "Nahuatl, Guerrero", QObject::tr("Nahuatl, Guerrero")) );
- //: Language name nhy
- m_langList.append( new Language("nhy", "Nahuatl, Northern Oaxaca", QObject::tr("Nahuatl, Northern Oaxaca")) );
- // m_langList.append( new Language("ng", "Ndonga", QObject::tr("Ndonga")) );
- //: Language name nl
- m_langList.append( new Language("nl", "Dutch", QObject::tr("Dutch")) );
- //: Language name nn
- m_langList.append( new Language("nn", "Norwegian Nynorsk", QObject::tr("Norwegian Nynorsk")) );
- //: Language name no
- m_langList.append( new Language("no", "Norwegian", QObject::tr("Norwegian")) );
- // m_langList.append( new Language("nr", "Ndebele, South", QObject::tr("Ndebele, South")) );
- // m_langList.append( new Language("nv", "Navajo", QObject::tr("Navajo")) );
- // m_langList.append( new Language("ny", "Chichewa; Nyanja", QObject::tr("Chichewa; Nyanja")) );
- // m_langList.append( new Language("oc", "Occitan (post 1500); Provençal", QObject::tr("Occitan (post 1500); Provençal")) );
- // m_langList.append( new Language("om", "Oromo", QObject::tr("Oromo")) );
- // m_langList.append( new Language("or", "Oriya", QObject::tr("Oriya")) );
- // m_langList.append( new Language("os", "Ossetian; Ossetic", QObject::tr("Ossetian; Ossetic")) );
- //: Language name otq
- m_langList.append( new Language("otq", "Otomi, Quer\u00e9taro", QObject::tr("Otomi, Quer\u00e9taro")) );
- // m_langList.append( new Language("pa", "Panjabi", QObject::tr("Panjabi")) );
- //: Language name pap
- m_langList.append( new Language("pap", "Papiamento", QObject::tr("Papiamento")) );
- // m_langList.append( new Language("pi", "Pali", QObject::tr("Pali")) );
- //: Language name ppk
- m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
- //: Language name pl
- m_langList.append( new Language("pl", "Polish", QObject::tr("Polish")) );
- //: Language name pot
- m_langList.append( new Language("pot", "Potawatomi", QObject::tr("Potawatomi")) );
- //: Language name ppk
- m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
- //: Language name prs
- m_langList.append( new Language("prs", "Persian (Dari)", QObject::tr("Persian (Dari)")) );
+ /*:
+ The string "Names of languages" doesn't actually need translation.
+ It is put here to help translators notice this help text.
+ -------
+ The names of the languages should follow the conventions of your
+ language. You can write the names with a capital first letter even if your language
+ uses non-capitalized language names (they look better with capital
+ first letter when they are listed).
+ -------
+ To find the names of all languages from internet try searching for
+ "names of languages in language_x" but in your own language, e.g.
+ "kielten nimet suomeksi" in Finnish or "names of languages in english"
+ in English.
+ -------
+ You can find the language codes and names by googling for the standards
+ mentioned below.
+ -------
+ Preference order for locale codes are:
+ -------
+ ISO 639-1 -------
+ ISO 639-2 -------
+ ISO 639-3
+ -------
+ x-E-XXX form is deprecated and no modules in repositories use it.
+ If you find a module with x-E-XXX language, update the module.
+ */
+ QObject::tr("Names of languages", "No need to translate - see the longer comment (If there is no longer comment, it doesn't work yet :)) ------ ");
+ // m_langList.append( new Language("aa", "Afar", QObject::tr("Afar")) );
+ // m_langList.append( new Language("ab", "Abkhazian", QObject::tr("Abkhazian")) );
+ // m_langList.append( new Language("ae", "Avestan", QObject::tr("Avestan")) );
+ //: Language name af
+ m_langList.append( new Language("af", "Afrikaans", QObject::tr("Afrikaans")) );
+ // m_langList.append( new Language("am", "Amharic", QObject::tr("Amharic")) );
+ //: Language name amu
+ m_langList.append( new Language("amu", "Amuzgo, Guerrero", QObject::tr("Amuzgo, Guerrero")) );
+ //: Language name ang
+ m_langList.append( new Language("ang", "English, Old (ca.450-1100)", QObject::tr("English, Old (ca.450-1100)")) );
+ //: Language name ar
+ m_langList.append( new Language("ar", "Arabic", QObject::tr("Arabic")) );
+ // m_langList.append( new Language("as", "Assamese", QObject::tr("Assamese")) );
+ //: Language name az
+ m_langList.append( new Language("az", "Azerbaijani", QObject::tr("Azerbaijani")) );
+ //: Language name azb
+ m_langList.append( new Language("azb", "Azerbaijani, South", QObject::tr("Azerbaijani, South")) );
+ // m_langList.append( new Language("ba", "Bashkir", QObject::tr("Bashkir")) );
+ //: Language name bar
+ m_langList.append( new Language("bar", "Bavarian", QObject::tr("Bavarian")) );
+ //: Language name be
+ m_langList.append( new Language("be", "Belarusian", QObject::tr("Belarusian")) );
+ //: Language name bg
+ m_langList.append( new Language("bg", "Bulgarian", QObject::tr("Bulgarian")) );
+ // m_langList.append( new Language("bh", "Bihari", QObject::tr("Bihari")) );
+ // m_langList.append( new Language("bi", "Bislama", QObject::tr("Bislama")) );
+ // m_langList.append( new Language("bn", "Bengali", QObject::tr("Bengali")) );
+ // m_langList.append( new Language("bo", "Tibetan", QObject::tr("Tibetan")) );
+ //: Language name br
+ m_langList.append( new Language("br", "Breton", QObject::tr("Breton")) );
+ //: Language name bs
+ m_langList.append( new Language("bs", "Bosnian", QObject::tr("Bosnian")) );
+ //: Language name ca
+ m_langList.append( new Language("ca", "Catalan", QObject::tr("Catalan")) );
+ // m_langList.append( new Language("ce", "Chechen", QObject::tr("Chechen")) );
+ //: Language name cco
+ m_langList.append( new Language("cco", "Chinantec, Comaltepec", QObject::tr("Chinantec, Comaltepec")) );
+ //: Language name ceb
+ m_langList.append( new Language("ceb", "Cebuano", QObject::tr("Cebuano")) );
+ //: Language name ch
+ m_langList.append( new Language("ch", "Chamorro", QObject::tr("Chamorro")) );
+ //: Language name chd
+ m_langList.append( new Language("chd", "Chontal, Highland Oaxaca", QObject::tr("Chontal, Highland Oaxaca")) );
+ //: Language name chq
+ m_langList.append( new Language("chq", "Chinantec, Quiotepec", QObject::tr("Chinantec, Quiotepec")) );
+ //: Language name chz
+ m_langList.append( new Language("chz", "Chinantec, Ozumac\u00edn", QObject::tr("Chinantec, Ozumac\u00edn")) );
+ // m_langList.append( new Language("co", "Corsican", QObject::tr("Corsican")) );
+ //: Language name ckw
+ m_langList.append( new Language("ckw", "Cakchiquel, Western", QObject::tr("Cakchiquel, Western")) );
+ //: Language name cnl
+ m_langList.append( new Language("cnl", "Chinantec, Lalana", QObject::tr("Chinantec, Lalana")) );
+ //: Language name cnt
+ m_langList.append( new Language("cnt", "Chinantec, Tepetotutla", QObject::tr("Chinantec, Tepetotutla")) );
+ //: Language name cop
+ m_langList.append( new Language("cop", "Coptic", QObject::tr("Coptic")) );
+ //: Language name cs
+ m_langList.append( new Language("cs", "Czech", QObject::tr("Czech")) );
+ //: Language name cso
+ m_langList.append( new Language("cso", "Chinantec, Sochiapan", QObject::tr("Chinantec, Sochiapan")) );
+ //: Language name cti
+ m_langList.append( new Language("cti", "Chol, Tila", QObject::tr("Chol, Tila")) );
+ //: Language name ctp
+ m_langList.append( new Language("ctp", "Chatino, Western Highland", QObject::tr("Chatino, Western Highland")) );
+ //: Language name cu
+ m_langList.append( new Language("cu", "Church Slavic", QObject::tr("Church Slavic")) );
+ // m_langList.append( new Language("cv", "Chuvash", QObject::tr("Chuvash")) );
+ //: Language name cy
+ m_langList.append( new Language("cy", "Welsh", QObject::tr("Welsh")) );
+ //: Language name da
+ m_langList.append( new Language("da", "Danish", QObject::tr("Danish")) );
+ //: Language name de
+ m_langList.append( new Language("de", "German", QObject::tr("German")) );
+ //: Language name dug
+ m_langList.append( new Language("dug", "Duruma", QObject::tr("Duruma")) );
+ // m_langList.append( new Language("dz", "Dzongkha", QObject::tr("Dzongkha")) );
+ //: Language name el
+ m_langList.append( new Language("el", "Greek, Modern (1453-)", QObject::tr("Greek, Modern (1453-)"), makeStringList("gre;ell")) );
+ //: Language name en
+ m_langList.append( new Language("en", "English", QObject::tr("English")) );
+ //: Language name en_US
+ m_langList.append( new Language("en_US", "American English", QObject::tr("American English")) );
+ //: Language name enm
+ m_langList.append( new Language("enm", "English, Middle (1100-1500)", QObject::tr("English, Middle (1100-1500)")) );
+ //: Language name eo
+ m_langList.append( new Language("eo", "Esperanto", QObject::tr("Esperanto")) );
+ //: Language name es
+ m_langList.append( new Language("es", "Spanish", QObject::tr("Spanish")) );
+ //: Language name et
+ m_langList.append( new Language("et", "Estonian", QObject::tr("Estonian")) );
+ //: Language name eu
+ m_langList.append( new Language("eu", "Basque", QObject::tr("Basque")) );
+ //: Language name fa
+ m_langList.append( new Language("fa", "Persian", QObject::tr("Persian")) );
+ //: Language name fi
+ m_langList.append( new Language("fi", "Finnish", QObject::tr("Finnish")) );
+ // m_langList.append( new Language("fj", "Fijian", QObject::tr("Fijian")) );
+ // m_langList.append( new Language("fo", "Faroese", QObject::tr("Faroese")) );
+ //: Language name fr
+ m_langList.append( new Language("fr", "French", QObject::tr("French")) );
+ //: Language name fy
+ m_langList.append( new Language("fy", "Frisian", QObject::tr("Frisian")) );
+ //: Language name ga
+ m_langList.append( new Language("ga", "Irish", QObject::tr("Irish")) );
+ //: Language name gd
+ m_langList.append( new Language("gd", "Gaelic (Scots)", QObject::tr("Gaelic (Scots)")) );
+ //: Language name gez
+ m_langList.append( new Language("gez", "Geez", QObject::tr("Geez")) );
+ // m_langList.append( new Language("gl", "Gallegan", QObject::tr("Gallegan")) );
+ // m_langList.append( new Language("gn", "Guarani", QObject::tr("Guarani")) );
+ // m_langList.append( new Language("gn", "Gujarati", QObject::tr("Gujarati")) );
+ //: Language name got
+ m_langList.append( new Language("got", "Gothic", QObject::tr("Gothic")) );
+ //: Language name gv
+ m_langList.append( new Language("gv", "Manx", QObject::tr("Manx")) );
+ //: Language name grc
+ m_langList.append( new Language("grc", "Greek, Ancient (to 1453)", QObject::tr("Greek, Ancient (to 1453)")) );
+ //: Language name he
+ m_langList.append( new Language("he", "Hebrew", QObject::tr("Hebrew")) );
+ //: Language name hau
+ m_langList.append( new Language("hau", "Hausa", QObject::tr("Hausa")) );
+ //: Language name haw
+ m_langList.append( new Language("haw", "Hawaiian", QObject::tr("Hawaiian")) );
+ //: Language name hi
+ m_langList.append( new Language("hi", "Hindi", QObject::tr("Hindi")) );
+ // m_langList.append( new Language("ho", "Hiri Motu", QObject::tr("Hiri Motu")) );
+ //: Language name hr
+ m_langList.append( new Language("hr", "Croatian", QObject::tr("Croatian")) );
+ //: Language name ht
+ m_langList.append( new Language("ht", "Haitian Creole", QObject::tr("Haitian Creole")) );
+ //: Language name hu
+ m_langList.append( new Language("hu", "Hungarian", QObject::tr("Hungarian")) );
+ //: Language name huv
+ m_langList.append( new Language("huv", "Huave, San Mateo Del Mar", QObject::tr("Huave, San Mateo Del Mar")) );
+ //: Language name hy
+ m_langList.append( new Language("hy", "Armenian", QObject::tr("Armenian")) );
+ // m_langList.append( new Language("hz", "Herero", QObject::tr("Herero")) );
+ // m_langList.append( new Language("ia", "Interlingua", QObject::tr("Interlingua")) );
+ //: Language name id
+ m_langList.append( new Language("id", "Indonesian", QObject::tr("Indonesian")) );
+ // m_langList.append( new Language("ie", "Interlingue", QObject::tr("Interlingue")) );
+ // m_langList.append( new Language("ik", "Inupiaq", QObject::tr("Inupiaq")) );
+ //: Language name is
+ m_langList.append( new Language("is", "Icelandic", QObject::tr("Icelandic")) );
+ //: Language name it
+ m_langList.append( new Language("it", "Italian", QObject::tr("Italian")) );
+ //: Language name itz
+ m_langList.append( new Language("itz", "Itz\u00e1", QObject::tr("Itz\u00e1")) );
+ //: Language name ixl
+ m_langList.append( new Language("ixl", "Ixil, San Juan Cotzal", QObject::tr("Ixil, San Juan Cotzal")) );
+ // m_langList.append( new Language("iu", "Inuktitut", QObject::tr("Inuktitut")) );
+ //: Language name ja
+ m_langList.append( new Language("ja", "Japanese", QObject::tr("Japanese")) );
+ //: Language name jac
+ m_langList.append( new Language("jac", "Jacalteco, Eastern", QObject::tr("Jacalteco, Eastern")) );
+ //: Language name jvn
+ m_langList.append( new Language("jvn", "Javanese, Caribbean", QObject::tr("Javanese, Caribbean")) );
+ //: Language name ka
+ m_langList.append( new Language("ka", "Georgian", QObject::tr("Georgian")) );
+ //: Language name kek
+ m_langList.append( new Language("kek", "Kekch\u00ed", QObject::tr("Kekch\u00ed", "kek")) );
+ // m_langList.append( new Language("ki", "Kikuyu", QObject::tr("Kikuyu")) );
+ // m_langList.append( new Language("kj", "Kuanyama", QObject::tr("Kuanyama")) );
+ // m_langList.append( new Language("kk", "Kazakh", QObject::tr("Kazakh")) );
+ // m_langList.append( new Language("kl", "Kalaallisut", QObject::tr("Kalaallisut")) );
+ // m_langList.append( new Language("km", "Khmer", QObject::tr("Khmer")) );
+ // m_langList.append( new Language("kn", "Kannada", QObject::tr("Kannada")) );
+ //: Language name ko
+ m_langList.append( new Language("ko", "Korean", QObject::tr("Korean")) );
+ // m_langList.append( new Language("ks", "Kashmiri", QObject::tr("Kashmiri")) );
+ //: Language name ku
+ m_langList.append( new Language("ku", "Kurdish", QObject::tr("Kurdish")) );
+ // m_langList.append( new Language("kv", "Komi", QObject::tr("Komi")) );
+ // m_langList.append( new Language("kw", "Cornish", QObject::tr("Cornish")) );
+ //: Language name ky
+ m_langList.append( new Language("ky", "Kirghiz", QObject::tr("Kirghiz")) );
+ //: Language name la
+ m_langList.append( new Language("la", "Latin", QObject::tr("Latin")) );
+ //: Language name lac
+ m_langList.append( new Language("lac", "Lacandon", QObject::tr("Lacandon")) );
+ // m_langList.append( new Language("lb", "Letzeburgesch", QObject::tr("Letzeburgesch")) );
+ //: Language name lmo
+ m_langList.append( new Language("lmo", "Lombard", QObject::tr("Lombard")) );
+ // m_langList.append( new Language("ln", "Lingala", QObject::tr("Lingala")) );
+ // m_langList.append( new Language("lo", "Lao", QObject::tr("Lao")) );
+ //: Language name lt
+ m_langList.append( new Language("lt", "Lithuanian", QObject::tr("Lithuanian")) );
+ //: Language name lv
+ m_langList.append( new Language("lv", "Latvian", QObject::tr("Latvian")) );
+ //: Language name mg
+ m_langList.append( new Language("mg", "Malagasy", QObject::tr("Malagasy")) );
+ // m_langList.append( new Language("mh", "Marshall", QObject::tr("Marshall")) );
+ //: Language name mi
+ m_langList.append( new Language("mi", "Maori", QObject::tr("Maori")) );
+ //: Language name mir
+ m_langList.append( new Language("mir", "Mixe, Isthmus", QObject::tr("Mixe, Isthmus")) );
+ //: Language name miz
+ m_langList.append( new Language("miz", "Mixtec, Coatzospan", QObject::tr("Mixtec, Coatzospan")) );
+ //: Language name mk
+ m_langList.append( new Language("mk", "Macedonian", QObject::tr("Macedonian")) );
+ //: Language name mks
+ m_langList.append( new Language("mks", "Mixtec, Silacayoapan", QObject::tr("Mixtec, Silacayoapan")) );
+ // m_langList.append( new Language("ml", "Malayalam", QObject::tr("Malayalam")) );
+ // m_langList.append( new Language("mn", "Mongolian", QObject::tr("Mongolian")) );
+ // m_langList.append( new Language("mo", "Moldavian", QObject::tr("Moldavian")) );
+ //: Language name mos
+ m_langList.append( new Language("mos", "More", QObject::tr("More")) );
+ // m_langList.append( new Language("mr", "Marathi", QObject::tr("Marathi")) );
+ //: Language name ms
+ m_langList.append( new Language("ms", "Malay", QObject::tr("Malay")) );
+ //: Language name mt
+ m_langList.append( new Language("mt", "Maltese", QObject::tr("Maltese")) );
+ //: Language name mul (meaning that the work has multiple languages)
+ m_langList.append( new Language("mul", "(Multiple languages)", QObject::tr("(Multiple languages)")) );
+ //: Language name mvc
+ m_langList.append( new Language("mvc", "Mam, Central", QObject::tr("Mam, Central")) );
+ //: Language name mvj
+ m_langList.append( new Language("mvj", "Mam, Todos Santos Cuchumat\u00e1n", QObject::tr("Mam, Todos Santos Cuchumat\u00e1n")) );
+ //: Language name mxq
+ m_langList.append( new Language("mxq", "Mixe, Juquila", QObject::tr("Mixe, Juquila")) );
+ //: Language name mxt
+ m_langList.append( new Language("mxt", "Mixtec, Jamiltepec", QObject::tr("Mixtec, Jamiltepec")) );
+ //: Language name my
+ m_langList.append( new Language("my", "Burmese", QObject::tr("Burmese")) );
+ // m_langList.append( new Language("na", "Nauru", QObject::tr("Nauru")) );
+ //: Language name nb
+ m_langList.append( new Language("nb", "Norwegian Bokm\u00e5l", QObject::tr("Norwegian Bokm\u00e5l")) );
+ //: Language name ncl
+ m_langList.append( new Language("ncl", "Nahuatl, Michoac\u00e1n", QObject::tr("Nahuatl, Michoac\u00e1n")) );
+ // m_langList.append( new Language("nd", "Ndebele, North", QObject::tr("Ndebele, North")) );
+ //: Language name nds
+ m_langList.append( new Language("nds", "Low German; Low Saxon", QObject::tr("Low German; Low Saxon")) );
+ //: Language name ne
+ m_langList.append( new Language("ne", "Nepali", QObject::tr("Nepali")) );
+ //: Language name ngu
+ m_langList.append( new Language("ngu", "Nahuatl, Guerrero", QObject::tr("Nahuatl, Guerrero")) );
+ //: Language name nhy
+ m_langList.append( new Language("nhy", "Nahuatl, Northern Oaxaca", QObject::tr("Nahuatl, Northern Oaxaca")) );
+ // m_langList.append( new Language("ng", "Ndonga", QObject::tr("Ndonga")) );
+ //: Language name nl
+ m_langList.append( new Language("nl", "Dutch", QObject::tr("Dutch")) );
+ //: Language name nn
+ m_langList.append( new Language("nn", "Norwegian Nynorsk", QObject::tr("Norwegian Nynorsk")) );
+ //: Language name no
+ m_langList.append( new Language("no", "Norwegian", QObject::tr("Norwegian")) );
+ // m_langList.append( new Language("nr", "Ndebele, South", QObject::tr("Ndebele, South")) );
+ // m_langList.append( new Language("nv", "Navajo", QObject::tr("Navajo")) );
+ // m_langList.append( new Language("ny", "Chichewa; Nyanja", QObject::tr("Chichewa; Nyanja")) );
+ // m_langList.append( new Language("oc", "Occitan (post 1500); Provençal", QObject::tr("Occitan (post 1500); Provençal")) );
+ // m_langList.append( new Language("om", "Oromo", QObject::tr("Oromo")) );
+ // m_langList.append( new Language("or", "Oriya", QObject::tr("Oriya")) );
+ // m_langList.append( new Language("os", "Ossetian; Ossetic", QObject::tr("Ossetian; Ossetic")) );
+ //: Language name otq
+ m_langList.append( new Language("otq", "Otomi, Quer\u00e9taro", QObject::tr("Otomi, Quer\u00e9taro")) );
+ // m_langList.append( new Language("pa", "Panjabi", QObject::tr("Panjabi")) );
+ //: Language name pap
+ m_langList.append( new Language("pap", "Papiamento", QObject::tr("Papiamento")) );
+ // m_langList.append( new Language("pi", "Pali", QObject::tr("Pali")) );
+ //: Language name ppk
+ m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
+ //: Language name pl
+ m_langList.append( new Language("pl", "Polish", QObject::tr("Polish")) );
+ //: Language name pot
+ m_langList.append( new Language("pot", "Potawatomi", QObject::tr("Potawatomi")) );
+ //: Language name ppk
+ m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
+ //: Language name prs
+ m_langList.append( new Language("prs", "Persian (Dari)", QObject::tr("Persian (Dari)")) );
- // m_langList.append( new Language("ps", "Pushto", QObject::tr("Pushto")) );
- //: Language name pt
- m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) );
- //: Language name pt_BR
- m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself
- // m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) );
- //: Language name qut
- m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) );
- // m_langList.append( new Language("rm", "Raeto-Romance", QObject::tr("Raeto-Romance")) );
- // m_langList.append( new Language("rn", "Rundi", QObject::tr("Rundi")) );
- //: Language name ro
- m_langList.append( new Language("ro", "Romanian", QObject::tr("Romanian")) );
- //: Language name ru
- m_langList.append( new Language("ru", "Russian", QObject::tr("Russian")) );
- // m_langList.append( new Language("rw", "Kinyarwanda", QObject::tr("Kinyarwanda")) );
- // m_langList.append( new Language("sa", "Sanskrit", QObject::tr("Sanskrit")) );
- // m_langList.append( new Language("sc", "Sardinian", QObject::tr("Sardinian")) );
- //: Language name sco
- m_langList.append( new Language("sco", "Scots", QObject::tr("Scots")) );
- // m_langList.append( new Language("sd", "Sindhi", QObject::tr("Sindhi")) );
- // m_langList.append( new Language("se", "Northern Sami", QObject::tr("Northern Sami")) );
- // m_langList.append( new Language("sg", "Sango", QObject::tr("Sango")) );
- // m_langList.append( new Language("si", "Sinhalese", QObject::tr("Sinhalese")) );
- //: Language name sk
- m_langList.append( new Language("sk", "Slovak", QObject::tr("Slovak")) );
- //: Language name sl
- m_langList.append( new Language("sl", "Slovenian", QObject::tr("Slovenian")) );
- // m_langList.append( new Language("sm", "Samoan", QObject::tr("Samoan")) );
- // m_langList.append( new Language("sn", "Shona", QObject::tr("Shona")) );
- //: Language name so
- m_langList.append( new Language("so", "Somali", QObject::tr("Somali")) );
- //: Language name sq
- m_langList.append( new Language("sq", "Albanian", QObject::tr("Albanian")) );
- // m_langList.append( new Language("sr", "Serbian", QObject::tr("Serbian")) );
- //: Language name srn
- m_langList.append( new Language("srn", "Sranan", QObject::tr("Sranan")) );
- // m_langList.append( new Language("ss", "Swati", QObject::tr("Swati")) );
- // m_langList.append( new Language("st", "Sotho, Southern", QObject::tr("Sotho, Southern")) );
- // m_langList.append( new Language("su", "Sundanese", QObject::tr("Sundanese")) );
- //: Language name sv
- m_langList.append( new Language("sv", "Swedish", QObject::tr("Swedish")) );
- //: Language name sw
- m_langList.append( new Language("sw", "Swahili", QObject::tr("Swahili")) );
- //: Language name syr
- m_langList.append( new Language("syr", "Syriac", QObject::tr("Syriac")) );
- //: Language name ta
- m_langList.append( new Language("ta", "Tamil", QObject::tr("Tamil")) );
- // m_langList.append( new Language("te", "Telugu", QObject::tr("Telugu")) );
- // m_langList.append( new Language("tg", "Tajik", QObject::tr("Tajik")) );
- //: Language name th
- m_langList.append( new Language("th", "Thai", QObject::tr("Thai")) );
- // m_langList.append( new Language("tk", "Turkmen", QObject::tr("Turkmen")) );
- //: Language name tl
- m_langList.append( new Language("tl", "Tagalog", QObject::tr("Tagalog")) );
- //: Language name tlh
- m_langList.append( new Language("tlh", "Klingon", QObject::tr("Klingon")) );
- //: Language name tn
- m_langList.append( new Language("tn", "Tswana", QObject::tr("Tswana")) );
- //: Language name tr
- m_langList.append( new Language("tr", "Turkish", QObject::tr("Turkish")) );
- // m_langList.append( new Language("ts", "Tsonga", QObject::tr("Tsonga")) );
- // m_langList.append( new Language("tt", "Tatar", QObject::tr("Tatar")) );
- //: Language name ttc
- m_langList.append( new Language("ttc", "Tektiteko", QObject::tr("Tektiteko")) );
- // m_langList.append( new Language("tw", "Twi", QObject::tr("Twi")) );
- //: Language name ty
- m_langList.append( new Language("ty", "Tahitian", QObject::tr("Tahitian")) );
- //: Language name tzz
- m_langList.append( new Language("tzz", "Tzotzil, Zinacant\u00e1n", QObject::tr("Tzotzil, Zinacant\u00e1n")) );
- // m_langList.append( new Language("ug", "Uighur", QObject::tr("Uighur")) );
- //: Language name uk
- m_langList.append( new Language("uk", "Ukrainian", QObject::tr("Ukrainian")) );
- // m_langList.append( new Language("ur", "Urdu", QObject::tr("Urdu")) );
- //: Language name ury
- m_langList.append( new Language("ury", "Orya", QObject::tr("Orya")) );
- //: Language name usp
- m_langList.append( new Language("usp", "Uspanteco", QObject::tr("Uspanteco")) );
- // m_langList.append( new Language("uz", "Uzbek", QObject::tr("Uzbek")) );
- //: Language name vi
- m_langList.append( new Language("vi", "Vietnamese", QObject::tr("Vietnamese")) );
- // m_langList.append( new Language("vo", "Volapük", QObject::tr("Volapük")) );
- // m_langList.append( new Language("wo", "Wolof", QObject::tr("Wolof")) );
- //: Language name xh
- m_langList.append( new Language("xh", "Xhosa", QObject::tr("Xhosa")) );
- //: Language name xtd
- m_langList.append( new Language("xtd", "Mixtec, Diuxi-Tilantongo", QObject::tr("Mixtec, Diuxi-Tilantongo")) );
- //: Language name yi
- m_langList.append( new Language("yi", "Yiddish", QObject::tr("Yiddish")) );
- //: Language name yo
- m_langList.append( new Language("yo", "Yoruba", QObject::tr("Yoryba")) );
- // m_langList.append( new Language("za", "Zhuang", QObject::tr("Zhuang")) );
- //: Language name zab
- m_langList.append( new Language("zab", "Zapotec, San Juan Guelav\u00eda", QObject::tr("Zapotec, San Juan Guelav\u00eda")) );
- //: Language name zaw
- m_langList.append( new Language("zaw", "Zapotec, Mitla", QObject::tr("Zapotec, Mitla")) );
- //: Language name zh
- m_langList.append( new Language("zh", "Chinese", QObject::tr("Chinese")) );
- //: Language name zpo
- m_langList.append( new Language("zpo", "Zapotec, Amatl\u00e1n", QObject::tr("Zapotec, Amatl\u00e1n")) );
- //: Language name zpq
- m_langList.append( new Language("zpq", "Zapotec, Zoogocho", QObject::tr("Zapotec, Zoogocho")) );
- //: Language name zpu
- m_langList.append( new Language("zpu", "Zapotec, Yal\u00e1lag", QObject::tr("Zapotec, Yal\u00e1lag")) );
- //: Language name zpv
- m_langList.append( new Language("zpv", "Zapotec, Chichicapan", QObject::tr("Zapotec, Chichicapan")) );
- //: Language name zsr
- m_langList.append( new Language("zsr", "Zapotec, Southern Rincon", QObject::tr("Zapotec, Southern Rincon")) );
- //: Language name ztq
- m_langList.append( new Language("ztq", "Zapotec, Quioquitani-Quier\u00ed", QObject::tr("Zapotec, Quioquitani-Quier\u00ed")) );
- //: Language name zty
- m_langList.append( new Language("zty", "Zapotec, Yatee", QObject::tr("Zapotec, Yatee")) );
- //: Language name zu
- m_langList.append( new Language("zu", "Zulu", QObject::tr("Zulu")) );
+ // m_langList.append( new Language("ps", "Pushto", QObject::tr("Pushto")) );
+ //: Language name pt
+ m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) );
+ //: Language name pt_BR
+ m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself
+ // m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) );
+ //: Language name qut
+ m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) );
+ // m_langList.append( new Language("rm", "Raeto-Romance", QObject::tr("Raeto-Romance")) );
+ // m_langList.append( new Language("rn", "Rundi", QObject::tr("Rundi")) );
+ //: Language name ro
+ m_langList.append( new Language("ro", "Romanian", QObject::tr("Romanian")) );
+ //: Language name ru
+ m_langList.append( new Language("ru", "Russian", QObject::tr("Russian")) );
+ // m_langList.append( new Language("rw", "Kinyarwanda", QObject::tr("Kinyarwanda")) );
+ // m_langList.append( new Language("sa", "Sanskrit", QObject::tr("Sanskrit")) );
+ // m_langList.append( new Language("sc", "Sardinian", QObject::tr("Sardinian")) );
+ //: Language name sco
+ m_langList.append( new Language("sco", "Scots", QObject::tr("Scots")) );
+ // m_langList.append( new Language("sd", "Sindhi", QObject::tr("Sindhi")) );
+ // m_langList.append( new Language("se", "Northern Sami", QObject::tr("Northern Sami")) );
+ // m_langList.append( new Language("sg", "Sango", QObject::tr("Sango")) );
+ // m_langList.append( new Language("si", "Sinhalese", QObject::tr("Sinhalese")) );
+ //: Language name sk
+ m_langList.append( new Language("sk", "Slovak", QObject::tr("Slovak")) );
+ //: Language name sl
+ m_langList.append( new Language("sl", "Slovenian", QObject::tr("Slovenian")) );
+ // m_langList.append( new Language("sm", "Samoan", QObject::tr("Samoan")) );
+ // m_langList.append( new Language("sn", "Shona", QObject::tr("Shona")) );
+ //: Language name so
+ m_langList.append( new Language("so", "Somali", QObject::tr("Somali")) );
+ //: Language name sq
+ m_langList.append( new Language("sq", "Albanian", QObject::tr("Albanian")) );
+ // m_langList.append( new Language("sr", "Serbian", QObject::tr("Serbian")) );
+ //: Language name srn
+ m_langList.append( new Language("srn", "Sranan", QObject::tr("Sranan")) );
+ // m_langList.append( new Language("ss", "Swati", QObject::tr("Swati")) );
+ // m_langList.append( new Language("st", "Sotho, Southern", QObject::tr("Sotho, Southern")) );
+ // m_langList.append( new Language("su", "Sundanese", QObject::tr("Sundanese")) );
+ //: Language name sv
+ m_langList.append( new Language("sv", "Swedish", QObject::tr("Swedish")) );
+ //: Language name sw
+ m_langList.append( new Language("sw", "Swahili", QObject::tr("Swahili")) );
+ //: Language name syr
+ m_langList.append( new Language("syr", "Syriac", QObject::tr("Syriac")) );
+ //: Language name ta
+ m_langList.append( new Language("ta", "Tamil", QObject::tr("Tamil")) );
+ // m_langList.append( new Language("te", "Telugu", QObject::tr("Telugu")) );
+ // m_langList.append( new Language("tg", "Tajik", QObject::tr("Tajik")) );
+ //: Language name th
+ m_langList.append( new Language("th", "Thai", QObject::tr("Thai")) );
+ // m_langList.append( new Language("tk", "Turkmen", QObject::tr("Turkmen")) );
+ //: Language name tl
+ m_langList.append( new Language("tl", "Tagalog", QObject::tr("Tagalog")) );
+ //: Language name tlh
+ m_langList.append( new Language("tlh", "Klingon", QObject::tr("Klingon")) );
+ //: Language name tn
+ m_langList.append( new Language("tn", "Tswana", QObject::tr("Tswana")) );
+ //: Language name tr
+ m_langList.append( new Language("tr", "Turkish", QObject::tr("Turkish")) );
+ // m_langList.append( new Language("ts", "Tsonga", QObject::tr("Tsonga")) );
+ // m_langList.append( new Language("tt", "Tatar", QObject::tr("Tatar")) );
+ //: Language name ttc
+ m_langList.append( new Language("ttc", "Tektiteko", QObject::tr("Tektiteko")) );
+ // m_langList.append( new Language("tw", "Twi", QObject::tr("Twi")) );
+ //: Language name ty
+ m_langList.append( new Language("ty", "Tahitian", QObject::tr("Tahitian")) );
+ //: Language name tzz
+ m_langList.append( new Language("tzz", "Tzotzil, Zinacant\u00e1n", QObject::tr("Tzotzil, Zinacant\u00e1n")) );
+ // m_langList.append( new Language("ug", "Uighur", QObject::tr("Uighur")) );
+ //: Language name uk
+ m_langList.append( new Language("uk", "Ukrainian", QObject::tr("Ukrainian")) );
+ // m_langList.append( new Language("ur", "Urdu", QObject::tr("Urdu")) );
+ //: Language name ury
+ m_langList.append( new Language("ury", "Orya", QObject::tr("Orya")) );
+ //: Language name usp
+ m_langList.append( new Language("usp", "Uspanteco", QObject::tr("Uspanteco")) );
+ // m_langList.append( new Language("uz", "Uzbek", QObject::tr("Uzbek")) );
+ //: Language name vi
+ m_langList.append( new Language("vi", "Vietnamese", QObject::tr("Vietnamese")) );
+ // m_langList.append( new Language("vo", "Volapük", QObject::tr("Volapük")) );
+ // m_langList.append( new Language("wo", "Wolof", QObject::tr("Wolof")) );
+ //: Language name xh
+ m_langList.append( new Language("xh", "Xhosa", QObject::tr("Xhosa")) );
+ //: Language name xtd
+ m_langList.append( new Language("xtd", "Mixtec, Diuxi-Tilantongo", QObject::tr("Mixtec, Diuxi-Tilantongo")) );
+ //: Language name yi
+ m_langList.append( new Language("yi", "Yiddish", QObject::tr("Yiddish")) );
+ //: Language name yo
+ m_langList.append( new Language("yo", "Yoruba", QObject::tr("Yoryba")) );
+ // m_langList.append( new Language("za", "Zhuang", QObject::tr("Zhuang")) );
+ //: Language name zab
+ m_langList.append( new Language("zab", "Zapotec, San Juan Guelav\u00eda", QObject::tr("Zapotec, San Juan Guelav\u00eda")) );
+ //: Language name zaw
+ m_langList.append( new Language("zaw", "Zapotec, Mitla", QObject::tr("Zapotec, Mitla")) );
+ //: Language name zh
+ m_langList.append( new Language("zh", "Chinese", QObject::tr("Chinese")) );
+ //: Language name zpo
+ m_langList.append( new Language("zpo", "Zapotec, Amatl\u00e1n", QObject::tr("Zapotec, Amatl\u00e1n")) );
+ //: Language name zpq
+ m_langList.append( new Language("zpq", "Zapotec, Zoogocho", QObject::tr("Zapotec, Zoogocho")) );
+ //: Language name zpu
+ m_langList.append( new Language("zpu", "Zapotec, Yal\u00e1lag", QObject::tr("Zapotec, Yal\u00e1lag")) );
+ //: Language name zpv
+ m_langList.append( new Language("zpv", "Zapotec, Chichicapan", QObject::tr("Zapotec, Chichicapan")) );
+ //: Language name zsr
+ m_langList.append( new Language("zsr", "Zapotec, Southern Rincon", QObject::tr("Zapotec, Southern Rincon")) );
+ //: Language name ztq
+ m_langList.append( new Language("ztq", "Zapotec, Quioquitani-Quier\u00ed", QObject::tr("Zapotec, Quioquitani-Quier\u00ed")) );
+ //: Language name zty
+ m_langList.append( new Language("zty", "Zapotec, Yatee", QObject::tr("Zapotec, Yatee")) );
+ //: Language name zu
+ m_langList.append( new Language("zu", "Zulu", QObject::tr("Zulu")) );
- foreach (Language* lang, m_langList) {
- m_langMap.insert( lang->abbrev(), lang);
- }
+ foreach (Language* lang, m_langList) {
+ m_langMap.insert( lang->abbrev(), lang);
+ }
}
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index f421e62..6d3a5c3 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -22,129 +22,129 @@
class CLanguageMgr {
-public:
- /** Language container.
- * This class (Language) contains the information about the chosen language.
- */
- class Language {
- public:
- /** Default constructor of a language object.
- * Uses the abbreviation parameter to lookup the
- * language name and to be able to return the name, flag etc.
- * Possible values for abbrev are de, en, fr, it etc.
- */
- Language();
- /** Copy constructor.
- */
- Language(const Language&);
- /** Constructor which takes all necessary data.
- */
- Language(const QString& abbrev, const QString& englishName, const QString& translatedName, const QStringList& altAbbrevs = QStringList());
- /** Destructor.
- */
- ~Language();
- /** Returns the abbreviation.
- * @return The abbreviation of the chosen language.
- */
- inline const QString& abbrev() const {
- if (m_abbrev.isEmpty() && m_altAbbrevs.count()) { //no standard abbrev but alternative ones
- return m_altAbbrevs.first();
- }
- return m_abbrev;
- }
- /** Returns the translated name.
- * @return The translated name of the language.
- */
- inline const QString& translatedName() const {
- return m_translatedName;
- }
- /** The english name of the language.
- * @return The english name of the chosen language.
- */
- inline const QString& name() const {
- return m_englishName;
- }
- /** The alternative abbreviations which are avalable for this language.
- * @return The List of alternate abbreviations
- */
- inline const QStringList alternativeAbbrevs() const {
- return m_altAbbrevs;
- }
- /**
- * Returns true if this language object is valid, i.e. has an abbrev and name.
- * @return True if the data is valid for this language.
- */
- inline bool isValid() const {
- return (!abbrev().isEmpty() && !name().isEmpty());
- }
+ public:
+ /** Language container.
+ * This class (Language) contains the information about the chosen language.
+ */
+ class Language {
+ public:
+ /** Default constructor of a language object.
+ * Uses the abbreviation parameter to lookup the
+ * language name and to be able to return the name, flag etc.
+ * Possible values for abbrev are de, en, fr, it etc.
+ */
+ Language();
+ /** Copy constructor.
+ */
+ Language(const Language&);
+ /** Constructor which takes all necessary data.
+ */
+ Language(const QString& abbrev, const QString& englishName, const QString& translatedName, const QStringList& altAbbrevs = QStringList());
+ /** Destructor.
+ */
+ ~Language();
+ /** Returns the abbreviation.
+ * @return The abbreviation of the chosen language.
+ */
+ inline const QString& abbrev() const {
+ if (m_abbrev.isEmpty() && m_altAbbrevs.count()) { //no standard abbrev but alternative ones
+ return m_altAbbrevs.first();
+ }
+ return m_abbrev;
+ }
+ /** Returns the translated name.
+ * @return The translated name of the language.
+ */
+ inline const QString& translatedName() const {
+ return m_translatedName;
+ }
+ /** The english name of the language.
+ * @return The english name of the chosen language.
+ */
+ inline const QString& name() const {
+ return m_englishName;
+ }
+ /** The alternative abbreviations which are avalable for this language.
+ * @return The List of alternate abbreviations
+ */
+ inline const QStringList alternativeAbbrevs() const {
+ return m_altAbbrevs;
+ }
+ /**
+ * Returns true if this language object is valid, i.e. has an abbrev and name.
+ * @return True if the data is valid for this language.
+ */
+ inline bool isValid() const {
+ return (!abbrev().isEmpty() && !name().isEmpty());
+ }
- private:
- QString m_abbrev;
- QString m_englishName;
- QString m_translatedName;
- QStringList m_altAbbrevs;
- };
+ private:
+ QString m_abbrev;
+ QString m_englishName;
+ QString m_translatedName;
+ QStringList m_altAbbrevs;
+ };
- typedef QList<Language*> LanguageList;
- typedef QHash<QString, const Language*> LangMap;
- typedef QHash<QString, const Language*>::const_iterator LangMapIterator;
+ typedef QList<Language*> LanguageList;
+ typedef QHash<QString, const Language*> LangMap;
+ typedef QHash<QString, const Language*>::const_iterator LangMapIterator;
- /** Constructor.
- */
- CLanguageMgr();
- /** Destructor
- */
- virtual ~CLanguageMgr();
- /**
- * Returns the standard languages available as standard. Does nothing for Sword.
- * @return A LangMap map which contains all known languages
- */
- inline const CLanguageMgr::LangMap* languages() const {
- return &m_langMap;
- }
- /**
- * Returns the languages which are available. The languages cover all available modules, but nothing more.
- * @return A map of all languages with modules available for them
- */
- const CLanguageMgr::LangMap& availableLanguages();
- /** Language for abbreviation.
- * @param abbrev The language abbreviation
- * @return Pointer to a language for the given string abbreviation.
- */
- const CLanguageMgr::Language* languageForAbbrev( const QString& abbrev ) const;
- /** Language for english name.
- * @param abbrev The english language name.
- * @return Pointer to a language for the given name
- */
- const CLanguageMgr::Language* languageForName( const QString& language ) const;
- /** Language for translated language name.
- * @param abbrev The translated language name
- * @return Pointer to a language for the given translated language name
- */
- const CLanguageMgr::Language* languageForTranslatedName( const QString& language ) const;
- /** Default language so we don't return NULL pointers.
- * @return Pointer to the default language
- */
- inline const CLanguageMgr::Language* defaultLanguage() const {
- return &m_defaultLanguage;
- }
+ /** Constructor.
+ */
+ CLanguageMgr();
+ /** Destructor
+ */
+ virtual ~CLanguageMgr();
+ /**
+ * Returns the standard languages available as standard. Does nothing for Sword.
+ * @return A LangMap map which contains all known languages
+ */
+ inline const CLanguageMgr::LangMap* languages() const {
+ return &m_langMap;
+ }
+ /**
+ * Returns the languages which are available. The languages cover all available modules, but nothing more.
+ * @return A map of all languages with modules available for them
+ */
+ const CLanguageMgr::LangMap& availableLanguages();
+ /** Language for abbreviation.
+ * @param abbrev The language abbreviation
+ * @return Pointer to a language for the given string abbreviation.
+ */
+ const CLanguageMgr::Language* languageForAbbrev( const QString& abbrev ) const;
+ /** Language for english name.
+ * @param abbrev The english language name.
+ * @return Pointer to a language for the given name
+ */
+ const CLanguageMgr::Language* languageForName( const QString& language ) const;
+ /** Language for translated language name.
+ * @param abbrev The translated language name
+ * @return Pointer to a language for the given translated language name
+ */
+ const CLanguageMgr::Language* languageForTranslatedName( const QString& language ) const;
+ /** Default language so we don't return NULL pointers.
+ * @return Pointer to the default language
+ */
+ inline const CLanguageMgr::Language* defaultLanguage() const {
+ return &m_defaultLanguage;
+ }
-private:
- void init();
- inline const QStringList makeStringList(const QString& abbrevs) {
- return abbrevs.split( ";", QString::KeepEmptyParts, Qt::CaseSensitive );
- }
+ private:
+ void init();
+ inline const QStringList makeStringList(const QString& abbrevs) {
+ return abbrevs.split( ";", QString::KeepEmptyParts, Qt::CaseSensitive );
+ }
- Language m_defaultLanguage;
- mutable LanguageList m_langList;
- mutable LangMap m_langMap;
- mutable LanguageList m_cleanupLangPtrs;
+ Language m_defaultLanguage;
+ mutable LanguageList m_langList;
+ mutable LangMap m_langMap;
+ mutable LanguageList m_cleanupLangPtrs;
- struct ModuleCache {
- unsigned int moduleCount;
- LangMap availableLanguages;
- }
- m_availableModulesCache;
+ struct ModuleCache {
+ unsigned int moduleCount;
+ LangMap availableLanguages;
+ }
+ m_availableModulesCache;
};
#endif
diff --git a/src/backend/managers/creferencemanager.cpp b/src/backend/managers/creferencemanager.cpp
index adae180..41f8954 100644
--- a/src/backend/managers/creferencemanager.cpp
+++ b/src/backend/managers/creferencemanager.cpp
@@ -21,402 +21,402 @@
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
const QString CReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const CReferenceManager::Type type) {
- QString ret = QString::null;
-
- switch (type) {
-
- case Bible:
- ret = QString("sword://Bible/");
- break;
- case Commentary:
- ret = QString("sword://Commentary/");
- break;
- case Lexicon:
- ret = QString("sword://Lexicon/");
- break;
- case GenericBook:
- ret = QString("sword://Book/");
- break;
- case MorphHebrew:
- ret = QString("morph://Hebrew/");
- break;
- case MorphGreek:
- ret = QString("morph://Greek/");
- break;
- case StrongsHebrew:
- ret = QString("strongs://Hebrew/");
- break;
- case StrongsGreek:
- ret = QString("strongs://Greek/");
- break;
- default:
- break;
- }
-
- if (!moduleName.isEmpty()) {
- ret.append( moduleName ).append('/');
- }
- else { //if module is empty use fallback module
- ret.append( preferredModule(type) ).append('/');
- }
-
- if (type == GenericBook) {
- const QString s = (!key.isEmpty() ? key : QString::null);
- QString newKey = QString::null;
- //replace all / of the key (e.g. of a CSwordTreeKey) with
- // the escape sequence \/ so we know it's a link internal divider (e.g. of CSwordTreeKey)!
-
- QChar c;
-
- for(int i = 0; i < s.length(); ++i) {
- c = s.at(i);
-
- if (c == '/') {
- newKey.append("\\/");
- }
- else {
- newKey.append(c);
- }
- }
-
- ret.append( newKey );
- }
- else { //slashes do not appear in verses and dictionary entries
-
- switch (type) {
-
- case Bible: //bibles or commentary keys need parsing
-
- case Commentary: {
-/* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
-
- ParseOptions options;
- options.refDestinationModule = mod->name();
- options.refBase =
- options.sourceLanguage = mod->module()->Lang();
- options.destinationLanguage = "en";
-
- ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
- ret.append(key);
- break;
- }
-
- default:
- ret.append( key ); //use the standard key, no parsing required
- break;
- }
- }
-
- return ret;
+ QString ret = QString::null;
+
+ switch (type) {
+
+ case Bible:
+ ret = QString("sword://Bible/");
+ break;
+ case Commentary:
+ ret = QString("sword://Commentary/");
+ break;
+ case Lexicon:
+ ret = QString("sword://Lexicon/");
+ break;
+ case GenericBook:
+ ret = QString("sword://Book/");
+ break;
+ case MorphHebrew:
+ ret = QString("morph://Hebrew/");
+ break;
+ case MorphGreek:
+ ret = QString("morph://Greek/");
+ break;
+ case StrongsHebrew:
+ ret = QString("strongs://Hebrew/");
+ break;
+ case StrongsGreek:
+ ret = QString("strongs://Greek/");
+ break;
+ default:
+ break;
+ }
+
+ if (!moduleName.isEmpty()) {
+ ret.append( moduleName ).append('/');
+ }
+ else { //if module is empty use fallback module
+ ret.append( preferredModule(type) ).append('/');
+ }
+
+ if (type == GenericBook) {
+ const QString s = (!key.isEmpty() ? key : QString::null);
+ QString newKey = QString::null;
+ //replace all / of the key (e.g. of a CSwordTreeKey) with
+ // the escape sequence \/ so we know it's a link internal divider (e.g. of CSwordTreeKey)!
+
+ QChar c;
+
+ for (int i = 0; i < s.length(); ++i) {
+ c = s.at(i);
+
+ if (c == '/') {
+ newKey.append("\\/");
+ }
+ else {
+ newKey.append(c);
+ }
+ }
+
+ ret.append( newKey );
+ }
+ else { //slashes do not appear in verses and dictionary entries
+
+ switch (type) {
+
+ case Bible: //bibles or commentary keys need parsing
+
+ case Commentary: {
+ /* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+
+ ParseOptions options;
+ options.refDestinationModule = mod->name();
+ options.refBase =
+ options.sourceLanguage = mod->module()->Lang();
+ options.destinationLanguage = "en";
+
+ ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
+ ret.append(key);
+ break;
+ }
+
+ default:
+ ret.append( key ); //use the standard key, no parsing required
+ break;
+ }
+ }
+
+ return ret;
}
/** Decodes the given hyperlink to module and key. */
bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, CReferenceManager::Type& type ) {
- /**
- * We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
- */
- module = QString::null;
- key = QString::null;
-
- type = Unknown; //not yet known
- QString ref = hyperlink;
- //remove the trailing slash
-
- if (ref.right(1)=="/" && ref.right(2) != "\\/") //trailing slash, but not escaped
- ref = ref.left(ref.length()-1);
-
- //find out which type we have by looking at the beginning (protocoll section of URL)
- if (ref.left(8).toLower() == "sword://") { //Bible, Commentary or Lexicon
- ref = ref.mid(8);
-
- if (ref.left(5).toLower() == "bible") { //a bible hyperlink
- type = CReferenceManager::Bible;
- ref = ref.mid(6); //inclusive trailing slash
- }
- else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
- type = CReferenceManager::Commentary;
- ref = ref.mid(11); //inclusive trailing slash
- }
- else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
- type = CReferenceManager::Lexicon;
- ref = ref.mid(8); //inclusive trailing slash
- }
- else if (ref.left(4).toLower() == "book") { // a Book hyperlink
- type = CReferenceManager::GenericBook;
- ref = ref.mid(5); //inclusive trailing slash
- }
-
- // string up to next slash is the modulename
- if (ref.at(0) != '/' ) { //we have a module given
-
- while (true) {
- const int pos = ref.indexOf("/");
-
- if ((pos>0) && ref.at(pos-1) != '\\') { //found a slash which is not escaped
- module = ref.mid(0,pos);
- ref = ref.mid(pos+1);
- break;
- }
- else if (pos == -1) {
- break;
- }
- }
-
- // the rest is the key
- key = ref;
- }
- else {
- key = ref.mid(1);
- }
-
- //the key may be an osis key like "NASBLex:Moses", which sets the module, too
- // const int modPos = key.find(":");
- // if (modPos != -1 && key.at(modPos-1).isLetter() && key.at(modPos+1).isLetter()) {
- // module = key.left(modPos);
- // key = key.mid(modPos+1);
- //
- // qWarning("found the module name %s with key %s", module.latin1(), key.latin1());
- // }
-
- //replace \/ escapes with /
- key.replace(QRegExp("\\\\/"), "/");
- }
- else if (ref.left(8).toLower() == "morph://" || ref.left(10).toLower() == "strongs://") { //strongs or morph URL have the same format
- enum PreType {IsMorph, IsStrongs};
- PreType preType = IsMorph;
-
- if (ref.left(8).toLower() == "morph://") { //morph code hyperlink
- ref = ref.mid(8);
- preType = IsMorph;
- }
- else if (ref.left(10).toLower() == "strongs://") {
- ref = ref.mid(10);
- preType = IsStrongs;
- }
-
- //part up to next slash is the language
- const int pos = ref.indexOf("/");
-
- if (pos>0) { //found
- const QString language = ref.mid(0,pos);
-
- if (language.toLower() == "hebrew") {
- switch (preType) {
-
- case IsMorph:
- type = CReferenceManager::MorphHebrew;
- break;
-
- case IsStrongs:
- type = CReferenceManager::StrongsHebrew;
- break;
- }
- }
- else if (language.toLower() == "greek") {
- switch (preType) {
-
- case IsMorph:
- type = CReferenceManager::MorphGreek;
- break;
-
- case IsStrongs:
- type = CReferenceManager::StrongsGreek;
- break;
- }
- }
-
- ref = ref.mid(pos+1);
- key = ref; //the remaining part is the key
-
- module = preferredModule(type);
- }
- }
-
- if (key.isEmpty() && module.isEmpty())
- return false;
-
- return true;
+ /**
+ * We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
+ */
+ module = QString::null;
+ key = QString::null;
+
+ type = Unknown; //not yet known
+ QString ref = hyperlink;
+ //remove the trailing slash
+
+ if (ref.right(1) == "/" && ref.right(2) != "\\/") //trailing slash, but not escaped
+ ref = ref.left(ref.length() - 1);
+
+ //find out which type we have by looking at the beginning (protocoll section of URL)
+ if (ref.left(8).toLower() == "sword://") { //Bible, Commentary or Lexicon
+ ref = ref.mid(8);
+
+ if (ref.left(5).toLower() == "bible") { //a bible hyperlink
+ type = CReferenceManager::Bible;
+ ref = ref.mid(6); //inclusive trailing slash
+ }
+ else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
+ type = CReferenceManager::Commentary;
+ ref = ref.mid(11); //inclusive trailing slash
+ }
+ else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
+ type = CReferenceManager::Lexicon;
+ ref = ref.mid(8); //inclusive trailing slash
+ }
+ else if (ref.left(4).toLower() == "book") { // a Book hyperlink
+ type = CReferenceManager::GenericBook;
+ ref = ref.mid(5); //inclusive trailing slash
+ }
+
+ // string up to next slash is the modulename
+ if (ref.at(0) != '/' ) { //we have a module given
+
+ while (true) {
+ const int pos = ref.indexOf("/");
+
+ if ((pos > 0) && ref.at(pos - 1) != '\\') { //found a slash which is not escaped
+ module = ref.mid(0, pos);
+ ref = ref.mid(pos + 1);
+ break;
+ }
+ else if (pos == -1) {
+ break;
+ }
+ }
+
+ // the rest is the key
+ key = ref;
+ }
+ else {
+ key = ref.mid(1);
+ }
+
+ //the key may be an osis key like "NASBLex:Moses", which sets the module, too
+ // const int modPos = key.find(":");
+ // if (modPos != -1 && key.at(modPos-1).isLetter() && key.at(modPos+1).isLetter()) {
+ // module = key.left(modPos);
+ // key = key.mid(modPos+1);
+ //
+ // qWarning("found the module name %s with key %s", module.latin1(), key.latin1());
+ // }
+
+ //replace \/ escapes with /
+ key.replace(QRegExp("\\\\/"), "/");
+ }
+ else if (ref.left(8).toLower() == "morph://" || ref.left(10).toLower() == "strongs://") { //strongs or morph URL have the same format
+ enum PreType {IsMorph, IsStrongs};
+ PreType preType = IsMorph;
+
+ if (ref.left(8).toLower() == "morph://") { //morph code hyperlink
+ ref = ref.mid(8);
+ preType = IsMorph;
+ }
+ else if (ref.left(10).toLower() == "strongs://") {
+ ref = ref.mid(10);
+ preType = IsStrongs;
+ }
+
+ //part up to next slash is the language
+ const int pos = ref.indexOf("/");
+
+ if (pos > 0) { //found
+ const QString language = ref.mid(0, pos);
+
+ if (language.toLower() == "hebrew") {
+ switch (preType) {
+
+ case IsMorph:
+ type = CReferenceManager::MorphHebrew;
+ break;
+
+ case IsStrongs:
+ type = CReferenceManager::StrongsHebrew;
+ break;
+ }
+ }
+ else if (language.toLower() == "greek") {
+ switch (preType) {
+
+ case IsMorph:
+ type = CReferenceManager::MorphGreek;
+ break;
+
+ case IsStrongs:
+ type = CReferenceManager::StrongsGreek;
+ break;
+ }
+ }
+
+ ref = ref.mid(pos + 1);
+ key = ref; //the remaining part is the key
+
+ module = preferredModule(type);
+ }
+ }
+
+ if (key.isEmpty() && module.isEmpty())
+ return false;
+
+ return true;
}
const QString CReferenceManager::encodeReference(const QString &module, const QString &reference) {
- //return QString("(%1)%2").arg(module).arg(reference);
- return QString("(").append(module).append(")").append(reference);
+ //return QString("(%1)%2").arg(module).arg(reference);
+ return QString("(").append(module).append(")").append(reference);
}
void CReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
- const int pos = dragreference.indexOf(")");
- const QString fallbackModule = dragreference.mid( 1, pos - 1);
- dragreference = dragreference.mid(pos+1);
+ const int pos = dragreference.indexOf(")");
+ const QString fallbackModule = dragreference.mid( 1, pos - 1);
+ dragreference = dragreference.mid(pos + 1);
- module = fallbackModule;
- reference = dragreference;
+ module = fallbackModule;
+ reference = dragreference;
}
/** Returns true if the parameter is a hyperlink. */
bool CReferenceManager::isHyperlink( const QString& hyperlink ) {
- return ( hyperlink.left(8) == "sword://")
- || (hyperlink.left(10) == "strongs://")
- || (hyperlink.left(8) == "morph://");
+ return ( hyperlink.left(8) == "sword://")
+ || (hyperlink.left(10) == "strongs://")
+ || (hyperlink.left(8) == "morph://");
}
/** Returns the preferred module name for the given type. */
const QString CReferenceManager::preferredModule( const CReferenceManager::Type type ) {
- QString moduleName = QString::null;
- CSwordModuleInfo* module = 0;
+ QString moduleName = QString::null;
+ CSwordModuleInfo* module = 0;
- switch (type) {
+ switch (type) {
- case CReferenceManager::Bible:
+ case CReferenceManager::Bible:
- module = CBTConfig::get
- ( CBTConfig::standardBible );
+ module = CBTConfig::get
+ ( CBTConfig::standardBible );
- break;
+ break;
- case CReferenceManager::Commentary:
- module = CBTConfig::get
- ( CBTConfig::standardCommentary );
+ case CReferenceManager::Commentary:
+ module = CBTConfig::get
+ ( CBTConfig::standardCommentary );
- break;
+ break;
- case CReferenceManager::Lexicon:
- module = CBTConfig::get
- ( CBTConfig::standardLexicon );
+ case CReferenceManager::Lexicon:
+ module = CBTConfig::get
+ ( CBTConfig::standardLexicon );
- break;
+ break;
- case CReferenceManager::StrongsHebrew:
- module = CBTConfig::get
- ( CBTConfig::standardHebrewStrongsLexicon );
+ case CReferenceManager::StrongsHebrew:
+ module = CBTConfig::get
+ ( CBTConfig::standardHebrewStrongsLexicon );
- break;
+ break;
- case CReferenceManager::StrongsGreek:
- module = CBTConfig::get
- ( CBTConfig::standardGreekStrongsLexicon );
+ case CReferenceManager::StrongsGreek:
+ module = CBTConfig::get
+ ( CBTConfig::standardGreekStrongsLexicon );
- break;
+ break;
- case CReferenceManager::MorphHebrew:
- module = CBTConfig::get
- ( CBTConfig::standardHebrewMorphLexicon );
+ case CReferenceManager::MorphHebrew:
+ module = CBTConfig::get
+ ( CBTConfig::standardHebrewMorphLexicon );
- break;
+ break;
- case CReferenceManager::MorphGreek:
- module = CBTConfig::get
- ( CBTConfig::standardGreekMorphLexicon );
+ case CReferenceManager::MorphGreek:
+ module = CBTConfig::get
+ ( CBTConfig::standardGreekMorphLexicon );
- break;
+ break;
- default:
- module = 0;
+ default:
+ module = 0;
- break;
- }
+ break;
+ }
- return module ? module->name() : QString::null;
+ return module ? module->name() : QString::null;
}
/** No descriptions */
CReferenceManager::Type CReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
- switch (type) {
+ switch (type) {
- case CSwordModuleInfo::Bible:
- return CReferenceManager::Bible;
+ case CSwordModuleInfo::Bible:
+ return CReferenceManager::Bible;
- case CSwordModuleInfo::Commentary:
- return CReferenceManager::Commentary;
+ case CSwordModuleInfo::Commentary:
+ return CReferenceManager::Commentary;
- case CSwordModuleInfo::Lexicon:
- return CReferenceManager::Lexicon;
+ case CSwordModuleInfo::Lexicon:
+ return CReferenceManager::Lexicon;
- case CSwordModuleInfo::GenericBook:
- return CReferenceManager::GenericBook;
+ case CSwordModuleInfo::GenericBook:
+ return CReferenceManager::GenericBook;
- default:
- return CReferenceManager::Unknown;
- }
+ default:
+ return CReferenceManager::Unknown;
+ }
}
/** Parses the given verse references using the given language and the module.*/
const QString CReferenceManager::parseVerseReference( const QString& ref, const CReferenceManager::ParseOptions& options) {
- CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
- //Q_ASSERT(mod); tested later
+ CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
+ //Q_ASSERT(mod); tested later
- if (!mod) {
- //parsing of non-verse based references is not supported
- return ref;
- }
+ if (!mod) {
+ //parsing of non-verse based references is not supported
+ return ref;
+ }
- if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
- qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
- return QString::null;
- }
+ if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
+ qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
+ return QString::null;
+ }
- QString sourceLanguage = options.sourceLanguage;
- QString destinationLanguage = options.destinationLanguage;
+ QString sourceLanguage = options.sourceLanguage;
+ QString destinationLanguage = options.destinationLanguage;
- sword::StringList locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- if (/*options.sourceLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //sourceLanguage not available
- sourceLanguage = "en_US";
- }
+ sword::StringList locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ if (/*options.sourceLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //sourceLanguage not available
+ sourceLanguage = "en_US";
+ }
- if (/*options.destinationLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //destination not available
- destinationLanguage = "en_US";
- }
+ if (/*options.destinationLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //destination not available
+ destinationLanguage = "en_US";
+ }
- QString ret;
- QStringList refList = ref.split(";");
+ QString ret;
+ QStringList refList = ref.split(";");
- CSwordVerseKey baseKey(0);
- baseKey.setLocale( sourceLanguage.toUtf8().constData() );
- baseKey.key( options.refBase ); //probably in the sourceLanguage
- baseKey.setLocale( "en_US" ); //english works in all environments as base
+ CSwordVerseKey baseKey(0);
+ baseKey.setLocale( sourceLanguage.toUtf8().constData() );
+ baseKey.key( options.refBase ); //probably in the sourceLanguage
+ baseKey.setLocale( "en_US" ); //english works in all environments as base
// CSwordVerseKey dummy(0);
- //HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage !
- const QString oldLocaleName = CPointers::backend()->booknameLanguage();
- CPointers::backend()->booknameLanguage(sourceLanguage);
+ //HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage !
+ const QString oldLocaleName = CPointers::backend()->booknameLanguage();
+ CPointers::backend()->booknameLanguage(sourceLanguage);
- sword::VerseKey dummy;
- dummy.setLocale( sourceLanguage.toUtf8().constData() );
- Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.toUtf8().constData()) );
+ sword::VerseKey dummy;
+ dummy.setLocale( sourceLanguage.toUtf8().constData() );
+ Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.toUtf8().constData()) );
// qDebug("Parsing '%s' in '%s' using '%s' as base, source lang '%s', dest lang '%s'", ref.latin1(), options.refDestinationModule.latin1(), baseKey.key().latin1(), sourceLanguage.latin1(), destinationLanguage.latin1());
- for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) {
- //The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
- sword::ListKey lk = dummy.ParseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
- Q_ASSERT(!dummy.Error());
-
- //Q_ASSERT(lk.Count());
- if (!lk.Count()) {
- ret.append( *it ); //don't change the original
- continue;
- }
-
- for (int i = 0; i < lk.Count(); ++i) {
- if (dynamic_cast<sword::VerseKey*>(lk.getElement(i))) { // a range
- sword::VerseKey* k = dynamic_cast<sword::VerseKey*>(lk.getElement(i));
- Q_ASSERT(k);
- k->setLocale( destinationLanguage.toUtf8().constData() );
-
- ret.append( QString::fromUtf8(k->getRangeText()) ).append("; ");
- }
- else { // a single ref
- sword::VerseKey vk;
- vk.setLocale( sourceLanguage.toUtf8().constData() );
- vk = lk.getElement(i)->getText();
- vk.setLocale( destinationLanguage.toUtf8().constData() );
-
- ret.append( QString::fromUtf8(vk.getText()) ).append("; ");
- }
- }
-
- }
-
- CPointers::backend()->booknameLanguage(oldLocaleName);
- return ret;
+ for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) {
+ //The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
+ sword::ListKey lk = dummy.ParseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
+ Q_ASSERT(!dummy.Error());
+
+ //Q_ASSERT(lk.Count());
+ if (!lk.Count()) {
+ ret.append( *it ); //don't change the original
+ continue;
+ }
+
+ for (int i = 0; i < lk.Count(); ++i) {
+ if (dynamic_cast<sword::VerseKey*>(lk.getElement(i))) { // a range
+ sword::VerseKey* k = dynamic_cast<sword::VerseKey*>(lk.getElement(i));
+ Q_ASSERT(k);
+ k->setLocale( destinationLanguage.toUtf8().constData() );
+
+ ret.append( QString::fromUtf8(k->getRangeText()) ).append("; ");
+ }
+ else { // a single ref
+ sword::VerseKey vk;
+ vk.setLocale( sourceLanguage.toUtf8().constData() );
+ vk = lk.getElement(i)->getText();
+ vk.setLocale( destinationLanguage.toUtf8().constData() );
+
+ ret.append( QString::fromUtf8(vk.getText()) ).append("; ");
+ }
+ }
+
+ }
+
+ CPointers::backend()->booknameLanguage(oldLocaleName);
+ return ret;
}
diff --git a/src/backend/managers/creferencemanager.h b/src/backend/managers/creferencemanager.h
index 19baae7..85131d6 100644
--- a/src/backend/managers/creferencemanager.h
+++ b/src/backend/managers/creferencemanager.h
@@ -22,88 +22,88 @@
class CReferenceManager {
-public:
- enum Type {
- Bible, /**< Bibles */
- Commentary, /**< Commentary */
- Lexicon, /**< Lexicon */
- GenericBook, /**< Generic Book */
- MorphHebrew, /**< Module for hebrew morphology*/
- MorphGreek, /**< Module for greek morphology */
- StrongsHebrew, /**< Module for hebrew strongs */
- StrongsGreek, /**< Module for greek strongs */
- Unknown /**< Unknown */
- };
+ public:
+ enum Type {
+ Bible, /**< Bibles */
+ Commentary, /**< Commentary */
+ Lexicon, /**< Lexicon */
+ GenericBook, /**< Generic Book */
+ MorphHebrew, /**< Module for hebrew morphology*/
+ MorphGreek, /**< Module for greek morphology */
+ StrongsHebrew, /**< Module for hebrew strongs */
+ StrongsGreek, /**< Module for greek strongs */
+ Unknown /**< Unknown */
+ };
- /** Turn a hyperlink into module, key and type.
- * Decodes the given hyperlink into module, key and type.
- * @param hyperlink The hyperlink to decode
- * @param module The string which will contain the module name after decoding
- * @param key The string which will contain the key after decoding
- * @param type The type param will contain the reference type after decoding
- */
- static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
- /**
- * Returns a hyperlink used to be embedded in the display windows.
- * At the moment the format is sword://module/key
- * @param module The module which is used to encode the hyperlink
- * @param key The key which is used to encode the hyperlink
- * @param type The type which is used to encode the hyperlink
- * @return The encoded hyperlink
- */
- static const QString encodeHyperlink( const QString module, const QString key, const Type type);
- /**
- * Puts a module Name and a Reference together in the 'draggable' form
- * (module)reference
- * @param module The name of the module
- * @param reference The key reference as text
- * @return The encoded reference using module and reference
- * @author Martin Gruner
- */
- static const QString encodeReference(const QString &module, const QString &reference);
- /**
- * decodes a 'draggable' reference into a modulename and a reference
- * @author Martin Gruner
- */
- static void decodeReference(QString &dragreference, QString &module, QString &reference);
- /**
- * Returns true if the parameter is a hyperlink.
- * @param hyperlink The string which is tested
- * @return True if the passed string is a hyperlink
- */
- static bool isHyperlink( const QString& hyperlink );
- /**
- * Returns the preferred module name for the given type.
- * @param type The type which is used to find the module
- * @return The default module name for the passed type
- */
- static const QString preferredModule( const Type type );
- /**
- * Returns the type of the passed module type
- * @param type The CSwordModuleInfo module typpe
- * @return The ReferenceManager type
- */
- static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
+ /** Turn a hyperlink into module, key and type.
+ * Decodes the given hyperlink into module, key and type.
+ * @param hyperlink The hyperlink to decode
+ * @param module The string which will contain the module name after decoding
+ * @param key The string which will contain the key after decoding
+ * @param type The type param will contain the reference type after decoding
+ */
+ static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
+ /**
+ * Returns a hyperlink used to be embedded in the display windows.
+ * At the moment the format is sword://module/key
+ * @param module The module which is used to encode the hyperlink
+ * @param key The key which is used to encode the hyperlink
+ * @param type The type which is used to encode the hyperlink
+ * @return The encoded hyperlink
+ */
+ static const QString encodeHyperlink( const QString module, const QString key, const Type type);
+ /**
+ * Puts a module Name and a Reference together in the 'draggable' form
+ * (module)reference
+ * @param module The name of the module
+ * @param reference The key reference as text
+ * @return The encoded reference using module and reference
+ * @author Martin Gruner
+ */
+ static const QString encodeReference(const QString &module, const QString &reference);
+ /**
+ * decodes a 'draggable' reference into a modulename and a reference
+ * @author Martin Gruner
+ */
+ static void decodeReference(QString &dragreference, QString &module, QString &reference);
+ /**
+ * Returns true if the parameter is a hyperlink.
+ * @param hyperlink The string which is tested
+ * @return True if the passed string is a hyperlink
+ */
+ static bool isHyperlink( const QString& hyperlink );
+ /**
+ * Returns the preferred module name for the given type.
+ * @param type The type which is used to find the module
+ * @return The default module name for the passed type
+ */
+ static const QString preferredModule( const Type type );
+ /**
+ * Returns the type of the passed module type
+ * @param type The CSwordModuleInfo module typpe
+ * @return The ReferenceManager type
+ */
+ static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
- struct ParseOptions {
- QString refDestinationModule;
- QString refBase; /* only valid for verse based destination modules*/
- QString sourceLanguage; /* only valid for verse based destination modules*/
- QString destinationLanguage; /* only valid for verse based destination modules*/
+ struct ParseOptions {
+ QString refDestinationModule;
+ QString refBase; /* only valid for verse based destination modules*/
+ QString sourceLanguage; /* only valid for verse based destination modules*/
+ QString destinationLanguage; /* only valid for verse based destination modules*/
- ParseOptions() {
- destinationLanguage = "en";
- };
- };
+ ParseOptions() {
+ destinationLanguage = "en";
+ };
+ };
- /** Parses the given verse references using the given language and the module.
- * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
- * @param ref The verse reference.
- * @param lang The language of the verse reference
- * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
- */
- static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
+ /** Parses the given verse references using the given language and the module.
+ * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
+ * @param ref The verse reference.
+ * @param lang The language of the verse reference
+ * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
+ */
+ static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
};
#endif
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index f17538a..6420627 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -49,503 +49,523 @@ using namespace Filters;
using namespace Rendering;
CSwordBackend::CSwordBackend()
- : sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true)
+ : sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true),
+ m_dataModel(this)
{
- m_filters.gbf = new BT_GBFHTML();
- m_filters.plain = new BT_PLAINHTML();
- m_filters.thml = new BT_ThMLHTML();
- m_filters.osis = new BT_OSISHTML();
+ m_filters.gbf = new BT_GBFHTML();
+ m_filters.plain = new BT_PLAINHTML();
+ m_filters.thml = new BT_ThMLHTML();
+ m_filters.osis = new BT_OSISHTML();
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
+ m_displays.entry = new CEntryDisplay();
+ m_displays.chapter = new CChapterDisplay();
+ m_displays.book = new CBookDisplay();
- filterInit();
+ filterInit();
}
CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome)
- : sword::SWMgr(!path.isEmpty() ? path.toLocal8Bit().constData() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) // don't allow module renaming, because we load from a path
-{
- m_filters.gbf = new BT_GBFHTML();
- m_filters.plain = new BT_PLAINHTML();
- m_filters.thml = new BT_ThMLHTML();
- m_filters.osis = new BT_OSISHTML();
+ : sword::SWMgr(!path.isEmpty() ? path.toLocal8Bit().constData() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) { // don't allow module renaming, because we load from a path
+ m_filters.gbf = new BT_GBFHTML();
+ m_filters.plain = new BT_PLAINHTML();
+ m_filters.thml = new BT_ThMLHTML();
+ m_filters.osis = new BT_OSISHTML();
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
+ m_displays.entry = new CEntryDisplay();
+ m_displays.chapter = new CChapterDisplay();
+ m_displays.book = new CBookDisplay();
- filterInit();
+ filterInit();
}
CSwordBackend::~CSwordBackend() {
- shutdownModules();
+ shutdownModules();
- delete m_filters.gbf;
- delete m_filters.plain;
- delete m_filters.thml;
- delete m_filters.osis;
+ delete m_filters.gbf;
+ delete m_filters.plain;
+ delete m_filters.thml;
+ delete m_filters.osis;
- delete m_displays.book;
- delete m_displays.chapter;
- delete m_displays.entry;
+ delete m_displays.book;
+ delete m_displays.chapter;
+ delete m_displays.entry;
}
void CSwordBackend::filterInit() {
- //HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
- if (sword::SWOptionFilter* filter = optionFilters["OSISMorphSegmentation"])
- {
- cleanupFilters.remove(filter);
- optionFilters.erase("OSISMorphSegmentation");
- delete filter;
- }
- sword::SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
- optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- //HACK: replace Sword's ThML strip filter with our own version
- //remove this hack as soon as Sword is fixed
- cleanupFilters.remove(thmlplain);
- delete thmlplain;
- thmlplain = new BT_ThMLPlain();
- cleanupFilters.push_back(thmlplain);
+ //HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
+ if (sword::SWOptionFilter* filter = optionFilters["OSISMorphSegmentation"]) {
+ cleanupFilters.remove(filter);
+ optionFilters.erase("OSISMorphSegmentation");
+ delete filter;
+ }
+ sword::SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
+ optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+
+ //HACK: replace Sword's ThML strip filter with our own version
+ //remove this hack as soon as Sword is fixed
+ cleanupFilters.remove(thmlplain);
+ delete thmlplain;
+ thmlplain = new BT_ThMLPlain();
+ cleanupFilters.push_back(thmlplain);
}
-QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names)
-{
- int numberOfRemoved = 0;
- QList<CSwordModuleInfo*> list;
- foreach(QString name, names) {
- CSwordModuleInfo* mInfo = findModuleByName(name);
- if (mInfo) {
- m_moduleList.removeAll(mInfo);
- ++numberOfRemoved;
- list.append(mInfo);
- }
- }
- if (numberOfRemoved > 0)
- emit sigSwordSetupChanged(RemovedModules);
- return list;
+QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names) {
+ int numberOfRemoved = 0;
+ QList<CSwordModuleInfo*> list;
+ foreach(QString name, names) {
+ CSwordModuleInfo* mInfo = findModuleByName(name);
+ if (mInfo) {
+ m_dataModel.removeModule(mInfo);
+ ++numberOfRemoved;
+ list.append(mInfo);
+ }
+ }
+ if (numberOfRemoved > 0)
+ emit sigSwordSetupChanged(RemovedModules);
+ return list;
}
/** Initializes the Sword modules. */
CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
- // qWarning("globalSwordConfigPath is %s", globalConfPath);
- LoadError ret = NoError;
-
- shutdownModules(); //remove previous modules
- m_moduleList.clear();
-
- sword::ModMap::iterator end = Modules.end();
- ret = LoadError( Load() );
-
- for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
- sword::SWModule* const curMod = (*it).second;
- CSwordModuleInfo* newModule = 0;
-
- if (!strcmp(curMod->Type(), "Biblical Texts")) {
- newModule = new CSwordBibleModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.chapter);
- }
- else if (!strcmp(curMod->Type(), "Commentaries")) {
- newModule = new CSwordCommentaryModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
- }
- else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
- newModule = new CSwordLexiconModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
- }
- else if (!strcmp(curMod->Type(), "Generic Books")) {
- newModule = new CSwordBookModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.book);
- }
-
- if (newModule) {
- //Append the new modules to our list, but only if it's supported
- //The constructor of CSwordModuleInfo prints a warning on stdout
- if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
- m_moduleList.append( newModule );
- }
- else
- {
- delete newModule;
- }
- }
- }
-
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
-
- foreach (CSwordModuleInfo* mod, m_moduleList) {
- m_moduleDescriptionMap.insert( mod->config(CSwordModuleInfo::Description), mod->name() );
- //unlock modules if keys are present
- if ( mod->isEncrypted() ) {
- const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
- if (!unlockKey.isNull()) {
- setCipherKey( mod->name().toUtf8().constData(), unlockKey.toUtf8().constData() );
- }
- }
- }
-
- emit sigSwordSetupChanged(reason);
- return ret;
+ // qWarning("globalSwordConfigPath is %s", globalConfPath);
+ LoadError ret = NoError;
+
+ shutdownModules(); //remove previous modules
+ m_dataModel.clear();
+
+ sword::ModMap::iterator end = Modules.end();
+ ret = LoadError( Load() );
+
+ for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
+ sword::SWModule* const curMod = (*it).second;
+ CSwordModuleInfo* newModule = 0;
+
+ if (!strcmp(curMod->Type(), "Biblical Texts")) {
+ newModule = new CSwordBibleModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.chapter);
+ }
+ else if (!strcmp(curMod->Type(), "Commentaries")) {
+ newModule = new CSwordCommentaryModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.entry);
+ }
+ else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
+ newModule = new CSwordLexiconModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.entry);
+ }
+ else if (!strcmp(curMod->Type(), "Generic Books")) {
+ newModule = new CSwordBookModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.book);
+ }
+
+ if (newModule) {
+ //Append the new modules to our list, but only if it's supported
+ //The constructor of CSwordModuleInfo prints a warning on stdout
+ if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
+ m_dataModel.addModule(newModule);
+ }
+ else {
+ delete newModule;
+ }
+ }
+ }
+
+ Q_FOREACH(CSwordModuleInfo* mod, m_dataModel.modules()) {
+ m_moduleDescriptionMap.insert( mod->config(CSwordModuleInfo::Description), mod->name() );
+ //unlock modules if keys are present
+ if ( mod->isEncrypted() ) {
+ const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
+ if (!unlockKey.isNull()) {
+ setCipherKey( mod->name().toUtf8().constData(), unlockKey.toUtf8().constData() );
+ }
+ }
+ }
+
+ emit sigSwordSetupChanged(reason);
+ return ret;
}
void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section) {
- sword::SWBuf moduleDriver;
- sword::SWBuf sourceformat;
- sword::ConfigEntMap::iterator entry;
- bool noDriver = true;
-
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
- moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
-
- if (sourceformat == "GBF") {
- module->AddRenderFilter(m_filters.gbf);
- noDriver = false;
- }
- else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(m_filters.plain);
- noDriver = false;
- }
- else if (sourceformat == "ThML") {
- module->AddRenderFilter(m_filters.thml);
- noDriver = false;
- }
- else if (sourceformat == "OSIS") {
- module->AddRenderFilter(m_filters.osis);
- noDriver = false;
- }
-
- if (noDriver) { //no driver found
- if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
- module->AddRenderFilter(m_filters.plain);
- noDriver = false;
- }
- }
+ sword::SWBuf moduleDriver;
+ sword::SWBuf sourceformat;
+ sword::ConfigEntMap::iterator entry;
+ bool noDriver = true;
+
+ sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
+ moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
+
+ if (sourceformat == "GBF") {
+ module->AddRenderFilter(m_filters.gbf);
+ noDriver = false;
+ }
+ else if (sourceformat == "PLAIN") {
+ module->AddRenderFilter(m_filters.plain);
+ noDriver = false;
+ }
+ else if (sourceformat == "ThML") {
+ module->AddRenderFilter(m_filters.thml);
+ noDriver = false;
+ }
+ else if (sourceformat == "OSIS") {
+ module->AddRenderFilter(m_filters.osis);
+ noDriver = false;
+ }
+
+ if (noDriver) { //no driver found
+ if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
+ module->AddRenderFilter(m_filters.plain);
+ noDriver = false;
+ }
+ }
}
/** This function deinitializes the modules and deletes them. */
bool CSwordBackend::shutdownModules() {
- QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin();
- QList<CSwordModuleInfo*>::iterator end = m_moduleList.end();
-
- while (it != end) {
- CSwordModuleInfo* current = (*it);
- it = m_moduleList.erase(it);
- delete current;
- }
-
- Q_ASSERT(m_moduleList.count() == 0);
- //BT mods are deleted now, delete Sword mods, too.
- DeleteMods();
-
- /* Cipher filters must be handled specially, because SWMgr creates them,
- * stores them in cipherFilters and cleanupFilters and attaches them to locked
- * modules. If these modules are removed, the filters need to be removed as well,
- * so that they are re-created for the new module objects.
- */
- sword::FilterMap::iterator cipher_it;
- for (cipher_it = cipherFilters.begin(); cipher_it != cipherFilters.end(); cipher_it++)
- {
- //Delete the Filter and remove it from the cleanup list
- cleanupFilters.remove(cipher_it->second);
- delete cipher_it->second;
- }
- cipherFilters.clear();
-
- return true;
+ m_dataModel.clear(true);
+ //BT mods are deleted now, delete Sword mods, too.
+ DeleteMods();
+
+ /* Cipher filters must be handled specially, because SWMgr creates them,
+ * stores them in cipherFilters and cleanupFilters and attaches them to locked
+ * modules. If these modules are removed, the filters need to be removed as well,
+ * so that they are re-created for the new module objects.
+ */
+ sword::FilterMap::iterator cipher_it;
+ for (cipher_it = cipherFilters.begin(); cipher_it != cipherFilters.end(); cipher_it++) {
+ //Delete the Filter and remove it from the cleanup list
+ cleanupFilters.remove(cipher_it->second);
+ delete cipher_it->second;
+ }
+ cipherFilters.clear();
+
+ return true;
}
void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) {
- sword::SWBuf value;
+ sword::SWBuf value;
- switch (type) {
+ switch (type) {
- case CSwordModuleInfo::textualVariants:
+ case CSwordModuleInfo::textualVariants:
- if (state == 0) {
- value = "Primary Reading";
- }
- else if (state == 1) {
- value = "Secondary Reading";
- }
- else {
- value = "All Readings";
- }
+ if (state == 0) {
+ value = "Primary Reading";
+ }
+ else if (state == 1) {
+ value = "Secondary Reading";
+ }
+ else {
+ value = "All Readings";
+ }
- break;
+ break;
- default:
- value = state ? "On": "Off";
- break;
- };
+ default:
+ value = state ? "On" : "Off";
+ break;
+ };
- if (value.length())
- setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
+ if (value.length())
+ setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
}
void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) {
- setOption( CSwordModuleInfo::footnotes, options.footnotes );
- setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
- setOption( CSwordModuleInfo::headings, options.headings );
- setOption( CSwordModuleInfo::morphTags, options.morphTags );
- setOption( CSwordModuleInfo::lemmas, options.lemmas );
- setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
- setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
- setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
- setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
- setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
- setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
- // setOption( CSwordModuleInfo::transliteration, options.transliteration );
- setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
+ setOption( CSwordModuleInfo::footnotes, options.footnotes );
+ setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
+ setOption( CSwordModuleInfo::headings, options.headings );
+ setOption( CSwordModuleInfo::morphTags, options.morphTags );
+ setOption( CSwordModuleInfo::lemmas, options.lemmas );
+ setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
+ setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
+ setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
+ setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
+ setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
+ setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
+ // setOption( CSwordModuleInfo::transliteration, options.transliteration );
+ setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
}
/** This function searches for a module with the specified description */
CSwordModuleInfo* CSwordBackend::findModuleByDescription(const QString& description) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->config(CSwordModuleInfo::Description) == description) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->config(CSwordModuleInfo::Description) == description) return mod;
+ }
+ return 0;
}
/** This function searches for a module with the specified description */
const QString CSwordBackend::findModuleNameByDescription(const QString& description) {
- if (m_moduleDescriptionMap.contains(description)) {
- return m_moduleDescriptionMap[description];
- }
- return QString::null;
+ if (m_moduleDescriptionMap.contains(description)) {
+ return m_moduleDescriptionMap[description];
+ }
+ return QString::null;
}
/** This function searches for a module with the specified name */
CSwordModuleInfo* CSwordBackend::findModuleByName(const QString& name) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->name() == name) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->name() == name) return mod;
+ }
+ return 0;
}
CSwordModuleInfo* CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->module() == swmodule ) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->module() == swmodule ) return mod;
+ }
+ return 0;
}
CSwordModuleInfo* CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod == module) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod == module) return mod;
+ }
+ return 0;
}
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) {
- sword::SectionMap::iterator section;
- DIR *dir = opendir(configPath);
-
- struct dirent *ent;
-
- bool foundConfig = false;
- QString modFile;
-
- if (dir) { // find and update .conf file
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = QString(configPath);
- modFile.append("/");
- modFile.append( QString::fromLocal8Bit(ent->d_name) );
-
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
-
- closedir(dir);
- }
- else { //try to read mods.conf
- moduleConfig = sword::SWConfig("");//global config
- section = config->Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != config->Sections.end() );
-
- sword::ConfigEntMap::iterator entry;
-
- if (foundConfig) { //copy module section
-
- for (entry = section->second.begin(); entry != section->second.end(); entry++) {
- moduleConfig.Sections[section->first].insert(sword::ConfigEntMap::value_type(entry->first, entry->second));
- }
- }
- }
-
- if (!foundConfig && configType != 2) { //search in $HOME/.sword/
-
- QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
- myPath.append("/.sword/mods.d");
- dir = opendir(myPath.toUtf8().constData());
-
- if (dir) {
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = myPath;
- modFile.append('/');
- modFile.append(ent->d_name);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
-
- closedir(dir);
- }
- }
-
- return foundConfig;
+ sword::SectionMap::iterator section;
+ DIR *dir = opendir(configPath);
+
+ struct dirent *ent;
+
+ bool foundConfig = false;
+ QString modFile;
+
+ if (dir) { // find and update .conf file
+ rewinddir(dir);
+
+ while ((ent = readdir(dir)) && !foundConfig) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = QString(configPath);
+ modFile.append("/");
+ modFile.append( QString::fromLocal8Bit(ent->d_name) );
+
+ moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
+ }
+
+ closedir(dir);
+ }
+ else { //try to read mods.conf
+ moduleConfig = sword::SWConfig("");//global config
+ section = config->Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != config->Sections.end() );
+
+ sword::ConfigEntMap::iterator entry;
+
+ if (foundConfig) { //copy module section
+
+ for (entry = section->second.begin(); entry != section->second.end(); entry++) {
+ moduleConfig.Sections[section->first].insert(sword::ConfigEntMap::value_type(entry->first, entry->second));
+ }
+ }
+ }
+
+ if (!foundConfig && configType != 2) { //search in $HOME/.sword/
+
+ QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
+ myPath.append("/.sword/mods.d");
+ dir = opendir(myPath.toUtf8().constData());
+
+ if (dir) {
+ rewinddir(dir);
+
+ while ((ent = readdir(dir)) && !foundConfig) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = myPath;
+ modFile.append('/');
+ modFile.append(ent->d_name);
+ moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
+ }
+
+ closedir(dir);
+ }
+ }
+
+ return foundConfig;
}
/** Returns the text used for the option given as parameter. */
const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
- switch (option) {
- case CSwordModuleInfo::footnotes: return QString("Footnotes");
- case CSwordModuleInfo::strongNumbers: return QString("Strong's Numbers");
- case CSwordModuleInfo::headings: return QString("Headings");
- case CSwordModuleInfo::morphTags: return QString("Morphological Tags");
- case CSwordModuleInfo::lemmas: return QString("Lemmas");
- case CSwordModuleInfo::hebrewPoints: return QString("Hebrew Vowel Points");
- case CSwordModuleInfo::hebrewCantillation: return QString("Hebrew Cantillation");
- case CSwordModuleInfo::greekAccents: return QString("Greek Accents");
- case CSwordModuleInfo::redLetterWords: return QString("Words of Christ in Red");
- case CSwordModuleInfo::textualVariants: return QString("Textual Variants");
- case CSwordModuleInfo::scriptureReferences: return QString("Cross-references");
- case CSwordModuleInfo::morphSegmentation: return QString("Morph Segmentation");
- }
- return QString::null;
+ switch (option) {
+ case CSwordModuleInfo::footnotes:
+ return QString("Footnotes");
+ case CSwordModuleInfo::strongNumbers:
+ return QString("Strong's Numbers");
+ case CSwordModuleInfo::headings:
+ return QString("Headings");
+ case CSwordModuleInfo::morphTags:
+ return QString("Morphological Tags");
+ case CSwordModuleInfo::lemmas:
+ return QString("Lemmas");
+ case CSwordModuleInfo::hebrewPoints:
+ return QString("Hebrew Vowel Points");
+ case CSwordModuleInfo::hebrewCantillation:
+ return QString("Hebrew Cantillation");
+ case CSwordModuleInfo::greekAccents:
+ return QString("Greek Accents");
+ case CSwordModuleInfo::redLetterWords:
+ return QString("Words of Christ in Red");
+ case CSwordModuleInfo::textualVariants:
+ return QString("Textual Variants");
+ case CSwordModuleInfo::scriptureReferences:
+ return QString("Cross-references");
+ case CSwordModuleInfo::morphSegmentation:
+ return QString("Morph Segmentation");
+ }
+ return QString::null;
}
/** Returns the translated name of the option given as parameter. */
const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
- switch (option) {
- case CSwordModuleInfo::footnotes: return QObject::tr("Footnotes");
- case CSwordModuleInfo::strongNumbers: return QObject::tr("Strong's numbers");
- case CSwordModuleInfo::headings: return QObject::tr("Headings");
- case CSwordModuleInfo::morphTags: return QObject::tr("Morphological tags");
- case CSwordModuleInfo::lemmas: return QObject::tr("Lemmas");
- case CSwordModuleInfo::hebrewPoints: return QObject::tr("Hebrew vowel points");
- case CSwordModuleInfo::hebrewCantillation: return QObject::tr("Hebrew cantillation marks");
- case CSwordModuleInfo::greekAccents: return QObject::tr("Greek accents");
- case CSwordModuleInfo::redLetterWords: return QObject::tr("Red letter words");
- case CSwordModuleInfo::textualVariants: return QObject::tr("Textual variants");
- case CSwordModuleInfo::scriptureReferences: return QObject::tr("Scripture cross-references");
- case CSwordModuleInfo::morphSegmentation: return QObject::tr("Morph segmentation");
- }
- return QString::null;
+ switch (option) {
+ case CSwordModuleInfo::footnotes:
+ return QObject::tr("Footnotes");
+ case CSwordModuleInfo::strongNumbers:
+ return QObject::tr("Strong's numbers");
+ case CSwordModuleInfo::headings:
+ return QObject::tr("Headings");
+ case CSwordModuleInfo::morphTags:
+ return QObject::tr("Morphological tags");
+ case CSwordModuleInfo::lemmas:
+ return QObject::tr("Lemmas");
+ case CSwordModuleInfo::hebrewPoints:
+ return QObject::tr("Hebrew vowel points");
+ case CSwordModuleInfo::hebrewCantillation:
+ return QObject::tr("Hebrew cantillation marks");
+ case CSwordModuleInfo::greekAccents:
+ return QObject::tr("Greek accents");
+ case CSwordModuleInfo::redLetterWords:
+ return QObject::tr("Red letter words");
+ case CSwordModuleInfo::textualVariants:
+ return QObject::tr("Textual variants");
+ case CSwordModuleInfo::scriptureReferences:
+ return QObject::tr("Scripture cross-references");
+ case CSwordModuleInfo::morphSegmentation:
+ return QObject::tr("Morph segmentation");
+ }
+ return QString::null;
}
const QString CSwordBackend::configOptionName( const CSwordModuleInfo::FilterTypes option ) {
- switch (option) {
- case CSwordModuleInfo::footnotes: return QString("Footnotes");
- case CSwordModuleInfo::strongNumbers: return QString("Strongs");
- case CSwordModuleInfo::headings: return QString("Headings");
- case CSwordModuleInfo::morphTags: return QString("Morph");
- case CSwordModuleInfo::lemmas: return QString("Lemma");
- case CSwordModuleInfo::hebrewPoints: return QString("HebrewPoints");
- case CSwordModuleInfo::hebrewCantillation: return QString("Cantillation");
- case CSwordModuleInfo::greekAccents: return QString("GreekAccents");
- case CSwordModuleInfo::redLetterWords: return QString("RedLetterWords");
- case CSwordModuleInfo::textualVariants: return QString("Variants");
- case CSwordModuleInfo::scriptureReferences: return QString("Scripref");
- case CSwordModuleInfo::morphSegmentation: return QString("MorphSegmentation");
- }
- return QString::null;
+ switch (option) {
+ case CSwordModuleInfo::footnotes:
+ return QString("Footnotes");
+ case CSwordModuleInfo::strongNumbers:
+ return QString("Strongs");
+ case CSwordModuleInfo::headings:
+ return QString("Headings");
+ case CSwordModuleInfo::morphTags:
+ return QString("Morph");
+ case CSwordModuleInfo::lemmas:
+ return QString("Lemma");
+ case CSwordModuleInfo::hebrewPoints:
+ return QString("HebrewPoints");
+ case CSwordModuleInfo::hebrewCantillation:
+ return QString("Cantillation");
+ case CSwordModuleInfo::greekAccents:
+ return QString("GreekAccents");
+ case CSwordModuleInfo::redLetterWords:
+ return QString("RedLetterWords");
+ case CSwordModuleInfo::textualVariants:
+ return QString("Variants");
+ case CSwordModuleInfo::scriptureReferences:
+ return QString("Scripref");
+ case CSwordModuleInfo::morphSegmentation:
+ return QString("MorphSegmentation");
+ }
+ return QString::null;
}
const QString CSwordBackend::booknameLanguage( const QString& language ) {
- if (!language.isEmpty()) {
- sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.toUtf8().constData() );
-
- //refresh the locale of all Bible and commentary modules!
- //use what sword returns, language may be different
- QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
-
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) {
- //Create a new key, it will get the default bookname language
- ((sword::VerseKey*)(mod->module()->getKey()))->setLocale( newLocaleName.toUtf8().constData() );
- }
- }
-
- }
- return QString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
+ if (!language.isEmpty()) {
+ sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.toUtf8().constData() );
+
+ //refresh the locale of all Bible and commentary modules!
+ //use what sword returns, language may be different
+ QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
+
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) {
+ //Create a new key, it will get the default bookname language
+ ((sword::VerseKey*)(mod->module()->getKey()))->setLocale( newLocaleName.toUtf8().constData() );
+ }
+ }
+
+ }
+ return QString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
}
/** Reload all Sword modules. */
void CSwordBackend::reloadModules(SetupChangedReason reason) {
- shutdownModules();
-
- //delete Sword's config to make Sword reload it!
-
- if (myconfig) { // force reload on config object because we may have changed the paths
- delete myconfig;
- config = myconfig = 0;
- // we need to call findConfig to make sure that augPaths are reloaded
- findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig);
- // now re-read module configuration files
- loadConfigDir(configPath);
- }
- else if (config) {
- config->Load();
- }
-
- initModules(reason);
+ shutdownModules();
+
+ //delete Sword's config to make Sword reload it!
+
+ if (myconfig) { // force reload on config object because we may have changed the paths
+ delete myconfig;
+ config = myconfig = 0;
+ // we need to call findConfig to make sure that augPaths are reloaded
+ findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig);
+ // now re-read module configuration files
+ loadConfigDir(configPath);
+ }
+ else if (config) {
+ config->Load();
+ }
+
+ initModules(reason);
}
const QStringList CSwordBackend::swordDirList() {
- QSet<QString> ret;
- const QString home = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
-
- //return a list of used Sword dirs. Useful for the installer
- QString configPath = QString("%1/.sword/sword.conf").arg(home);
-
- if (!QFile(configPath).exists()) {
- configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf
- }
-
- QStringList configs = configPath.split(":");
-
- for (QStringList::const_iterator 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
- }
- }
-
- 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();
+ QSet<QString> ret;
+ const QString home = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
+
+ //return a list of used Sword dirs. Useful for the installer
+ QString configPath = QString("%1/.sword/sword.conf").arg(home);
+
+ if (!QFile(configPath).exists()) {
+ configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf
+ }
+
+ QStringList configs = configPath.split(":");
+
+ for (QStringList::const_iterator 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
+ }
+ }
+
+ 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();
}
-void CSwordBackend::notifyChange(SetupChangedReason reason)
-{
- emit sigSwordSetupChanged(reason);
+void CSwordBackend::notifyChange(SetupChangedReason reason) {
+ emit sigSwordSetupChanged(reason);
}
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index 0ffb484..9169c33 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -12,6 +12,7 @@
//BibleTime includes
#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
//Qt includes
#include <QObject>
@@ -29,9 +30,9 @@
//forward declarations
namespace Rendering {
- class CEntryDisplay;
- class CChapterDisplay;
- class CBookDisplay;
+class CEntryDisplay;
+class CChapterDisplay;
+class CBookDisplay;
}
/** The backend layer main class.
@@ -43,231 +44,238 @@ namespace Rendering {
* @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:
+class CSwordBackend : public QObject, public sword::SWMgr {
+ Q_OBJECT
+ public:
- /** The reason for the sigSwordSetupChanged signal, i.e. why the module list has changed. */
- enum SetupChangedReason {
- AddedModules = 1,
- RemovedModules = 2,
- HidedModules = 4,
- PathChanged = 8,
- OtherChange = 16
- };
+ /** The reason for the sigSwordSetupChanged signal, i.e. why the module list has changed. */
+ enum SetupChangedReason {
+ AddedModules = 1,
+ RemovedModules = 2,
+ HidedModules = 4,
+ PathChanged = 8,
+ OtherChange = 16
+ };
- /** Filter options. Filter options to
- * control the text display of modules. Uses int and not bool because not all
- * options have just two toggle values.
- */
- struct FilterOptions {
- int footnotes; /**< 0 for disabled, 1 for enabled */
- int strongNumbers; /**< 0 for disabled, 1 for enabled */
- int headings; /**< 0 for disabled, 1 for enabled */
- int morphTags; /**< 0 for disabled, 1 for enabled */
- int lemmas; /**< 0 for disabled, 1 for enabled */
- int hebrewPoints; /**< 0 for disabled, 1 for enabled */
- int hebrewCantillation; /**< 0 for disabled, 1 for enabled */
- int greekAccents; /**< 0 for disabled, 1 for enabled */
- int textualVariants; /**< Number n to enabled the n-th variant */
- int redLetterWords; /**< 0 for disabled, 1 for enabled */
- int scriptureReferences; /**< 0 for disabled, 1 for enabled */
- int morphSegmentation; /**< 0 for disabled, 1 for enabled */
- };
+ /** Filter options. Filter options to
+ * control the text display of modules. Uses int and not bool because not all
+ * options have just two toggle values.
+ */
+ struct FilterOptions {
+ int footnotes; /**< 0 for disabled, 1 for enabled */
+ int strongNumbers; /**< 0 for disabled, 1 for enabled */
+ int headings; /**< 0 for disabled, 1 for enabled */
+ int morphTags; /**< 0 for disabled, 1 for enabled */
+ int lemmas; /**< 0 for disabled, 1 for enabled */
+ int hebrewPoints; /**< 0 for disabled, 1 for enabled */
+ int hebrewCantillation; /**< 0 for disabled, 1 for enabled */
+ int greekAccents; /**< 0 for disabled, 1 for enabled */
+ int textualVariants; /**< Number n to enabled the n-th variant */
+ int redLetterWords; /**< 0 for disabled, 1 for enabled */
+ int scriptureReferences; /**< 0 for disabled, 1 for enabled */
+ int morphSegmentation; /**< 0 for disabled, 1 for enabled */
+ };
- /** Control the display of a text.
- */
- struct DisplayOptions {
- int lineBreaks;
- int verseNumbers;
- };
+ /** Control the display of a text.
+ */
+ struct DisplayOptions {
+ int lineBreaks;
+ int verseNumbers;
+ };
- /** The error codes which may be returned by the @ref Load() call.
- */
- enum LoadError { // the values exist to cast from the char return of SWMgr::Load
- NoSwordConfig = -1,
- NoError = 0,
- NoModules = 1
- };
- /**
- * The constructor of the Sword backend.
- * It creates the SWModule objects using SWMgr's methods, it adds the necessary
- * filters for the module format.
- */
- CSwordBackend();
- /**
- * The constructor of the Sword backend. This is actually used nowhere.
- * Notice that using augmentHome=false can mess up the system because it is true elsewhere.
- * @param path The path which is used to load modules
- * @param augmentHome True if the $HOME/.sword/ modules should be augmented with the other modules
- */
- CSwordBackend( const QString& path, const bool augmentHome = true );
+ /** The error codes which may be returned by the @ref Load() call.
+ */
+ enum LoadError { // the values exist to cast from the char return of SWMgr::Load
+ NoSwordConfig = -1,
+ NoError = 0,
+ NoModules = 1
+ };
+ /**
+ * The constructor of the Sword backend.
+ * It creates the SWModule objects using SWMgr's methods, it adds the necessary
+ * filters for the module format.
+ */
+ CSwordBackend();
+ /**
+ * The constructor of the Sword backend. This is actually used nowhere.
+ * Notice that using augmentHome=false can mess up the system because it is true elsewhere.
+ * @param path The path which is used to load modules
+ * @param augmentHome True if the $HOME/.sword/ modules should be augmented with the other modules
+ */
+ CSwordBackend( const QString& path, const bool augmentHome = true );
- /**
- * The destrctor of this backend. This function shuts the modules down using @ref shutdownModules.
- */
- virtual ~CSwordBackend();
+ /**
+ * The destrctor of this backend. This function shuts the modules down using @ref shutdownModules.
+ */
+ ~CSwordBackend();
- /**
- * This function returns the list of available modules managed by this backend.
- * You have to call initModules() first;
- *
- * @return The list of modules managed by this backend
- */
- inline virtual QList<CSwordModuleInfo*>& moduleList();
- /**
- * Initializes the Sword modules.
- *
- * @return True if the initializiation was succesful, otherwise return false.
- */
- virtual CSwordBackend::LoadError initModules(SetupChangedReason reason);
- /**
- * This function deinitializes the modules and deletes them.
- *
- * @return True if it was succesful, otherwise return false
- */
- virtual bool shutdownModules();
- /**
- * Sets the given options enabled or disabled depending on the second parameter.
- *
- * @param type This is the type this function should set enabled or disabled
- * @param enable If this is true the option will be enabled, otherwise it will be disabled.
- */
- void setOption( const CSwordModuleInfo::FilterTypes type, const int state );
- /** */
- void setFilterOptions( const CSwordBackend::FilterOptions options );
- /**
- * Sets the language for the international booknames of Sword.
- * @param langName The abbreviation string which should be used for the Sword backend
- */
- const QString booknameLanguage( const QString& langName = QString::null );
- /**
- * This function searches for a module with the specified description
- * @param description The description of the desired module
- * @return pointer to the desired module; null if no module has the specified description
- */
- virtual CSwordModuleInfo* findModuleByDescription(const QString& description);
- /**
- * This function searches for a module with the specified description
- * @param description The description of the desired module
- * @return pointer to the desired module; null if no module has the specified description
- */
- const QString findModuleNameByDescription(const QString& description);
- /**
- * This function searches for a module with the specified name
- * @param name The name of the desired module
- * @return Pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findModuleByName(const QString& name);
- /**
- * This function searches for a module with the specified sword module as module() object!
- * @param swmodule to a Sword module
- * @return pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findSwordModuleByPointer(const sword::SWModule* const swmodule);
- /**
- * This function searches for a module which is the same as the passed module.
- * @param module The module which should be used for searching the new one. May be child of a different backend.
- * @return Pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findModuleByPointer(const CSwordModuleInfo* const module);
- /**
- * @return Our global config object which contains the configs of all modules merged together.
- */
- inline sword::SWConfig* getConfig() const;
- /**
- * Tries to find the config object for the module. The second paramter will be the found config.
- * @return True if the config was found, false if not. If false is returned the moduleConfig object is in undefined/unknwon state.
- */
- bool moduleConfig(const QString& module, sword::SWConfig& moduleConfig );
- /**
- * Returns the text used for the option given as parameter.
- * @param The paramter enum
- * @return The name of the option given by the parameter
- */
- static const QString optionName( const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the text used for the option given as parameter.
- */
- static const QString configOptionName( const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the translated name of the option given as parameter.
- * @param The translated option name
- */
- static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the version of the Sword library.
- * @return The version used by this backend
- */
- inline virtual const sword::SWVersion Version();
- /**
- * Reload all Sword modules.
- */
- void reloadModules(SetupChangedReason reason);
+ /**
+ * This function returns the list of available modules managed by this
+ * backend. You have to call initModules() first; This method is
+ * equivalent to model()->modules().
+ *
+ * @return The list of modules managed by this backend
+ */
+ inline const QList<CSwordModuleInfo*>& moduleList() const;
- /**
- * Takes off the given modules from the list and returns them.
- * User must take care of the deletion of the returned CSwordModuleInfo pointers.
- */
- QList<CSwordModuleInfo*> takeModulesFromList(QStringList names);
+ inline BtBookshelfModel *model();
- /** Sword prefix list.
- * @return A list of all known Sword prefix dirs
- */
- const QStringList swordDirList();
+ /**
+ * Initializes the Sword modules.
+ *
+ * @return True if the initializiation was succesful, otherwise return false.
+ */
+ CSwordBackend::LoadError initModules(SetupChangedReason reason);
+ /**
+ * This function deinitializes the modules and deletes them.
+ *
+ * @return True if it was succesful, otherwise return false
+ */
+ bool shutdownModules();
+ /**
+ * Sets the given options enabled or disabled depending on the second parameter.
+ *
+ * @param type This is the type this function should set enabled or disabled
+ * @param enable If this is true the option will be enabled, otherwise it will be disabled.
+ */
+ void setOption( const CSwordModuleInfo::FilterTypes type, const int state );
+ /** */
+ void setFilterOptions( const CSwordBackend::FilterOptions options );
+ /**
+ * Sets the language for the international booknames of Sword.
+ * @param langName The abbreviation string which should be used for the Sword backend
+ */
+ const QString booknameLanguage( const QString& langName = QString::null );
+ /**
+ * This function searches for a module with the specified description
+ * @param description The description of the desired module
+ * @return pointer to the desired module; null if no module has the specified description
+ */
+ CSwordModuleInfo* findModuleByDescription(const QString& description);
+ /**
+ * This function searches for a module with the specified description
+ * @param description The description of the desired module
+ * @return pointer to the desired module; null if no module has the specified description
+ */
+ const QString findModuleNameByDescription(const QString& description);
+ /**
+ * This function searches for a module with the specified name
+ * @param name The name of the desired module
+ * @return Pointer to the desired module; null if no module has the specified name
+ */
+ CSwordModuleInfo* findModuleByName(const QString& name);
+ /**
+ * This function searches for a module with the specified sword module as module() object!
+ * @param swmodule to a Sword module
+ * @return pointer to the desired module; null if no module has the specified name
+ */
+ CSwordModuleInfo* findSwordModuleByPointer(const sword::SWModule* const swmodule);
+ /**
+ * This function searches for a module which is the same as the passed module.
+ * @param module The module which should be used for searching the new one. May be child of a different backend.
+ * @return Pointer to the desired module; null if no module has the specified name
+ */
+ CSwordModuleInfo* findModuleByPointer(const CSwordModuleInfo* const module);
+ /**
+ * @return Our global config object which contains the configs of all modules merged together.
+ */
+ inline sword::SWConfig* getConfig() const;
+ /**
+ * Tries to find the config object for the module. The second paramter will be the found config.
+ * @return True if the config was found, false if not. If false is returned the moduleConfig object is in undefined/unknwon state.
+ */
+ bool moduleConfig(const QString& module, sword::SWConfig& moduleConfig );
+ /**
+ * Returns the text used for the option given as parameter.
+ * @param The paramter enum
+ * @return The name of the option given by the parameter
+ */
+ static const QString optionName( const CSwordModuleInfo::FilterTypes option );
+ /**
+ * Returns the text used for the option given as parameter.
+ */
+ static const QString configOptionName( const CSwordModuleInfo::FilterTypes option );
+ /**
+ * Returns the translated name of the option given as parameter.
+ * @param The translated option name
+ */
+ static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option );
+ /**
+ * Returns the version of the Sword library.
+ * @return The version used by this backend
+ */
+ inline const sword::SWVersion Version();
+ /**
+ * Reload all Sword modules.
+ */
+ void reloadModules(SetupChangedReason reason);
- /** Emits the sigSwordSetupChanged signal.
- * This can be called directly from outside if there is no need to reload the backend.
- */
- void notifyChange(SetupChangedReason reason);
+ /**
+ * Takes off the given modules from the list and returns them.
+ * User must take care of the deletion of the returned CSwordModuleInfo pointers.
+ */
+ QList<CSwordModuleInfo*> takeModulesFromList(QStringList names);
-signals:
- void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
+ /** Sword prefix list.
+ * @return A list of all known Sword prefix dirs
+ */
+ const QStringList swordDirList();
-protected:
- /**
- * Adds a render filter to the module.
- * This is used to apply our own render filters to our modules instead of the sword filters
- */
- virtual void AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section);
- /**
- * Overrides Sword filters which appear to be buggy.
- */
- virtual void filterInit();
+ /** Emits the sigSwordSetupChanged signal.
+ * This can be called directly from outside if there is no need to reload the backend.
+ */
+ void notifyChange(SetupChangedReason reason);
-private:
- // Filters
- struct Filters {
- sword::SWFilter* gbf;
- sword::SWFilter* plain;
- sword::SWFilter* thml;
- sword::SWFilter* osis;
- } m_filters;
+ signals:
+ void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
- struct Displays {
- Rendering::CChapterDisplay* chapter;
- Rendering::CEntryDisplay* entry;
- Rendering::CBookDisplay* book;
- } m_displays;
+ protected:
+ /**
+ * Adds a render filter to the module.
+ * This is used to apply our own render filters to our modules instead of the sword filters
+ */
+ void AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section);
+ /**
+ * Overrides Sword filters which appear to be buggy.
+ */
+ void filterInit();
- QList<CSwordModuleInfo*> m_moduleList;
- QMap<QString, QString> m_moduleDescriptionMap;
+ private:
+ // Filters
+ struct Filters {
+ sword::SWFilter* gbf;
+ sword::SWFilter* plain;
+ sword::SWFilter* thml;
+ sword::SWFilter* osis;
+ } m_filters;
+
+ struct Displays {
+ Rendering::CChapterDisplay* chapter;
+ Rendering::CEntryDisplay* entry;
+ Rendering::CBookDisplay* book;
+ } m_displays;
+
+ BtBookshelfModel m_dataModel;
+ QMap<QString, QString> m_moduleDescriptionMap;
};
/**Returns The list of modules managed by this backend*/
-inline QList<CSwordModuleInfo*>& CSwordBackend::moduleList() {
- return m_moduleList;
+inline const QList<CSwordModuleInfo*> &CSwordBackend::moduleList() const {
+ return m_dataModel.modules();
+}
+
+inline BtBookshelfModel *CSwordBackend::model() {
+ return &m_dataModel;
}
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
inline sword::SWConfig* CSwordBackend::getConfig() const {
- return config;
+ return config;
}
/** Returns the version of the Sword library. */
inline const sword::SWVersion CSwordBackend::Version() {
- return sword::SWVersion::currentVersion;
+ return sword::SWVersion::currentVersion;
}
#endif
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index fd57034..99990f8 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -18,119 +18,119 @@
/** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */
const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
- CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(modules.first());
- Q_ASSERT(book);
+ CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(modules.first());
+ Q_ASSERT(book);
- CSwordBackend::DisplayOptions dOpts = displayOptions;
- dOpts.lineBreaks = true; //books should render with blocks, not with inlined sections
+ CSwordBackend::DisplayOptions dOpts = displayOptions;
+ dOpts.lineBreaks = true; //books should render with blocks, not with inlined sections
- CDisplayRendering render(dOpts, filterOptions);
- CDisplayRendering::KeyTree tree;
- CDisplayRendering::KeyTreeItem::Settings itemSettings;
+ CDisplayRendering render(dOpts, filterOptions);
+ CDisplayRendering::KeyTree tree;
+ CDisplayRendering::KeyTreeItem::Settings itemSettings;
- // the number of levels which should be display together, 1 means display no entries together
- int displayLevel = book->config( CSwordModuleInfo::DisplayLevel ).toInt();
+ // the number of levels which should be display together, 1 means display no entries together
+ int displayLevel = book->config( CSwordModuleInfo::DisplayLevel ).toInt();
- boost::scoped_ptr<CSwordTreeKey> key (
- dynamic_cast<CSwordTreeKey*>( CSwordKey::createInstance(book) )
- );
- key->key(keyName); //set the key to position we'd like to get
+ boost::scoped_ptr<CSwordTreeKey> key (
+ dynamic_cast<CSwordTreeKey*>( CSwordKey::createInstance(book) )
+ );
+ key->key(keyName); //set the key to position we'd like to get
- const unsigned long offset = key->getOffset();
+ const unsigned long offset = key->getOffset();
- // standard of DisplayLevel, display nothing together
- // if the current key is the root entry don't display anything together!
+ // standard of DisplayLevel, display nothing together
+ // if the current key is the root entry don't display anything together!
- if ((displayLevel <= 1) || (key->key().isEmpty() || (key->key() == "/") )) {
- tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
+ if ((displayLevel <= 1) || (key->key().isEmpty() || (key->key() == "/") )) {
+ tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
- const QString renderedText = render.renderKeyTree(tree);
- key->setOffset( offset );
- return renderedText;
- };
+ const QString renderedText = render.renderKeyTree(tree);
+ key->setOffset( offset );
+ return renderedText;
+ };
- /**
- * Check whether displaying displayLevel levels together is possible.
- * For this count the childs and parents
- * of the required position
- */
+ /**
+ * Check whether displaying displayLevel levels together is possible.
+ * For this count the childs and parents
+ * of the required position
+ */
- int possibleLevels = 1; //we start with the default value of displayLevel, which means no entries together
+ int possibleLevels = 1; //we start with the default value of displayLevel, which means no entries together
- while( key->parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents
- ++possibleLevels;
- };
+ while ( key->parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents
+ ++possibleLevels;
+ };
- // key->key(keyName); //set the key to the start position
+ // key->key(keyName); //set the key to the start position
- key->setOffset( offset );
+ key->setOffset( offset );
- while( key->firstChild( )) { //add childs
- ++possibleLevels;
- };
+ while ( key->firstChild( )) { //add childs
+ ++possibleLevels;
+ };
- if (possibleLevels < displayLevel) { //too few levels available!
- //display current level, we could also decide to display the available levels together
- tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
+ if (possibleLevels < displayLevel) { //too few levels available!
+ //display current level, we could also decide to display the available levels together
+ tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
- const QString renderedText = render.renderKeyTree(tree);
- key->setOffset( offset );
- return renderedText;
- };
+ const QString renderedText = render.renderKeyTree(tree);
+ key->setOffset( offset );
+ return renderedText;
+ };
- if ((displayLevel > 2) && (displayLevel == possibleLevels)) { //fix not to diplay the whole module
- --displayLevel;
- }
+ if ((displayLevel > 2) && (displayLevel == possibleLevels)) { //fix not to diplay the whole module
+ --displayLevel;
+ }
- // at this point we're sure that we can display the required levels toogether
- // at the moment we're at the lowest level, so we only have to go up!
- for (int currentLevel = 1; currentLevel < displayLevel; ++currentLevel) { //we start again with 1 == standard of displayLevel
+ // at this point we're sure that we can display the required levels toogether
+ // at the moment we're at the lowest level, so we only have to go up!
+ for (int currentLevel = 1; currentLevel < displayLevel; ++currentLevel) { //we start again with 1 == standard of displayLevel
- if ( !key->parent() ) { //something went wrong although we checked before! Be safe and return entry's text
- tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
+ if ( !key->parent() ) { //something went wrong although we checked before! Be safe and return entry's text
+ tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
- const QString renderedText = render.renderKeyTree(tree);
- key->setOffset( offset );
- return renderedText;
- };
- };
+ const QString renderedText = render.renderKeyTree(tree);
+ key->setOffset( offset );
+ return renderedText;
+ };
+ };
- // no we can display all sub levels together! We checked before that this is possible!
- itemSettings.highlight = (key->key() == keyName);
+ // no we can display all sub levels together! We checked before that this is possible!
+ itemSettings.highlight = (key->key() == keyName);
- tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
+ tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
- //const bool hasToplevelText = !key->strippedText().isEmpty();
- key->firstChild(); //go to the first sibling on the same level
+ //const bool hasToplevelText = !key->strippedText().isEmpty();
+ key->firstChild(); //go to the first sibling on the same level
- setupRenderTree(key.get(), &tree, keyName);
+ setupRenderTree(key.get(), &tree, keyName);
- const QString renderedText = render.renderKeyTree(tree);
+ const QString renderedText = render.renderKeyTree(tree);
- key->setOffset( offset ); //restore key
+ key->setOffset( offset ); //restore key
- return renderedText;
+ return renderedText;
}
void Rendering::CBookDisplay::setupRenderTree(CSwordTreeKey * swordTree, CTextRendering::KeyTree * renderTree, const QString& highlightKey) {
- const QString key = swordTree->key();
- const unsigned long offset = swordTree->getOffset();
+ const QString key = swordTree->key();
+ const unsigned long offset = swordTree->getOffset();
- CTextRendering::KeyTreeItem::Settings settings;
- settings.highlight = (key == highlightKey);
+ CTextRendering::KeyTreeItem::Settings settings;
+ settings.highlight = (key == highlightKey);
- CTextRendering::KeyTreeItem* item = new CTextRendering::KeyTreeItem(key, swordTree->module(0), settings );
- renderTree->append( item );
+ CTextRendering::KeyTreeItem* item = new CTextRendering::KeyTreeItem(key, swordTree->module(0), settings );
+ renderTree->append( item );
- if (swordTree->hasChildren()) { //print tree for the child items
- swordTree->firstChild();
- setupRenderTree(swordTree, item->childList(), highlightKey);
- swordTree->setOffset( offset ); //go back where we came from
- }
+ if (swordTree->hasChildren()) { //print tree for the child items
+ swordTree->firstChild();
+ setupRenderTree(swordTree, item->childList(), highlightKey);
+ swordTree->setOffset( offset ); //go back where we came from
+ }
- if (swordTree->nextSibling()) { //print tree for next entry on the same depth
- setupRenderTree(swordTree, renderTree, highlightKey);
- swordTree->setOffset( offset ); //return to the value we had at the beginning of this block!
- }
+ if (swordTree->nextSibling()) { //print tree for next entry on the same depth
+ setupRenderTree(swordTree, renderTree, highlightKey);
+ swordTree->setOffset( offset ); //return to the value we had at the beginning of this block!
+ }
}
diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h
index 6f0b031..35d7221 100644
--- a/src/backend/rendering/cbookdisplay.h
+++ b/src/backend/rendering/cbookdisplay.h
@@ -11,7 +11,7 @@
#define RENDERINGCBOOKDISPLAY_H
#include "centrydisplay.h"
-#include "ctextrendering.h"
+#include "ctextrendering.h"
//TODO: It would be sufficient to forward declare CTextRendering and CTextRendering::KeyTree
//but I don't know how :(
@@ -19,25 +19,25 @@ class CSwordTreeKey;
namespace Rendering {
- /**
- * A CEntryDisplay implementation which works on tree-based GenBook modules
- * of Sword.
- * @short CEntryDisplay implementation for GenBook modules,
- * @author The BibleTime team
- */
+/**
+* A CEntryDisplay implementation which works on tree-based GenBook modules
+* of Sword.
+* @short CEntryDisplay implementation for GenBook modules,
+* @author The BibleTime team
+*/
class CBookDisplay : public CEntryDisplay {
-public: // Public methods
- virtual ~CBookDisplay() {}
+ public: // Public methods
+ virtual ~CBookDisplay() {}
- /**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
- */
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
+ /**
+ * Returns the rendered text using the modules in the list and using the key parameter.
+ * The displayoptions and filter options are used, too.
+ */
+ virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
-protected:
- void setupRenderTree(CSwordTreeKey* swordTree, CTextRendering::KeyTree* renderTree, const QString& highlightKey);
+ protected:
+ void setupRenderTree(CSwordTreeKey* swordTree, CTextRendering::KeyTree* renderTree, const QString& highlightKey);
};
}
diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp
index 921ed78..f96bada 100644
--- a/src/backend/rendering/cchapterdisplay.cpp
+++ b/src/backend/rendering/cchapterdisplay.cpp
@@ -14,46 +14,46 @@
#include "backend/drivers/cswordbiblemoduleinfo.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 );
- Q_ASSERT( !keyName.isEmpty() );
+ Q_ASSERT( modules.count() >= 1 );
+ Q_ASSERT( !keyName.isEmpty() );
- CSwordModuleInfo* module = modules.first();
+ CSwordModuleInfo* module = modules.first();
- if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses
+ if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses
- CTextRendering::KeyTreeItem::Settings settings;
- settings.keyRenderingFace =
- displayOptions.verseNumbers
- ? CTextRendering::KeyTreeItem::Settings::SimpleKey
- : CTextRendering::KeyTreeItem::Settings::NoKey;
+ CTextRendering::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace =
+ displayOptions.verseNumbers
+ ? CTextRendering::KeyTreeItem::Settings::SimpleKey
+ : CTextRendering::KeyTreeItem::Settings::NoKey;
- QString startKey = keyName;
- QString endKey = startKey;
+ QString startKey = keyName;
+ QString endKey = startKey;
- //check whether there's an intro we have to include
- Q_ASSERT((module->type() == CSwordModuleInfo::Bible));
+ //check whether there's an intro we have to include
+ Q_ASSERT((module->type() == CSwordModuleInfo::Bible));
- if (module->type() == CSwordModuleInfo::Bible) {
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ if (module->type() == CSwordModuleInfo::Bible) {
+ ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
- Q_ASSERT(bible);
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
+ Q_ASSERT(bible);
- CSwordVerseKey k1(module);
- k1.Headings(1);
- k1.key(keyName);
+ CSwordVerseKey k1(module);
+ k1.Headings(1);
+ k1.key(keyName);
- if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0
-
- k1.Verse(0);
+ if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0
- startKey = k1.key();
-
- if (k1.Chapter() == 0) k1.Chapter(1);
- k1.Verse(bible->verseCount(k1.book(), k1.Chapter()));
- endKey = k1.key();
- }
+ k1.Verse(0);
- CDisplayRendering render(displayOptions, filterOptions);
- return render.renderKeyRange( startKey, endKey, modules, keyName, settings );
+ startKey = k1.key();
+
+ if (k1.Chapter() == 0) k1.Chapter(1);
+ k1.Verse(bible->verseCount(k1.book(), k1.Chapter()));
+ endKey = k1.key();
+ }
+
+ CDisplayRendering render(displayOptions, filterOptions);
+ return render.renderKeyRange( startKey, endKey, modules, keyName, settings );
}
diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h
index cf00adf..916f257 100644
--- a/src/backend/rendering/cchapterdisplay.h
+++ b/src/backend/rendering/cchapterdisplay.h
@@ -22,14 +22,14 @@ namespace Rendering {
class CChapterDisplay : public CEntryDisplay {
-public: // Public methods
- virtual ~CChapterDisplay() {}
-
- /**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
- */
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
+ public: // Public methods
+ virtual ~CChapterDisplay() {}
+
+ /**
+ * Returns the rendered text using the modules in the list and using the key parameter.
+ * The displayoptions and filter options are used, too.
+ */
+ virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
};
}
diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp
index 32444b4..e648303 100644
--- a/src/backend/rendering/cdisplayrendering.cpp
+++ b/src/backend/rendering/cdisplayrendering.cpp
@@ -23,139 +23,139 @@
namespace Rendering {
- CDisplayRendering::CDisplayRendering(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
-: CHTMLExportRendering(CHTMLExportRendering::Settings(true), displayOptions, filterOptions) {}
+CDisplayRendering::CDisplayRendering(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
+ : CHTMLExportRendering(CHTMLExportRendering::Settings(true), displayOptions, filterOptions) {}
+
+const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) {
+ QString linkText;
+
+ const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
+ CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
+ vk.Headings(true);
+
+ if (isBible) {
+ vk.key(item.key());
+ }
+
+ if (isBible && (vk.Verse() == 0)) {
+ return QString::null; //Warning: return already here
+ }
+
+ switch (item.settings().keyRenderingFace) {
+
+ case KeyTreeItem::Settings::NoKey: {
+ linkText = QString::null;
+ break; //no key is valid for all modules
+ }
+
+ case KeyTreeItem::Settings::CompleteShort: {
+ if (isBible) {
+ linkText = QString::fromUtf8(vk.getShortText());
+ break;
+ }
+
+ //fall through for non-Bible modules
+ }
+
+ case KeyTreeItem::Settings::CompleteLong: {
+ if (isBible) {
+ linkText = vk.key();
+ break;
+ }
+
+ //fall through for non-Bible modules
+ }
+
+ case KeyTreeItem::Settings::SimpleKey: {
+ if (isBible) {
+ linkText = QString::number(vk.Verse());
+ break;
+ }
+
+ //fall through for non-Bible modules
+ }
+
+ default: { //default behaviour to return the passed key
+ linkText = item.key();
+ break;
+ }
+ }
+
+
+ if (linkText.isEmpty()) {
+ return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\"></a>");
+ }
+ else {
+ return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" ")
+ .append("href=\"")
+ .append(CReferenceManager::encodeHyperlink(
+ module->name(), item.key(), CReferenceManager::typeFromModule(module->type()))
+ )
+ .append("\">").append(linkText).append("</a>\n");
+ }
+
+ return QString::null;
+}
+
+const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) {
+ QString ret = key;
+ // Be careful not to remove non-ASCII characters, this causes problems
+ // with many languages.
+ ret = ret.trimmed().remove(QRegExp("\\s")).replace(QString(":"), QString("_"));
+
+ return ret;
+}
+
+const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
+ QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ qDebug("CDisplayRendering::finishText");
+
+ //marking words is very slow, we have to find a better solution
+
+ /*
+ //mark all words by spans
+
+ QString text = oldText;
+
+ QRegExp re("(\\b)(?=\\w)"); //word begin marker
+ int pos = text.find(re, 0);
- const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) {
- QString linkText;
-
- const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
- CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
- vk.Headings(true);
-
- if (isBible) {
- vk.key(item.key());
- }
-
- if (isBible && (vk.Verse() == 0)) {
- return QString::null; //Warning: return already here
- }
-
- switch (item.settings().keyRenderingFace) {
-
- case KeyTreeItem::Settings::NoKey: {
- linkText = QString::null;
- break; //no key is valid for all modules
- }
-
- case KeyTreeItem::Settings::CompleteShort: {
- if (isBible) {
- linkText = QString::fromUtf8(vk.getShortText());
- break;
- }
-
- //fall through for non-Bible modules
- }
-
- case KeyTreeItem::Settings::CompleteLong: {
- if (isBible) {
- linkText = vk.key();
- break;
- }
-
- //fall through for non-Bible modules
- }
-
- case KeyTreeItem::Settings::SimpleKey: {
- if (isBible) {
- linkText = QString::number(vk.Verse());
- break;
- }
-
- //fall through for non-Bible modules
- }
-
- default: { //default behaviour to return the passed key
- linkText = item.key();
- break;
- }
- }
-
-
- if (linkText.isEmpty()) {
- return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\"></a>");
- }
- else {
- return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" ")
- .append("href=\"")
- .append(CReferenceManager::encodeHyperlink(
- module->name(), item.key(), CReferenceManager::typeFromModule(module->type()))
- )
- .append("\">").append(linkText).append("</a>\n");
- }
-
- return QString::null;
- }
-
- const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) {
- QString ret = key;
- // Be careful not to remove non-ASCII characters, this causes problems
- // with many languages.
- ret = ret.trimmed().remove(QRegExp("\\s")).replace(QString(":"), QString("_"));
-
- return ret;
- }
-
- const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
- qDebug("CDisplayRendering::finishText");
-
- //marking words is very slow, we have to find a better solution
-
- /*
- //mark all words by spans
-
- QString text = oldText;
-
- QRegExp re("(\\b)(?=\\w)"); //word begin marker
- int pos = text.find(re, 0);
-
- 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
- //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
- text.insert(endPos, "</span>");
- text.insert(pos, "<span class=\"word\">");
-
- endPos += 26;
- }
- }
- pos = text.find(re, endPos);
- }
- */
- const CLanguageMgr::Language* const lang =
- (modules.count() >= 1)
- ? modules.first()->language()
- : CPointers::languageMgr()->defaultLanguage();
-
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
-
- //Q_ASSERT(modules.count() >= 1);
-
- CDisplayTemplateMgr::Settings settings;
- settings.modules = modules;
- settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : QString::null;
-
- if (modules.count() == 1)
- settings.pageDirection = (modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl";
- else
- settings.pageDirection = QString::null;
-
- return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), oldText, settings);
- }
+ 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
+ //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
+ text.insert(endPos, "</span>");
+ text.insert(pos, "<span class=\"word\">");
+
+ endPos += 26;
+ }
+ }
+ pos = text.find(re, endPos);
+ }
+ */
+ const CLanguageMgr::Language* const lang =
+ (modules.count() >= 1)
+ ? modules.first()->language()
+ : CPointers::languageMgr()->defaultLanguage();
+
+ CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+
+ //Q_ASSERT(modules.count() >= 1);
+
+ CDisplayTemplateMgr::Settings settings;
+ settings.modules = modules;
+ settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : QString::null;
+
+ if (modules.count() == 1)
+ settings.pageDirection = (modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl";
+ else
+ settings.pageDirection = QString::null;
+
+ return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), oldText, settings);
+}
}
diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h
index 9c4451b..d52d6b7 100644
--- a/src/backend/rendering/cdisplayrendering.h
+++ b/src/backend/rendering/cdisplayrendering.h
@@ -20,17 +20,17 @@ namespace Rendering {
*/
class CDisplayRendering : public CHTMLExportRendering {
-public:
- static const QString keyToHTMLAnchor(const QString& key);
+ public:
+ static const QString keyToHTMLAnchor(const QString& key);
- CDisplayRendering(
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
- );
+ CDisplayRendering(
+ CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ );
-protected:
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* const module );
- virtual const QString finishText( const QString&, KeyTree& tree );
+ protected:
+ virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* const module );
+ virtual const QString finishText( const QString&, KeyTree& tree );
};
}
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index 7a4626c..89743e2 100644
--- a/src/backend/rendering/centrydisplay.cpp
+++ b/src/backend/rendering/centrydisplay.cpp
@@ -27,37 +27,37 @@
using namespace Rendering;
/** Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
+ * The displayoptions and filter options are used, too.
*/
const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
- CDisplayRendering render(displayOptions, filterOptions);
-
- //no highlighted key and no extra key link in the text
- CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
- CSwordModuleInfo* module = modules.first();
- QString result;
-
- //in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
- if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) {
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
-
- CSwordVerseKey k1(module);
- k1.Headings(1);
- k1.key(keyName);
-
- // don't print the key
- CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey);
-
- if (k1.Verse() == 1){ //X:1, prepend X:0
- 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 ) );
- k1.Chapter(1);
- }
- k1.Verse(0);
- if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
- }
- }
- return result.append( render.renderSingleKey(keyName, modules, normal_settings) );
+ CDisplayRendering render(displayOptions, filterOptions);
+
+ //no highlighted key and no extra key link in the text
+ CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
+ CSwordModuleInfo* module = modules.first();
+ QString result;
+
+ //in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
+ if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) {
+ ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+
+ CSwordVerseKey k1(module);
+ k1.Headings(1);
+ k1.key(keyName);
+
+ // don't print the key
+ CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey);
+
+ if (k1.Verse() == 1) { //X:1, prepend X:0
+ 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 ) );
+ k1.Chapter(1);
+ }
+ k1.Verse(0);
+ if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
+ }
+ }
+ return result.append( render.renderSingleKey(keyName, modules, normal_settings) );
}
diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h
index 96f0dba..0c451b4 100644
--- a/src/backend/rendering/centrydisplay.h
+++ b/src/backend/rendering/centrydisplay.h
@@ -35,14 +35,14 @@ namespace Rendering {
class CEntryDisplay : public sword::SWDisplay, public CPointers {
-public:
- virtual ~CEntryDisplay() {}
-
- /**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
- */
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
+ public:
+ virtual ~CEntryDisplay() {}
+
+ /**
+ * Returns the rendered text using the modules in the list and using the key parameter.
+ * The displayoptions and filter options are used, too.
+ */
+ virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
};
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 38a83d3..7a0833a 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -27,208 +27,208 @@ namespace {
*/
void dumpEntryAttributes(sword::SWModule *module) {
- std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
- sword::AttributeTypeList::iterator i1;
- sword::AttributeList::iterator i2;
- sword::AttributeValue::iterator i3;
- for (i1 = module->getEntryAttributes().begin(); i1 != module->getEntryAttributes().end(); i1++) {
- std::cout << "[ " << i1->first << " ]\n";
- for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
- std::cout << "\t[ " << i2->first << " ]\n";
- for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
- std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
- }
- }
- }
- std::cout << std::endl;
+ std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+ sword::AttributeTypeList::iterator i1;
+ sword::AttributeList::iterator i2;
+ sword::AttributeValue::iterator i3;
+ for (i1 = module->getEntryAttributes().begin(); i1 != module->getEntryAttributes().end(); i1++) {
+ std::cout << "[ " << i1->first << " ]\n";
+ for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
+ std::cout << "\t[ " << i2->first << " ]\n";
+ for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
+ std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+ }
+ }
+ }
+ std::cout << std::endl;
}
}
namespace Rendering {
- CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
-: m_displayOptions(displayOptions),
- m_filterOptions(filterOptions),
- m_settings(settings) {}
-
- CHTMLExportRendering::~CHTMLExportRendering() {}
-
- const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) {
-
- if (i.hasAlternativeContent()) {
- QString ret = QString(i.settings().highlight ? "<div class=\"currententry\">" : "<div class=\"entry\">");
- ret.append(i.getAlternativeContent());
-
- // Q_ASSERT(i.hasChildItems());
-
- if (!i.childList()->isEmpty()) {
- KeyTree * const tree = i.childList();
-
- const QList<CSwordModuleInfo*> modules = collectModules(tree);
-
- if (modules.count() == 1) { //insert the direction into the sorrounding div
- ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" ));
- }
-
- foreach ( KeyTreeItem* c, (*tree) ) {
- ret.append( renderEntry( *c ) );
- }
- }
-
- ret.append("</div>");
- return ret; //WARNING: Return already here!
- }
-
-
- const QList<CSwordModuleInfo*>& modules( i.modules() );
- if (modules.count() == 0) {
- return QString(""); //no module present for rendering
- }
-
- boost::scoped_ptr<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
- CSwordKey* key = k ? k : scoped_key.get();
- Q_ASSERT(key);
-
- CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key);
-
- if ( myVK ) myVK->Headings(1);
-
- QString renderedText( (modules.count() > 1) ? "\n\t\t<tr>\n" : "\n" );
- // Only insert the table stuff if we are displaying parallel.
-
- //declarations out of the loop for optimization
- QString entry;
- QString keyText;
- bool isRTL;
- QString preverseHeading;
- QString langAttr;
- QString key_renderedText;
-
- QList<CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
-
- for (QList<CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
- key->module(*mod_Itr);
- key->key( i.key() );
-
- keyText = key->key();
- isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft);
- entry = QString::null;
-
- if ((*mod_Itr)->language()->isValid()) {
- langAttr = QString("xml:lang=\"")
- .append((*mod_Itr)->language()->abbrev())
- .append("\" lang=\"")
- .append((*mod_Itr)->language()->abbrev())
- .append("\"");
- }
- else {
- langAttr = QString("xml:lang=\"")
- .append((*mod_Itr)->module()->Lang())
- .append("\" lang=\"")
- .append((*mod_Itr)->module()->Lang())
- .append("\"");
- }
-
- key_renderedText = key->renderedText();
-
- if (m_filterOptions.headings) {
- (*mod_Itr)->module()->RenderText();
- sword::AttributeValue::const_iterator it =
- (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin();
- const sword::AttributeValue::const_iterator end =
- (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end();
-
- for (; it != end; ++it) {
- preverseHeading = QString::fromUtf8(it->second.c_str());
- //TODO: Take care of the heading type!
- if (!preverseHeading.isEmpty()) {
- entry.append("<div ")
- .append(langAttr)
- .append(" class=\"sectiontitle\">")
- .append(preverseHeading)
- .append("</div>");
- }
- }
- }
-
- entry.append(m_displayOptions.lineBreaks ? "<div " : "<div style=\"display: inline;\" ");
-
- if (modules.count() == 1) { //insert only the class if we're not in a td
- entry.append( i.settings().highlight ? "class=\"currententry\" " : "class=\"entry\" " );
- }
-
- entry.append(langAttr).append(isRTL ? " dir=\"rtl\"" : " dir=\"ltr\"").append(">");
-
- //keys should normally be left-to-right, but this doesn't apply in all cases
- entry.append("<span class=\"entryname\" dir=\"ltr\">").append(entryLink(i, *mod_Itr)).append("</span>");
-
- if (m_settings.addText) {
- //entry.append( QString::fromLatin1("<span %1>%2</span>").arg(langAttr).arg(key_renderedText) );
- entry.append( key_renderedText );
- }
-
- if (!i.childList()->isEmpty()) {
- KeyTree* tree(i.childList());
-
- foreach (KeyTreeItem* c, (*tree)) {
- entry.append( renderEntry(*c) );
- }
- }
-
- entry.append("</div>");
-
- if (modules.count() == 1) {
- renderedText.append( "\t\t" ).append( entry ).append("\n");
- }
- else {
- renderedText.append("\t\t<td class=\"")
- .append(i.settings().highlight ? "currententry" : "entry")
- .append("\" ")
- .append(langAttr)
- .append(" dir=\"")
- .append(isRTL ? "rtl" : "ltr")
- .append("\">\n")
- .append( "\t\t\t" ).append( entry ).append("\n")
- .append("\t\t</td>\n");
- }
- }
-
- if (modules.count() > 1) {
- renderedText.append("\t\t</tr>\n");
- }
-
- // qDebug("CHTMLExportRendering: %s", renderedText.latin1());
- return renderedText;
+CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
+ : m_displayOptions(displayOptions),
+ m_filterOptions(filterOptions),
+ m_settings(settings) {}
+
+CHTMLExportRendering::~CHTMLExportRendering() {}
+
+const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) {
+
+ if (i.hasAlternativeContent()) {
+ QString ret = QString(i.settings().highlight ? "<div class=\"currententry\">" : "<div class=\"entry\">");
+ ret.append(i.getAlternativeContent());
+
+ // Q_ASSERT(i.hasChildItems());
+
+ if (!i.childList()->isEmpty()) {
+ KeyTree * const tree = i.childList();
+
+ const QList<CSwordModuleInfo*> modules = collectModules(tree);
+
+ if (modules.count() == 1) { //insert the direction into the sorrounding div
+ ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" ));
+ }
+
+ foreach ( KeyTreeItem* c, (*tree) ) {
+ ret.append( renderEntry( *c ) );
+ }
+ }
+
+ ret.append("</div>");
+ return ret; //WARNING: Return already here!
+ }
+
+
+ const QList<CSwordModuleInfo*>& modules( i.modules() );
+ if (modules.count() == 0) {
+ return QString(""); //no module present for rendering
+ }
+
+ boost::scoped_ptr<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
+ CSwordKey* key = k ? k : scoped_key.get();
+ Q_ASSERT(key);
+
+ CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key);
+
+ if ( myVK ) myVK->Headings(1);
+
+ QString renderedText( (modules.count() > 1) ? "\n\t\t<tr>\n" : "\n" );
+ // Only insert the table stuff if we are displaying parallel.
+
+ //declarations out of the loop for optimization
+ QString entry;
+ QString keyText;
+ bool isRTL;
+ QString preverseHeading;
+ QString langAttr;
+ QString key_renderedText;
+
+ QList<CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
+
+ for (QList<CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
+ key->module(*mod_Itr);
+ key->key( i.key() );
+
+ keyText = key->key();
+ isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft);
+ entry = QString::null;
+
+ if ((*mod_Itr)->language()->isValid()) {
+ langAttr = QString("xml:lang=\"")
+ .append((*mod_Itr)->language()->abbrev())
+ .append("\" lang=\"")
+ .append((*mod_Itr)->language()->abbrev())
+ .append("\"");
+ }
+ else {
+ langAttr = QString("xml:lang=\"")
+ .append((*mod_Itr)->module()->Lang())
+ .append("\" lang=\"")
+ .append((*mod_Itr)->module()->Lang())
+ .append("\"");
+ }
+
+ key_renderedText = key->renderedText();
+
+ if (m_filterOptions.headings) {
+ (*mod_Itr)->module()->RenderText();
+ sword::AttributeValue::const_iterator it =
+ (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin();
+ const sword::AttributeValue::const_iterator end =
+ (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end();
+
+ for (; it != end; ++it) {
+ preverseHeading = QString::fromUtf8(it->second.c_str());
+ //TODO: Take care of the heading type!
+ if (!preverseHeading.isEmpty()) {
+ entry.append("<div ")
+ .append(langAttr)
+ .append(" class=\"sectiontitle\">")
+ .append(preverseHeading)
+ .append("</div>");
+ }
+ }
+ }
+
+ entry.append(m_displayOptions.lineBreaks ? "<div " : "<div style=\"display: inline;\" ");
+
+ if (modules.count() == 1) { //insert only the class if we're not in a td
+ entry.append( i.settings().highlight ? "class=\"currententry\" " : "class=\"entry\" " );
+ }
+
+ entry.append(langAttr).append(isRTL ? " dir=\"rtl\"" : " dir=\"ltr\"").append(">");
+
+ //keys should normally be left-to-right, but this doesn't apply in all cases
+ entry.append("<span class=\"entryname\" dir=\"ltr\">").append(entryLink(i, *mod_Itr)).append("</span>");
+
+ if (m_settings.addText) {
+ //entry.append( QString::fromLatin1("<span %1>%2</span>").arg(langAttr).arg(key_renderedText) );
+ entry.append( key_renderedText );
+ }
+
+ if (!i.childList()->isEmpty()) {
+ KeyTree* tree(i.childList());
+
+ foreach (KeyTreeItem* c, (*tree)) {
+ entry.append( renderEntry(*c) );
+ }
+ }
+
+ entry.append("</div>");
+
+ if (modules.count() == 1) {
+ renderedText.append( "\t\t" ).append( entry ).append("\n");
+ }
+ else {
+ renderedText.append("\t\t<td class=\"")
+ .append(i.settings().highlight ? "currententry" : "entry")
+ .append("\" ")
+ .append(langAttr)
+ .append(" dir=\"")
+ .append(isRTL ? "rtl" : "ltr")
+ .append("\">\n")
+ .append( "\t\t\t" ).append( entry ).append("\n")
+ .append("\t\t</td>\n");
+ }
+ }
+
+ if (modules.count() > 1) {
+ renderedText.append("\t\t</tr>\n");
+ }
+
+ // qDebug("CHTMLExportRendering: %s", renderedText.latin1());
+ return renderedText;
}
void CHTMLExportRendering::initRendering() {
- //CPointers::backend()->setDisplayOptions( m_displayOptions );
- CPointers::backend()->setFilterOptions( m_filterOptions );
+ //CPointers::backend()->setDisplayOptions( m_displayOptions );
+ CPointers::backend()->setFilterOptions( m_filterOptions );
}
const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tree ) {
- const QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ const QList<CSwordModuleInfo*> modules = collectModules(&tree);
- const CLanguageMgr::Language* const lang = modules.first()->language();
+ const CLanguageMgr::Language* const lang = modules.first()->language();
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
- CDisplayTemplateMgr::Settings settings;
- settings.modules = modules;
- settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : "unknown";
- if (modules.count() == 1)
- settings.pageDirection = ((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl");
- else
- settings.pageDirection = QString::null;
+ CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr::Settings settings;
+ settings.modules = modules;
+ settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : "unknown";
+ if (modules.count() == 1)
+ settings.pageDirection = ((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl");
+ else
+ settings.pageDirection = QString::null;
- return tMgr->fillTemplate(QObject::tr("Export"), text, settings);
+ return tMgr->fillTemplate(QObject::tr("Export"), text, settings);
}
/*!
\fn CHTMLExportRendering::entryLink( KeyTreeItem& item )
*/
const QString CHTMLExportRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* ) {
- return item.key();
+ return item.key();
}
}//end of namespace "Rendering"
diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h
index 6a8153e..2240cda 100644
--- a/src/backend/rendering/chtmlexportrendering.h
+++ b/src/backend/rendering/chtmlexportrendering.h
@@ -17,40 +17,40 @@
namespace Rendering {
- /**
- * This CTextRenerding implementation
- * creates HTML specially made for export as HTML files.
- * @short HTML rendering for export.
- * @author The BibleTime team
- */
+/**
+ * This CTextRenerding implementation
+ * creates HTML specially made for export as HTML files.
+ * @short HTML rendering for export.
+ * @author The BibleTime team
+ */
class CHTMLExportRendering : public CTextRendering {
-public:
- struct Settings {
- Settings(const bool text = true) {
- addText = text;
- };
-
- bool addText;
- };
-
- CHTMLExportRendering(
- const Settings& settings,
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
- );
- virtual ~CHTMLExportRendering();
-
-protected:
- virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
- virtual const QString finishText( const QString&, KeyTree& tree );
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
- virtual void initRendering();
-
- CSwordBackend::DisplayOptions m_displayOptions;
- CSwordBackend::FilterOptions m_filterOptions;
- Settings m_settings;
+ public:
+ struct Settings {
+ Settings(const bool text = true) {
+ addText = text;
+ };
+
+ bool addText;
+ };
+
+ CHTMLExportRendering(
+ const Settings& settings,
+ CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ );
+ virtual ~CHTMLExportRendering();
+
+ protected:
+ virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
+ virtual const QString finishText( const QString&, KeyTree& tree );
+ virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
+ virtual void initRendering();
+
+ CSwordBackend::DisplayOptions m_displayOptions;
+ CSwordBackend::FilterOptions m_filterOptions;
+ Settings m_settings;
};
}
diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp
index d99cff3..dbcbff6 100644
--- a/src/backend/rendering/cplaintextexportrendering.cpp
+++ b/src/backend/rendering/cplaintextexportrendering.cpp
@@ -17,37 +17,37 @@
namespace Rendering {
CPlainTextExportRendering::CPlainTextExportRendering(const CPlainTextExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
- : CHTMLExportRendering(settings, displayOptions, filterOptions) {}
+ : CHTMLExportRendering(settings, displayOptions, filterOptions) {}
CPlainTextExportRendering::~CPlainTextExportRendering() {}
const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* ) {
- if (!m_settings.addText) {
- return QString(i.key()).append("\n");
- }
+ if (!m_settings.addText) {
+ return QString(i.key()).append("\n");
+ }
- QList<CSwordModuleInfo*> modules = i.modules();
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(modules.first()) );
- QString renderedText = QString(i.key()).append(":\n");
+ QList<CSwordModuleInfo*> modules = i.modules();
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(modules.first()) );
+ QString renderedText = QString(i.key()).append(":\n");
- QString entry;
- // for (CSwordModuleInfo* m = modules.first(); m; m = modules.next()) {
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+ QString entry;
+ // for (CSwordModuleInfo* m = modules.first(); m; m = modules.next()) {
+ QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- key->module(*it);
- key->key( i.key() );
+ for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ key->module(*it);
+ key->key( i.key() );
- //ToDo: Check this code
- entry.append(key->strippedText()).append("\n");
- renderedText.append( entry );
- }
+ //ToDo: Check this code
+ entry.append(key->strippedText()).append("\n");
+ renderedText.append( entry );
+ }
- return renderedText;
+ return renderedText;
}
const QString CPlainTextExportRendering::finishText( const QString& oldText, KeyTree& ) {
- return oldText;
+ return oldText;
}
}
diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h
index 9ec388b..acd6054 100644
--- a/src/backend/rendering/cplaintextexportrendering.h
+++ b/src/backend/rendering/cplaintextexportrendering.h
@@ -14,25 +14,25 @@
namespace Rendering {
- /**
- * This implementation can be used to export content as plain text.
- * @short Text rendering as plain text.
- * @author The BibleTime team
- */
+/**
+ * This implementation can be used to export content as plain text.
+ * @short Text rendering as plain text.
+ * @author The BibleTime team
+ */
class CPlainTextExportRendering : public CHTMLExportRendering {
-public:
- CPlainTextExportRendering(
- const Settings& settings,
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
- );
- virtual ~CPlainTextExportRendering();
-
-protected:
- virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
- virtual const QString finishText( const QString&, KeyTree& tree );
+ public:
+ CPlainTextExportRendering(
+ const Settings& settings,
+ CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ );
+ virtual ~CPlainTextExportRendering();
+
+ protected:
+ virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
+ virtual const QString finishText( const QString&, KeyTree& tree );
};
}
diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp
index c7ac0bd..5fce14b 100644
--- a/src/backend/rendering/ctextrendering.cpp
+++ b/src/backend/rendering/ctextrendering.cpp
@@ -29,235 +29,231 @@
using namespace Rendering;
CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, CSwordModuleInfo const * mod, const Settings settings )
- : m_settings( settings ),
- m_moduleList(),
- m_key( key ),
- m_childList(),
- m_stopKey( QString::null ),
- m_alternativeContent( QString::null )
-{
- m_moduleList.append( const_cast<CSwordModuleInfo*>(mod) ); //BAD CODE
+ : m_settings( settings ),
+ m_moduleList(),
+ m_key( key ),
+ m_childList(),
+ m_stopKey( QString::null ),
+ m_alternativeContent( QString::null ) {
+ m_moduleList.append( const_cast<CSwordModuleInfo*>(mod) ); //BAD CODE
}
CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings settings )
- : m_settings( settings ),
- m_moduleList(),
- m_key( QString::null ),
- m_childList(),
- m_stopKey( QString::null ),
- m_alternativeContent( content )
-{
+ : m_settings( settings ),
+ m_moduleList(),
+ m_key( QString::null ),
+ m_childList(),
+ m_stopKey( QString::null ),
+ m_alternativeContent( content ) {
}
CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, const QList<CSwordModuleInfo*>& mods, const Settings settings )
- : m_settings( settings ),
- m_moduleList( mods ),
- m_key( key ),
- m_childList(),
- m_stopKey( QString::null ),
- m_alternativeContent( QString::null )
-{
+ : m_settings( settings ),
+ m_moduleList( mods ),
+ m_key( key ),
+ m_childList(),
+ m_stopKey( QString::null ),
+ m_alternativeContent( QString::null ) {
}
CTextRendering::KeyTreeItem::KeyTreeItem()
- : m_settings(),
- m_moduleList(),
- m_key(QString::null),
- m_childList(),
- m_stopKey(QString::null),
- m_alternativeContent(QString::null)
-{
+ : m_settings(),
+ m_moduleList(),
+ m_key(QString::null),
+ m_childList(),
+ m_stopKey(QString::null),
+ m_alternativeContent(QString::null) {
}
CTextRendering::KeyTreeItem::KeyTreeItem(const KeyTreeItem& i)
- : m_settings( i.m_settings ),
- m_moduleList( i.m_moduleList ),
- m_key( i.m_key ),
- m_childList(),
- m_stopKey( i.m_stopKey ),
- m_alternativeContent( i.m_alternativeContent )
-{
- foreach(KeyTreeItem* item, (*i.childList())){
- m_childList.append(new KeyTreeItem((*item))); //deep copy
- }
+ : m_settings( i.m_settings ),
+ m_moduleList( i.m_moduleList ),
+ m_key( i.m_key ),
+ m_childList(),
+ m_stopKey( i.m_stopKey ),
+ m_alternativeContent( i.m_alternativeContent ) {
+ foreach(KeyTreeItem* item, (*i.childList())) {
+ m_childList.append(new KeyTreeItem((*item))); //deep copy
+ }
}
CTextRendering::KeyTreeItem::~KeyTreeItem() {
- qDeleteAll(m_childList);
+ qDeleteAll(m_childList);
}
CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings)
-: m_settings( settings ),
-m_moduleList(),
-m_key( startKey ),
-m_childList(),
-m_stopKey( stopKey ),
-m_alternativeContent( QString::null ) {
- Q_ASSERT(module);
- m_moduleList.append(module);
-
- //use the start and stop key to ceate our child items
-
- if (module->type() == CSwordModuleInfo::Bible) {
- CSwordVerseKey start(module);
- start.key(startKey);
-
- CSwordVerseKey stop(module);
- stop.key(stopKey);
-
- if (!m_key.isEmpty() && !m_stopKey.isEmpty()) { //we have a range of keys
- bool ok = true;
-
- while (ok && ((start < stop) || (start == stop)) ) { //range
- m_childList.append(
- new KeyTreeItem(start.key(), module, KeyTreeItem::Settings(false, settings.keyRenderingFace))
- );
-
-
- ok = start.next(CSwordVerseKey::UseVerse);
- }
- }
- else if (m_key.isEmpty()) {
- m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, settings.keyRenderingFace)) );
- }
- }
- else if ((module->type() == CSwordModuleInfo::Lexicon) || (module->type() == CSwordModuleInfo::Commentary) ) {
- m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) );
- }
- else if (module->type() == CSwordModuleInfo::GenericBook) {
- m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) );
- }
-
- //make it into "<simple|range> (modulename)"
-
- if (startKey == stopKey) {
- m_alternativeContent = startKey;
- }
- else {
- sword::VerseKey vk(startKey.toUtf8().constData(), stopKey.toUtf8().constData());
-
- if (vk.LowerBound().Book() != vk.UpperBound().Book()) {
- m_alternativeContent = QString::fromUtf8(vk.getRangeText());
- }
- else if (vk.LowerBound().Chapter() != vk.UpperBound().Chapter()) {
- m_alternativeContent = QString("%1 - %2:%3")
- .arg(QString::fromUtf8(vk.LowerBound().getText()))
- .arg(vk.UpperBound().Chapter())
- .arg(vk.UpperBound().Verse());
- }
- else { //only verses differ (same book, same chapter)
- m_alternativeContent = QString("%1 - %2")
- .arg(QString::fromUtf8(vk.LowerBound().getText()))
- .arg(vk.UpperBound().Verse());
- }
- }
-
- m_alternativeContent.append(" (").append(module->name()).append(")");
- m_alternativeContent.prepend("<div class=\"rangeheading\" dir=\"ltr\">").append("</div>"); //insert the right tags
+ : m_settings( settings ),
+ m_moduleList(),
+ m_key( startKey ),
+ m_childList(),
+ m_stopKey( stopKey ),
+ m_alternativeContent( QString::null ) {
+ Q_ASSERT(module);
+ m_moduleList.append(module);
+
+ //use the start and stop key to ceate our child items
+
+ if (module->type() == CSwordModuleInfo::Bible) {
+ CSwordVerseKey start(module);
+ start.key(startKey);
+
+ CSwordVerseKey stop(module);
+ stop.key(stopKey);
+
+ if (!m_key.isEmpty() && !m_stopKey.isEmpty()) { //we have a range of keys
+ bool ok = true;
+
+ while (ok && ((start < stop) || (start == stop)) ) { //range
+ m_childList.append(
+ new KeyTreeItem(start.key(), module, KeyTreeItem::Settings(false, settings.keyRenderingFace))
+ );
+
+
+ ok = start.next(CSwordVerseKey::UseVerse);
+ }
+ }
+ else if (m_key.isEmpty()) {
+ m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, settings.keyRenderingFace)) );
+ }
+ }
+ else if ((module->type() == CSwordModuleInfo::Lexicon) || (module->type() == CSwordModuleInfo::Commentary) ) {
+ m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) );
+ }
+ else if (module->type() == CSwordModuleInfo::GenericBook) {
+ m_childList.append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) );
+ }
+
+ //make it into "<simple|range> (modulename)"
+
+ if (startKey == stopKey) {
+ m_alternativeContent = startKey;
+ }
+ else {
+ sword::VerseKey vk(startKey.toUtf8().constData(), stopKey.toUtf8().constData());
+
+ if (vk.LowerBound().Book() != vk.UpperBound().Book()) {
+ m_alternativeContent = QString::fromUtf8(vk.getRangeText());
+ }
+ else if (vk.LowerBound().Chapter() != vk.UpperBound().Chapter()) {
+ m_alternativeContent = QString("%1 - %2:%3")
+ .arg(QString::fromUtf8(vk.LowerBound().getText()))
+ .arg(vk.UpperBound().Chapter())
+ .arg(vk.UpperBound().Verse());
+ }
+ else { //only verses differ (same book, same chapter)
+ m_alternativeContent = QString("%1 - %2")
+ .arg(QString::fromUtf8(vk.LowerBound().getText()))
+ .arg(vk.UpperBound().Verse());
+ }
+ }
+
+ m_alternativeContent.append(" (").append(module->name()).append(")");
+ m_alternativeContent.prepend("<div class=\"rangeheading\" dir=\"ltr\">").append("</div>"); //insert the right tags
}
const QString& CTextRendering::KeyTreeItem::getAlternativeContent() const {
- return m_alternativeContent;
+ return m_alternativeContent;
}
const QList<CSwordModuleInfo*> CTextRendering::collectModules(KeyTree* const tree) const {
- //collect all modules which are available and used by child items
- QList<CSwordModuleInfo*> modules;
-
- foreach (KeyTreeItem* c, (*tree)) {
- Q_ASSERT(c);
- foreach (CSwordModuleInfo* mod, c->modules()) {
- if (!modules.contains(mod)) {
- modules.append(mod);
- }
- }
- }
- return modules;
+ //collect all modules which are available and used by child items
+ QList<CSwordModuleInfo*> modules;
+
+ foreach (KeyTreeItem* c, (*tree)) {
+ Q_ASSERT(c);
+ foreach (CSwordModuleInfo* mod, c->modules()) {
+ if (!modules.contains(mod)) {
+ modules.append(mod);
+ }
+ }
+ }
+ return modules;
}
const QString CTextRendering::renderKeyTree( KeyTree& tree ) {
- initRendering();
-
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
- QString t;
-
- //optimization for entries with the same key
- boost::scoped_ptr<CSwordKey> key(
- (modules.count() == 1) ? CSwordKey::createInstance(modules.first()) : 0
- );
-
- foreach (KeyTreeItem* c, tree) {
- if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items
- key->key( c->key() );
- t.append( renderEntry( *c, key.get()) );
- }
- else {
- t.append( renderEntry( *c ) );
- }
- }
-
- return finishText(t, tree);
+ initRendering();
+
+ QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ QString t;
+
+ //optimization for entries with the same key
+ boost::scoped_ptr<CSwordKey> key(
+ (modules.count() == 1) ? CSwordKey::createInstance(modules.first()) : 0
+ );
+
+ foreach (KeyTreeItem* c, tree) {
+ if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items
+ key->key( c->key() );
+ t.append( renderEntry( *c, key.get()) );
+ }
+ else {
+ t.append( renderEntry( *c ) );
+ }
+ }
+
+ return finishText(t, tree);
}
const QString CTextRendering::renderKeyRange( const QString& start, const QString& stop, const QList<CSwordModuleInfo*>& modules, const QString& highlightKey, const KeyTreeItem::Settings& keySettings ) {
- CSwordModuleInfo* module = modules.first();
- //qWarning( "renderKeyRange start %s stop %s \n", start.latin1(), stop.latin1() );
-
- boost::scoped_ptr<CSwordKey> lowerBound( CSwordKey::createInstance(module) );
- lowerBound->key(start);
-
- boost::scoped_ptr<CSwordKey> upperBound( CSwordKey::createInstance(module) );
- upperBound->key(stop);
-
- sword::SWKey* sw_start = dynamic_cast<sword::SWKey*>(lowerBound.get());
- sword::SWKey* sw_stop = dynamic_cast<sword::SWKey*>(upperBound.get());
-
- Q_ASSERT((*sw_start == *sw_stop) || (*sw_start < *sw_stop));
-
- if (*sw_start == *sw_stop) { //same key, render single key
- return renderSingleKey(lowerBound->key(), modules);
- }
- else if (*sw_start < *sw_stop) { // Render range
- KeyTree tree;
- KeyTreeItem::Settings settings = keySettings;
-
- CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.get());
- Q_ASSERT(vk_start);
-
- CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.get());
- Q_ASSERT(vk_stop);
-
- bool ok = true;
- while (ok && ((*vk_start < *vk_stop) || (*vk_start == *vk_stop))) {
- //make sure the key given by highlightKey gets marked as current key
- settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false);
-
- /*TODO: We need to take care of linked verses if we render one or (esp) more modules
- If the verses 2,3,4,5 are linked to 1, it should be displayed as one entry with the caption 1-5 */
-
- if (vk_start->Chapter() == 0){ //range was 0:0-1:x, render 0:0 first and jump to 1:0
- vk_start->Verse(0);
- tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
- vk_start->Chapter(1);
- vk_start->Verse(0);
- }
- tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
- ok = vk_start->next(CSwordVerseKey::UseVerse);
- }
-
- return renderKeyTree(tree);
- }
-
- return QString::null;
+ CSwordModuleInfo* module = modules.first();
+ //qWarning( "renderKeyRange start %s stop %s \n", start.latin1(), stop.latin1() );
+
+ boost::scoped_ptr<CSwordKey> lowerBound( CSwordKey::createInstance(module) );
+ lowerBound->key(start);
+
+ boost::scoped_ptr<CSwordKey> upperBound( CSwordKey::createInstance(module) );
+ upperBound->key(stop);
+
+ sword::SWKey* sw_start = dynamic_cast<sword::SWKey*>(lowerBound.get());
+ sword::SWKey* sw_stop = dynamic_cast<sword::SWKey*>(upperBound.get());
+
+ Q_ASSERT((*sw_start == *sw_stop) || (*sw_start < *sw_stop));
+
+ if (*sw_start == *sw_stop) { //same key, render single key
+ return renderSingleKey(lowerBound->key(), modules);
+ }
+ else if (*sw_start < *sw_stop) { // Render range
+ KeyTree tree;
+ KeyTreeItem::Settings settings = keySettings;
+
+ CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.get());
+ Q_ASSERT(vk_start);
+
+ CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.get());
+ Q_ASSERT(vk_stop);
+
+ bool ok = true;
+ while (ok && ((*vk_start < *vk_stop) || (*vk_start == *vk_stop))) {
+ //make sure the key given by highlightKey gets marked as current key
+ settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false);
+
+ /*TODO: We need to take care of linked verses if we render one or (esp) more modules
+ If the verses 2,3,4,5 are linked to 1, it should be displayed as one entry with the caption 1-5 */
+
+ if (vk_start->Chapter() == 0) { //range was 0:0-1:x, render 0:0 first and jump to 1:0
+ vk_start->Verse(0);
+ tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
+ 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);
+ }
+
+ return QString::null;
}
const QString CTextRendering::renderSingleKey( const QString& key, const QList<CSwordModuleInfo*>& moduleList, const KeyTreeItem::Settings& settings ) {
- KeyTree tree;
- tree.append( new KeyTreeItem(key, moduleList, settings) );
+ KeyTree tree;
+ tree.append( new KeyTreeItem(key, moduleList, settings) );
- return renderKeyTree(tree);
+ return renderKeyTree(tree);
}
diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h
index 403962b..5d0531b 100644
--- a/src/backend/rendering/ctextrendering.h
+++ b/src/backend/rendering/ctextrendering.h
@@ -34,89 +34,89 @@ namespace Rendering {
class CTextRendering {
-public:
+ public:
- class KeyTreeItem;
- typedef QList<KeyTreeItem*> KeyTree;
+ class KeyTreeItem;
+ typedef QList<KeyTreeItem*> KeyTree;
- class KeyTreeItem {
- public:
+ class KeyTreeItem {
+ public:
- struct Settings {
- enum KeyRenderingFace {
- NoKey, //< means no key shown at all
- SimpleKey, //< means only versenumber or only lexicon entry name
- CompleteShort, //< means key like "Gen 1:1"
- CompleteLong //< means "Genesis 1:1"
- };
+ struct Settings {
+ enum KeyRenderingFace {
+ NoKey, //< means no key shown at all
+ SimpleKey, //< means only versenumber or only lexicon entry name
+ CompleteShort, //< means key like "Gen 1:1"
+ CompleteLong //< means "Genesis 1:1"
+ };
- Settings(const bool highlight = false, KeyRenderingFace keyRendering = SimpleKey) : highlight(highlight), keyRenderingFace(keyRendering) {}
+ Settings(const bool highlight = false, KeyRenderingFace keyRendering = SimpleKey) : highlight(highlight), keyRenderingFace(keyRendering) {}
- bool highlight;
- KeyRenderingFace keyRenderingFace;
- };
+ bool highlight;
+ KeyRenderingFace keyRenderingFace;
+ };
- KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings);
- KeyTreeItem(const QString& key, const QList<CSwordModuleInfo*>& modules, const Settings settings);
- KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings);
- KeyTreeItem(const QString& content, const Settings settings);
- KeyTreeItem(const KeyTreeItem& i);
+ KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings);
+ KeyTreeItem(const QString& key, const QList<CSwordModuleInfo*>& modules, const Settings settings);
+ KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings);
+ KeyTreeItem(const QString& content, const Settings settings);
+ KeyTreeItem(const KeyTreeItem& i);
- virtual ~KeyTreeItem();
+ virtual ~KeyTreeItem();
- const QString& getAlternativeContent() const;
- inline void setAlternativeContent(const QString& newContent) {
- m_alternativeContent = newContent;
- };
+ const QString& getAlternativeContent() const;
+ inline void setAlternativeContent(const QString& newContent) {
+ m_alternativeContent = newContent;
+ };
- inline bool hasAlternativeContent() const {
- return !m_alternativeContent.isNull();
- };
+ inline bool hasAlternativeContent() const {
+ return !m_alternativeContent.isNull();
+ };
- inline const QList<CSwordModuleInfo*>& modules() const {
- return m_moduleList;
- };
+ inline const QList<CSwordModuleInfo*>& modules() const {
+ return m_moduleList;
+ };
- inline const QString& key() const {
- return m_key;
- };
+ inline const QString& key() const {
+ return m_key;
+ };
- inline const Settings& settings() const {
- return m_settings;
- };
+ inline const Settings& settings() const {
+ return m_settings;
+ };
- inline KeyTree* childList() const;
+ inline KeyTree* childList() const;
// inline const bool hasChildItems() const;
- protected:
- KeyTreeItem();
+ protected:
+ KeyTreeItem();
- Settings m_settings;
- QList<CSwordModuleInfo*> m_moduleList;
- QString m_key;
- mutable KeyTree m_childList;
+ Settings m_settings;
+ QList<CSwordModuleInfo*> m_moduleList;
+ QString m_key;
+ mutable KeyTree m_childList;
- QString m_stopKey;
- QString m_alternativeContent;
- };
+ QString m_stopKey;
+ QString m_alternativeContent;
+ };
- virtual ~CTextRendering() {}
+ virtual ~CTextRendering() {}
- const QString renderKeyTree( KeyTree& );
+ const QString renderKeyTree( KeyTree& );
- const QString renderKeyRange( const QString& start, const QString& stop, const QList<CSwordModuleInfo*>& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
+ const QString renderKeyRange( const QString& start, const QString& stop, const QList<CSwordModuleInfo*>& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
- const QString renderSingleKey( const QString& key, const QList<CSwordModuleInfo*>&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
+ const QString renderSingleKey( const QString& key, const QList<CSwordModuleInfo*>&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
-protected:
- const QList<CSwordModuleInfo*> collectModules(KeyTree* const tree) const;
- virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0;
- virtual const QString finishText( const QString&, KeyTree& tree ) = 0;
- virtual void initRendering() = 0;
+ protected:
+ const QList<CSwordModuleInfo*> collectModules(KeyTree* const tree) const;
+ virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0;
+ virtual const QString finishText( const QString&, KeyTree& tree ) = 0;
+ virtual void initRendering() = 0;
};
-inline CTextRendering::KeyTree* CTextRendering::KeyTreeItem::childList() const{
- return &m_childList;
+inline CTextRendering::KeyTree* CTextRendering::KeyTreeItem::childList() const {
+ return &m_childList;
}
//
//inline const bool CTextRendering::KeyTreeItem::hasChildItems() const {
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index c7af792..7286844 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -49,149 +49,134 @@
using namespace Profile;
BibleTime::BibleTime() {
- QPixmap pm;
- if ( !pm.load( util::filesystem::DirectoryUtil::getPicsDir().canonicalPath().append( "/startuplogo.png")) )
- {
- qWarning("Can't load startuplogo! Check your installation.");
- }
- QSplashScreen splash(pm);
- QString splashHtml("<div style='background:transparent;color:white;font-weight:bold'>%1</div>");
- if (CBTConfig::get(CBTConfig::logo))
- {
- splash.show();
- }
- splash.showMessage(splashHtml.arg(tr("Initializing the SWORD engine...")), Qt::AlignCenter);
- initBackends();
- splash.showMessage(splashHtml.arg(tr("Creating BibleTime's user interface...")), Qt::AlignCenter);
- initView();
- splash.showMessage(splashHtml.arg(tr("Initializing menu- and toolbars...")), Qt::AlignCenter);
- initActions();
- initConnections();
- readSettings();
- setPlainCaption(QString());
- setWindowIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::mainWindow::icon) );
+ QPixmap pm;
+ if ( !pm.load( util::filesystem::DirectoryUtil::getPicsDir().canonicalPath().append( "/startuplogo.png")) ) {
+ qWarning("Can't load startuplogo! Check your installation.");
+ }
+ QSplashScreen splash(pm);
+ QString splashHtml("<div style='background:transparent;color:white;font-weight:bold'>%1</div>");
+ if (CBTConfig::get(CBTConfig::logo)) {
+ splash.show();
+ }
+ splash.showMessage(splashHtml.arg(tr("Initializing the SWORD engine...")), Qt::AlignCenter);
+ initBackends();
+ splash.showMessage(splashHtml.arg(tr("Creating BibleTime's user interface...")), Qt::AlignCenter);
+ initView();
+ splash.showMessage(splashHtml.arg(tr("Initializing menu- and toolbars...")), Qt::AlignCenter);
+ initActions();
+ initConnections();
+ readSettings();
+ setPlainCaption(QString());
+ setWindowIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::mainWindow::icon) );
}
-BibleTime::~BibleTime()
-{
- // delete m_dcopInterface;
- // The backend is deleted by the BibleTimeApp instance
+BibleTime::~BibleTime() {
+ // delete m_dcopInterface;
+ // The backend is deleted by the BibleTimeApp instance
}
/** Saves the properties of BibleTime to the application wide configfile */
-void BibleTime::saveSettings()
-{
- //TODO: how to write settings?
- //accel()->writeSettings(CBTConfig::getConfig());
-
- CBTConfig::set(CBTConfig::toolbar, m_viewToolbar_action->isChecked());
-
- // set the default to false
- /* CBTConfig::set(CBTConfig::autoTileVertical, false);
- CBTConfig::set(CBTConfig::autoTileHorizontal, false);
- CBTConfig::set(CBTConfig::autoCascade, false);
- */
- CBTConfig::set(CBTConfig::autoTileVertical, m_windowAutoTileVertical_action->isChecked());
- CBTConfig::set(CBTConfig::autoTileHorizontal, m_windowAutoTileHorizontal_action->isChecked());
- CBTConfig::set(CBTConfig::autoCascade, m_windowAutoCascade_action->isChecked());
-
- CProfile* p = m_profileMgr.startupProfile();
- if (p)
- {
- saveProfile(p);
- }
+void BibleTime::saveSettings() {
+ //TODO: how to write settings?
+ //accel()->writeSettings(CBTConfig::getConfig());
+
+ CBTConfig::set(CBTConfig::toolbar, m_viewToolbar_action->isChecked());
+
+ // set the default to false
+ /* CBTConfig::set(CBTConfig::autoTileVertical, false);
+ CBTConfig::set(CBTConfig::autoTileHorizontal, false);
+ CBTConfig::set(CBTConfig::autoCascade, false);
+ */
+ CBTConfig::set(CBTConfig::autoTileVertical, m_windowAutoTileVertical_action->isChecked());
+ CBTConfig::set(CBTConfig::autoTileHorizontal, m_windowAutoTileHorizontal_action->isChecked());
+ CBTConfig::set(CBTConfig::autoCascade, m_windowAutoCascade_action->isChecked());
+
+ CProfile* p = m_profileMgr.startupProfile();
+ if (p) {
+ saveProfile(p);
+ }
}
/** Reads the settings from the configfile and sets the right properties. */
-void BibleTime::readSettings()
-{
- qDebug("******************BibleTime::readSettings******************************");
- // accel()->readSettings(CBTConfig::getConfig());
+void BibleTime::readSettings() {
+ qDebug("******************BibleTime::readSettings******************************");
+ // accel()->readSettings(CBTConfig::getConfig());
CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
- m_viewToolbar_action->setChecked( CBTConfig::get(CBTConfig::toolbar) );
- slotToggleToolbar();
-
- if ( CBTConfig::get(CBTConfig::autoTileVertical) )
- {
- m_windowAutoTileVertical_action->setChecked( true );
- m_windowManualMode_action->setChecked(false);
- slotAutoTileVertical();
- }
- else if ( CBTConfig::get(CBTConfig::autoTileHorizontal) )
- {
- m_windowAutoTileHorizontal_action->setChecked( true );
- m_windowManualMode_action->setChecked(false);
- slotAutoTileHorizontal();
- }
- else if ( CBTConfig::get(CBTConfig::autoCascade) )
- {
- m_windowAutoCascade_action->setChecked(true);
- m_windowManualMode_action->setChecked(false);
- slotAutoCascade();
- }
- else
- {
- m_windowManualMode_action->setChecked(true);
- slotManualArrangementMode();
- }
+ m_viewToolbar_action->setChecked( CBTConfig::get(CBTConfig::toolbar) );
+ slotToggleToolbar();
+
+ if ( CBTConfig::get(CBTConfig::autoTileVertical) ) {
+ m_windowAutoTileVertical_action->setChecked( true );
+ m_windowManualMode_action->setChecked(false);
+ slotAutoTileVertical();
+ }
+ else if ( CBTConfig::get(CBTConfig::autoTileHorizontal) ) {
+ m_windowAutoTileHorizontal_action->setChecked( true );
+ m_windowManualMode_action->setChecked(false);
+ slotAutoTileHorizontal();
+ }
+ else if ( CBTConfig::get(CBTConfig::autoCascade) ) {
+ m_windowAutoCascade_action->setChecked(true);
+ m_windowManualMode_action->setChecked(false);
+ slotAutoCascade();
+ }
+ else {
+ m_windowManualMode_action->setChecked(true);
+ slotManualArrangementMode();
+ }
}
/** 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)");
- CDisplayWindow* displayWindow = CDisplayWindowFactory::createReadInstance(modules, m_mdi);
- if ( displayWindow )
- {
- displayWindow->init();
- if (m_mdi->subWindowList().count() == 0)
- displayWindow->showMaximized();
- else
- displayWindow->show();
- // if (!key.isEmpty())
- displayWindow->lookupKey(key);
- }
- // We have to process pending events here, otherwise displayWindow is not fully painted
- qApp->processEvents();
- // Now all events, including mouse clicks for the displayWindow have been handled
- // and we can let the user click the same module again
+CDisplayWindow* BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key) {
+ qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
+ qDebug("BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key)");
+ CDisplayWindow* displayWindow = CDisplayWindowFactory::createReadInstance(modules, m_mdi);
+ if ( displayWindow ) {
+ displayWindow->init();
+ if (m_mdi->subWindowList().count() == 0)
+ displayWindow->showMaximized();
+ else
+ displayWindow->show();
+ // if (!key.isEmpty())
+ displayWindow->lookupKey(key);
+ }
+ // We have to process pending events here, otherwise displayWindow is not fully painted
+ qApp->processEvents();
+ // Now all events, including mouse clicks for the displayWindow have been handled
+ // and we can let the user click the same module again
//m_bookshelfPage->unfreezeModules(modules);
- qApp->restoreOverrideCursor();
- return displayWindow;
+ qApp->restoreOverrideCursor();
+ return displayWindow;
}
/** Creates a new presenter in the MDI area according to the type of the module. */
-CDisplayWindow* BibleTime::createReadDisplayWindow(CSwordModuleInfo* module, const QString& key)
-{
- QList<CSwordModuleInfo*> list;
- list.append(module);
+CDisplayWindow* BibleTime::createReadDisplayWindow(CSwordModuleInfo* module, const QString& key) {
+ QList<CSwordModuleInfo*> list;
+ list.append(module);
- return createReadDisplayWindow(list, key);
+ return createReadDisplayWindow(list, key);
}
-CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type)
-{
- qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
-
- QList<CSwordModuleInfo*> modules;
- modules.append(module);
-
- CDisplayWindow* displayWindow = CDisplayWindowFactory::createWriteInstance(modules, m_mdi, type);
- if ( displayWindow )
- {
- displayWindow->init();
- if (m_mdi->subWindowList().count() == 0)
- displayWindow->showMaximized();
- else
- displayWindow->show();
- displayWindow->lookupKey(key);
- }
-
- qApp->restoreOverrideCursor();
- return displayWindow;
+CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type) {
+ qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
+
+ QList<CSwordModuleInfo*> modules;
+ modules.append(module);
+
+ CDisplayWindow* displayWindow = CDisplayWindowFactory::createWriteInstance(modules, m_mdi, type);
+ if ( displayWindow ) {
+ displayWindow->init();
+ if (m_mdi->subWindowList().count() == 0)
+ displayWindow->showMaximized();
+ else
+ displayWindow->show();
+ displayWindow->lookupKey(key);
+ }
+
+ qApp->restoreOverrideCursor();
+ return displayWindow;
}
CDisplayWindow* BibleTime::moduleEditPlain(CSwordModuleInfo *module) {
@@ -242,105 +227,88 @@ void BibleTime::moduleAbout(CSwordModuleInfo *module) {
}
/** Refreshes all presenters.*/
-void BibleTime::refreshDisplayWindows()
-{
- foreach (QMdiSubWindow* subWindow, m_mdi->subWindowList())
- {
- if (CDisplayWindow* window = dynamic_cast<CDisplayWindow*>(subWindow->widget()))
- {
- window->reload(CSwordBackend::OtherChange);
- }
- }
+void BibleTime::refreshDisplayWindows() {
+ foreach (QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
+ if (CDisplayWindow* window = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
+ window->reload(CSwordBackend::OtherChange);
+ }
+ }
}
/** Refresh main window accelerators */
-void::BibleTime::refreshBibleTimeAccel()
-{
+void::BibleTime::refreshBibleTimeAccel() {
CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
}
/** Called before quit. */
-void BibleTime::slot_aboutToQuit()
-{
- saveSettings();
+void BibleTime::slot_aboutToQuit() {
+ saveSettings();
}
/** Called before a window is closed */
-bool BibleTime::queryClose()
-{
- qDebug("BibleTime::queryClose");
- bool ret = true;
-
- foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList())
- {
- if (CDisplayWindow* window = dynamic_cast<CDisplayWindow*>(subWindow->widget()))
- {
- ret = ret && window->queryClose();
- }
- qDebug() << "return value:" << ret;
- }
- qDebug() << "final return value:" << ret;
- return ret;
+bool BibleTime::queryClose() {
+ qDebug("BibleTime::queryClose");
+ bool ret = true;
+
+ foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
+ if (CDisplayWindow* window = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
+ ret = ret && window->queryClose();
+ }
+ qDebug() << "return value:" << ret;
+ }
+ qDebug() << "final return value:" << ret;
+ return ret;
}
/** Restores the workspace if the flag for this is set in the config. */
-void BibleTime::restoreWorkspace()
-{
- if (CProfile* p = m_profileMgr.startupProfile())
- {
- loadProfile(p);
- }
+void BibleTime::restoreWorkspace() {
+ if (CProfile* p = m_profileMgr.startupProfile()) {
+ loadProfile(p);
+ }
}
/** Sets the plain caption of the main window */
-void BibleTime::setPlainCaption(const QString& title)
-{
- QString suffix;
- //Watch out, subtitles must be appended with the form " - [%s]", otherwise
- //QMdiSubWindow will mess up when it is maximized
- if (!title.isEmpty())
- {
- suffix = QString(" - [").append(title).append("]");
- }
- QMainWindow::setWindowTitle( QString("BibleTime ").append(BT_VERSION) + suffix );
+void BibleTime::setPlainCaption(const QString& title) {
+ QString suffix;
+ //Watch out, subtitles must be appended with the form " - [%s]", otherwise
+ //QMdiSubWindow will mess up when it is maximized
+ if (!title.isEmpty()) {
+ suffix = QString(" - [").append(title).append("]");
+ }
+ QMainWindow::setWindowTitle( QString("BibleTime ").append(BT_VERSION) + suffix );
}
/** Processes the commandline options given to BibleTime. */
-void BibleTime::processCommandline()
-{
- QStringList args = qApp->QCoreApplication::arguments();
-
- if ( !CBTConfig::get(CBTConfig::crashedTwoTimes) &&
- !args.contains("--ignore-session") )
- {
- restoreWorkspace();
- }
-
- if ( args.contains("--open-default-bible") &&
- !CBTConfig::get(CBTConfig::crashedLastTime) &&
- !CBTConfig::get(CBTConfig::crashedTwoTimes))
- {
- int index = args.indexOf("--open-default-bible");
- QString bibleKey;
- if (index >= 0 && (index+1) < args.size())
- {
- bibleKey = args.at(index+1);
- }
- CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
- if (bibleKey == "random")
- {
- CSwordVerseKey vk(0);
- const int maxIndex = 31100;
- time_t seconds;
- seconds = time (NULL);
- srand(seconds);
- int newIndex = rand() % maxIndex;
- vk.setPosition(sword::TOP);
- vk.Index(newIndex);
- bibleKey = vk.key();
- }
- createReadDisplayWindow(bible, bibleKey);
- m_mdi->myTileVertical();//we are sure only one window is open, which should be displayed fullscreen in the working area
- }
+void BibleTime::processCommandline() {
+ QStringList args = qApp->QCoreApplication::arguments();
+
+ if ( !CBTConfig::get(CBTConfig::crashedTwoTimes) &&
+ !args.contains("--ignore-session") ) {
+ restoreWorkspace();
+ }
+
+ if ( args.contains("--open-default-bible") &&
+ !CBTConfig::get(CBTConfig::crashedLastTime) &&
+ !CBTConfig::get(CBTConfig::crashedTwoTimes)) {
+ int index = args.indexOf("--open-default-bible");
+ QString bibleKey;
+ if (index >= 0 && (index + 1) < args.size()) {
+ bibleKey = args.at(index + 1);
+ }
+ CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
+ if (bibleKey == "random") {
+ CSwordVerseKey vk(0);
+ const int maxIndex = 31100;
+ time_t seconds;
+ seconds = time (NULL);
+ srand(seconds);
+ int newIndex = rand() % maxIndex;
+ vk.setPosition(sword::TOP);
+ vk.Index(newIndex);
+ bibleKey = vk.key();
+ }
+ createReadDisplayWindow(bible, bibleKey);
+ m_mdi->myTileVertical();//we are sure only one window is open, which should be displayed fullscreen in the working area
+ }
}
diff --git a/src/bibletime.h b/src/bibletime.h
index 4ddf2e1..cb3c26d 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -27,7 +27,7 @@ class CBookshelfIndex;
class BtBookshelfDockWidget;
namespace InfoDisplay {
- class CInfoDisplay;
+class CInfoDisplay;
}
class QAction;
class QMenu;
@@ -118,271 +118,270 @@ class QSplitter;
* saveSettings().
* This is the general way of all BibleTime classes.
*/
-class BibleTime : public QMainWindow
-{
- friend class CMDIArea;
- friend class BibleTimeDBusAdaptor;
- Q_OBJECT
-public:
- /**
- * construtor of BibleTime
- */
- BibleTime();
- /**
- * destructor of BibleTime
- */
- ~BibleTime();
+class BibleTime : public QMainWindow {
+ friend class CMDIArea;
+ friend class BibleTimeDBusAdaptor;
+ Q_OBJECT
+ public:
+ /**
+ * construtor of BibleTime
+ */
+ BibleTime();
+ /**
+ * destructor of BibleTime
+ */
+ ~BibleTime();
- /**
- * Reads the settings from the configfile and sets the right properties.
- */
- void readSettings();
- /**
- * Saves the settings of this class
- */
- void saveSettings();
- /**
- * Restores the workspace if the flaf for this is set in the config.
- */
- void restoreWorkspace();
- /**
- * Apply the settings given by the profile p
- */
- void applyProfileSettings( Profile::CProfile* p );
- /**
- * Stores the settings of the mainwindow in the profile p
- */
- void storeProfileSettings( Profile::CProfile* p );
- /**
- * Save the configuration dialog settings, don't open dialog
- */
- void saveConfigSettings();
+ /**
+ * Reads the settings from the configfile and sets the right properties.
+ */
+ void readSettings();
+ /**
+ * Saves the settings of this class
+ */
+ void saveSettings();
+ /**
+ * Restores the workspace if the flaf for this is set in the config.
+ */
+ void restoreWorkspace();
+ /**
+ * Apply the settings given by the profile p
+ */
+ void applyProfileSettings( Profile::CProfile* p );
+ /**
+ * Stores the settings of the mainwindow in the profile p
+ */
+ void storeProfileSettings( Profile::CProfile* p );
+ /**
+ * Save the configuration dialog settings, don't open dialog
+ */
+ void saveConfigSettings();
-public slots:
- /**
- * Opens the optionsdialog of BibleTime.
- */
- void slotSettingsOptions();
- /**
- * Opens the optionsdialog of BibleTime.
- */
- void slotSwordSetupDialog();
- /**
- * Opens the handbook.
- */
- void openOnlineHelp_Handbook();
- /**
- * Opens the bible study howto.
- */
- void openOnlineHelp_Howto();
- /**
- * Sets the plain caption of the main window
- */
- void setPlainCaption( const QString& );
- /**
- * Processes the commandline options given to BibleTime.
- */
- void processCommandline();
- /**
- * Creates QAction's that have keyboard shortcuts
- */
- static void insertKeyboardActions( BtActionCollection* const a );
+ public slots:
+ /**
+ * Opens the optionsdialog of BibleTime.
+ */
+ void slotSettingsOptions();
+ /**
+ * Opens the optionsdialog of BibleTime.
+ */
+ void slotSwordSetupDialog();
+ /**
+ * Opens the handbook.
+ */
+ void openOnlineHelp_Handbook();
+ /**
+ * Opens the bible study howto.
+ */
+ void openOnlineHelp_Howto();
+ /**
+ * Sets the plain caption of the main window
+ */
+ void setPlainCaption( const QString& );
+ /**
+ * Processes the commandline options given to BibleTime.
+ */
+ void processCommandline();
+ /**
+ * Creates QAction's that have keyboard shortcuts
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
-protected: // Protected methods
- /**
- * Initializes the view of this widget
- */
- void initView();
- /**
- * Initializes the menubar of BibleTime.
- */
- void initMenubar();
- /**
- * Initializes the SIGNAL / SLOT connections
- */
- void initConnections();
- /**
- * Initializes the backend
- */
- void initBackends();
- /**
- * Initializes the action objects of the GUI
- */
- void initActions();
- /**
- * Initializes one action object
- */
- QAction* initAction(QAction* action, QString text, QString icon, QKeySequence accel,
- const QString& tooltip, const QString& actionName, const char* slot );
- /**
- * Refreshes all presenter supporting at least in of the features given as parameter.
- */
- void refreshDisplayWindows();
- /**
- * Refresh main window accelerators
- */
- void refreshBibleTimeAccel();
- /**
- * Called before a window is closed
- */
- bool queryClose();
+ protected: // Protected methods
+ /**
+ * Initializes the view of this widget
+ */
+ void initView();
+ /**
+ * Initializes the menubar of BibleTime.
+ */
+ void initMenubar();
+ /**
+ * Initializes the SIGNAL / SLOT connections
+ */
+ void initConnections();
+ /**
+ * Initializes the backend
+ */
+ void initBackends();
+ /**
+ * Initializes the action objects of the GUI
+ */
+ void initActions();
+ /**
+ * Initializes one action object
+ */
+ QAction* initAction(QAction* action, QString text, QString icon, QKeySequence accel,
+ const QString& tooltip, const QString& actionName, const char* slot );
+ /**
+ * Refreshes all presenter supporting at least in of the features given as parameter.
+ */
+ void refreshDisplayWindows();
+ /**
+ * Refresh main window accelerators
+ */
+ void refreshBibleTimeAccel();
+ /**
+ * Called before a window is closed
+ */
+ bool queryClose();
-protected slots:
- /**
- * Creates a new presenter in the MDI area according to the type of the module.
- */
- CDisplayWindow* createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key);
- CDisplayWindow* createReadDisplayWindow(CSwordModuleInfo* module, const QString& key = QString::null);
- CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type);
- CDisplayWindow* moduleEditPlain(CSwordModuleInfo *module);
- CDisplayWindow* moduleEditHtml(CSwordModuleInfo *module);
- void searchInModule(CSwordModuleInfo *module);
- void moduleUnlock(CSwordModuleInfo *module);
- void moduleAbout(CSwordModuleInfo *module);
+ protected slots:
+ /**
+ * Creates a new presenter in the MDI area according to the type of the module.
+ */
+ CDisplayWindow* createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key);
+ CDisplayWindow* createReadDisplayWindow(CSwordModuleInfo* module, const QString& key = QString::null);
+ CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type);
+ CDisplayWindow* moduleEditPlain(CSwordModuleInfo *module);
+ CDisplayWindow* moduleEditHtml(CSwordModuleInfo *module);
+ void searchInModule(CSwordModuleInfo *module);
+ void moduleUnlock(CSwordModuleInfo *module);
+ void moduleAbout(CSwordModuleInfo *module);
- /**
- * Is called when the window menu is about to show ;-)
- */
- void slotWindowMenuAboutToShow();
- /**
- * This slot is connected with the windowAutoTile_action object
- */
- void slotAutoTileVertical();
- /**
- * This slot is connected with the windowAutoTile_action object
- */
- void slotAutoTileHorizontal();
- /**
- * This slot is connected with the windowAutoCascade_action object
- */
- void slotAutoCascade();
- void slotUpdateWindowArrangementActions( QAction* );
+ /**
+ * Is called when the window menu is about to show ;-)
+ */
+ void slotWindowMenuAboutToShow();
+ /**
+ * This slot is connected with the windowAutoTile_action object
+ */
+ void slotAutoTileVertical();
+ /**
+ * This slot is connected with the windowAutoTile_action object
+ */
+ void slotAutoTileHorizontal();
+ /**
+ * This slot is connected with the windowAutoCascade_action object
+ */
+ void slotAutoCascade();
+ void slotUpdateWindowArrangementActions( QAction* );
- void slotCascade();
- void slotTileVertical();
- void slotTileHorizontal();
+ void slotCascade();
+ void slotTileVertical();
+ void slotTileHorizontal();
- void slotManualArrangementMode();
+ void slotManualArrangementMode();
- /**
- * Is called when a client was selected in the window menu
- */
- void slotWindowMenuActivated();
- /**
- * Shows/hides the toolbar
- */
- void slotToggleToolbar();
- /**
- * Saves to the profile with the menu id ID
- */
- void saveProfile(QAction* action);
- /**
- * Saves the current settings into the currently activatred profile.
- */
- void saveProfile(Profile::CProfile* p);
- /**
- * Deletes the chosen session from the menu and from disk.
- */
- void deleteProfile(QAction* action);
- /**
- * Loads the profile with the menu id ID
- */
- void loadProfile(QAction* action);
- /**
- * Loads the profile with the menu ID id
- */
- void loadProfile(Profile::CProfile* p);
- /**
- * Toggles between normal and fullscreen mode.
- */
- void toggleFullscreen();
- /**
- * Is called when settings in the optionsdialog have been
- * changed (ok or apply)
- */
- void slotSettingsChanged();
- /**
- * Is called when settings in the sword setup dialog have been
- * changed (ok or apply)
- */
- void slotSwordSetupChanged();
- /**
- * Called when search button is pressed
- **/
- void slotSearchModules();
- /**
- * Called for search default bible
- **/
- void slotSearchDefaultBible();
- /**
- Saves current settings into a new profile.
- */
- void saveToNewProfile();
- /**
- * Slot to refresh the save profile and load profile menus.
- */
- void refreshProfileMenus();
- /**
- * Called before quit.
- */
- void slot_aboutToQuit();
- /**
- * Open the About Dialog
- */
- void slotOpenAboutDialog();
+ /**
+ * Is called when a client was selected in the window menu
+ */
+ void slotWindowMenuActivated();
+ /**
+ * Shows/hides the toolbar
+ */
+ void slotToggleToolbar();
+ /**
+ * Saves to the profile with the menu id ID
+ */
+ void saveProfile(QAction* action);
+ /**
+ * Saves the current settings into the currently activatred profile.
+ */
+ void saveProfile(Profile::CProfile* p);
+ /**
+ * Deletes the chosen session from the menu and from disk.
+ */
+ void deleteProfile(QAction* action);
+ /**
+ * Loads the profile with the menu id ID
+ */
+ void loadProfile(QAction* action);
+ /**
+ * Loads the profile with the menu ID id
+ */
+ void loadProfile(Profile::CProfile* p);
+ /**
+ * Toggles between normal and fullscreen mode.
+ */
+ void toggleFullscreen();
+ /**
+ * Is called when settings in the optionsdialog have been
+ * changed (ok or apply)
+ */
+ void slotSettingsChanged();
+ /**
+ * Is called when settings in the sword setup dialog have been
+ * changed (ok or apply)
+ */
+ void slotSwordSetupChanged();
+ /**
+ * Called when search button is pressed
+ **/
+ void slotSearchModules();
+ /**
+ * Called for search default bible
+ **/
+ void slotSearchDefaultBible();
+ /**
+ Saves current settings into a new profile.
+ */
+ void saveToNewProfile();
+ /**
+ * Slot to refresh the save profile and load profile menus.
+ */
+ void refreshProfileMenus();
+ /**
+ * Called before quit.
+ */
+ void slot_aboutToQuit();
+ /**
+ * Open the About Dialog
+ */
+ void slotOpenAboutDialog();
-private:
- // Docking widgets and their respective content widgets:
- BtBookshelfDockWidget* m_bookshelfDock;
- QDockWidget* m_bookmarksDock;
+ private:
+ // Docking widgets and their respective content widgets:
+ BtBookshelfDockWidget* m_bookshelfDock;
+ QDockWidget* m_bookmarksDock;
CBookmarkIndex* m_bookmarksPage;
- QDockWidget* m_magDock;
+ QDockWidget* m_magDock;
InfoDisplay::CInfoDisplay* m_infoDisplay;
- QToolBar* m_mainToolBar;
- // VIEW menu actions
- QAction* m_viewToolbar_action;
- QMenu* m_windowMenu;
- /** WINDOW menu actions */
- QAction* m_windowCascade_action;
- QAction* m_windowTileHorizontal_action;
- QAction* m_windowTileVertical_action;
- QAction* m_windowManualMode_action;
- QAction* m_windowAutoCascade_action;
- QAction* m_windowAutoTileVertical_action;
- QAction* m_windowAutoTileHorizontal_action;
- QAction* m_windowCloseAll_action;
- BtActionCollection* m_actionCollection;
+ QToolBar* m_mainToolBar;
+ // VIEW menu actions
+ QAction* m_viewToolbar_action;
+ QMenu* m_windowMenu;
+ /** WINDOW menu actions */
+ QAction* m_windowCascade_action;
+ QAction* m_windowTileHorizontal_action;
+ QAction* m_windowTileVertical_action;
+ QAction* m_windowManualMode_action;
+ QAction* m_windowAutoCascade_action;
+ QAction* m_windowAutoTileVertical_action;
+ QAction* m_windowAutoTileHorizontal_action;
+ QAction* m_windowCloseAll_action;
+ BtActionCollection* m_actionCollection;
- QMenu* m_windowSaveProfileMenu;
- QAction* m_windowSaveToNewProfile_action;
- QMenu* m_windowLoadProfileMenu;
- QMenu* m_windowDeleteProfileMenu;
- QAction* m_windowFullscreen_action;
+ QMenu* m_windowSaveProfileMenu;
+ QAction* m_windowSaveToNewProfile_action;
+ QMenu* m_windowLoadProfileMenu;
+ QMenu* m_windowDeleteProfileMenu;
+ QAction* m_windowFullscreen_action;
- /// \todo remove?
- // QList<QAction*> m_windowOpenWindowsList;
+ /// \todo remove?
+ // QList<QAction*> m_windowOpenWindowsList;
- CMDIArea* m_mdi;
+ CMDIArea* m_mdi;
- Profile::CProfileMgr m_profileMgr;
+ Profile::CProfileMgr m_profileMgr;
-protected: //DBUS interface implementation
- void closeAllModuleWindows();
- void syncAllBibles(const QString& key);
- void syncAllCommentaries(const QString& key);
- void syncAllLexicons(const QString& key);
- void syncAllVerseBasedModules(const QString& key);
- void openWindow(const QString& moduleName, const QString& key);
- void openDefaultBible(const QString& key);
- QString getCurrentReference();
- QStringList searchInModule(const QString& module, const QString& searchText);
- QStringList searchInOpenModules(const QString& searchText);
- QStringList searchInDefaultBible(const QString& searchText);
- QStringList getModulesOfType(const QString& type);
- void reloadModules();
- //helper function
- void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key);
+ protected: //DBUS interface implementation
+ void closeAllModuleWindows();
+ void syncAllBibles(const QString& key);
+ void syncAllCommentaries(const QString& key);
+ void syncAllLexicons(const QString& key);
+ void syncAllVerseBasedModules(const QString& key);
+ void openWindow(const QString& moduleName, const QString& key);
+ void openDefaultBible(const QString& key);
+ QString getCurrentReference();
+ QStringList searchInModule(const QString& module, const QString& searchText);
+ QStringList searchInOpenModules(const QString& searchText);
+ QStringList searchInDefaultBible(const QString& searchText);
+ QStringList getModulesOfType(const QString& type);
+ void reloadModules();
+ //helper function
+ void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key);
};
#endif
diff --git a/src/bibletime_dbus.cpp b/src/bibletime_dbus.cpp
index e2976b5..fae2751 100644
--- a/src/bibletime_dbus.cpp
+++ b/src/bibletime_dbus.cpp
@@ -27,182 +27,182 @@
//helper function
void BibleTime::syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key) {
- qDebug() << "Syncing modules by type to key" << key.toLatin1();
- foreach (QMdiSubWindow* w, m_mdi->usableWindowList()) {
- CDisplayWindow* d = dynamic_cast<CDisplayWindow*>(w->widget());
- if (d && d->modules().count() && d->modules().first()->type() == type) {
- d->lookupKey(key);
- }
- }
+ qDebug() << "Syncing modules by type to key" << key.toLatin1();
+ foreach (QMdiSubWindow* w, m_mdi->usableWindowList()) {
+ CDisplayWindow* d = dynamic_cast<CDisplayWindow*>(w->widget());
+ if (d && d->modules().count() && d->modules().first()->type() == type) {
+ d->lookupKey(key);
+ }
+ }
}
void BibleTime::closeAllModuleWindows() {
- qDebug() << "DBUS: close all windows now...";
- m_mdi->deleteAll();
+ qDebug() << "DBUS: close all windows now...";
+ m_mdi->deleteAll();
}
void BibleTime::syncAllBibles(const QString& key) {
- qDebug() << "DBUS: syncing all bibles ...";
- syncAllModulesByType(CSwordModuleInfo::Bible, key);
+ qDebug() << "DBUS: syncing all bibles ...";
+ syncAllModulesByType(CSwordModuleInfo::Bible, key);
}
void BibleTime::syncAllCommentaries(const QString& key) {
- qDebug() << "DBUS: syncing all commentaries ...";
- syncAllModulesByType(CSwordModuleInfo::Commentary, key);
+ qDebug() << "DBUS: syncing all commentaries ...";
+ syncAllModulesByType(CSwordModuleInfo::Commentary, key);
}
void BibleTime::syncAllLexicons(const QString& key) {
- qDebug() << "DBUS: syncing all lexicons ...";
- syncAllModulesByType(CSwordModuleInfo::Lexicon, key);
+ qDebug() << "DBUS: syncing all lexicons ...";
+ syncAllModulesByType(CSwordModuleInfo::Lexicon, key);
}
void BibleTime::syncAllVerseBasedModules(const QString& key) {
- qDebug() << "DBUS: syncing all verse based modules ...";
- syncAllModulesByType(CSwordModuleInfo::Bible, key);
- syncAllModulesByType(CSwordModuleInfo::Commentary, key);
+ qDebug() << "DBUS: syncing all verse based modules ...";
+ syncAllModulesByType(CSwordModuleInfo::Bible, key);
+ syncAllModulesByType(CSwordModuleInfo::Commentary, key);
}
void BibleTime::openWindow(const QString& moduleName, const QString& key) {
- qDebug() << "DBUS: open window for module" << moduleName.toLatin1() << "and key" << key.toLatin1();
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName);
- if (module) {
- createReadDisplayWindow(module, key);
- }
+ qDebug() << "DBUS: open window for module" << moduleName.toLatin1() << "and key" << key.toLatin1();
+ CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName);
+ if (module) {
+ createReadDisplayWindow(module, key);
+ }
}
void BibleTime::openDefaultBible(const QString& key) {
- qDebug() << "DBUS: open default bible ...";
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
- if (mod) {
- openWindow(mod->name(), key);
- }
+ qDebug() << "DBUS: open default bible ...";
+ CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ if (mod) {
+ openWindow(mod->name(), key);
+ }
}
QStringList BibleTime::searchInModule(const QString& moduleName, const QString& searchText) {
- qDebug() << "DBUS: searchInModule" << moduleName.toLatin1();
- QStringList ret;
- CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
-
- if (mod) {
- //mod->search(searchText, CSwordModuleSearch::multipleWords, sword::ListKey());
- sword::ListKey scope;
- mod->searchIndexed( searchText, scope );
-
- sword::ListKey result = mod->searchResult();
- const QString lead = QString("[%1] ").arg(moduleName);
- ;
- for ( int i = 0; i < result.Count(); ++i ) {
- sword::SWKey* key = result.getElement(i);
- Q_ASSERT(key);
-
-
- if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
- sword::VerseKey vk(key->getText());
- ret << lead + QString::fromUtf8( vk.getOSISRef() );
- }
- else {
- ret << lead + QString::fromUtf8( key->getText() );
- }
- }
- }
-
- return ret;
+ qDebug() << "DBUS: searchInModule" << moduleName.toLatin1();
+ QStringList ret;
+ CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+
+ if (mod) {
+ //mod->search(searchText, CSwordModuleSearch::multipleWords, sword::ListKey());
+ sword::ListKey scope;
+ mod->searchIndexed( searchText, scope );
+
+ sword::ListKey result = mod->searchResult();
+ const QString lead = QString("[%1] ").arg(moduleName);
+ ;
+ for ( int i = 0; i < result.Count(); ++i ) {
+ sword::SWKey* key = result.getElement(i);
+ Q_ASSERT(key);
+
+
+ if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
+ sword::VerseKey vk(key->getText());
+ ret << lead + QString::fromUtf8( vk.getOSISRef() );
+ }
+ else {
+ ret << lead + QString::fromUtf8( key->getText() );
+ }
+ }
+ }
+
+ return ret;
}
QStringList BibleTime::searchInOpenModules(const QString& searchText) {
- qDebug() << "DBUS: search in open modules ...";
- QStringList ret;
- foreach (QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
- if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
- QList<CSwordModuleInfo*> windowModules = w->modules();
- QList<CSwordModuleInfo*>::iterator end_it = windowModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(windowModules.begin()); it != end_it; ++it) {
- ret += searchInModule((*it)->name(), searchText);
- }
- }
- }
- return ret;
+ qDebug() << "DBUS: search in open modules ...";
+ QStringList ret;
+ foreach (QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
+ if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
+ QList<CSwordModuleInfo*> windowModules = w->modules();
+ QList<CSwordModuleInfo*>::iterator end_it = windowModules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(windowModules.begin()); it != end_it; ++it) {
+ ret += searchInModule((*it)->name(), searchText);
+ }
+ }
+ }
+ return ret;
}
QStringList BibleTime::searchInDefaultBible(const QString& searchText) {
- CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
- return searchInModule(bible->name(), searchText);
+ CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
+ return searchInModule(bible->name(), searchText);
}
QString BibleTime::getCurrentReference() {
- qDebug() << "BibleTime::getCurrentReference";
- QString ret = QString::null;
-
- QMdiSubWindow* activeSubWindow = m_mdi->activeSubWindow();
- if (!activeSubWindow) return ret;
-
- CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(activeSubWindow->widget());
-
- if (w) {
- QString modType;
- Q_ASSERT(w->modules().first());
- switch (w->modules().first()->type()) {
- case CSwordModuleInfo::Bible:
- modType = "BIBLE";
- break;
- case CSwordModuleInfo::Commentary:
- modType = "COMMENTARY";
- break;
- case CSwordModuleInfo::GenericBook:
- modType = "BOOK";
- break;
- case CSwordModuleInfo::Lexicon:
- modType = "LEXICON";
- break;
- default:
- modType = "UNSUPPORTED";
- break;
- }
-
- ret.append("[").append(w->modules().first()->name()).append("] ");
- ret.append("[").append(modType).append("] ");
-
- CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>( w->key() );
- if (vk) {
- ret.append( vk->getOSISRef() );
- }
- else {
- ret.append( w->key()->key() );
- }
- }
-
- return ret;
+ qDebug() << "BibleTime::getCurrentReference";
+ QString ret = QString::null;
+
+ QMdiSubWindow* activeSubWindow = m_mdi->activeSubWindow();
+ if (!activeSubWindow) return ret;
+
+ CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(activeSubWindow->widget());
+
+ if (w) {
+ QString modType;
+ Q_ASSERT(w->modules().first());
+ switch (w->modules().first()->type()) {
+ case CSwordModuleInfo::Bible:
+ modType = "BIBLE";
+ break;
+ case CSwordModuleInfo::Commentary:
+ modType = "COMMENTARY";
+ break;
+ case CSwordModuleInfo::GenericBook:
+ modType = "BOOK";
+ break;
+ case CSwordModuleInfo::Lexicon:
+ modType = "LEXICON";
+ break;
+ default:
+ modType = "UNSUPPORTED";
+ break;
+ }
+
+ ret.append("[").append(w->modules().first()->name()).append("] ");
+ ret.append("[").append(modType).append("] ");
+
+ CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>( w->key() );
+ if (vk) {
+ ret.append( vk->getOSISRef() );
+ }
+ else {
+ ret.append( w->key()->key() );
+ }
+ }
+
+ return ret;
}
QStringList BibleTime::getModulesOfType(const QString& type) {
- QStringList ret;
-
- CSwordModuleInfo::ModuleType modType = CSwordModuleInfo::Unknown;
- if (type == "BIBLES") {
- modType = CSwordModuleInfo::Bible;
- }
- else if (type == "COMMENTARIES") {
- modType = CSwordModuleInfo::Commentary;
- }
- else if (type == "LEXICONS") {
- modType = CSwordModuleInfo::Lexicon;
-
- }
- else if (type == "BOOKS") {
- modType = CSwordModuleInfo::GenericBook;
- }
-
- QList<CSwordModuleInfo*> modList = CPointers::backend()->moduleList();
- for (QList<CSwordModuleInfo*>::iterator it( modList.begin() ); it != modList.end(); ++it) {
- if ((*it)->type() == modType) {
- ret.append( (*it)->name() );
- }
- }
-
- return ret;
+ QStringList ret;
+
+ CSwordModuleInfo::ModuleType modType = CSwordModuleInfo::Unknown;
+ if (type == "BIBLES") {
+ modType = CSwordModuleInfo::Bible;
+ }
+ else if (type == "COMMENTARIES") {
+ modType = CSwordModuleInfo::Commentary;
+ }
+ else if (type == "LEXICONS") {
+ modType = CSwordModuleInfo::Lexicon;
+
+ }
+ else if (type == "BOOKS") {
+ modType = CSwordModuleInfo::GenericBook;
+ }
+
+ QList<CSwordModuleInfo*> modList = CPointers::backend()->moduleList();
+ for (QList<CSwordModuleInfo*>::iterator it( modList.begin() ); it != modList.end(); ++it) {
+ if ((*it)->type() == modType) {
+ ret.append( (*it)->name() );
+ }
+ }
+
+ return ret;
}
void BibleTime::reloadModules() {
- slotSwordSetupChanged();
+ slotSwordSetupChanged();
}
diff --git a/src/bibletime_dbus_adaptor.cpp b/src/bibletime_dbus_adaptor.cpp
index ac32c47..6bd72ec 100644
--- a/src/bibletime_dbus_adaptor.cpp
+++ b/src/bibletime_dbus_adaptor.cpp
@@ -11,61 +11,60 @@
#include "bibletime_dbus_adaptor.h"
-BibleTimeDBusAdaptor::BibleTimeDBusAdaptor(BibleTime *bibletime_ptr) :
- QDBusAbstractAdaptor(bibletime_ptr),
- m_bibletime(bibletime_ptr)
-{
+BibleTimeDBusAdaptor::BibleTimeDBusAdaptor(BibleTime *bibletime_ptr) :
+ QDBusAbstractAdaptor(bibletime_ptr),
+ m_bibletime(bibletime_ptr) {
}
-
-void BibleTimeDBusAdaptor::syncAllBibles(const QString& key){
- m_bibletime->syncAllBibles(key);
+
+void BibleTimeDBusAdaptor::syncAllBibles(const QString& key) {
+ m_bibletime->syncAllBibles(key);
}
-void BibleTimeDBusAdaptor::syncAllCommentaries(const QString& key){
- m_bibletime->syncAllCommentaries(key);
+void BibleTimeDBusAdaptor::syncAllCommentaries(const QString& key) {
+ m_bibletime->syncAllCommentaries(key);
}
-void BibleTimeDBusAdaptor::syncAllLexicons(const QString& key){
- m_bibletime->syncAllLexicons(key);
+void BibleTimeDBusAdaptor::syncAllLexicons(const QString& key) {
+ m_bibletime->syncAllLexicons(key);
}
-void BibleTimeDBusAdaptor::syncAllVerseBasedModules(const QString& key){
- m_bibletime->syncAllVerseBasedModules(key);
+void BibleTimeDBusAdaptor::syncAllVerseBasedModules(const QString& key) {
+ m_bibletime->syncAllVerseBasedModules(key);
}
-void BibleTimeDBusAdaptor::reloadModules(){
- m_bibletime->reloadModules();
+void BibleTimeDBusAdaptor::reloadModules() {
+ m_bibletime->reloadModules();
}
-void BibleTimeDBusAdaptor::openWindow(const QString& moduleName, const QString& key){
- m_bibletime->openWindow(moduleName, key);
+void BibleTimeDBusAdaptor::openWindow(const QString& moduleName, const QString& key) {
+ m_bibletime->openWindow(moduleName, key);
}
-void BibleTimeDBusAdaptor::openDefaultBible(const QString& key){
- m_bibletime->openDefaultBible(key);
+void BibleTimeDBusAdaptor::openDefaultBible(const QString& key) {
+ m_bibletime->openDefaultBible(key);
}
-void BibleTimeDBusAdaptor::closeAllModuleWindows(){
- m_bibletime->closeAllModuleWindows();
+void BibleTimeDBusAdaptor::closeAllModuleWindows() {
+ m_bibletime->closeAllModuleWindows();
}
-QString BibleTimeDBusAdaptor::getCurrentReference(){
- return m_bibletime->getCurrentReference();
+QString BibleTimeDBusAdaptor::getCurrentReference() {
+ return m_bibletime->getCurrentReference();
}
-QStringList BibleTimeDBusAdaptor::searchInModule(const QString& moduleName, const QString& searchText){
- return m_bibletime->searchInModule(moduleName, searchText);
+QStringList BibleTimeDBusAdaptor::searchInModule(const QString& moduleName, const QString& searchText) {
+ return m_bibletime->searchInModule(moduleName, searchText);
}
-QStringList BibleTimeDBusAdaptor::searchInOpenModules(const QString& searchText){
- return m_bibletime->searchInOpenModules(searchText);
+QStringList BibleTimeDBusAdaptor::searchInOpenModules(const QString& searchText) {
+ return m_bibletime->searchInOpenModules(searchText);
}
-QStringList BibleTimeDBusAdaptor::searchInDefaultBible(const QString& searchText){
- return m_bibletime->searchInDefaultBible(searchText);
+QStringList BibleTimeDBusAdaptor::searchInDefaultBible(const QString& searchText) {
+ return m_bibletime->searchInDefaultBible(searchText);
}
-QStringList BibleTimeDBusAdaptor::getModulesOfType(const QString& type){
- return m_bibletime->getModulesOfType(type);
+QStringList BibleTimeDBusAdaptor::getModulesOfType(const QString& type) {
+ return m_bibletime->getModulesOfType(type);
}
#endif //NO_DBUS
diff --git a/src/bibletime_dbus_adaptor.h b/src/bibletime_dbus_adaptor.h
index dc238db..4116463 100644
--- a/src/bibletime_dbus_adaptor.h
+++ b/src/bibletime_dbus_adaptor.h
@@ -21,88 +21,87 @@
#include <QDBusAbstractAdaptor>
#endif
-class BibleTimeDBusAdaptor : QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "info.bibletime.BibleTime")
+class BibleTimeDBusAdaptor : QDBusAbstractAdaptor {
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "info.bibletime.BibleTime")
-private:
- BibleTime* m_bibletime;
+ private:
+ BibleTime* m_bibletime;
-public:
- BibleTimeDBusAdaptor(BibleTime *bibletime_ptr);
-
-public slots:
- /** Sync all open Bible windows to the key.
- * @param key The key which is set to all Bible windows.
- */
- void syncAllBibles(const QString& key);
- /** Sync all open commentary windows to the key.
- * @param key The key which is set to all Commentary windows.
- */
- void syncAllCommentaries(const QString& key);
- /** Sync all open lexicon windows to the key.
- * @param key The key which is set to all Lexicon windows.
- */
- void syncAllLexicons(const QString& key);
- /** Sync all open verse based (i.e. Bibles and commentaries) windows to the key.
- * @param key The key which is set to all Bible and Commentary windows.
- */
- void syncAllVerseBasedModules(const QString& key);
- /** Reload all modules
- */
- void reloadModules();
- /** Open a new read window for the module moduleName using the given key
- * @param moduleName The name of the module which is opened in a new module window.
- * @param key The key to set to the newly opened window.
- */
- void openWindow(const QString& moduleName, const QString& key);
- /** Open a new read window for the default Bible module using the given key
- * @param key The key to set to the newly opened window.
- */
- void openDefaultBible(const QString& key);
- /** Close all open windows.
- */
- void closeAllModuleWindows();
- /** Returns the reference used in the current window.
- * The format of the returned reference is
- * [Module] [Type] OSIS_Reference,
- * wtih type one of BIBLE/COMMENTARY/BOOK/LEXICON/UNSUPPORTED
- * If the type is BIBLE or COMMENTARY the reference is an OSIS ref
- * in the other cases it's the key name, for books /Chapter/Subsection
- * for Lexicons just the plain key, e.g. "ADAM".
- * e.g.
- * [KJV] [BIBLE] Gen.1.1
- * [MHC] [COMMENTARY] Gen.1.1
- * [ISBE] [LEXICON] REDEMPTION
- * @return The reference displayed in the currently active module window. Empty if none is active.
- */
- QString getCurrentReference();
- /** Seach the searchText in the specified module.
- * @param moduleName The module to search in
- * @param searchText Search for this in the modules
- * @return The search result. It's in the format [modulename] osis_ref_of_the_found_key. For example "[KJV] Gen.1.1".
- */
- QStringList searchInModule(const QString& moduleName, const QString& searchText) ;
- /** Search in all open modules and return the search result.
- * The result is in the same format as searchInModule
- * @param searchText Search for this in the modules
- * @return The search result for a searchin all opened module windows
- * @see searchInModule For the search result format.
- */
- QStringList searchInOpenModules(const QString& searchText);
- /** Search in the default Bible module and return the search result.
- * The result is in the same format as searchInModule
- * @param searchText Search for this in the modules
- * @return The search result for a search in the default Bible
- * @see searchInModule
- */
- QStringList searchInDefaultBible(const QString& searchText);
- /** Return a list of modules of the given type.
- * @param type One of BIBLES, COMMENTARIES, LEXICONS, BOOKS
- * @return The list of modules of the given type, may be empty
- */
- QStringList getModulesOfType(const QString& type);
+ public:
+ BibleTimeDBusAdaptor(BibleTime *bibletime_ptr);
+
+ public slots:
+ /** Sync all open Bible windows to the key.
+ * @param key The key which is set to all Bible windows.
+ */
+ void syncAllBibles(const QString& key);
+ /** Sync all open commentary windows to the key.
+ * @param key The key which is set to all Commentary windows.
+ */
+ void syncAllCommentaries(const QString& key);
+ /** Sync all open lexicon windows to the key.
+ * @param key The key which is set to all Lexicon windows.
+ */
+ void syncAllLexicons(const QString& key);
+ /** Sync all open verse based (i.e. Bibles and commentaries) windows to the key.
+ * @param key The key which is set to all Bible and Commentary windows.
+ */
+ void syncAllVerseBasedModules(const QString& key);
+ /** Reload all modules
+ */
+ void reloadModules();
+ /** Open a new read window for the module moduleName using the given key
+ * @param moduleName The name of the module which is opened in a new module window.
+ * @param key The key to set to the newly opened window.
+ */
+ void openWindow(const QString& moduleName, const QString& key);
+ /** Open a new read window for the default Bible module using the given key
+ * @param key The key to set to the newly opened window.
+ */
+ void openDefaultBible(const QString& key);
+ /** Close all open windows.
+ */
+ void closeAllModuleWindows();
+ /** Returns the reference used in the current window.
+ * The format of the returned reference is
+ * [Module] [Type] OSIS_Reference,
+ * wtih type one of BIBLE/COMMENTARY/BOOK/LEXICON/UNSUPPORTED
+ * If the type is BIBLE or COMMENTARY the reference is an OSIS ref
+ * in the other cases it's the key name, for books /Chapter/Subsection
+ * for Lexicons just the plain key, e.g. "ADAM".
+ * e.g.
+ * [KJV] [BIBLE] Gen.1.1
+ * [MHC] [COMMENTARY] Gen.1.1
+ * [ISBE] [LEXICON] REDEMPTION
+ * @return The reference displayed in the currently active module window. Empty if none is active.
+ */
+ QString getCurrentReference();
+ /** Seach the searchText in the specified module.
+ * @param moduleName The module to search in
+ * @param searchText Search for this in the modules
+ * @return The search result. It's in the format [modulename] osis_ref_of_the_found_key. For example "[KJV] Gen.1.1".
+ */
+ QStringList searchInModule(const QString& moduleName, const QString& searchText) ;
+ /** Search in all open modules and return the search result.
+ * The result is in the same format as searchInModule
+ * @param searchText Search for this in the modules
+ * @return The search result for a searchin all opened module windows
+ * @see searchInModule For the search result format.
+ */
+ QStringList searchInOpenModules(const QString& searchText);
+ /** Search in the default Bible module and return the search result.
+ * The result is in the same format as searchInModule
+ * @param searchText Search for this in the modules
+ * @return The search result for a search in the default Bible
+ * @see searchInModule
+ */
+ QStringList searchInDefaultBible(const QString& searchText);
+ /** Return a list of modules of the given type.
+ * @param type One of BIBLES, COMMENTARIES, LEXICONS, BOOKS
+ * @return The list of modules of the given type, may be empty
+ */
+ QStringList getModulesOfType(const QString& type);
};
#endif
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index 614469b..dd68265 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -45,354 +45,349 @@ using namespace InfoDisplay;
using namespace Profile;
/**Initializes the view of this widget*/
-void BibleTime::initView()
-{
- m_mdi = new CMDIArea(this);
- setCentralWidget(m_mdi);
+void BibleTime::initView() {
+ m_mdi = new CMDIArea(this);
+ setCentralWidget(m_mdi);
m_bookshelfDock = new BtBookshelfDockWidget(this);
addDockWidget(Qt::LeftDockWidgetArea, m_bookshelfDock);
-
+
m_bookmarksDock = new QDockWidget(tr("Bookmarks"), this);
m_bookmarksDock->setObjectName("BookmarksDock");
- m_bookmarksPage = new CBookmarkIndex(0);
+ m_bookmarksPage = new CBookmarkIndex(0);
m_bookmarksDock->setWidget(m_bookmarksPage);
addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksDock);
tabifyDockWidget(m_bookmarksDock, m_bookshelfDock);
-
+
m_magDock = new QDockWidget(tr("Mag"), this);
m_magDock->setObjectName("MagDock");
- m_infoDisplay = new CInfoDisplay(this);
- m_infoDisplay->resize(150,150);
+ m_infoDisplay = new CInfoDisplay(this);
+ m_infoDisplay->resize(150, 150);
m_magDock->setWidget(m_infoDisplay);
addDockWidget(Qt::LeftDockWidgetArea, m_magDock);
-
- CPointers::setInfoDisplay(m_infoDisplay);
- m_mdi->setMinimumSize(100, 100);
- m_mdi->setFocusPolicy(Qt::ClickFocus);
+
+ CPointers::setInfoDisplay(m_infoDisplay);
+ m_mdi->setMinimumSize(100, 100);
+ 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 )
-{
- action->setText(text);
- if ( ! icon.isEmpty() )
- action->setIcon(util::filesystem::DirectoryUtil::getIcon(icon));
- action->setShortcut(accel);
- if (tooltip != QString::null) action->setToolTip(tooltip);
+QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKeySequence accel,
+ const QString& tooltip, const QString& actionName, const char* slot ) {
+ action->setText(text);
+ if ( ! icon.isEmpty() )
+ action->setIcon(util::filesystem::DirectoryUtil::getIcon(icon));
+ action->setShortcut(accel);
+ if (tooltip != QString::null) action->setToolTip(tooltip);
m_actionCollection->addAction(actionName, action);
- if (slot) QObject::connect( action, SIGNAL(triggered()), this, slot );
- return action;
+ if (slot) QObject::connect( action, SIGNAL(triggered()), this, slot );
+ return action;
}
// 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 )
-{
- QAction* action = new QAction(a);
- action->setText(tr("&Quit"));
- action->setIcon(util::filesystem::DirectoryUtil::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->setShortcut(QKeySequence(CResMgr::mainMenu::window::showFullscreen::accel));
- action->setToolTip(tr("Toggle fullscreen mode of the main window"));
- a->addAction("toggleFullscreen", action);
-
- action = new QAction(a);
- action->setText(tr("&Show toolbar"));
- action->setShortcut(QKeySequence(Qt::Key_F6));
- a->addAction("showToolbar", action);
-
- action = new QAction(a);
- action->setText(tr("Search in &open works..."));
- action->setIcon(util::filesystem::DirectoryUtil::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->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->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->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->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->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->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->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->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->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("Cl&ose all windows"));
- action->setIcon(util::filesystem::DirectoryUtil::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->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->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->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->setShortcut(QKeySequence(CResMgr::mainMenu::help::bibleStudyHowTo::accel));
- action->setToolTip(tr("Open the Bible study HowTo included with BibleTime.<BR>This HowTo is an introduction on how to study the Bible in an efficient way."));
- a->addAction("bibleStudyHowto", action);
-
- action = new QAction(a);
- action->setText(tr("&About BibleTime"));
- action->setToolTip(tr("Information about the BibleTime program"));
- a->addAction("aboutBibleTime", action);
+void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
+ QAction* action = new QAction(a);
+ action->setText(tr("&Quit"));
+ action->setIcon(util::filesystem::DirectoryUtil::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->setShortcut(QKeySequence(CResMgr::mainMenu::window::showFullscreen::accel));
+ action->setToolTip(tr("Toggle fullscreen mode of the main window"));
+ a->addAction("toggleFullscreen", action);
+
+ action = new QAction(a);
+ action->setText(tr("&Show toolbar"));
+ action->setShortcut(QKeySequence(Qt::Key_F6));
+ a->addAction("showToolbar", action);
+
+ action = new QAction(a);
+ action->setText(tr("Search in &open works..."));
+ action->setIcon(util::filesystem::DirectoryUtil::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->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->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->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->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->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->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->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->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->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("Cl&ose all windows"));
+ action->setIcon(util::filesystem::DirectoryUtil::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->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->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->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->setShortcut(QKeySequence(CResMgr::mainMenu::help::bibleStudyHowTo::accel));
+ action->setToolTip(tr("Open the Bible study HowTo included with BibleTime.<BR>This HowTo is an introduction on how to study the Bible in an efficient way."));
+ a->addAction("bibleStudyHowto", action);
+
+ action = new QAction(a);
+ action->setText(tr("&About BibleTime"));
+ action->setToolTip(tr("Information about the BibleTime program"));
+ a->addAction("aboutBibleTime", action);
}
/** Initializes the action objects of the GUI */
-void BibleTime::initActions()
-{
+void BibleTime::initActions() {
m_actionCollection = new BtActionCollection(this);
- insertKeyboardActions(m_actionCollection);
-
- // Main menus
- QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
- QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
- QMenu* searchMenu = menuBar()->addMenu(tr("&Search"));
- m_windowMenu = menuBar()->addMenu(tr("&Window"));
- QMenu* settingsMenu = menuBar()->addMenu(tr("Se&ttings"));
- QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
-
- // Name of the main toolbar
- m_mainToolBar = addToolBar(tr("Main Toolbar"));
- m_mainToolBar->setObjectName("MainToolBar");
- m_mainToolBar->setFloatable(false);
- m_mainToolBar->setMovable(false);
-
- QAction* tmp = m_actionCollection->action("quit");
- fileMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- m_mainToolBar->addSeparator();
- connect(tmp, SIGNAL(triggered()), this, SLOT(close()) );
-
- m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
- m_windowFullscreen_action->setCheckable(true);
- viewMenu->addAction(m_windowFullscreen_action);
- m_mainToolBar->addAction(m_windowFullscreen_action);
- connect(m_windowFullscreen_action, SIGNAL(triggered()), this, SLOT(toggleFullscreen()) );
-
- m_viewToolbar_action = m_actionCollection->action("showToolbar");
- m_viewToolbar_action->setCheckable(true);
- m_viewToolbar_action->setChecked(true);
- viewMenu->addAction(m_viewToolbar_action);
- connect(m_viewToolbar_action, SIGNAL(triggered()), this, SLOT(slotToggleToolbar()) );
-
-
+ insertKeyboardActions(m_actionCollection);
+
+ // Main menus
+ QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
+ QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
+ QMenu* searchMenu = menuBar()->addMenu(tr("&Search"));
+ m_windowMenu = menuBar()->addMenu(tr("&Window"));
+ QMenu* settingsMenu = menuBar()->addMenu(tr("Se&ttings"));
+ QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
+
+ // Name of the main toolbar
+ m_mainToolBar = addToolBar(tr("Main Toolbar"));
+ m_mainToolBar->setObjectName("MainToolBar");
+ m_mainToolBar->setFloatable(false);
+ m_mainToolBar->setMovable(false);
+
+ QAction* tmp = m_actionCollection->action("quit");
+ fileMenu->addAction(tmp);
+ m_mainToolBar->addAction(tmp);
+ m_mainToolBar->addSeparator();
+ connect(tmp, SIGNAL(triggered()), this, SLOT(close()) );
+
+ m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
+ m_windowFullscreen_action->setCheckable(true);
+ viewMenu->addAction(m_windowFullscreen_action);
+ m_mainToolBar->addAction(m_windowFullscreen_action);
+ connect(m_windowFullscreen_action, SIGNAL(triggered()), this, SLOT(toggleFullscreen()) );
+
+ m_viewToolbar_action = m_actionCollection->action("showToolbar");
+ m_viewToolbar_action->setCheckable(true);
+ m_viewToolbar_action->setChecked(true);
+ viewMenu->addAction(m_viewToolbar_action);
+ connect(m_viewToolbar_action, SIGNAL(triggered()), this, SLOT(slotToggleToolbar()) );
+
+
QAction* action = m_bookshelfDock->toggleViewAction();
- action->setText(tr("Show Bookshelf"));
- viewMenu->addAction(action);
-
+ action->setText(tr("Show Bookshelf"));
+ viewMenu->addAction(action);
+
action = m_bookmarksDock->toggleViewAction();
- action->setText(tr("Show Bookmarks"));
- viewMenu->addAction(action);
-
+ action->setText(tr("Show Bookmarks"));
+ viewMenu->addAction(action);
+
action = m_magDock->toggleViewAction();
- action->setText(tr("Show Mag"));
- viewMenu->addAction(action);
-
- m_mainToolBar->addSeparator();
+ action->setText(tr("Show Mag"));
+ viewMenu->addAction(action);
+
+ m_mainToolBar->addSeparator();
- tmp = m_actionCollection->action("searchOpenWorks");
- searchMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- m_mainToolBar->addSeparator();
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchModules()) );
+ tmp = m_actionCollection->action("searchOpenWorks");
+ searchMenu->addAction(tmp);
+ m_mainToolBar->addAction(tmp);
+ m_mainToolBar->addSeparator();
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchModules()) );
- tmp = m_actionCollection->action("searchStdBible");
- searchMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchDefaultBible()) );
+ tmp = m_actionCollection->action("searchStdBible");
+ searchMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchDefaultBible()) );
- m_windowSaveProfileMenu = new QMenu(tr("&Save session"));
- m_windowMenu->addMenu(m_windowSaveProfileMenu);
+ 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()) );
+ m_windowSaveToNewProfile_action = m_actionCollection->action("saveNewSession");
+ m_windowMenu->addAction(m_windowSaveToNewProfile_action);
+ connect(m_windowSaveToNewProfile_action, SIGNAL(triggered()), this, SLOT(saveToNewProfile()) );
- m_windowLoadProfileMenu = new QMenu(tr("&Load session"));
- m_windowMenu->addMenu(m_windowLoadProfileMenu);
+ 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*)));
+ m_windowDeleteProfileMenu = new QMenu(tr("&Delete session"));
+ m_windowMenu->addMenu(m_windowDeleteProfileMenu);
- refreshProfileMenus();
+ QObject::connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)), SLOT(loadProfile(QAction*)));
+ QObject::connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)), SLOT(saveProfile(QAction*)));
+ QObject::connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)), SLOT(deleteProfile(QAction*)));
- m_windowMenu->addSeparator();
+ refreshProfileMenus();
+
+ m_windowMenu->addSeparator();
//--------------------------Window arrangement actions---------------------------------------
- QMenu* arrangementMenu = new QMenu(tr("&Arrangement mode"));
- m_windowMenu->addMenu(arrangementMenu);
+ QMenu* arrangementMenu = new QMenu(tr("&Arrangement mode"));
+ m_windowMenu->addMenu(arrangementMenu);
+
+ m_windowManualMode_action = m_actionCollection->action("manualArrangement");
+ m_windowManualMode_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowManualMode_action);
+ connect(m_windowManualMode_action, SIGNAL(triggered()), this, SLOT(slotManualArrangementMode()) );
- m_windowManualMode_action = m_actionCollection->action("manualArrangement");
- m_windowManualMode_action->setCheckable(true);
- arrangementMenu->addAction(m_windowManualMode_action);
- connect(m_windowManualMode_action, SIGNAL(triggered()), this, SLOT(slotManualArrangementMode()) );
+ //: Vertical tiling means that windows are vertical, placed side by side
+ m_windowAutoTileVertical_action = m_actionCollection->action("autoVertical");
+ m_windowAutoTileVertical_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowAutoTileVertical_action);
+ connect(m_windowAutoTileVertical_action, SIGNAL(triggered()), this, SLOT(slotAutoTileVertical()) );
- //: Vertical tiling means that windows are vertical, placed side by side
- m_windowAutoTileVertical_action = m_actionCollection->action("autoVertical");
- m_windowAutoTileVertical_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoTileVertical_action);
- connect(m_windowAutoTileVertical_action, SIGNAL(triggered()), this, SLOT(slotAutoTileVertical()) );
+ //: Horizontal tiling means that windows are horizontal, placed on top of each other
+ m_windowAutoTileHorizontal_action = m_actionCollection->action("autoHorizontal");
+ m_windowAutoTileHorizontal_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowAutoTileHorizontal_action);
+ connect(m_windowAutoTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotAutoTileHorizontal()) );
- //: Horizontal tiling means that windows are horizontal, placed on top of each other
- m_windowAutoTileHorizontal_action = m_actionCollection->action("autoHorizontal");
- m_windowAutoTileHorizontal_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoTileHorizontal_action);
- connect(m_windowAutoTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotAutoTileHorizontal()) );
+ m_windowAutoCascade_action = m_actionCollection->action("autoCascade");
+ m_windowAutoCascade_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowAutoCascade_action);
+ connect(m_windowAutoCascade_action, SIGNAL(triggered()), this, SLOT(slotAutoCascade()) );
- m_windowAutoCascade_action = m_actionCollection->action("autoCascade");
- m_windowAutoCascade_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoCascade_action);
- connect(m_windowAutoCascade_action, SIGNAL(triggered()), this, SLOT(slotAutoCascade()) );
+ m_windowCascade_action = m_actionCollection->action("cascade");
+ m_windowMenu->addAction(m_windowCascade_action);
+ connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
- m_windowCascade_action = m_actionCollection->action("cascade");
- m_windowMenu->addAction(m_windowCascade_action);
- connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
+ m_windowTileVertical_action = m_actionCollection->action("tileVertically");
+ m_windowMenu->addAction(m_windowTileVertical_action);
+ connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
- m_windowTileVertical_action = m_actionCollection->action("tileVertically");
- m_windowMenu->addAction(m_windowTileVertical_action);
- connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
+ m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
+ m_windowMenu->addAction(m_windowTileHorizontal_action);
+ connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
- m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
- m_windowMenu->addAction(m_windowTileHorizontal_action);
- connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
+ m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
+ m_windowMenu->addAction(m_windowCloseAll_action);
+ connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(deleteAll()));
- m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
- m_windowMenu->addAction(m_windowCloseAll_action);
- connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(deleteAll()));
+ tmp = m_actionCollection->action("setPreferences");
+ settingsMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSettingsOptions()) );
- tmp = m_actionCollection->action("setPreferences");
- settingsMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSettingsOptions()) );
+ settingsMenu->addSeparator();
- settingsMenu->addSeparator();
-
- tmp = m_actionCollection->action("bookshelfManager");
- settingsMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSwordSetupDialog()) );
+ tmp = m_actionCollection->action("bookshelfManager");
+ settingsMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotSwordSetupDialog()) );
- tmp = m_actionCollection->action("openHandbook");
- helpMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Handbook()) );
+ tmp = m_actionCollection->action("openHandbook");
+ helpMenu->addAction(tmp);
+ m_mainToolBar->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Handbook()) );
- tmp = m_actionCollection->action("bibleStudyHowto");
- helpMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Howto()) );
+ tmp = m_actionCollection->action("bibleStudyHowto");
+ helpMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Howto()) );
- helpMenu->addSeparator();
+ helpMenu->addSeparator();
- tmp = m_actionCollection->action("aboutBibleTime");
- helpMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotOpenAboutDialog()) );
+ tmp = m_actionCollection->action("aboutBibleTime");
+ helpMenu->addAction(tmp);
+ connect(tmp, SIGNAL(triggered()), this, SLOT(slotOpenAboutDialog()) );
}
/** Initializes the SIGNAL / SLOT connections */
-void BibleTime::initConnections()
-{
- QObject::connect(m_mdi, SIGNAL(sigSetToplevelCaption(const QString&)),
- this, SLOT(setPlainCaption(const QString&)));
- QObject::connect(m_mdi, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
- this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
-
- if (m_windowMenu) {
- QObject::connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowMenuAboutToShow()));
- }
- else {
- qWarning() << "Main window: can't find window menu";
- }
-
- bool ok;
- ok = connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
- this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>,const QString&)));
- Q_ASSERT(ok);
+void BibleTime::initConnections() {
+ QObject::connect(m_mdi, SIGNAL(sigSetToplevelCaption(const QString&)),
+ this, SLOT(setPlainCaption(const QString&)));
+ QObject::connect(m_mdi, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
+ this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
+
+ if (m_windowMenu) {
+ QObject::connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowMenuAboutToShow()));
+ }
+ else {
+ qWarning() << "Main window: can't find window menu";
+ }
+
+ bool ok;
+ ok = connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
+ this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
+ Q_ASSERT(ok);
connect(m_bookshelfDock, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)),
this, SLOT(createReadDisplayWindow(CSwordModuleInfo*)));
connect(m_bookshelfDock, SIGNAL(moduleSearchTriggered(CSwordModuleInfo*)),
@@ -406,26 +401,25 @@ void BibleTime::initConnections()
connect(m_bookshelfDock, SIGNAL(moduleAboutTriggered(CSwordModuleInfo*)),
this, SLOT(moduleAbout(CSwordModuleInfo*)));
- connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slot_aboutToQuit()));
+ connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slot_aboutToQuit()));
}
/** Initializes the backend */
-void BibleTime::initBackends()
-{
- qDebug("BibleTime::initBackends");
-
- sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
- sword::SWLog::getSystemLog()->setLogLevel(1);
-
- CSwordBackend* backend = new CSwordBackend();
- backend->booknameLanguage(CBTConfig::get(CBTConfig::language) );
-
- CPointers::setBackend(backend);
- const CSwordBackend::LoadError errorCode = CPointers::backend()->initModules(CSwordBackend::OtherChange);
-
- if (errorCode != CSwordBackend::NoError) {
- //show error message that initBackend failed
- //TODO:
+void BibleTime::initBackends() {
+ qDebug("BibleTime::initBackends");
+
+ sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
+ sword::SWLog::getSystemLog()->setLogLevel(1);
+
+ CSwordBackend* backend = new CSwordBackend();
+ backend->booknameLanguage(CBTConfig::get(CBTConfig::language) );
+
+ CPointers::setBackend(backend);
+ const CSwordBackend::LoadError errorCode = CPointers::backend()->initModules(CSwordBackend::OtherChange);
+
+ if (errorCode != CSwordBackend::NoError) {
+ //show error message that initBackend failed
+ //TODO:
// switch (errorCode) {
// case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
// {
@@ -436,7 +430,7 @@ void BibleTime::initBackends()
// dlg.exec();
// break;
// }
-//
+//
// case CSwordBackend::NoModules: //no modules installed, but config exists
// {
// KStartupLogo::hideSplash();
@@ -446,7 +440,7 @@ void BibleTime::initBackends()
// dlg.exec();
// break;
// }
-//
+//
// default: //unknown error
// {
// KStartupLogo::hideSplash();
@@ -457,56 +451,62 @@ void BibleTime::initBackends()
// break;
// }
// }
- }
-
- //This function will
- // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
- // - delete all indices of modules where hasIndex() returns false
- //BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices();
- //TODO: //backend::deleteOrphanedIndices();
-
+ }
+
+ //This function will
+ // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
+ // - delete all indices of modules where hasIndex() returns false
+ //BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices();
+ //TODO: //backend::deleteOrphanedIndices();
+
}
-void BibleTime::applyProfileSettings( CProfile* p )
-{
- 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());
-
- const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
- //make sure actions are updated by calling the slot functions
- //updatesEnabled in the MDI area is false atm, so changes won't actually be displayed yet
- switch(newArrangementMode){
- case CMDIArea::ArrangementModeTileVertical: slotAutoTileVertical(); break;
- case CMDIArea::ArrangementModeTileHorizontal: slotAutoTileHorizontal(); break;
- case CMDIArea::ArrangementModeCascade: slotAutoCascade(); break;
- default: slotManualArrangementMode(); break;
- }
+void BibleTime::applyProfileSettings( CProfile* p ) {
+ 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());
+
+ const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
+ //make sure actions are updated by calling the slot functions
+ //updatesEnabled in the MDI area is false atm, so changes won't actually be displayed yet
+ switch (newArrangementMode) {
+ case CMDIArea::ArrangementModeTileVertical:
+ slotAutoTileVertical();
+ break;
+ case CMDIArea::ArrangementModeTileHorizontal:
+ slotAutoTileHorizontal();
+ break;
+ case CMDIArea::ArrangementModeCascade:
+ slotAutoCascade();
+ break;
+ default:
+ slotManualArrangementMode();
+ break;
+ }
}
-void BibleTime::storeProfileSettings( CProfile* p )
-{
- Q_ASSERT(p && m_windowFullscreen_action);
- 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->setMDIArrangementMode(m_mdi->getMDIArrangementMode());
+void BibleTime::storeProfileSettings( CProfile* p ) {
+ Q_ASSERT(p && m_windowFullscreen_action);
+ 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->setMDIArrangementMode(m_mdi->getMDIArrangementMode());
}
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index 40d1319..aaf1b1d 100644
--- a/src/bibletime_slots.cpp
+++ b/src/bibletime_slots.cpp
@@ -50,47 +50,44 @@ using namespace Profile;
// class KUserDataAction : public KToggleAction {
// public:
// KUserDataAction( QString caption, const KShortcut& shortcut, const QObject* receiver, const char* slot, KActionCollection* actionCollection)
-// : KToggleAction(caption, actionCollection), m_userData(0)
+// : KToggleAction(caption, actionCollection), m_userData(0)
// {
// setShortcut(shortcut);
// QObject::connect(this, SIGNAL(triggered()), receiver, slot);
// };
-//
+//
// void setUserData(QWidget* const data) {
// m_userData = data;
// };
// QWidget* const getUserData() const {
// return m_userData;
// };
-//
+//
// private:
// QWidget* m_userData;
// };
/** Opens the optionsdialog of BibleTime. */
-void BibleTime::slotSettingsOptions()
-{
- qDebug("BibleTime::slotSettingsOptions");
+void BibleTime::slotSettingsOptions() {
+ qDebug("BibleTime::slotSettingsOptions");
CConfigurationDialog *dlg = new CConfigurationDialog(this, m_actionCollection);
- QObject::connect(dlg, SIGNAL(signalSettingsChanged()), this, SLOT(slotSettingsChanged()) );
+ QObject::connect(dlg, SIGNAL(signalSettingsChanged()), this, SLOT(slotSettingsChanged()) );
- dlg->show();
+ dlg->show();
}
/** Save the settings, used when no settings have been saved before **/
-void BibleTime::saveConfigSettings()
-{
- CConfigurationDialog* dlg = new CConfigurationDialog(this, 0);
- dlg->save();
- delete dlg;
+void BibleTime::saveConfigSettings() {
+ CConfigurationDialog* dlg = new CConfigurationDialog(this, 0);
+ dlg->save();
+ delete dlg;
}
/** Is called when settings in the optionsdialog were changed (ok or apply) */
-void BibleTime::slotSettingsChanged()
-{
- qDebug("BibleTime::slotSettingsChanged");
- const QString language = CBTConfig::get(CBTConfig::language);
- CPointers::backend()->booknameLanguage(language);
+void 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
// QTreeWidgetItemIterator it(m_mainIndex);
@@ -102,95 +99,88 @@ void BibleTime::slotSettingsChanged()
// ++it;
// }
- refreshBibleTimeAccel();
- refreshDisplayWindows();
- refreshProfileMenus();
- qDebug("BibleTime::slotSettingsChanged");
+ refreshBibleTimeAccel();
+ refreshDisplayWindows();
+ refreshProfileMenus();
+ qDebug("BibleTime::slotSettingsChanged");
}
/** Opens the sword setup dialog of BibleTime. */
-void BibleTime::slotSwordSetupDialog()
-{
- //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
- //QObject::disconnect(dlg, SIGNAL(swordSetupChanged()), this, SLOT(slotSwordSetupChanged()) );
- //connect(dlg, SIGNAL(swordSetupChanged()), SLOT(slotSwordSetupChanged()) );
-
- dlg->showNormal();
- dlg->show();
- dlg->raise();
- dlg->activateWindow();
+void BibleTime::slotSwordSetupDialog() {
+ //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
+ //QObject::disconnect(dlg, SIGNAL(swordSetupChanged()), this, SLOT(slotSwordSetupChanged()) );
+ //connect(dlg, SIGNAL(swordSetupChanged()), SLOT(slotSwordSetupChanged()) );
+
+ dlg->showNormal();
+ dlg->show();
+ dlg->raise();
+ dlg->activateWindow();
}
/** Is called when settings in the sword setup dialog were changed (ok or apply) */
-void BibleTime::slotSwordSetupChanged()
-{
- /*
- Refresh everything here what might have changed
- these are the mainindex, the searchdialog, the displaywindows
- But at first we have to reset the Sword backend to reload the modules
+void BibleTime::slotSwordSetupChanged() {
+ /*
+ Refresh everything here what might have changed
+ 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?
- Should there be different signals/slots for visual changes,
- i.e. grouping/hiding?
+ TODO: should bookshelf manager be updated?
+ Should there be different signals/slots for visual changes,
+ i.e. grouping/hiding?
- */
+ */
- //CPointers::deleteBackend();
- //m_backend = new CSwordBackend();
- //CPointers::setBackend(new CSwordBackend());
- //CPointers::backend()->reloadModules();
+ //CPointers::deleteBackend();
+ //m_backend = new CSwordBackend();
+ //CPointers::setBackend(new CSwordBackend());
+ //CPointers::backend()->reloadModules();
- //m_mainIndex->reloadSword();
+ //m_mainIndex->reloadSword();
- // refresh display windows
- //refreshDisplayWindows();
+ // refresh display windows
+ //refreshDisplayWindows();
}
/** Is called just before the window menu is ahown. */
-void BibleTime::slotWindowMenuAboutToShow()
-{
- Q_ASSERT(m_windowMenu);
- if (!m_windowMenu)
- {
- return;
- }
-
- if ( m_mdi->subWindowList().isEmpty() )
- {
- m_windowCascade_action->setEnabled(false);
- m_windowTileVertical_action->setEnabled(false);
- m_windowTileHorizontal_action->setEnabled(false);
- m_windowCloseAll_action->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_windowMenu->insertSeparator();
- }
- else
- {
- slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
- m_windowCloseAll_action->setEnabled( true );
- }
-
- // QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
+void BibleTime::slotWindowMenuAboutToShow() {
+ Q_ASSERT(m_windowMenu);
+ if (!m_windowMenu) {
+ return;
+ }
+
+ if ( m_mdi->subWindowList().isEmpty() ) {
+ m_windowCascade_action->setEnabled(false);
+ m_windowTileVertical_action->setEnabled(false);
+ m_windowTileHorizontal_action->setEnabled(false);
+ m_windowCloseAll_action->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_windowMenu->insertSeparator();
+ }
+ else {
+ slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
+ m_windowCloseAll_action->setEnabled( true );
+ }
+
+ // QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
// for (QList<QAction*>::iterator it = m_windowOpenWindowsList.begin(); it != end; ++it )
// {
- //(*it)->unplugAll(); //see kde porting doc
- // foreach (QWidget *w, (*it)->associatedWidgets() )
- // {
- // w->removeAction(*it);
- // }
+ //(*it)->unplugAll(); //see kde porting doc
+ // foreach (QWidget *w, (*it)->associatedWidgets() )
+ // {
+ // w->removeAction(*it);
+ // }
// }
- //m_windowOpenWindowsList.setAutoDelete(true);
+ //m_windowOpenWindowsList.setAutoDelete(true);
// qDeleteAll(m_windowOpenWindowsList);
// m_windowOpenWindowsList.clear();
@@ -203,11 +193,11 @@ void BibleTime::slotWindowMenuAboutToShow()
// for ( int i = 0; i < count; ++i ) {
// QWidget* w = windows.at(i);
// Q_ASSERT(w);
-//
+//
// KUserDataAction* action = new KUserDataAction(w->windowTitle(), KShortcut(), this, SLOT(slotWindowMenuActivated()), m_windowActionCollection);
// Q_ASSERT(action);
// action->setUserData(w);
-//
+//
// m_windowOpenWindowsList.append(action);
// action->setChecked( w == m_mdi->activeWindow() );
// m_windowMenu->addAction(action);
@@ -215,366 +205,313 @@ void BibleTime::slotWindowMenuAboutToShow()
}
/** 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
- * enable/disable the simple cascade and tile options accordingly
- */
- m_windowTileVertical_action->setEnabled( m_windowManualMode_action->isChecked() );
- m_windowTileHorizontal_action->setEnabled( m_windowManualMode_action->isChecked() );
- m_windowCascade_action->setEnabled( m_windowManualMode_action->isChecked() );
-
- if (clickedAction)
- {
- m_windowManualMode_action->setEnabled(
- m_windowManualMode_action != clickedAction
- && m_windowTileHorizontal_action != clickedAction
- && m_windowTileVertical_action != clickedAction
- && m_windowCascade_action != clickedAction
- );
- m_windowAutoTileVertical_action->setEnabled( m_windowAutoTileVertical_action != clickedAction );
- m_windowAutoTileHorizontal_action->setEnabled( m_windowAutoTileHorizontal_action != clickedAction );
- m_windowAutoCascade_action->setEnabled( m_windowAutoCascade_action != clickedAction );
- }
-
- if (clickedAction == m_windowManualMode_action)
- {
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
-
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- }
- else if (clickedAction == m_windowAutoTileVertical_action)
- {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
-
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileVertical );
- }
- else if (clickedAction == m_windowAutoTileHorizontal_action)
- {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
-
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileHorizontal );
- }
- else if (clickedAction == m_windowAutoCascade_action)
- {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoTileVertical_action->setChecked(false);
-
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeCascade );
- }
- else if (clickedAction == m_windowCascade_action)
- {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myCascade();
- }
- else if (clickedAction == m_windowTileVertical_action)
- {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myTileVertical();
- }
- else if (clickedAction == m_windowTileHorizontal_action)
- {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myTileHorizontal();
- }
+void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
+ /* If a toggle action was clicked we see if it checked ot unchecked and
+ * enable/disable the simple cascade and tile options accordingly
+ */
+ m_windowTileVertical_action->setEnabled( m_windowManualMode_action->isChecked() );
+ m_windowTileHorizontal_action->setEnabled( m_windowManualMode_action->isChecked() );
+ m_windowCascade_action->setEnabled( m_windowManualMode_action->isChecked() );
+
+ if (clickedAction) {
+ m_windowManualMode_action->setEnabled(
+ m_windowManualMode_action != clickedAction
+ && m_windowTileHorizontal_action != clickedAction
+ && m_windowTileVertical_action != clickedAction
+ && m_windowCascade_action != clickedAction
+ );
+ m_windowAutoTileVertical_action->setEnabled( m_windowAutoTileVertical_action != clickedAction );
+ m_windowAutoTileHorizontal_action->setEnabled( m_windowAutoTileHorizontal_action != clickedAction );
+ m_windowAutoCascade_action->setEnabled( m_windowAutoCascade_action != clickedAction );
+ }
+
+ if (clickedAction == m_windowManualMode_action) {
+ m_windowAutoTileVertical_action->setChecked(false);
+ m_windowAutoTileHorizontal_action->setChecked(false);
+ m_windowAutoCascade_action->setChecked(false);
+
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
+ }
+ else if (clickedAction == m_windowAutoTileVertical_action) {
+ m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileHorizontal_action->setChecked(false);
+ m_windowAutoCascade_action->setChecked(false);
+
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileVertical );
+ }
+ else if (clickedAction == m_windowAutoTileHorizontal_action) {
+ m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileVertical_action->setChecked(false);
+ m_windowAutoCascade_action->setChecked(false);
+
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileHorizontal );
+ }
+ else if (clickedAction == m_windowAutoCascade_action) {
+ m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileHorizontal_action->setChecked(false);
+ m_windowAutoTileVertical_action->setChecked(false);
+
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeCascade );
+ }
+ else if (clickedAction == m_windowCascade_action) {
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
+ m_mdi->myCascade();
+ }
+ else if (clickedAction == m_windowTileVertical_action) {
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
+ m_mdi->myTileVertical();
+ }
+ else if (clickedAction == m_windowTileHorizontal_action) {
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
+ m_mdi->myTileHorizontal();
+ }
}
-void BibleTime::slotManualArrangementMode()
-{
- slotUpdateWindowArrangementActions( m_windowManualMode_action );
+void BibleTime::slotManualArrangementMode() {
+ slotUpdateWindowArrangementActions( m_windowManualMode_action );
}
/** This slot is connected with the windowAutoTile_action object */
-void BibleTime::slotAutoTileHorizontal()
-{
- slotUpdateWindowArrangementActions( m_windowAutoTileHorizontal_action );
+void BibleTime::slotAutoTileHorizontal() {
+ slotUpdateWindowArrangementActions( m_windowAutoTileHorizontal_action );
}
/** This slot is connected with the windowAutoTile_action object */
-void BibleTime::slotAutoTileVertical()
-{
- slotUpdateWindowArrangementActions( m_windowAutoTileVertical_action );
+void BibleTime::slotAutoTileVertical() {
+ slotUpdateWindowArrangementActions( m_windowAutoTileVertical_action );
}
-void BibleTime::slotCascade()
-{
- slotUpdateWindowArrangementActions( m_windowCascade_action );
+void BibleTime::slotCascade() {
+ slotUpdateWindowArrangementActions( m_windowCascade_action );
}
-void BibleTime::slotTileVertical()
-{
- slotUpdateWindowArrangementActions( m_windowTileVertical_action );
+void BibleTime::slotTileVertical() {
+ slotUpdateWindowArrangementActions( m_windowTileVertical_action );
}
-void BibleTime::slotTileHorizontal()
-{
- slotUpdateWindowArrangementActions( m_windowTileHorizontal_action );
+void BibleTime::slotTileHorizontal() {
+ slotUpdateWindowArrangementActions( m_windowTileHorizontal_action );
}
/** This slot is connected with the windowAutoCascade_action object */
-void BibleTime::slotAutoCascade()
-{
- slotUpdateWindowArrangementActions( m_windowAutoCascade_action );
+void BibleTime::slotAutoCascade() {
+ slotUpdateWindowArrangementActions( m_windowAutoCascade_action );
}
-void BibleTime::slotWindowMenuActivated()
-{
- if (!m_windowMenu)
- {
- return;
- }
-
-/* const KUserDataAction* action = dynamic_cast<const KUserDataAction*>(sender());
- Q_ASSERT(action);
- if (action) {
- QWidget* const window = action->getUserData();
- Q_ASSERT(window);
- if ( window ) {
- window->setFocus();
- }
- }*/
+void BibleTime::slotWindowMenuActivated() {
+ if (!m_windowMenu) {
+ return;
+ }
+
+ /* const KUserDataAction* action = dynamic_cast<const KUserDataAction*>(sender());
+ Q_ASSERT(action);
+ if (action) {
+ QWidget* const window = action->getUserData();
+ Q_ASSERT(window);
+ if ( window ) {
+ window->setFocus();
+ }
+ }*/
}
/** Shows/hides the toolbar */
-void BibleTime::slotToggleToolbar()
-{
- Q_ASSERT(m_mainToolBar);
- if (m_viewToolbar_action->isChecked())
- {
- m_mainToolBar->show();
- }
- else
- {
- m_mainToolBar->hide();
- }
+void BibleTime::slotToggleToolbar() {
+ Q_ASSERT(m_mainToolBar);
+ if (m_viewToolbar_action->isChecked()) {
+ m_mainToolBar->show();
+ }
+ else {
+ m_mainToolBar->hide();
+ }
}
-void BibleTime::slotSearchModules()
-{
- //get the modules of the open windows
- QList<CSwordModuleInfo*> modules;
-
- foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList())
- {
- if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget()))
- {
- modules << w->modules();
- }
- }
- Search::CSearchDialog::openDialog(modules, QString::null);
+void BibleTime::slotSearchModules() {
+ //get the modules of the open windows
+ QList<CSwordModuleInfo*> modules;
+
+ foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
+ if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
+ modules << w->modules();
+ }
+ }
+ Search::CSearchDialog::openDialog(modules, QString::null);
}
/* Search default Bible slot
* Call CSearchDialog::openDialog with only the default bible module
*/
-void BibleTime::slotSearchDefaultBible()
-{
- QList<CSwordModuleInfo*> module;
- CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
- if (bible)
- {
- module.append(bible);
- }
- Search::CSearchDialog::openDialog(module, QString::null);
+void BibleTime::slotSearchDefaultBible() {
+ QList<CSwordModuleInfo*> module;
+ CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
+ if (bible) {
+ module.append(bible);
+ }
+ Search::CSearchDialog::openDialog(module, QString::null);
}
-void BibleTime::openOnlineHelp_Handbook()
-{
- QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHandbookDir().canonicalPath() +"/index.html";
- QDesktopServices::openUrl(QUrl(urlPath));
+void BibleTime::openOnlineHelp_Handbook() {
+ QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHandbookDir().canonicalPath() + "/index.html";
+ QDesktopServices::openUrl(QUrl(urlPath));
}
-void BibleTime::openOnlineHelp_Howto()
-{
- QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHowtoDir().canonicalPath() +"/index.html";
- QDesktopServices::openUrl(QUrl(urlPath));
+void BibleTime::openOnlineHelp_Howto() {
+ QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHowtoDir().canonicalPath() + "/index.html";
+ QDesktopServices::openUrl(QUrl(urlPath));
}
-void BibleTime::slotOpenAboutDialog()
-{
- BtAboutDialog* dlg = new BtAboutDialog(this);
- dlg->show();
+void BibleTime::slotOpenAboutDialog() {
+ BtAboutDialog* dlg = new BtAboutDialog(this);
+ dlg->show();
}
/** Saves the current settings into the currently activated profile. */
-void BibleTime::saveProfile(QAction* action)
-{
- m_mdi->setUpdatesEnabled(false);
-
- const QString profileName = action->text().remove("&");
- CProfile* p = m_profileMgr.profile( profileName );
- Q_ASSERT(p);
- if ( p )
- {
- saveProfile(p);
- }
-
- m_mdi->setUpdatesEnabled(true);
+void BibleTime::saveProfile(QAction* action) {
+ m_mdi->setUpdatesEnabled(false);
+
+ const QString profileName = action->text().remove("&");
+ CProfile* p = m_profileMgr.profile( profileName );
+ Q_ASSERT(p);
+ if ( p ) {
+ saveProfile(p);
+ }
+
+ m_mdi->setUpdatesEnabled(true);
}
-void BibleTime::saveProfile(CProfile* profile)
-{
- if (!profile)
- {
- return;
- }
- //save mainwindow settings
- storeProfileSettings(profile);
-
- QList<CProfileWindow*> profileWindows;
- foreach (QMdiSubWindow* w, m_mdi->subWindowList())
- {
- CDisplayWindow* displayWindow = dynamic_cast<CDisplayWindow*>(w->widget());
- if (!displayWindow)
- {
- continue;
- }
-
- CProfileWindow* profileWindow = new CProfileWindow();
- displayWindow->storeProfileSettings(profileWindow);
- profileWindows.append(profileWindow);
- }
- profile->save(profileWindows);
-
- //clean up memory - delete all created profile windows
- //profileWindows.setAutoDelete(true);
- qDeleteAll(profileWindows);
- profileWindows.clear();
+void BibleTime::saveProfile(CProfile* profile) {
+ if (!profile) {
+ return;
+ }
+ //save mainwindow settings
+ storeProfileSettings(profile);
+
+ QList<CProfileWindow*> profileWindows;
+ foreach (QMdiSubWindow* w, m_mdi->subWindowList()) {
+ CDisplayWindow* displayWindow = dynamic_cast<CDisplayWindow*>(w->widget());
+ if (!displayWindow) {
+ continue;
+ }
+
+ CProfileWindow* profileWindow = new CProfileWindow();
+ displayWindow->storeProfileSettings(profileWindow);
+ profileWindows.append(profileWindow);
+ }
+ profile->save(profileWindows);
+
+ //clean up memory - delete all created profile windows
+ //profileWindows.setAutoDelete(true);
+ qDeleteAll(profileWindows);
+ profileWindows.clear();
}
-void BibleTime::loadProfile(QAction* action)
-{
- const QString profileName = action->text().remove("&");
- CProfile* p = m_profileMgr.profile( profileName );
- Q_ASSERT(p);
- if ( p )
- {
- m_mdi->deleteAll();
- loadProfile(p);
- }
+void BibleTime::loadProfile(QAction* action) {
+ const QString profileName = action->text().remove("&");
+ CProfile* p = m_profileMgr.profile( profileName );
+ Q_ASSERT(p);
+ if ( p ) {
+ m_mdi->deleteAll();
+ loadProfile(p);
+ }
}
-void BibleTime::loadProfile(CProfile* p)
-{
- if (!p)
- return;
-
- QList<CProfileWindow*> windows = p->load();
-
- m_mdi->setUpdatesEnabled(false);//don't auto tile or auto cascade, this would mess up everything!!
-
- //load mainwindow setttings
- applyProfileSettings(p);
-
- QWidget* focusWindow = 0;
-
- // for (CProfileWindow* w = windows.last(); w; w = windows.prev()) { //from the last one to make sure the order is right in the mdi area
- foreach (CProfileWindow* w, windows)
- {
- const QString key = w->key();
- QStringList usedModules = w->modules();
-
- QList<CSwordModuleInfo*> modules;
- for ( QStringList::Iterator it = usedModules.begin(); it != usedModules.end(); ++it )
- {
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(*it))
- {
- modules.append(m);
- }
- }
- if (!modules.count())
- { //are the modules still installed? If not continue wih next session window
- continue;
- }
-
- //is w->isWriteWindow is false we create a write window, otherwise a read window
- CDisplayWindow* displayWindow = 0;
- if (w->writeWindowType() > 0)
- { //create a write window
- displayWindow = createWriteDisplayWindow(modules.first(), key, CDisplayWindow::WriteWindowType(w->writeWindowType()) );
- }
- else
- { //create a read window
- displayWindow = createReadDisplayWindow(modules, key);
- }
-
- if (displayWindow)
- { //if a window was created initialize it.
- if (w->hasFocus())
- {
- focusWindow = displayWindow;
- }
-
- displayWindow->applyProfileSettings(w);
- }
- }
-
- m_mdi->setUpdatesEnabled(true);
- m_mdi->triggerWindowUpdate();
-
- if (focusWindow)
- {
- focusWindow->setFocus();
- }
+void BibleTime::loadProfile(CProfile* p) {
+ if (!p)
+ return;
+
+ QList<CProfileWindow*> windows = p->load();
+
+ m_mdi->setUpdatesEnabled(false);//don't auto tile or auto cascade, this would mess up everything!!
+
+ //load mainwindow setttings
+ applyProfileSettings(p);
+
+ QWidget* focusWindow = 0;
+
+ // for (CProfileWindow* w = windows.last(); w; w = windows.prev()) { //from the last one to make sure the order is right in the mdi area
+ foreach (CProfileWindow* w, windows) {
+ const QString key = w->key();
+ QStringList usedModules = w->modules();
+
+ QList<CSwordModuleInfo*> modules;
+ for ( QStringList::Iterator it = usedModules.begin(); it != usedModules.end(); ++it ) {
+ if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(*it)) {
+ modules.append(m);
+ }
+ }
+ if (!modules.count()) { //are the modules still installed? If not continue wih next session window
+ continue;
+ }
+
+ //is w->isWriteWindow is false we create a write window, otherwise a read window
+ CDisplayWindow* displayWindow = 0;
+ if (w->writeWindowType() > 0) { //create a write window
+ displayWindow = createWriteDisplayWindow(modules.first(), key, CDisplayWindow::WriteWindowType(w->writeWindowType()) );
+ }
+ else { //create a read window
+ displayWindow = createReadDisplayWindow(modules, key);
+ }
+
+ if (displayWindow) { //if a window was created initialize it.
+ if (w->hasFocus()) {
+ focusWindow = displayWindow;
+ }
+
+ displayWindow->applyProfileSettings(w);
+ }
+ }
+
+ m_mdi->setUpdatesEnabled(true);
+ m_mdi->triggerWindowUpdate();
+
+ if (focusWindow) {
+ focusWindow->setFocus();
+ }
}
-void BibleTime::deleteProfile(QAction* action)
-{
- //HACK: work around the inserted & char by KPopupMenu
- const QString profileName = action->text().remove("&");
- CProfile* p = m_profileMgr.profile( profileName );
- Q_ASSERT(p);
- if ( p ) m_profileMgr.remove(p);
- refreshProfileMenus();
+void BibleTime::deleteProfile(QAction* action) {
+ //HACK: work around the inserted & char by KPopupMenu
+ const QString profileName = action->text().remove("&");
+ CProfile* p = m_profileMgr.profile( profileName );
+ Q_ASSERT(p);
+ if ( p ) m_profileMgr.remove(p);
+ refreshProfileMenus();
}
-void BibleTime::toggleFullscreen()
-{
- m_windowFullscreen_action->isChecked() ? showFullScreen() : showNormal();
- m_mdi->triggerWindowUpdate();
+void BibleTime::toggleFullscreen() {
+ m_windowFullscreen_action->isChecked() ? showFullScreen() : showNormal();
+ m_mdi->triggerWindowUpdate();
}
/** Saves current settings into a new profile. */
-void BibleTime::saveToNewProfile()
-{
- bool ok = false;
- const QString name = QInputDialog::getText(this, tr("New Session"),
- tr("Please enter a name for the new session."), QLineEdit::Normal, QString::null, &ok);
- if (ok && !name.isEmpty())
- {
- CProfile* profile = m_profileMgr.create(name);
- saveProfile(profile);
- }
- refreshProfileMenus();
+void BibleTime::saveToNewProfile() {
+ bool ok = false;
+ const QString name = QInputDialog::getText(this, tr("New Session"),
+ tr("Please enter a name for the new session."), QLineEdit::Normal, QString::null, &ok);
+ if (ok && !name.isEmpty()) {
+ CProfile* profile = m_profileMgr.create(name);
+ saveProfile(profile);
+ }
+ refreshProfileMenus();
}
/** Slot to refresh the save profile and load profile menus. */
-void BibleTime::refreshProfileMenus()
-{
- m_windowSaveProfileMenu->clear();
- m_windowLoadProfileMenu->clear();
- m_windowDeleteProfileMenu->clear();
-
- //refresh the load, save and delete profile menus
- m_profileMgr.refresh();
- QList<CProfile*> profiles = m_profileMgr.profiles();
-
- const bool enableActions = bool(profiles.count() != 0);
- m_windowSaveProfileMenu->setEnabled(enableActions);
- m_windowLoadProfileMenu->setEnabled(enableActions);
- m_windowDeleteProfileMenu->setEnabled(enableActions);
-
- foreach (CProfile* p, profiles)
- {
- m_windowSaveProfileMenu->addAction(p->name());
- m_windowLoadProfileMenu->addAction(p->name());
- m_windowDeleteProfileMenu->addAction(p->name());
- }
+void BibleTime::refreshProfileMenus() {
+ m_windowSaveProfileMenu->clear();
+ m_windowLoadProfileMenu->clear();
+ m_windowDeleteProfileMenu->clear();
+
+ //refresh the load, save and delete profile menus
+ m_profileMgr.refresh();
+ QList<CProfile*> profiles = m_profileMgr.profiles();
+
+ const bool enableActions = bool(profiles.count() != 0);
+ m_windowSaveProfileMenu->setEnabled(enableActions);
+ m_windowLoadProfileMenu->setEnabled(enableActions);
+ m_windowDeleteProfileMenu->setEnabled(enableActions);
+
+ foreach (CProfile* p, profiles) {
+ m_windowSaveProfileMenu->addAction(p->name());
+ m_windowLoadProfileMenu->addAction(p->name());
+ m_windowDeleteProfileMenu->addAction(p->name());
+ }
}
diff --git a/src/bibletimeapp.cpp b/src/bibletimeapp.cpp
index 13451fc..b6c8f59 100644
--- a/src/bibletimeapp.cpp
+++ b/src/bibletimeapp.cpp
@@ -14,21 +14,20 @@
//KDE includes
//#include <dcopclient.h> #TODO: USE DBUS INSTEAD OF DCOP
-BibleTimeApp::BibleTimeApp( int & argc, char ** argv ) : QApplication(argc, argv)
-{
+BibleTimeApp::BibleTimeApp( int & argc, char ** argv ) : QApplication(argc, argv) {
// initDCOP();
- CResMgr::init_tr();
+ CResMgr::init_tr();
}
BibleTimeApp::~BibleTimeApp() {
- //we can set this safely now because we close now (hopyfully without crash)
- CBTConfig::set(CBTConfig::crashedLastTime, false);
- CBTConfig::set(CBTConfig::crashedTwoTimes, false);
+ //we can set this safely now because we close now (hopyfully without crash)
+ CBTConfig::set(CBTConfig::crashedLastTime, false);
+ CBTConfig::set(CBTConfig::crashedTwoTimes, false);
- deleteDisplayTemplateMgr();
- deleteLanguageMgr();
- deleteBackend();
+ deleteDisplayTemplateMgr();
+ deleteLanguageMgr();
+ deleteBackend();
}
/*
diff --git a/src/bibletimeapp.h b/src/bibletimeapp.h
index 74f0ea5..0b1a845 100644
--- a/src/bibletimeapp.h
+++ b/src/bibletimeapp.h
@@ -19,11 +19,11 @@
* @author The BibleTime team
*/
class BibleTimeApp : public QApplication, public CPointers {
-public:
- BibleTimeApp(int &argc, char **argv);
- ~BibleTimeApp();
+ public:
+ BibleTimeApp(int &argc, char **argv);
+ ~BibleTimeApp();
-protected:
+ protected:
// void initDCOP();
};
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 87cb12e..0fcbc5a 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp
@@ -26,93 +26,88 @@
#include <QEvent>
BtConfigDialog::BtConfigDialog(QWidget* parent)
- : QDialog(parent),
- m_maxItemWidth(0),
- m_previousPageIndex(-2)
-{
- setWindowFlags(Qt::Window);
- m_contentsList = new QListWidget(this);
- m_contentsList->setViewMode(QListView::IconMode);
- m_contentsList->setMovement(QListView::Static);
-
- m_pageWidget = new QStackedWidget(this);
- m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-
- QHBoxLayout *mainLayout = new QHBoxLayout;
- setLayout(mainLayout);
- mainLayout->addWidget(m_contentsList);
- m_pageLayout = new QVBoxLayout;
- mainLayout->addLayout(m_pageLayout);
-
- m_pageLayout->addWidget(m_pageWidget);
-
- // Horizontal line
- QFrame* line = new QFrame();
- line->setGeometry(QRect(1, 1, 1, 3));
+ : QDialog(parent),
+ m_maxItemWidth(0),
+ m_previousPageIndex(-2) {
+ setWindowFlags(Qt::Window);
+ m_contentsList = new QListWidget(this);
+ m_contentsList->setViewMode(QListView::IconMode);
+ m_contentsList->setMovement(QListView::Static);
+
+ m_pageWidget = new QStackedWidget(this);
+ m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ setLayout(mainLayout);
+ mainLayout->addWidget(m_contentsList);
+ m_pageLayout = new QVBoxLayout;
+ mainLayout->addLayout(m_pageLayout);
+
+ m_pageLayout->addWidget(m_pageWidget);
+
+ // Horizontal line
+ QFrame* line = new QFrame();
+ line->setGeometry(QRect(1, 1, 1, 3));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
- line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_pageLayout->addWidget(line);
-
- connect(m_contentsList,
- SIGNAL(currentRowChanged(int)),
- this, SLOT(slotChangePage(int))
- );
-
+ line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_pageLayout->addWidget(line);
+
+ connect(m_contentsList,
+ SIGNAL(currentRowChanged(int)),
+ this, SLOT(slotChangePage(int))
+ );
+
}
BtConfigDialog::~BtConfigDialog() {}
-void BtConfigDialog::addPage(BtConfigPage* pageWidget)
-{
- // this is a friend
- pageWidget->m_parentDialog = this;
-
- QVBoxLayout* containerLayout = new QVBoxLayout;
- QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
- containerLayout->addWidget(headerLabel);
- containerLayout->addWidget(pageWidget);
- QWidget* containerWidget = new QWidget(m_pageWidget);
- containerWidget->setLayout(containerLayout);
- m_pageWidget->addWidget(containerWidget);
-
-
- QListWidgetItem* item = new QListWidgetItem(m_contentsList);
- item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName()));
- item->setText(pageWidget->header());
- item->setTextAlignment(Qt::AlignHCenter);
- item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- //set the list width - it may bee too wide (if there were no pages) or too narrow
- if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) {
- m_maxItemWidth = m_contentsList->visualItemRect(item).width();
- m_contentsList->setFixedWidth( m_maxItemWidth + (m_contentsList->frameWidth()*2) );
- }
- // all items should has the same width
- for(int i = 0; i < m_contentsList->count(); ++i) {
- m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) );
- }
-
- slotChangePage(m_contentsList->row(item));
+void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
+ // this is a friend
+ pageWidget->m_parentDialog = this;
+
+ QVBoxLayout* containerLayout = new QVBoxLayout;
+ QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
+ containerLayout->addWidget(headerLabel);
+ containerLayout->addWidget(pageWidget);
+ QWidget* containerWidget = new QWidget(m_pageWidget);
+ containerWidget->setLayout(containerLayout);
+ m_pageWidget->addWidget(containerWidget);
+
+
+ QListWidgetItem* item = new QListWidgetItem(m_contentsList);
+ item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName()));
+ item->setText(pageWidget->header());
+ item->setTextAlignment(Qt::AlignHCenter);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+
+ //set the list width - it may bee too wide (if there were no pages) or too narrow
+ if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) {
+ m_maxItemWidth = m_contentsList->visualItemRect(item).width();
+ m_contentsList->setFixedWidth( m_maxItemWidth + (m_contentsList->frameWidth()*2) );
+ }
+ // all items should has the same width
+ for (int i = 0; i < m_contentsList->count(); ++i) {
+ m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) );
+ }
+
+ slotChangePage(m_contentsList->row(item));
}
-void BtConfigDialog::addButtonBox(QDialogButtonBox* box)
-{
- m_pageLayout->addWidget(box);
+void BtConfigDialog::addButtonBox(QDialogButtonBox* box) {
+ m_pageLayout->addWidget(box);
}
-BtConfigPage* BtConfigDialog::currentPage()
-{
- return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget());
+BtConfigPage* BtConfigDialog::currentPage() {
+ return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget());
}
-void BtConfigDialog::slotChangePage(int newIndex)
-{
- if (m_previousPageIndex != newIndex) {
- m_previousPageIndex = newIndex;
- m_contentsList->setCurrentRow(newIndex);
- m_pageWidget->setCurrentIndex(newIndex);
- }
+void BtConfigDialog::slotChangePage(int newIndex) {
+ if (m_previousPageIndex != newIndex) {
+ m_previousPageIndex = newIndex;
+ m_contentsList->setCurrentRow(newIndex);
+ m_pageWidget->setCurrentIndex(newIndex);
+ }
}
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index 7fb3482..8773a83 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -32,31 +32,30 @@ class QVBoxLayout;
* Connect the button box signals. Use setAttribute(Qt::WA_DeleteOnClose) if you want
* an auto-destroying window.
*/
-class BtConfigDialog : public QDialog
-{
- Q_OBJECT
-public:
- BtConfigDialog(QWidget* parent);
- virtual ~BtConfigDialog();
-
- /** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
- void addPage(BtConfigPage* pageWidget);
- /** Adds a button box to the lower edge of the dialog. */
- void addButtonBox(QDialogButtonBox* buttonBox);
-
- /** Returns the currently selected page. */
- BtConfigPage* currentPage();
-
-public slots:
- /** Changes the current page using the given index number. */
- void slotChangePage(int newIndex);
-
-private:
- QListWidget* m_contentsList;
- QStackedWidget* m_pageWidget;
- QVBoxLayout* m_pageLayout;
- int m_maxItemWidth;
- int m_previousPageIndex;
+class BtConfigDialog : public QDialog {
+ Q_OBJECT
+ public:
+ BtConfigDialog(QWidget* parent);
+ virtual ~BtConfigDialog();
+
+ /** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
+ void addPage(BtConfigPage* pageWidget);
+ /** Adds a button box to the lower edge of the dialog. */
+ void addButtonBox(QDialogButtonBox* buttonBox);
+
+ /** Returns the currently selected page. */
+ BtConfigPage* currentPage();
+
+ public slots:
+ /** Changes the current page using the given index number. */
+ void slotChangePage(int newIndex);
+
+ private:
+ QListWidget* m_contentsList;
+ QStackedWidget* m_pageWidget;
+ QVBoxLayout* m_pageLayout;
+ int m_maxItemWidth;
+ int m_previousPageIndex;
};
@@ -64,24 +63,25 @@ private:
/**
* Base class for configuration dialog pages.
*/
-class BtConfigPage : public QWidget
-{
- Q_OBJECT
-public:
- BtConfigPage();
- virtual ~BtConfigPage();
-
- /** Implement these to return the correct values.
- * For example: header(){return tr("General");}
- */
- virtual QString iconName() = 0;
- virtual QString label() = 0;
- virtual QString header() = 0;
- BtConfigDialog* parentDialog() {return m_parentDialog;}
-
-private:
- friend class BtConfigDialog;
- BtConfigDialog* m_parentDialog;
+class BtConfigPage : public QWidget {
+ Q_OBJECT
+ public:
+ BtConfigPage();
+ virtual ~BtConfigPage();
+
+ /** Implement these to return the correct values.
+ * For example: header(){return tr("General");}
+ */
+ virtual QString iconName() = 0;
+ virtual QString label() = 0;
+ virtual QString header() = 0;
+ BtConfigDialog* parentDialog() {
+ return m_parentDialog;
+ }
+
+ private:
+ friend class BtConfigDialog;
+ BtConfigDialog* m_parentDialog;
};
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
index 976250f..799fa0d 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp
@@ -29,60 +29,56 @@ using namespace sword;
BtInstallMgr::BtInstallMgr()
- : InstallMgr(instbackend::configPath().toLatin1(), this),
- m_firstCallOfPreStatus(true)
-{ //use this class also as status reporter
- qDebug("BtInstallMgr::BtInstallMgr");
- this->setFTPPassive(true);
+ : InstallMgr(instbackend::configPath().toLatin1(), this),
+ m_firstCallOfPreStatus(true) { //use this class also as status reporter
+ qDebug("BtInstallMgr::BtInstallMgr");
+ this->setFTPPassive(true);
}
BtInstallMgr::~BtInstallMgr() {
- //doesn't really help because it only sets a flag
- terminate(); //make sure to close the connection
+ //doesn't really help because it only sets a flag
+ terminate(); //make sure to close the connection
}
-bool BtInstallMgr::isUserDisclaimerConfirmed() const
-{
- // TODO: Check from config if it's been confirmed with "don't show this anymore" checked.
- // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
- return true;
+bool BtInstallMgr::isUserDisclaimerConfirmed() const {
+ // TODO: Check from config if it's been confirmed with "don't show this anymore" checked.
+ // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
+ return true;
}
-void BtInstallMgr::statusUpdate(double dltotal, double dlnow)
-{
- //qDebug("BtInstallMgr::statusUpdate");
- if (dlnow > dltotal)
- dlnow = dltotal;
-
- int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0);
-
- if (totalPercent > 100) {
- totalPercent = 100;
- }
- else if (totalPercent < 0) {
- totalPercent = 0;
- }
-
- int filePercent = (int)((float)(dlnow) / (float)(dltotal+1) * 100.0);
- if (filePercent > 100) {
- filePercent = 100;
- }
- else if (filePercent < 0) {
- filePercent = 0;
- }
- //qApp->processEvents();
- //qDebug() << "status: total"<<totalPercent<<"file"<<filePercent;
- emit percentCompleted(totalPercent, filePercent);
+void BtInstallMgr::statusUpdate(double dltotal, double dlnow) {
+ //qDebug("BtInstallMgr::statusUpdate");
+ if (dlnow > dltotal)
+ dlnow = dltotal;
+
+ int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0);
+
+ if (totalPercent > 100) {
+ totalPercent = 100;
+ }
+ else if (totalPercent < 0) {
+ totalPercent = 0;
+ }
+
+ int filePercent = (int)((float)(dlnow) / (float)(dltotal + 1) * 100.0);
+ if (filePercent > 100) {
+ filePercent = 100;
+ }
+ else if (filePercent < 0) {
+ filePercent = 0;
+ }
+ //qApp->processEvents();
+ //qDebug() << "status: total"<<totalPercent<<"file"<<filePercent;
+ emit percentCompleted(totalPercent, filePercent);
}
-void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* message)
-{
- if (m_firstCallOfPreStatus) {
- m_firstCallOfPreStatus = false;
- emit downloadStarted();
- }
- qDebug() << "BtInstallMgr::preStatus:" << (int)totalBytes << "/" << (int)completedBytes << QString(message);
- m_completedBytes = completedBytes;
- m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero
+void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* message) {
+ if (m_firstCallOfPreStatus) {
+ m_firstCallOfPreStatus = false;
+ emit downloadStarted();
+ }
+ qDebug() << "BtInstallMgr::preStatus:" << (int)totalBytes << "/" << (int)completedBytes << QString(message);
+ m_completedBytes = completedBytes;
+ m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero
}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
index 1420079..0561b96 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ b/src/frontend/bookshelfmanager/btinstallmgr.h
@@ -29,44 +29,44 @@ typedef QList<sword::InstallSource*> InstallSourceList;
* Our own reimplementation to provide installation and status bar updates.
*/
class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
- Q_OBJECT
-public:
-
- BtInstallMgr();
- virtual ~BtInstallMgr();
-
- /**
- * Refreshing the source should be cancellable (othewise it might freeze the app if there is
- * for example something wrong with the network).
- */
- void slotRefreshCanceled();
-
- /** Re-implemented from sword::InstallMgr. */
- virtual bool isUserDisclaimerConfirmed() const;
-
-protected:
- /* Reimplementations of methods in StatusReporter */
- /**
- * Gets the total and current file status, emits the signal with those values as percents.
- */
- virtual void statusUpdate(double dltotal, double dlnow);
- /**
- * Called before starting to download each file of the module package.
- * The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
- * This function is not utilized in the UI ATM.
- */
- virtual void preStatus(long totalBytes, long completedBytes, const char *message);
-
- long m_totalBytes;
- long m_completedBytes;
-
-private:
- bool m_firstCallOfPreStatus;
-
-signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted( const int, const int);
- void downloadStarted();
+ Q_OBJECT
+ public:
+
+ BtInstallMgr();
+ virtual ~BtInstallMgr();
+
+ /**
+ * Refreshing the source should be cancellable (othewise it might freeze the app if there is
+ * for example something wrong with the network).
+ */
+ void slotRefreshCanceled();
+
+ /** Re-implemented from sword::InstallMgr. */
+ virtual bool isUserDisclaimerConfirmed() const;
+
+ protected:
+ /* Reimplementations of methods in StatusReporter */
+ /**
+ * Gets the total and current file status, emits the signal with those values as percents.
+ */
+ virtual void statusUpdate(double dltotal, double dlnow);
+ /**
+ * Called before starting to download each file of the module package.
+ * The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
+ * This function is not utilized in the UI ATM.
+ */
+ virtual void preStatus(long totalBytes, long completedBytes, const char *message);
+
+ long m_totalBytes;
+ long m_completedBytes;
+
+ private:
+ bool m_firstCallOfPreStatus;
+
+ signals:
+ /** Download status. Percent of total and file.*/
+ void percentCompleted( const int, const int);
+ void downloadStarted();
};
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index c26de6f..b361965 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -23,67 +23,61 @@
static BtModuleManagerDialog* m_staticModuleManagerDialog = 0;
-BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget* parent)
-{
- if (!m_staticModuleManagerDialog) {
- m_staticModuleManagerDialog = new BtModuleManagerDialog(parent);
- };
- Q_ASSERT(m_staticModuleManagerDialog);
- return m_staticModuleManagerDialog;
+BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget* parent) {
+ if (!m_staticModuleManagerDialog) {
+ m_staticModuleManagerDialog = new BtModuleManagerDialog(parent);
+ };
+ Q_ASSERT(m_staticModuleManagerDialog);
+ return m_staticModuleManagerDialog;
}
BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent)
- : BtConfigDialog(parent)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(tr("Bookshelf Manager"));
+ : BtConfigDialog(parent) {
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(tr("Bookshelf Manager"));
- // Install page
- BtInstallPage* installPage = new BtInstallPage();
- addPage(installPage);
+ // Install page
+ BtInstallPage* installPage = new BtInstallPage();
+ addPage(installPage);
- //Uninstall page
- BtRemovePage* removePage = new BtRemovePage();
- addPage(removePage);
+ //Uninstall page
+ BtRemovePage* removePage = new BtRemovePage();
+ addPage(removePage);
- //Index page
- BtIndexPage* indexPage = new BtIndexPage();
- addPage(indexPage);
+ //Index page
+ BtIndexPage* indexPage = new BtIndexPage();
+ addPage(indexPage);
- slotChangePage(0);
+ slotChangePage(0);
- // Dialog button (Close)
- QDialogButtonBox* bbox = new QDialogButtonBox(this);
- bbox->addButton(QDialogButtonBox::Close);
- util::prepareDialogBox(bbox);
- addButtonBox(bbox);
- connect(bbox, SIGNAL(rejected()), SLOT(close()));
+ // Dialog button (Close)
+ QDialogButtonBox* bbox = new QDialogButtonBox(this);
+ bbox->addButton(QDialogButtonBox::Close);
+ util::prepareDialogBox(bbox);
+ addButtonBox(bbox);
+ connect(bbox, SIGNAL(rejected()), SLOT(close()));
- loadDialogSettings();
+ loadDialogSettings();
}
-BtModuleManagerDialog::~BtModuleManagerDialog()
-{
- saveDialogSettings();
- m_staticModuleManagerDialog = 0;
+BtModuleManagerDialog::~BtModuleManagerDialog() {
+ saveDialogSettings();
+ m_staticModuleManagerDialog = 0;
}
// The QWidget close() sends close event, so does closing by the window X button.
-void BtModuleManagerDialog::closeEvent(QCloseEvent*)
-{
- qDebug("BtModuleManagerDialog::closeEvent");
+void BtModuleManagerDialog::closeEvent(QCloseEvent*) {
+ qDebug("BtModuleManagerDialog::closeEvent");
}
-void BtModuleManagerDialog::loadDialogSettings()
-{
- resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
- move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
+void BtModuleManagerDialog::loadDialogSettings() {
+ resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
+ move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
}
-void BtModuleManagerDialog::saveDialogSettings()
-{
- CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
- CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
- CBTConfig::set(CBTConfig::bookshelfPosX, x());
- CBTConfig::set(CBTConfig::bookshelfPosY, y());
+void BtModuleManagerDialog::saveDialogSettings() {
+ CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
+ CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
+ CBTConfig::set(CBTConfig::bookshelfPosX, x());
+ CBTConfig::set(CBTConfig::bookshelfPosY, y());
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index ffb7169..ff8c35f 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -18,30 +18,29 @@ class QWidget;
/**
* The Bookshelf Manager dialog. Includes pages for Install, Remove, Indexes.
*/
-class BtModuleManagerDialog : public BtConfigDialog
-{
- Q_OBJECT
+class BtModuleManagerDialog : public BtConfigDialog {
+ Q_OBJECT
-public:
- static BtModuleManagerDialog* getInstance(QWidget* parent);
-
- ~BtModuleManagerDialog();
+ public:
+ static BtModuleManagerDialog* getInstance(QWidget* parent);
+ ~BtModuleManagerDialog();
- //void slotClose();
-protected:
- /** Reimplementation from QWidget. */
- virtual void closeEvent(QCloseEvent* event);
- /** Adds the pages and the button box. */
- BtModuleManagerDialog(QWidget* parent);
+ //void slotClose();
+ protected:
+ /** Reimplementation from QWidget. */
+ virtual void closeEvent(QCloseEvent* event);
-private:
- // Load the settings from the resource file
- void loadDialogSettings();
+ /** Adds the pages and the button box. */
+ BtModuleManagerDialog(QWidget* parent);
- // Save the settings to the resource file
- void saveDialogSettings();
+ private:
+ // Load the settings from the resource file
+ void loadDialogSettings();
+
+ // Save the settings to the resource file
+ void saveDialogSettings();
//signals:
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index bca32fa..eca4498 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -35,150 +35,149 @@ const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
- : QDialog()
-{
- setWindowTitle(tr("New Installation Source"));
+ : QDialog() {
+ setWindowTitle(tr("New Installation Source"));
- QVBoxLayout* mainLayout = new QVBoxLayout( this );
- mainLayout->setMargin( 10 );
- mainLayout->setSpacing( 5 );
+ QVBoxLayout* mainLayout = new QVBoxLayout( this );
+ mainLayout->setMargin( 10 );
+ mainLayout->setSpacing( 5 );
- QHBoxLayout *captionLayout = new QHBoxLayout( this );
- mainLayout->addLayout(captionLayout);
- QLabel *label = new QLabel( tr("Caption"), this );
- captionLayout->addWidget( label );
+ QHBoxLayout *captionLayout = new QHBoxLayout( this );
+ mainLayout->addLayout(captionLayout);
+ QLabel *label = new QLabel( tr("Caption"), this );
+ captionLayout->addWidget( label );
- m_captionEdit = new QLineEdit( this );
- m_captionEdit->setText("Crosswire Bible Society");
- captionLayout->addWidget( m_captionEdit );
+ m_captionEdit = new QLineEdit( this );
+ m_captionEdit->setText("Crosswire Bible Society");
+ captionLayout->addWidget( m_captionEdit );
- mainLayout->addSpacing( 10 );
+ mainLayout->addSpacing( 10 );
- QGridLayout* layout = new QGridLayout( this );
- layout->setSpacing(3);
- layout->setMargin(3);
- mainLayout->addLayout(layout);
- layout->setSpacing( 5 );
+ QGridLayout* layout = new QGridLayout( this );
+ layout->setSpacing(3);
+ layout->setMargin(3);
+ mainLayout->addLayout(layout);
+ layout->setSpacing( 5 );
- label = new QLabel(tr("Type"), this);
- layout->addWidget( label, 0, 0);
+ label = new QLabel(tr("Type"), this);
+ layout->addWidget( label, 0, 0);
- m_serverLabel = new QLabel(tr("Server"), this);
- layout->addWidget( m_serverLabel, 0, 1);
+ m_serverLabel = new QLabel(tr("Server"), this);
+ layout->addWidget( m_serverLabel, 0, 1);
- label = new QLabel(tr("Path"), this);
- layout->addWidget( label, 0, 2 );
+ label = new QLabel(tr("Path"), this);
+ layout->addWidget( label, 0, 2 );
- m_protocolCombo = new QComboBox( this );
- layout->addWidget(m_protocolCombo, 1, 0);
- m_protocolCombo->addItem( PROTO_FTP );
- m_protocolCombo->addItem( PROTO_FILE );
+ m_protocolCombo = new QComboBox( this );
+ layout->addWidget(m_protocolCombo, 1, 0);
+ m_protocolCombo->addItem( PROTO_FTP );
+ m_protocolCombo->addItem( PROTO_FILE );
- m_serverEdit = new QLineEdit( this );
- layout->addWidget( m_serverEdit, 1, 1 );
- m_serverEdit->setText("ftp.crosswire.org");
+ m_serverEdit = new QLineEdit( this );
+ layout->addWidget( m_serverEdit, 1, 1 );
+ m_serverEdit->setText("ftp.crosswire.org");
- m_pathEdit = new QLineEdit( this );
- layout->addWidget( m_pathEdit, 1, 2 );
- m_pathEdit->setText("/pub/sword/raw");
+ m_pathEdit = new QLineEdit( this );
+ layout->addWidget( m_pathEdit, 1, 2 );
+ m_pathEdit->setText("/pub/sword/raw");
- mainLayout->addSpacing( 10 );
+ 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();
+ 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() ) );
- connect( m_protocolCombo, SIGNAL( activated(int) ), this, SLOT( slotProtocolChanged() ) );
+ connect( okButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
+ connect( discardButton, SIGNAL( clicked() ), this, 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);
- return;
- }
-
- //BTInstallMgr iMgr;
- //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);
- 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);
- 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);
- return;
- }
- else if ( m_pathEdit->text().isEmpty() ) {
- QMessageBox::information( this, tr( "Error" ), tr("Please provide a path."), QMessageBox::Retry);
-
- }
- }
-
- accept(); //only if nothing else failed
+ //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);
+ return;
+ }
+
+ //BTInstallMgr iMgr;
+ //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);
+ 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);
+ 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);
+ return;
+ }
+ else if ( m_pathEdit->text().isEmpty() ) {
+ QMessageBox::information( this, tr( "Error" ), tr("Please provide a path."), QMessageBox::Retry);
+
+ }
+ }
+
+ accept(); //only if nothing else failed
}
void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
- if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
- m_serverLabel->setEnabled(true);
- m_serverEdit->setEnabled(true);
- }
- else { //LOCAL, no server needed
- m_serverLabel->setEnabled(false);
- m_serverEdit->setEnabled(false);
-
- QString dirname = QFileDialog::getExistingDirectory(this);
- if (dirname.isEmpty()) {
- return; // user cancelled
- }
- QDir dir(dirname);
- if (dir.exists()) {
- m_pathEdit->setText( dir.canonicalPath() );
- }
- }
+ if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
+ m_serverLabel->setEnabled(true);
+ m_serverEdit->setEnabled(true);
+ }
+ else { //LOCAL, no server needed
+ m_serverLabel->setEnabled(false);
+ m_serverEdit->setEnabled(false);
+
+ QString dirname = QFileDialog::getExistingDirectory(this);
+ if (dirname.isEmpty()) {
+ return; // user cancelled
+ }
+ QDir dir(dirname);
+ if (dir.exists()) {
+ m_pathEdit->setText( dir.canonicalPath() );
+ }
+ }
}
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
- boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
- sword::InstallSource newSource(""); //empty, invalid Source
-
- if (dlg->exec() == QDialog::Accepted) {
- if (dlg->m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = dlg->m_serverEdit->text().toUtf8();
-
- //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";
- }
- newSource.caption = dlg->m_captionEdit->text().toUtf8();
- newSource.directory = dlg->m_pathEdit->text().toUtf8();
- }
- return newSource;
+ boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
+ sword::InstallSource newSource(""); //empty, invalid Source
+
+ if (dlg->exec() == QDialog::Accepted) {
+ if (dlg->m_protocolCombo->currentText() == PROTO_FTP) {
+ newSource.type = "FTP";
+ newSource.source = dlg->m_serverEdit->text().toUtf8();
+
+ //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";
+ }
+ newSource.caption = dlg->m_captionEdit->text().toUtf8();
+ newSource.directory = dlg->m_pathEdit->text().toUtf8();
+ }
+ return newSource;
}
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index 47f1973..d875cda 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -24,22 +24,22 @@ class QLineEdit;
class CSwordSetupInstallSourcesDialog : public QDialog {
- Q_OBJECT
+ Q_OBJECT
-public:
- static sword::InstallSource getSource();
+ public:
+ static sword::InstallSource getSource();
-protected:
- CSwordSetupInstallSourcesDialog();
+ protected:
+ CSwordSetupInstallSourcesDialog();
-protected slots:
- void slotOk();
- void slotProtocolChanged();
+ protected slots:
+ void slotOk();
+ void slotProtocolChanged();
-private:
- QLabel *m_serverLabel;
- QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
- QComboBox *m_protocolCombo;
+ private:
+ QLabel *m_serverLabel;
+ QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
+ QComboBox *m_protocolCombo;
};
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index cad5a84..2a628c9 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -31,185 +31,177 @@
BtIndexPage::BtIndexPage()
- : BtConfigPage()
-{
+ : BtConfigPage() {
- QVBoxLayout *vboxLayout;
- QHBoxLayout *hboxLayout;
+ QVBoxLayout *vboxLayout;
+ QHBoxLayout *hboxLayout;
vboxLayout = new QVBoxLayout(this);
- m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
- m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
- m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts"));
- vboxLayout->addWidget(m_autoDeleteOrphanedIndicesBox);
+ m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
+ m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
+ m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts"));
+ vboxLayout->addWidget(m_autoDeleteOrphanedIndicesBox);
- m_moduleList = new QTreeWidget(this);
- vboxLayout->addWidget(m_moduleList);
+ m_moduleList = new QTreeWidget(this);
+ vboxLayout->addWidget(m_moduleList);
- hboxLayout = new QHBoxLayout();
+ hboxLayout = new QHBoxLayout();
- QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hboxLayout->addItem(spacerItem);
+ QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hboxLayout->addItem(spacerItem);
- m_deleteButton = new QPushButton(this);
- m_deleteButton->setToolTip(tr("Delete the selected indexes"));
- m_deleteButton->setText(tr("Delete"));
- hboxLayout->addWidget(m_deleteButton);
+ m_deleteButton = new QPushButton(this);
+ m_deleteButton->setToolTip(tr("Delete the selected indexes"));
+ m_deleteButton->setText(tr("Delete"));
+ hboxLayout->addWidget(m_deleteButton);
- m_createButton = new QPushButton(this);
- m_createButton->setToolTip(tr("Create new indexes for the selected works"));
- m_createButton->setText(tr("Create..."));
- hboxLayout->addWidget(m_createButton);
+ m_createButton = new QPushButton(this);
+ m_createButton->setToolTip(tr("Create new indexes for the selected works"));
+ m_createButton->setText(tr("Create..."));
+ hboxLayout->addWidget(m_createButton);
- vboxLayout->addLayout(hboxLayout);
+ vboxLayout->addLayout(hboxLayout);
- // 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->setTextAlignment(1, Qt::AlignRight); see doc...
- m_moduleList->setSortingEnabled(false);
+ // 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->setTextAlignment(1, Qt::AlignRight); see doc...
+ m_moduleList->setSortingEnabled(false);
- m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );
+ 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));
+ // 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));
- // connect our signals/slots
- connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
- connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ // connect our signals/slots
+ connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
+ connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
+ connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- populateModuleList();
+ populateModuleList();
}
-BtIndexPage::~BtIndexPage()
-{
- CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
+BtIndexPage::~BtIndexPage() {
+ CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
}
-QString BtIndexPage::label()
-{
- return tr("Create new search indexes and delete created indexes for the installed works.");
+QString BtIndexPage::label() {
+ return tr("Create new search indexes and delete created indexes for the installed works.");
}
-QString BtIndexPage::iconName()
-{
- return CResMgr::bookshelfmgr::indexpage::icon;
+QString BtIndexPage::iconName() {
+ return CResMgr::bookshelfmgr::indexpage::icon;
}
-QString BtIndexPage::header()
-{
- return tr("Search Indexes");
+QString BtIndexPage::header() {
+ return tr("Search Indexes");
}
/** Populates the module list with installed modules and orphaned indices */
void BtIndexPage::populateModuleList() {
- m_moduleList->clear();
-
- // populate installed modules
- m_modsWithIndices = new QTreeWidgetItem(m_moduleList);
- m_modsWithIndices->setText(0, tr("Indexed Works"));
- m_modsWithIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- m_modsWithIndices->setExpanded(true);
-
- m_modsWithoutIndices = new QTreeWidgetItem(m_moduleList);
- m_modsWithoutIndices->setText(0, tr("Unindexed Works"));
- m_modsWithoutIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- m_modsWithoutIndices->setExpanded(true);
-
-
-
- QList<CSwordModuleInfo*>& modules = CPointers::backend()->moduleList();
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it = modules.begin(); it != end_it; ++it) {
- QTreeWidgetItem* item = 0;
-
- if ((*it)->hasIndex()) {
- item = new QTreeWidgetItem(m_modsWithIndices);
- item->setText(0, (*it)->name());
- item->setText(1, QString("%1 ").arg((*it)->indexSize() / 1024) + tr("KiB"));
- item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- item->setCheckState(0, Qt::Unchecked);
- }
- else {
- item = new QTreeWidgetItem(m_modsWithoutIndices);
- item->setText(0, (*it)->name());
- item->setText(1, QString("0 ") + tr("KiB"));
- item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- item->setCheckState(0, Qt::Checked);
- }
- }
+ typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
+
+ m_moduleList->clear();
+
+ // populate installed modules
+ m_modsWithIndices = new QTreeWidgetItem(m_moduleList);
+ m_modsWithIndices->setText(0, tr("Indexed Works"));
+ m_modsWithIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ m_modsWithIndices->setExpanded(true);
+
+ m_modsWithoutIndices = new QTreeWidgetItem(m_moduleList);
+ m_modsWithoutIndices->setText(0, tr("Unindexed Works"));
+ m_modsWithoutIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ m_modsWithoutIndices->setExpanded(true);
+
+
+
+ const QList<CSwordModuleInfo*> &modules(CPointers::backend()->moduleList());
+ for (MLCI it(modules.begin()); it != modules.end(); ++it) {
+ QTreeWidgetItem* item = 0;
+
+ if ((*it)->hasIndex()) {
+ item = new QTreeWidgetItem(m_modsWithIndices);
+ item->setText(0, (*it)->name());
+ item->setText(1, QString("%1 ").arg((*it)->indexSize() / 1024) + tr("KiB"));
+ item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ item->setCheckState(0, Qt::Unchecked);
+ }
+ else {
+ item = new QTreeWidgetItem(m_modsWithoutIndices);
+ item->setText(0, (*it)->name());
+ item->setText(1, QString("0 ") + tr("KiB"));
+ item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ item->setCheckState(0, Qt::Checked);
+ }
+ }
}
/** Creates indices for selected modules if no index currently exists */
-void BtIndexPage::createIndices()
-{
- bool indicesCreated = false;
- QList<CSwordModuleInfo*> moduleList;
-
- for (int i = 0; i < m_modsWithoutIndices->childCount(); i++) {
- if (m_modsWithoutIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
- if (module) {
- moduleList.append( module );
- indicesCreated = true;
- }
- }
- }
-
- //Shows the progress dialog
- if (indicesCreated) {
- CModuleIndexDialog::getInstance()->indexAllModules( moduleList );
- populateModuleList();
- }
+void BtIndexPage::createIndices() {
+ bool indicesCreated = false;
+ QList<CSwordModuleInfo*> moduleList;
+
+ for (int i = 0; i < m_modsWithoutIndices->childCount(); i++) {
+ if (m_modsWithoutIndices->child(i)->checkState(0) == Qt::Checked) {
+ CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
+ if (module) {
+ moduleList.append( module );
+ indicesCreated = true;
+ }
+ }
+ }
+
+ //Shows the progress dialog
+ if (indicesCreated) {
+ CModuleIndexDialog::getInstance()->indexAllModules( moduleList );
+ populateModuleList();
+ }
}
/** Deletes indices for selected modules */
-void BtIndexPage::deleteIndices()
-{
- bool indicesDeleted = false;
-
- for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
- if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
- if (module) {
- CSwordModuleInfo::deleteIndexForModule( module->name() );
- indicesDeleted = true;
- }
- }
- }
-
- // repopulate the list if an action was taken
- if (indicesDeleted) {
- populateModuleList();
- }
+void BtIndexPage::deleteIndices() {
+ bool indicesDeleted = false;
+
+ for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
+ if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
+ CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
+ if (module) {
+ CSwordModuleInfo::deleteIndexForModule( module->name() );
+ indicesDeleted = true;
+ }
+ }
+ }
+
+ // repopulate the list if an action was taken
+ if (indicesDeleted) {
+ populateModuleList();
+ }
}
-void BtIndexPage::deleteOrphanedIndices()
-{
- QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
- dir.setFilter(QDir::Dirs);
- CSwordModuleInfo* module;
-
- for (unsigned int i = 0; i < dir.count(); i++) {
- if (dir[i] != "." && dir[i] != "..") {
- if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
- if (!module->hasIndex()){ //index files found, but wrong version etc.
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- else{ //no module exists
- if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ){
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- }
- }
+void BtIndexPage::deleteOrphanedIndices() {
+ QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
+ dir.setFilter(QDir::Dirs);
+ CSwordModuleInfo* module;
+
+ for (unsigned int i = 0; i < dir.count(); i++) {
+ if (dir[i] != "." && dir[i] != "..") {
+ if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
+ if (!module->hasIndex()) { //index files found, but wrong version etc.
+ CSwordModuleInfo::deleteIndexForModule( dir[i] );
+ }
+ }
+ else { //no module exists
+ if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
+ CSwordModuleInfo::deleteIndexForModule( dir[i] );
+ }
+ }
+ }
+ }
}
-void BtIndexPage::slotSwordSetupChanged()
-{
- populateModuleList();
+void BtIndexPage::slotSwordSetupChanged() {
+ populateModuleList();
}
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index d8b49c4..139c4a7 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -23,64 +23,63 @@ class QTreeWidgetItem;
* Manager. It allows for creation and deletion of search indicies for each
* installed module. It also allows for deletion of orphaned indices.
*/
-class BtIndexPage : public BtConfigPage
-{
- Q_OBJECT
-
-public:
- /**
- * Constructor
- */
- BtIndexPage();
-
- /**
- * Destructor
- */
- ~BtIndexPage();
-
- // BtConfigPage methods
- QString header();
- QString iconName();
- QString label();
-
-public slots:
- void slotSwordSetupChanged();
-
-protected:
-
- /**
- * Populates the module list with installed modules and orphaned indices
- */
- void populateModuleList();
-
-
-
-public slots:
- /**
- * Creates indices for selected modules if no index currently exists
- */
- void createIndices();
- /**
- * Deletes indices for selected modules
- */
- void deleteIndices();
-
-public:
- /**
- * Deletes orphaned indices if the autoDeleteOrphanedIndices is true
- * Always deletes indices of existing modules where hasIndex() returns false
- */
- static void deleteOrphanedIndices();
-
-private:
-
- QCheckBox *m_autoDeleteOrphanedIndicesBox;
- QTreeWidget *m_moduleList;
- QPushButton *m_deleteButton;
- QPushButton *m_createButton;
-
- QTreeWidgetItem* m_modsWithIndices;
- QTreeWidgetItem* m_modsWithoutIndices;
+class BtIndexPage : public BtConfigPage {
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor
+ */
+ BtIndexPage();
+
+ /**
+ * Destructor
+ */
+ ~BtIndexPage();
+
+ // BtConfigPage methods
+ QString header();
+ QString iconName();
+ QString label();
+
+ public slots:
+ void slotSwordSetupChanged();
+
+ protected:
+
+ /**
+ * Populates the module list with installed modules and orphaned indices
+ */
+ void populateModuleList();
+
+
+
+ public slots:
+ /**
+ * Creates indices for selected modules if no index currently exists
+ */
+ void createIndices();
+ /**
+ * Deletes indices for selected modules
+ */
+ void deleteIndices();
+
+ public:
+ /**
+ * Deletes orphaned indices if the autoDeleteOrphanedIndices is true
+ * Always deletes indices of existing modules where hasIndex() returns false
+ */
+ static void deleteOrphanedIndices();
+
+ private:
+
+ QCheckBox *m_autoDeleteOrphanedIndicesBox;
+ QTreeWidget *m_moduleList;
+ QPushButton *m_deleteButton;
+ QPushButton *m_createButton;
+
+ QTreeWidgetItem* m_modsWithIndices;
+ QTreeWidgetItem* m_modsWithoutIndices;
};
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 739d2ea..1668a87 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -125,108 +125,106 @@
BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty)
- : CModuleChooserDialog(parent, title, label, empty)
-{
- qDebug("BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start");
- init();
- okButton()->setText(tr("Install"));
- m_nameList = QStringList();
+ : CModuleChooserDialog(parent, title, label, empty) {
+ qDebug("BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start");
+ init();
+ okButton()->setText(tr("Install"));
+ m_nameList = QStringList();
}
// Do nothing, the tree is initialized outside this class.
-void BtInstallModuleChooserDialog::initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*)
-{}
-
-void BtInstallModuleChooserDialog::initModuleItem(QString name, QTreeWidgetItem* sourceItem)
-{
- QTreeWidgetItem* moduleItem = new QTreeWidgetItem(sourceItem);
- moduleItem->setText(0, name);
- moduleItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
- moduleItem->setCheckState(0, Qt::Checked);
-
- // prevent double items
- if (m_nameList.contains(name)) {
- qDebug() << "item already in list:" << name;
- //moduleItem->setCheckState(0, Qt::Unchecked);
- QBrush bg(Qt::red);
- moduleItem->setBackground(0, bg);
- //find and change the other offending items
- foreach (QTreeWidgetItem* doubleItem, treeWidget()->findItems(name, Qt::MatchFixedString|Qt::MatchCaseSensitive|Qt::MatchRecursive, 0)) {
- //doubleItem->setCheckState(0, Qt::Unchecked);
- //qDebug() << "CInstallModuleChooserDialog::initModuleItem" << doubleItem;
- doubleItem->setBackground(0, bg);
- }
- m_doubleCheckedModules[name] = true;
- enableOk(false);
- }
- m_nameList << name;
+void BtInstallModuleChooserDialog::initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*) {}
+
+void BtInstallModuleChooserDialog::initModuleItem(QString name, QTreeWidgetItem* sourceItem) {
+ /// \todo Use new bookshelf model instead
+ /// \bug Valgrind reports memory leak:
+ QTreeWidgetItem* moduleItem = new QTreeWidgetItem(sourceItem);
+ moduleItem->setText(0, name);
+ moduleItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ moduleItem->setCheckState(0, Qt::Checked);
+
+ // prevent double items
+ if (m_nameList.contains(name)) {
+ qDebug() << "item already in list:" << name;
+ //moduleItem->setCheckState(0, Qt::Unchecked);
+ QBrush bg(Qt::red);
+ moduleItem->setBackground(0, bg);
+ //find and change the other offending items
+ foreach (QTreeWidgetItem* doubleItem, treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive, 0)) {
+ //doubleItem->setCheckState(0, Qt::Unchecked);
+ //qDebug() << "CInstallModuleChooserDialog::initModuleItem" << doubleItem;
+ doubleItem->setBackground(0, bg);
+ }
+ m_doubleCheckedModules[name] = true;
+ enableOk(false);
+ }
+ m_nameList << name;
}
-void BtInstallModuleChooserDialog::slotItemChecked(QTreeWidgetItem* item, int column)
-{
- QString moduleName = item->text(0);
- qDebug("BtInstallModuleChooserDialog::slotItemChecked start");
- // handle only non-toplevel items which has duplicates and where the first column was changed
- if (item->parent() && column == 0 && (findModuleItemsByName(moduleName).count() > 1)) {
- //prevent handling when the color is changed
- if (item->data(1, Qt::UserRole).toBool() == false) {
- qDebug("was not updating");
- item->setData(1, Qt::UserRole, true);
- } else {
- qDebug("was updating");
- item->setData(1, Qt::UserRole, false);
- return;
- }
-
- QList<QTreeWidgetItem*> doubleNameItems = findModuleItemsByName(moduleName);
- QList<QTreeWidgetItem*> doubleCheckedItems;
- foreach (QTreeWidgetItem* nItem, doubleNameItems) {
- if (nItem->checkState(0) == Qt::Checked) {
- doubleCheckedItems << nItem;
- }
- }
-
- if (doubleCheckedItems.count() > 1) {
- enableOk(false);
- // color the items
- qDebug() << "there were more than 1 item of the name" << moduleName;
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- QBrush bg(Qt::red);
- i->setBackground(0, bg);
- }
- m_doubleCheckedModules[moduleName] = true;
- } else if (doubleCheckedItems.count() == 1) {
- qDebug() << "there were 1 checked items of the name" << moduleName;
- // uncolor the items
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- i->setBackground(0, i->parent()->background(0));
- }
- m_doubleCheckedModules.remove(moduleName);
- if (m_doubleCheckedModules.count() == 0) {
- enableOk(true);
- }
- }
- }
+void BtInstallModuleChooserDialog::slotItemChecked(QTreeWidgetItem* item, int column) {
+ QString moduleName = item->text(0);
+ qDebug("BtInstallModuleChooserDialog::slotItemChecked start");
+ // handle only non-toplevel items which has duplicates and where the first column was changed
+ if (item->parent() && column == 0 && (findModuleItemsByName(moduleName).count() > 1)) {
+ //prevent handling when the color is changed
+ if (item->data(1, Qt::UserRole).toBool() == false) {
+ qDebug("was not updating");
+ item->setData(1, Qt::UserRole, true);
+ }
+ else {
+ qDebug("was updating");
+ item->setData(1, Qt::UserRole, false);
+ return;
+ }
+
+ QList<QTreeWidgetItem*> doubleNameItems = findModuleItemsByName(moduleName);
+ QList<QTreeWidgetItem*> doubleCheckedItems;
+ foreach (QTreeWidgetItem* nItem, doubleNameItems) {
+ if (nItem->checkState(0) == Qt::Checked) {
+ doubleCheckedItems << nItem;
+ }
+ }
+
+ if (doubleCheckedItems.count() > 1) {
+ enableOk(false);
+ // color the items
+ qDebug() << "there were more than 1 item of the name" << moduleName;
+ foreach (QTreeWidgetItem* i, doubleNameItems) {
+ QBrush bg(Qt::red);
+ i->setBackground(0, bg);
+ }
+ m_doubleCheckedModules[moduleName] = true;
+ }
+ else if (doubleCheckedItems.count() == 1) {
+ qDebug() << "there were 1 checked items of the name" << moduleName;
+ // uncolor the items
+ foreach (QTreeWidgetItem* i, doubleNameItems) {
+ i->setBackground(0, i->parent()->background(0));
+ }
+ m_doubleCheckedModules.remove(moduleName);
+ if (m_doubleCheckedModules.count() == 0) {
+ enableOk(true);
+ }
+ }
+ }
}
-QList<QTreeWidgetItem*> BtInstallModuleChooserDialog::findModuleItemsByName(QString name)
-{
- qDebug() << "BtInstallModuleChooserDialog::findModuleItemsByName:" << name << treeWidget()->topLevelItemCount();
- QList<QTreeWidgetItem*> doubleNamedAllItems = treeWidget()->findItems(name, Qt::MatchFixedString|Qt::MatchCaseSensitive|Qt::MatchRecursive);
- //qDebug() << "doubleNamedAllItems: " << doubleNamedAllItems.count();
- QList<QTreeWidgetItem*> doubleNamedModuleItems;
- foreach (QTreeWidgetItem* item, doubleNamedAllItems) {
- //qDebug() << "item:" << item;
- if (item->parent()) {
- doubleNamedModuleItems << item;
- }
- }
- //qDebug() << "module items:" << doubleNamedModuleItems.count();
- return doubleNamedModuleItems;
+QList<QTreeWidgetItem*> BtInstallModuleChooserDialog::findModuleItemsByName(QString name) {
+ qDebug() << "BtInstallModuleChooserDialog::findModuleItemsByName:" << name << treeWidget()->topLevelItemCount();
+ QList<QTreeWidgetItem*> doubleNamedAllItems = treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive);
+ //qDebug() << "doubleNamedAllItems: " << doubleNamedAllItems.count();
+ QList<QTreeWidgetItem*> doubleNamedModuleItems;
+ foreach (QTreeWidgetItem* item, doubleNamedAllItems) {
+ //qDebug() << "item:" << item;
+ if (item->parent()) {
+ doubleNamedModuleItems << item;
+ }
+ }
+ //qDebug() << "module items:" << doubleNamedModuleItems.count();
+ return doubleNamedModuleItems;
}
-void BtInstallModuleChooserDialog::enableOk(bool enabled)
-{
- qDebug() << "BtInstallModuleChooserDialog::enableOk" << enabled;
- okButton()->setEnabled(enabled);
+void BtInstallModuleChooserDialog::enableOk(bool enabled) {
+ qDebug() << "BtInstallModuleChooserDialog::enableOk" << enabled;
+ okButton()->setEnabled(enabled);
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 39b8a96..788dbf5 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -27,26 +27,25 @@ class QTreeWidgetItem;
* Confirmation dialog for installation. Lets the user
* uncheck modules from the list.
*/
-class BtInstallModuleChooserDialog : public CModuleChooserDialog
-{
- Q_OBJECT
+class BtInstallModuleChooserDialog : public CModuleChooserDialog {
+ Q_OBJECT
-public:
- BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty);
+ public:
+ BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty);
- void initModuleItem(QString name, QTreeWidgetItem* sourceItem);
- void enableOk(bool enabled);
+ void initModuleItem(QString name, QTreeWidgetItem* sourceItem);
+ void enableOk(bool enabled);
-public slots:
- void slotItemChecked(QTreeWidgetItem* item, int column);
+ public slots:
+ void slotItemChecked(QTreeWidgetItem* item, int column);
-protected:
- virtual void initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*);
+ protected:
+ virtual void initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*);
- QList<QTreeWidgetItem*> findModuleItemsByName(QString name);
-private:
- QStringList m_nameList;
- QMap<QString, bool> m_doubleCheckedModules;
+ QList<QTreeWidgetItem*> findModuleItemsByName(QString name);
+ private:
+ QStringList m_nameList;
+ QMap<QString, bool> m_doubleCheckedModules;
};
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index 9f8e6b9..4fe9c41 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -67,135 +67,126 @@
// *********************************************************
BtInstallPage::BtInstallPage()
- : BtConfigPage()
-{
- qDebug("BtInstallPage::BtInstallPage() start");
- initView();
- initConnections();
+ : BtConfigPage() {
+ qDebug("BtInstallPage::BtInstallPage() start");
+ initView();
+ initConnections();
}
-void BtInstallPage::setInstallEnabled(bool b)
-{
- qDebug("void BtInstallPage::setInstallEnabled(bool b) start");
- m_installButton->setEnabled(b);
+void BtInstallPage::setInstallEnabled(bool b) {
+ qDebug("void BtInstallPage::setInstallEnabled(bool b) start");
+ m_installButton->setEnabled(b);
}
-QString BtInstallPage::selectedInstallPath()
-{
- return m_pathCombo->currentText();
+QString BtInstallPage::selectedInstallPath() {
+ return m_pathCombo->currentText();
}
-void BtInstallPage::initView()
-{
- qDebug("void BtInstallPage::initView() start");
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
-
- // installation path chooser
- QHBoxLayout* pathLayout = new QHBoxLayout();
- // beautify the layout
- int top; int bottom; int left; int right;
- pathLayout->getContentsMargins(&left, &top, &right, &bottom);
- pathLayout->setContentsMargins(left, top + 7, right, bottom + 7 );
- QSpacerItem *pathSpacer= new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- QLabel* pathLabel = new QLabel(tr("Install path:"));
- m_pathCombo = new QComboBox();
- m_pathCombo->setToolTip(tr("The path where the new works will be installed"));
- 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));
-
- 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
- QHBoxLayout *installButtonLayout = new QHBoxLayout();
- installButtonLayout->setContentsMargins(0,5,0,5);
- QSpacerItem *installButtonSpacer = new QSpacerItem(371, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- installButtonLayout->addItem(installButtonSpacer);
- m_installButton = new QPushButton(tr("Install..."), this);
- m_installButton->setToolTip(tr("Install or update selected works"));
- m_installButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
- m_installButton->setEnabled(false);
- installButtonLayout->addWidget(m_installButton);
-
- mainLayout->addLayout(installButtonLayout);
+void BtInstallPage::initView() {
+ qDebug("void BtInstallPage::initView() start");
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+ // installation path chooser
+ QHBoxLayout* pathLayout = new QHBoxLayout();
+ // beautify the layout
+ int top;
+ int bottom;
+ int left;
+ int right;
+ pathLayout->getContentsMargins(&left, &top, &right, &bottom);
+ pathLayout->setContentsMargins(left, top + 7, right, bottom + 7 );
+ QSpacerItem *pathSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ QLabel* pathLabel = new QLabel(tr("Install path:"));
+ m_pathCombo = new QComboBox();
+ m_pathCombo->setToolTip(tr("The path where the new works will be installed"));
+ 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));
+
+ 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
+ QHBoxLayout *installButtonLayout = new QHBoxLayout();
+ installButtonLayout->setContentsMargins(0, 5, 0, 5);
+ QSpacerItem *installButtonSpacer = new QSpacerItem(371, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ installButtonLayout->addItem(installButtonSpacer);
+ m_installButton = new QPushButton(tr("Install..."), this);
+ m_installButton->setToolTip(tr("Install or update selected works"));
+ m_installButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
+ m_installButton->setEnabled(false);
+ installButtonLayout->addWidget(m_installButton);
+
+ mainLayout->addLayout(installButtonLayout);
}
-void BtInstallPage::initConnections()
-{
- qDebug("void BtInstallPage::initConnections() start");
- QObject::connect(m_pathCombo, SIGNAL(activated(const QString&)), this , SLOT(slotPathChanged(const QString&)));
- QObject::connect(m_configurePathButton, SIGNAL(clicked()), this, SLOT(slotEditPaths()));
- QObject::connect(m_installButton, SIGNAL(clicked()), m_sourceWidget, SLOT(slotInstall()) );
+void BtInstallPage::initConnections() {
+ qDebug("void BtInstallPage::initConnections() start");
+ QObject::connect(m_pathCombo, SIGNAL(activated(const QString&)), this , SLOT(slotPathChanged(const QString&)));
+ QObject::connect(m_configurePathButton, SIGNAL(clicked()), this, SLOT(slotEditPaths()));
+ QObject::connect(m_installButton, SIGNAL(clicked()), m_sourceWidget, SLOT(slotInstall()) );
- QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), this, SLOT(slotSwordSetupChanged()));
- //source widget has its own connections, not here
+ QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), this, SLOT(slotSwordSetupChanged()));
+ //source widget has its own connections, not here
}
-void BtInstallPage::initPathCombo()
-{
- 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) {
- if ((*it).isEmpty()) continue;
- m_pathCombo->addItem(*it);
- }
-
- // choose the current value from config but check whether we have so many items
- int configValue = CBTConfig::get(CBTConfig::installPathIndex);
- int index = configValue > (m_pathCombo->count()-1) ? m_pathCombo->count()-1 : configValue;
- m_pathCombo->setCurrentIndex(index);
+void BtInstallPage::initPathCombo() {
+ 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) {
+ if ((*it).isEmpty()) continue;
+ m_pathCombo->addItem(*it);
+ }
+
+ // choose the current value from config but check whether we have so many items
+ int configValue = CBTConfig::get(CBTConfig::installPathIndex);
+ int index = configValue > (m_pathCombo->count() - 1) ? m_pathCombo->count() - 1 : configValue;
+ m_pathCombo->setCurrentIndex(index);
}
-void BtInstallPage::slotPathChanged(const QString& /*pathText*/)
-{
- CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
+void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
+ CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
}
-void BtInstallPage::slotEditPaths()
-{
- qDebug("void BtInstallPage::slotEditPaths() start");
-
- BtInstallPathDialog* dlg = new BtInstallPathDialog();
- int result = dlg->exec();
- if (result == QDialog::Accepted) {
- //dynamic_cast<BtModuleManagerDialog*>(parentDialog())->slotSwordSetupChanged();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
- }
+void BtInstallPage::slotEditPaths() {
+ qDebug("void BtInstallPage::slotEditPaths() start");
+
+ BtInstallPathDialog* dlg = new BtInstallPathDialog();
+ int result = dlg->exec();
+ if (result == QDialog::Accepted) {
+ //dynamic_cast<BtModuleManagerDialog*>(parentDialog())->slotSwordSetupChanged();
+ CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
+ }
}
// implement the BtConfigPage methods
-QString BtInstallPage::iconName()
-{
- return CResMgr::bookshelfmgr::installpage::icon;
+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.
- 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::label() {
+ // TODO: move the warning to a dialog which is shown when adding a source.
+ return tr("Install and update works. Add remote or local sources, refresh them, select the works to be installed/updated and click Install.<br/><b>WARNING:</b> If you live in a persecuted country and don't want to risk detection don't use remote sources.");
}
-QString BtInstallPage::header()
-{
- return tr("Install/Update");
+QString BtInstallPage::header() {
+ return tr("Install/Update");
}
-void BtInstallPage::slotSwordSetupChanged()
-{
- qDebug() << "BtInstallPage::slotSwordSetupChanged";
- initPathCombo();
+void BtInstallPage::slotSwordSetupChanged() {
+ qDebug() << "BtInstallPage::slotSwordSetupChanged";
+ initPathCombo();
// for (int i = 0; i < m_sourceWidget->count(); i++ ) {
// BtSourceArea* sourceArea = dynamic_cast<BtSourceArea*>(m_sourceWidget->widget(i));
// Q_ASSERT(sourceArea);
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index 4d05577..41493f8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -27,40 +27,39 @@ class QToolButton;
/**
* The Install page includes module path chooser, source/module handler and install button.
*/
-class BtInstallPage : public BtConfigPage
-{
- Q_OBJECT
-public:
- BtInstallPage();
-
- // reimplemented from btinstallpage
- QString iconName();
- QString label();
- QString header();
-
- void setInstallEnabled(bool b);
-
- QString selectedInstallPath();
-
-public slots:
- void slotSwordSetupChanged();
-
-private:
- void initView();
- void initConnections();
- void initPathCombo();
-
-private slots:
- void slotPathChanged(const QString& pathText);
- void slotEditPaths();
-
-private:
-
- QComboBox* m_pathCombo;
- //QPushButton* m_configurePathButton;
- QToolButton* m_configurePathButton;
- BtSourceWidget* m_sourceWidget;
- QPushButton* m_installButton;
+class BtInstallPage : public BtConfigPage {
+ Q_OBJECT
+ public:
+ BtInstallPage();
+
+ // reimplemented from btinstallpage
+ QString iconName();
+ QString label();
+ QString header();
+
+ void setInstallEnabled(bool b);
+
+ QString selectedInstallPath();
+
+ public slots:
+ void slotSwordSetupChanged();
+
+ private:
+ void initView();
+ void initConnections();
+ void initPathCombo();
+
+ private slots:
+ void slotPathChanged(const QString& pathText);
+ void slotEditPaths();
+
+ private:
+
+ QComboBox* m_pathCombo;
+ //QPushButton* m_configurePathButton;
+ QToolButton* m_configurePathButton;
+ BtSourceWidget* m_sourceWidget;
+ QPushButton* m_installButton;
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index 82b8362..27b3d3a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -31,140 +31,137 @@
#include <QDebug>
-BtInstallPathDialog::BtInstallPathDialog()
-{
- setWindowTitle(tr("Bookshelf Paths"));
-
- QVBoxLayout *mainLayout;
- QHBoxLayout *viewLayout;
-
- 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.");
-
- QLabel* mainLabel = CToolClass::explanationLabel(this,
- tr("Configure bookshelf paths"), 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);
- confPathLabel->setWordWrap(true);
- mainLayout->addWidget(confPathLabel);
-
-
- m_swordPathListBox = new QTreeWidget(this);
- m_swordPathListBox->header()->hide();
-
- QDir swordDir = instbackend::swordDir();
- QStringList targets = instbackend::targetList();
- foreach (QString pathname, targets) {
- if (pathname.isEmpty() || QDir(pathname) == swordDir) continue;
- new QTreeWidgetItem(m_swordPathListBox, QStringList(pathname) );
- }
-
- 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));
- 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));
- 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));
- connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
- buttonLayout->addWidget(m_removeButton);
-
- QSpacerItem* spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
- buttonLayout->addItem(spacerItem);
-
- viewLayout->addLayout(buttonLayout);
- mainLayout->addLayout(viewLayout);
-
- QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
- buttonBox->setOrientation(Qt::Horizontal);
- buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
- mainLayout->addWidget(buttonBox);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+BtInstallPathDialog::BtInstallPathDialog() {
+ setWindowTitle(tr("Bookshelf Paths"));
+
+ QVBoxLayout *mainLayout;
+ QHBoxLayout *viewLayout;
+
+ 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.");
+
+ QLabel* mainLabel = CToolClass::explanationLabel(this,
+ tr("Configure bookshelf paths"), 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);
+ confPathLabel->setWordWrap(true);
+ mainLayout->addWidget(confPathLabel);
+
+
+ m_swordPathListBox = new QTreeWidget(this);
+ m_swordPathListBox->header()->hide();
+
+ QDir swordDir = instbackend::swordDir();
+ QStringList targets = instbackend::targetList();
+ foreach (QString pathname, targets) {
+ if (pathname.isEmpty() || QDir(pathname) == swordDir) continue;
+ new QTreeWidgetItem(m_swordPathListBox, QStringList(pathname) );
+ }
+
+ 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));
+ 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));
+ 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));
+ connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
+ buttonLayout->addWidget(m_removeButton);
+
+ QSpacerItem* spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+ buttonLayout->addItem(spacerItem);
+
+ viewLayout->addLayout(buttonLayout);
+ mainLayout->addLayout(viewLayout);
+
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
+ buttonBox->setOrientation(Qt::Horizontal);
+ buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
+ util::prepareDialogBox(buttonBox);
+ mainLayout->addWidget(buttonBox);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
void BtInstallPathDialog::slotEditClicked() {
- if (QTreeWidgetItem* i = m_swordPathListBox->currentItem()) {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), i->text(0), QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
-
- if (dirname.isEmpty()) { // if user cancelled the dialog
- return;
- }
- QDir dir = QDir(dirname);
- 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);
- if (result != QMessageBox::Yes) return;
- }
- i->setText(0, dir.absolutePath()); // absolute, not canonical
- }
- }
+ if (QTreeWidgetItem* i = m_swordPathListBox->currentItem()) {
+ QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), i->text(0), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+
+ if (dirname.isEmpty()) { // if user cancelled the dialog
+ return;
+ }
+ QDir dir = QDir(dirname);
+ 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);
+ if (result != QMessageBox::Yes) return;
+ }
+ i->setText(0, dir.absolutePath()); // absolute, not canonical
+ }
+ }
}
void BtInstallPathDialog::slotAddClicked() {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), "", QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
- if (dirname.isEmpty()) { // if user cancelled the dialog
- return;
- }
- QDir dir = QDir(dirname);
- 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);
- if (result != QMessageBox::Yes) {
- return;
- }
- }
- new QTreeWidgetItem(m_swordPathListBox, QStringList(dir.canonicalPath()) );
- }
+ QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ if (dirname.isEmpty()) { // if user cancelled the dialog
+ return;
+ }
+ QDir dir = QDir(dirname);
+ 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);
+ if (result != QMessageBox::Yes) {
+ return;
+ }
+ }
+ new QTreeWidgetItem(m_swordPathListBox, QStringList(dir.canonicalPath()) );
+ }
}
void BtInstallPathDialog::slotRemoveClicked() {
- QTreeWidgetItem* i = m_swordPathListBox->currentItem();
- if (i) {
- delete i;
- }
+ QTreeWidgetItem* i = m_swordPathListBox->currentItem();
+ if (i) {
+ delete i;
+ }
}
-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() << "save the target list" << targets;
- instbackend::setTargetList(targets); //creates new Sword config
- }
+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() << "save the target list" << targets;
+ instbackend::setTargetList(targets); //creates new Sword config
+ }
}
-void BtInstallPathDialog::accept()
-{
- writeSwordConfig();
- QDialog::accept();
+void BtInstallPathDialog::accept() {
+ writeSwordConfig();
+ QDialog::accept();
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index c3b56ac..b2f18a1 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -16,28 +16,27 @@ class QPushButton;
class QTreeWidget;
-class BtInstallPathDialog : public QDialog
-{
- Q_OBJECT
-public:
- BtInstallPathDialog();
-
-public slots:
- virtual void accept();
-
-private slots:
- void slotAddClicked();
- void slotRemoveClicked();
- void slotEditClicked();
-
-private:
- void writeSwordConfig();
-
-private:
- QPushButton* m_editButton;
- QPushButton* m_addButton;
- QPushButton* m_removeButton;
- QTreeWidget* m_swordPathListBox;
+class BtInstallPathDialog : public QDialog {
+ Q_OBJECT
+ public:
+ BtInstallPathDialog();
+
+ public slots:
+ virtual void accept();
+
+ private slots:
+ void slotAddClicked();
+ void slotRemoveClicked();
+ void slotEditClicked();
+
+ private:
+ void writeSwordConfig();
+
+ private:
+ QPushButton* m_editButton;
+ QPushButton* m_addButton;
+ QPushButton* m_removeButton;
+ QTreeWidget* m_swordPathListBox;
};
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index 2f60fc9..7883220 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
@@ -30,79 +30,77 @@
BtInstallProgressDialog::BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination)
- : QDialog(parent)
-{
- // we want this dialog to be deleted when user closes it or the downloads are completed
- setAttribute(Qt::WA_DeleteOnClose, true);
- setWindowTitle(tr("Install Progress"));
- //create the dialog which shows the status and lets the user stop installation
- m_statusWidget = new QTreeWidget();
- m_statusWidget->setRootIsDecorated(false);
- m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress") << QString::null);
- m_statusWidget->header()->setStretchLastSection(false);
- m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
- m_statusWidget->header()->setMovable(false);
- //m_statusWidget->setColumnWidth(1, CToolClass::mWidth(m_statusWidget, 2));
-
- foreach (QTreeWidgetItem* sourceItem, selectedModulesTreeWidget->invisibleRootItem()->takeChildren()) {
- // create items and threads for modules under this source
- foreach (QTreeWidgetItem* moduleItem, sourceItem->takeChildren()) {
- if (moduleItem->checkState(0) == Qt::Checked) {
- // create a thread for this module
- BtInstallThread* thread = new BtInstallThread(this, moduleItem->text(0), sourceItem->text(0), destination);
- m_waitingThreads.insert(sourceItem->text(0), thread);
- m_threadsByModule.insert(moduleItem->text(0), thread);
- // progress widget/item
- QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
- stopButton->setFixedSize(stopButton->sizeHint());
-
- // the item
- QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
- m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
- progressItem->setSizeHint(2, stopButton->sizeHint());
- progressItem->setText(0, moduleItem->text(0));
- progressItem->setFlags(Qt::ItemIsEnabled);
- m_statusWidget->setItemWidget(progressItem, 2, stopButton);
- progressItem->setText(1, tr("Waiting for turn..."));
-
- //connect the signals between the dialog, items and threads
- QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
- //is this needed or is statusUpdated enough?
- QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
-
- QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
-
- }
- }
- }
-
- m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
- QPushButton* stopAllButton = new QPushButton(tr("Stop All"), this);
-
- QVBoxLayout* layout = new QVBoxLayout(this);
- layout->addWidget(m_statusWidget);
- layout->addWidget(stopAllButton);
-
- connect(stopAllButton, SIGNAL(clicked()), SLOT(slotStopInstall()) );
-
- qApp->processEvents();
-
- startThreads();
+ : QDialog(parent) {
+ // we want this dialog to be deleted when user closes it or the downloads are completed
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ setWindowTitle(tr("Install Progress"));
+ //create the dialog which shows the status and lets the user stop installation
+ m_statusWidget = new QTreeWidget();
+ m_statusWidget->setRootIsDecorated(false);
+ m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress") << QString::null);
+ m_statusWidget->header()->setStretchLastSection(false);
+ m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
+ m_statusWidget->header()->setMovable(false);
+ //m_statusWidget->setColumnWidth(1, CToolClass::mWidth(m_statusWidget, 2));
+
+ foreach (QTreeWidgetItem* sourceItem, selectedModulesTreeWidget->invisibleRootItem()->takeChildren()) {
+ // create items and threads for modules under this source
+ foreach (QTreeWidgetItem* moduleItem, sourceItem->takeChildren()) {
+ if (moduleItem->checkState(0) == Qt::Checked) {
+ // create a thread for this module
+ BtInstallThread* thread = new BtInstallThread(this, moduleItem->text(0), sourceItem->text(0), destination);
+ m_waitingThreads.insert(sourceItem->text(0), thread);
+ m_threadsByModule.insert(moduleItem->text(0), thread);
+ // progress widget/item
+ QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
+ stopButton->setFixedSize(stopButton->sizeHint());
+
+ // the item
+ QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
+ m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
+ progressItem->setSizeHint(2, stopButton->sizeHint());
+ progressItem->setText(0, moduleItem->text(0));
+ progressItem->setFlags(Qt::ItemIsEnabled);
+ m_statusWidget->setItemWidget(progressItem, 2, stopButton);
+ progressItem->setText(1, tr("Waiting for turn..."));
+
+ //connect the signals between the dialog, items and threads
+ QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
+ //is this needed or is statusUpdated enough?
+ QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
+
+ QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
+
+ }
+ }
+ }
+
+ m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
+ QPushButton* stopAllButton = new QPushButton(tr("Stop All"), this);
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->addWidget(m_statusWidget);
+ layout->addWidget(stopAllButton);
+
+ connect(stopAllButton, SIGNAL(clicked()), SLOT(slotStopInstall()) );
+
+ qApp->processEvents();
+
+ startThreads();
}
-void BtInstallProgressDialog::startThreads()
-{
- // remove all the updated modules from the backend module list at once
- //foreach (QString mName, m_threadsByModule.keys()) {
- //}
- //QList<CSwordModuleInfo*> CPointers::backend()->takeModulesFromList(m_threadsByModule.keys());
- qDebug() << "start threads...";
- //loop through the multimap of the waiting threads, start at most 3 threads for each source
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
+void BtInstallProgressDialog::startThreads() {
+ // remove all the updated modules from the backend module list at once
+ //foreach (QString mName, m_threadsByModule.keys()) {
+ //}
+ //QList<CSwordModuleInfo*> CPointers::backend()->takeModulesFromList(m_threadsByModule.keys());
+ qDebug() << "start threads...";
+ //loop through the multimap of the waiting threads, start at most 3 threads for each source
+ QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
// concurrency is disabled for now
// while (threadIterator != m_waitingThreads.end()) {
// QString sourceName = threadIterator.key();
@@ -115,55 +113,51 @@ void BtInstallProgressDialog::startThreads()
// }
// else ++threadIterator;
// }
- //non-concurrent
- if (threadIterator != m_waitingThreads.begin()) {
- // go to the last item which is actually the first in the visible list
- // because the iterator is reversed compared to insert order
- threadIterator--;
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
-
- qDebug("BtInstallProgressDialog::startThreads end");
+ //non-concurrent
+ if (threadIterator != m_waitingThreads.begin()) {
+ // go to the last item which is actually the first in the visible list
+ // because the iterator is reversed compared to insert order
+ threadIterator--;
+ QString sourceName = threadIterator.key();
+ BtInstallThread* t = threadIterator.value();
+ m_runningThreads.insert(sourceName, t);
+ threadIterator = m_waitingThreads.erase(threadIterator);
+ t->start();
+ }
+
+ qDebug("BtInstallProgressDialog::startThreads end");
}
-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.
- if (status != 0) {
- message = tr("Failed");
- }
- else {
- message = tr("Completed");
- }
- oneItemStoppedOrCompleted(module, source, message);
+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.
+ if (status != 0) {
+ message = tr("Failed");
+ }
+ else {
+ message = tr("Completed");
+ }
+ oneItemStoppedOrCompleted(module, source, message);
}
-void BtInstallProgressDialog::slotOneItemStopped(QString module, QString source)
-{
- oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
+void BtInstallProgressDialog::slotOneItemStopped(QString module, QString source) {
+ oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
}
-void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage)
-{
- qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
- // update the list item
- m_statusWidget->setItemWidget(getItem(module), 1, 0);
- getItem(module)->setText(1, statusMessage);
- m_statusWidget->itemWidget(getItem(module), 2)->setEnabled(false);
- getItem(module)->setDisabled(true);
+void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage) {
+ qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
+ // update the list item
+ m_statusWidget->setItemWidget(getItem(module), 1, 0);
+ getItem(module)->setText(1, statusMessage);
+ m_statusWidget->itemWidget(getItem(module), 2)->setEnabled(false);
+ getItem(module)->setDisabled(true);
- qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
- m_runningThreads.remove(source, m_threadsByModule.value(module));
- m_waitingThreads.remove(source, m_threadsByModule.value(module));
+ qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
+ m_runningThreads.remove(source, m_threadsByModule.value(module));
+ m_waitingThreads.remove(source, m_threadsByModule.value(module));
//concurrency is disabled for now
// //start a waiting thread if there are any
@@ -177,85 +171,79 @@ void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString
// thread->start();
// }
- //non-concurrent
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
- if (m_runningThreads.size() == 0 && threadIterator != m_waitingThreads.begin()) {
- threadIterator--; // the last item
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
-
- if (threadsDone()) {
- qDebug() << "close the dialog";
- close();
- }
+ //non-concurrent
+ QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
+ if (m_runningThreads.size() == 0 && threadIterator != m_waitingThreads.begin()) {
+ threadIterator--; // the last item
+ QString sourceName = threadIterator.key();
+ BtInstallThread* t = threadIterator.value();
+ m_runningThreads.insert(sourceName, t);
+ threadIterator = m_waitingThreads.erase(threadIterator);
+ t->start();
+ }
+
+ if (threadsDone()) {
+ qDebug() << "close the dialog";
+ close();
+ }
}
-void BtInstallProgressDialog::slotStopInstall()
-{
- qDebug("BtInstallProgressDialog::slotStopInstall");
+void BtInstallProgressDialog::slotStopInstall() {
+ qDebug("BtInstallProgressDialog::slotStopInstall");
- // Clear the waiting threads map, stop all running threads.
+ // Clear the waiting threads map, stop all running threads.
- m_waitingThreads.clear();
- if (m_runningThreads.count() > 0) {
- foreach(BtInstallThread* thread, m_runningThreads) {
- thread->slotStopInstall();
- }
- } else {
- close();
- }
+ m_waitingThreads.clear();
+ if (m_runningThreads.count() > 0) {
+ foreach(BtInstallThread* thread, m_runningThreads) {
+ thread->slotStopInstall();
+ }
+ }
+ else {
+ close();
+ }
}
-void BtInstallProgressDialog::slotStatusUpdated(QString module, int status)
-{
- //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);
- QProgressBar* bar = dynamic_cast<QProgressBar*>(itemWidget);
- if (bar) bar->setValue(status);
+void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) {
+ //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);
+ QProgressBar* bar = dynamic_cast<QProgressBar*>(itemWidget);
+ if (bar) bar->setValue(status);
}
-void BtInstallProgressDialog::slotInstallStarted(QString module, QString)
-{
- getItem(module)->setText(1, tr("Preparing install..."));
+void BtInstallProgressDialog::slotInstallStarted(QString module, QString) {
+ getItem(module)->setText(1, tr("Preparing install..."));
}
-void BtInstallProgressDialog::slotDownloadStarted(QString module)
-{
- qDebug() << "BtInstallProgressDialog::slotDownloadStarted" << module;
- getItem(module)->setText(1, QString::null);
- //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true);
+void BtInstallProgressDialog::slotDownloadStarted(QString module) {
+ qDebug() << "BtInstallProgressDialog::slotDownloadStarted" << module;
+ getItem(module)->setText(1, QString::null);
+ //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true);
- QProgressBar* bar = new QProgressBar(m_statusWidget);
- bar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
- bar->setValue(0);
- m_statusWidget->setItemWidget(getItem(module), 1, bar);
+ QProgressBar* bar = new QProgressBar(m_statusWidget);
+ bar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ bar->setValue(0);
+ m_statusWidget->setItemWidget(getItem(module), 1, bar);
}
-QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName)
-{
- //qDebug() << "BtInstallProgressDialog::getItem" << moduleName;
- return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0);
+QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) {
+ //qDebug() << "BtInstallProgressDialog::getItem" << moduleName;
+ return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0);
}
-void BtInstallProgressDialog::closeEvent(QCloseEvent* event)
-{
- qDebug("BtInstallProgressDialog::closeEvent");
-
- if (event->spontaneous()) {
- event->ignore();
- return;
- }
- // other parts of the UI/engine must be updated
- CPointers::backend()->reloadModules(CSwordBackend::AddedModules);
+void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
+ qDebug("BtInstallProgressDialog::closeEvent");
+
+ if (event->spontaneous()) {
+ event->ignore();
+ return;
+ }
+ // other parts of the UI/engine must be updated
+ CPointers::backend()->reloadModules(CSwordBackend::AddedModules);
}
-bool BtInstallProgressDialog::threadsDone()
-{
- return (m_waitingThreads.count() == 0 && m_runningThreads.count() == 0);
+bool BtInstallProgressDialog::threadsDone() {
+ return (m_waitingThreads.count() == 0 && m_runningThreads.count() == 0);
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
index 67aa8fb..79c6331 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -23,48 +23,47 @@ class BtInstallThread;
/**
*/
-class BtInstallProgressDialog : public QDialog
-{
- Q_OBJECT
-public:
- BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination);
-
- ~BtInstallProgressDialog();
-
-public slots:
- void slotOneItemCompleted(QString module, QString source, int status);
- void slotOneItemStopped(QString module, QString source);
- void slotStopInstall();
- void slotStatusUpdated(QString module, int status);
- void slotDownloadStarted(QString module);
- void slotInstallStarted(QString module, QString);
-
-protected:
- /**
- * Handles closing by the window close button, Cancel (Stop) All button, or completing
- * the downloads.
- */
- virtual void closeEvent(QCloseEvent* event);
+class BtInstallProgressDialog : public QDialog {
+ Q_OBJECT
+ public:
+ BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination);
+
+ ~BtInstallProgressDialog();
+
+ public slots:
+ void slotOneItemCompleted(QString module, QString source, int status);
+ void slotOneItemStopped(QString module, QString source);
+ void slotStopInstall();
+ void slotStatusUpdated(QString module, int status);
+ void slotDownloadStarted(QString module);
+ void slotInstallStarted(QString module, QString);
+
+ protected:
+ /**
+ * Handles closing by the window close button, Cancel (Stop) All button, or completing
+ * the downloads.
+ */
+ virtual void closeEvent(QCloseEvent* event);
//signals:
// void swordSetupChanged();
-private:
+ private:
- //TODO: using maps is tedious and error prone. Find better solution for handling the modules
- // and their states.
- QMultiMap<QString, BtInstallThread*> m_waitingThreads;
- QMultiMap<QString, BtInstallThread*> m_runningThreads;
- QMap<QString, BtInstallThread*> m_threadsByModule;
- //QList<BtInstallThread*> m_doneThreads;
+ //TODO: using maps is tedious and error prone. Find better solution for handling the modules
+ // and their states.
+ QMultiMap<QString, BtInstallThread*> m_waitingThreads;
+ QMultiMap<QString, BtInstallThread*> m_runningThreads;
+ QMap<QString, BtInstallThread*> m_threadsByModule;
+ //QList<BtInstallThread*> m_doneThreads;
- QTreeWidget* m_statusWidget;
+ QTreeWidget* m_statusWidget;
-private:
- QTreeWidgetItem* getItem(QString moduleName);
- bool threadsDone();
- void startThreads();
- void oneItemStoppedOrCompleted(QString module, QString source, QString message);
+ private:
+ QTreeWidgetItem* getItem(QString moduleName);
+ bool threadsDone();
+ void startThreads();
+ void oneItemStoppedOrCompleted(QString module, QString source, QString message);
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
index d2570ff..48e38ce 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
@@ -25,176 +25,169 @@
#include <filemgr.h>
BtInstallThread::BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName)
- : QThread(parent),
- done(false),
- m_module(moduleName),
- m_destination(destinationName),
- m_source(sourceName),
- m_cancelled(false)
-{
- m_iMgr = new BtInstallMgr();
+ : QThread(parent),
+ done(false),
+ m_module(moduleName),
+ m_destination(destinationName),
+ m_source(sourceName),
+ m_cancelled(false) {
+ m_iMgr = new BtInstallMgr();
}
-BtInstallThread::~BtInstallThread()
-{
- delete m_iMgr;
+BtInstallThread::~BtInstallThread() {
+ delete m_iMgr;
}
-void BtInstallThread::run()
-{
- qDebug() << "****************************************\nBtInstallThread::run, mod:" << m_module << "\n************************************";
+void BtInstallThread::run() {
+ qDebug() << "****************************************\nBtInstallThread::run, mod:" << m_module << "\n************************************";
- emit preparingInstall(m_module, m_source);
+ emit preparingInstall(m_module, m_source);
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
- QDir dir(m_destination);
- if (!dir.exists()) {
- dir.mkdir(m_destination);
- qDebug() << "made directory" << m_destination;
- }
- if (!dir.exists("modules")) {
- dir.mkdir("modules");
- qDebug() << "made directory" << m_destination << "/modules";
- }
- if (!dir.exists("mods.d")) {
- dir.mkdir("mods.d");
- qDebug() << "made directory" << m_destination << "/mods.d";
- }
-
- QObject::connect(m_iMgr, SIGNAL(percentCompleted(int, int)), this, SLOT(slotManagerStatusUpdated(int, int)), Qt::QueuedConnection);
- QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection);
-
- //check whether it's an update. If yes, remove existing module first
- //TODO: silently removing without undo if the user cancels the update is WRONG!!!
- removeModule();
-
- // manager for the destination path
- sword::SWMgr lMgr( m_destination.toLatin1() );
+ //make sure target/mods.d and target/modules exist
+ //TODO: move this to some common precondition
+ QDir dir(m_destination);
+ if (!dir.exists()) {
+ dir.mkdir(m_destination);
+ qDebug() << "made directory" << m_destination;
+ }
+ if (!dir.exists("modules")) {
+ dir.mkdir("modules");
+ qDebug() << "made directory" << m_destination << "/modules";
+ }
+ if (!dir.exists("mods.d")) {
+ dir.mkdir("mods.d");
+ qDebug() << "made directory" << m_destination << "/mods.d";
+ }
+
+ QObject::connect(m_iMgr, SIGNAL(percentCompleted(int, int)), this, SLOT(slotManagerStatusUpdated(int, int)), Qt::QueuedConnection);
+ QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection);
+
+ //check whether it's an update. If yes, remove existing module first
+ //TODO: silently removing without undo if the user cancels the update is WRONG!!!
+ removeModule();
+
+ // manager for the destination path
+ sword::SWMgr lMgr( m_destination.toLatin1() );
if (instbackend::isRemote(*m_installSource)) {
- qDebug() << "calling install";
+ qDebug() << "calling install";
int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.get());
- if (status != 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else {
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
- else { //local source
- emit statusUpdated(m_module, 0);
+ if (status != 0) {
+ qWarning() << "Error with install: " << status << "module:" << m_module;
+ }
+ else {
+ done = true;
+ emit installCompleted(m_module, m_source, status);
+ }
+ }
+ else { //local source
+ emit statusUpdated(m_module, 0);
int status = m_iMgr->installModule(&lMgr, m_installSource->directory.c_str(), m_module.toLatin1());
- if (status > 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else if (status == -1) {
- // it was terminated, do nothing
- }
- else {
- emit statusUpdated(m_module, 100);
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
+ if (status > 0) {
+ qWarning() << "Error with install: " << status << "module:" << m_module;
+ }
+ else if (status == -1) {
+ // it was terminated, do nothing
+ }
+ else {
+ emit statusUpdated(m_module, 100);
+ done = true;
+ emit installCompleted(m_module, m_source, status);
+ }
+ }
}
-void BtInstallThread::slotStopInstall()
-{
- qDebug() << "*************************************\nBtInstallThread::slotStopInstall" << m_module << "\n********************************";
- if (!done) {
- done = true;
- qDebug() << "*********************************\nBtInstallThread::slotStopInstall, installing" << m_module << "was cancelled\n**************************************";
- m_iMgr->terminate();
- //this->terminate(); // It's dangerous to forcibly stop, but we will clean up the files
- 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);
- if (notRun) {
- this->terminate();
- this->wait(2);
- 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) {
- 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);
- }
- }
+void BtInstallThread::slotStopInstall() {
+ qDebug() << "*************************************\nBtInstallThread::slotStopInstall" << m_module << "\n********************************";
+ if (!done) {
+ done = true;
+ qDebug() << "*********************************\nBtInstallThread::slotStopInstall, installing" << m_module << "was cancelled\n**************************************";
+ m_iMgr->terminate();
+ //this->terminate(); // It's dangerous to forcibly stop, but we will clean up the files
+ 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);
+ if (notRun) {
+ this->terminate();
+ this->wait(2);
+ 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) {
+ 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);
+ }
+ }
}
-void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/)
-{
- //qDebug("BtInstallThread::slotManagerStatusUpdated");
- emit statusUpdated(m_module, totalProgress);
+void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
+ //qDebug("BtInstallThread::slotManagerStatusUpdated");
+ emit statusUpdated(m_module, totalProgress);
}
-void BtInstallThread::slotDownloadStarted()
-{
- qDebug("BtInstallThread::slotDownloadStarted");
- emit downloadStarted(m_module);
+void BtInstallThread::slotDownloadStarted() {
+ qDebug("BtInstallThread::slotDownloadStarted");
+ emit downloadStarted(m_module);
}
-void BtInstallThread::removeModule()
-{
- qDebug() << "BtInstallThread::removeModule start";
- CSwordModuleInfo* m;
- m = CPointers::backend()->findModuleByName(m_module);
- if (!m) {
- m = instbackend::backend(instbackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
- }
- if (m) { //module found?
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
- QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
- QString dataPath = m->config(CSwordModuleInfo::DataPath);
- if (dataPath.left(2) == "./") {
- dataPath = dataPath.mid(2);
- }
-
- if (prefixPath.contains(dataPath)) {
- prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
- }
- else {
- prefixPath = QString::fromLatin1(CPointers::backend()->prefixPath);
- }
-
- sword::SWMgr mgr(prefixPath.toLatin1());
- BtInstallMgr iMgr;
- iMgr.removeModule(&mgr, m->name().toLatin1());
- } else {
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "not found";
- }
+void BtInstallThread::removeModule() {
+ qDebug() << "BtInstallThread::removeModule start";
+ CSwordModuleInfo* m;
+ m = CPointers::backend()->findModuleByName(m_module);
+ if (!m) {
+ m = instbackend::backend(instbackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
+ }
+ if (m) { //module found?
+ qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
+ QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
+ QString dataPath = m->config(CSwordModuleInfo::DataPath);
+ if (dataPath.left(2) == "./") {
+ dataPath = dataPath.mid(2);
+ }
+
+ if (prefixPath.contains(dataPath)) {
+ prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
+ }
+ else {
+ prefixPath = QString::fromLatin1(CPointers::backend()->prefixPath);
+ }
+
+ sword::SWMgr mgr(prefixPath.toLatin1());
+ BtInstallMgr iMgr;
+ iMgr.removeModule(&mgr, m->name().toLatin1());
+ }
+ else {
+ qDebug() << "BtInstallThread::removeModule, module" << m_module << "not found";
+ }
}
-void BtInstallThread::removeTempFiles()
-{
- qDebug("BtInstallThread::removeTempFiles start");
+void BtInstallThread::removeTempFiles() {
+ qDebug("BtInstallThread::removeTempFiles start");
- // (take the remote conf file for this module, take DataPath,
- // take the absolute path of the InstallMgr)
+ // (take the remote conf file for this module, take DataPath,
+ // take the absolute path of the InstallMgr)
- //sword::InstallSource is = instbackend::source(m_source);
+ //sword::InstallSource is = instbackend::source(m_source);
if (instbackend::isRemote(*m_installSource)) {
- // get the path for the module temp files
- CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
- QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
- qDebug() << "Delete path:" << dataPath;
- // it's easier to use sword than qt
- sword::FileMgr::removeDir(dataPath.toLatin1().data());
- }
+ // get the path for the module temp files
+ CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
+ QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
+ qDebug() << "Delete path:" << dataPath;
+ // it's easier to use sword than qt
+ sword::FileMgr::removeDir(dataPath.toLatin1().data());
+ }
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
index a9a998a..8a8cb37 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
@@ -51,48 +51,47 @@ temporary files manually.
* We use ftp connection and file resources; the connection can be ignored but the files
* have to be cleaned up after termination.
*/
-class BtInstallThread : public QThread
-{
- Q_OBJECT
-public:
- BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName);
-
- ~BtInstallThread();
-
-public slots:
- void slotStopInstall();
- void slotManagerStatusUpdated(int totalProgress, int fileProgress);
- void slotDownloadStarted();
-
-public: // data member
- bool done;
-
-protected:
- virtual void run();
- void removeModule();
- void removeTempFiles();
-
- QString m_module;
- QString m_destination;
- QString m_source;
- bool m_cancelled;
- BtInstallMgr* m_iMgr;
- //BtInstallMgr m_iMgr;
- boost::scoped_ptr<sword::InstallSource> m_installSource;
- //TODO: it would be best to get the backend from the bookshelf manager install page
- // where it has already been created. Could fasten the progress dialog startup.
- boost::scoped_ptr<CSwordBackend> m_backendForSource;
-
-signals:
- /** Emitted when the install progress status is updated. */
- void statusUpdated(QString module, int progressPercent);
- /** Emitted when installing has been stopped/cancelled. */
- void installStopped(QString module, QString source);
- /** Emitted when installing is complete. */
- void installCompleted(QString module, QString source, int errorStatus);
- /** Emitted when the first file download has been started. */
- void downloadStarted(QString module);
- void preparingInstall(QString module, QString source);
+class BtInstallThread : public QThread {
+ Q_OBJECT
+ public:
+ BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName);
+
+ ~BtInstallThread();
+
+ public slots:
+ void slotStopInstall();
+ void slotManagerStatusUpdated(int totalProgress, int fileProgress);
+ void slotDownloadStarted();
+
+ public: // data member
+ bool done;
+
+ protected:
+ virtual void run();
+ void removeModule();
+ void removeTempFiles();
+
+ QString m_module;
+ QString m_destination;
+ QString m_source;
+ bool m_cancelled;
+ BtInstallMgr* m_iMgr;
+ //BtInstallMgr m_iMgr;
+ boost::scoped_ptr<sword::InstallSource> m_installSource;
+ //TODO: it would be best to get the backend from the bookshelf manager install page
+ // where it has already been created. Could fasten the progress dialog startup.
+ boost::scoped_ptr<CSwordBackend> m_backendForSource;
+
+ signals:
+ /** Emitted when the install progress status is updated. */
+ void statusUpdated(QString module, int progressPercent);
+ /** Emitted when installing has been stopped/cancelled. */
+ void installStopped(QString module, QString source);
+ /** Emitted when installing is complete. */
+ void installCompleted(QString module, QString source, int errorStatus);
+ /** Emitted when the first file download has been started. */
+ void downloadStarted(QString module);
+ void preparingInstall(QString module, QString source);
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
index 45bfe0f..cfdc8bb 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
@@ -41,258 +41,244 @@
// ****************************************************************
BtSourceArea::BtSourceArea(const QString& sourceName)
- : QWidget(),
- m_sourceName(sourceName),
- m_treeAlreadyInitialized(false),
- m_remoteBackend(0) //important!
-{
- m_checkedModules = QMap<QString, bool>();
- qDebug() << "BtSourceArea::BtSourceArea, " << m_sourceName;
- initView();
+ : QWidget(),
+ m_sourceName(sourceName),
+ m_treeAlreadyInitialized(false),
+ m_remoteBackend(0) { //important!
+ m_checkedModules = QMap<QString, bool>();
+ qDebug() << "BtSourceArea::BtSourceArea, " << m_sourceName;
+ initView();
}
-BtSourceArea::~BtSourceArea()
-{
- delete m_remoteBackend;
+BtSourceArea::~BtSourceArea() {
+ delete m_remoteBackend;
}
-void BtSourceArea::initView()
-{
- 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->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
- 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->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));
-
- sourceLayout->addWidget(m_refreshButton);
- sourceLayout->addItem(sourceSpacer);
- //sourceLayout->addWidget(m_editButton);
- sourceLayout->addWidget(m_deleteButton);
- sourceLayout->addWidget(m_addButton);
-
- mainLayout->addLayout(sourceLayout);
- // 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));
- mainLayout->addWidget(m_view);
-
- connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- connect(this, SIGNAL(signalCreateTree()), SLOT(slotCreateTree()), Qt::QueuedConnection);
+void BtSourceArea::initView() {
+ 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->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
+ 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->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));
+
+ sourceLayout->addWidget(m_refreshButton);
+ sourceLayout->addItem(sourceSpacer);
+ //sourceLayout->addWidget(m_editButton);
+ sourceLayout->addWidget(m_deleteButton);
+ sourceLayout->addWidget(m_addButton);
+
+ mainLayout->addLayout(sourceLayout);
+ // 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));
+ mainLayout->addWidget(m_view);
+
+ connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
+ connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ connect(this, SIGNAL(signalCreateTree()), SLOT(slotCreateTree()), Qt::QueuedConnection);
}
-QSize BtSourceArea::sizeHint() const
-{
- return QSize(100, m_refreshButton->height() + (m_view->header()->height() * 5));
+QSize BtSourceArea::sizeHint() const {
+ return QSize(100, m_refreshButton->height() + (m_view->header()->height() * 5));
}
-void BtSourceArea::initTreeFirstTime()
-{
- if (!m_treeAlreadyInitialized) {
- createModuleTree();
- m_treeAlreadyInitialized = true;
- }
+void BtSourceArea::initTreeFirstTime() {
+ if (!m_treeAlreadyInitialized) {
+ createModuleTree();
+ m_treeAlreadyInitialized = true;
+ }
}
-void BtSourceArea::createModuleTree()
-{
- 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();
+void BtSourceArea::createModuleTree() {
+ 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();
}
-void BtSourceArea::slotCreateTree()
-{
- qDebug()<<"BtSourceArea::slotCreateTree" << QTime::currentTime ();
- //let the dialog become visible
- QCoreApplication::processEvents();
- // Creating the view and populating list may take time
- QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
-
- // disconnect the signal so that we don't have to run functions for every module
- // (note: what to do if we want to restore the item selection when rebuilding?
- 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
- m_checkedModules.clear();
-
- sword::InstallSource is = instbackend::source(m_sourceName);
- delete m_remoteBackend; // the old one can be deleted
- m_remoteBackend = instbackend::backend(is);
- Q_ASSERT(m_remoteBackend);
- m_moduleList = m_remoteBackend->moduleList();
-
- // give the list to BTModuleTreeItem, create filter to remove
- // those modules which are installed already
- InstalledFilter alreadyInstalledFilter(m_sourceName);
- QList<BTModuleTreeItem::Filter*> filterList;
- filterList.append(&alreadyInstalledFilter);
- BTModuleTreeItem rootItem(filterList, BTModuleTreeItem::CatLangMod, &m_moduleList);
-
- addToTree(&rootItem, m_view->invisibleRootItem());
- QCoreApplication::processEvents();
- // receive signal when user checks modules
- connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- QApplication::restoreOverrideCursor();
- qDebug()<< "BtSourceArea::createModuleTree end"<< QTime::currentTime ();
+void BtSourceArea::slotCreateTree() {
+ qDebug() << "BtSourceArea::slotCreateTree" << QTime::currentTime ();
+ //let the dialog become visible
+ QCoreApplication::processEvents();
+ // Creating the view and populating list may take time
+ QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+
+ // disconnect the signal so that we don't have to run functions for every module
+ // (note: what to do if we want to restore the item selection when rebuilding?
+ 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
+ m_checkedModules.clear();
+
+ sword::InstallSource is = instbackend::source(m_sourceName);
+ delete m_remoteBackend; // the old one can be deleted
+ m_remoteBackend = instbackend::backend(is);
+ Q_ASSERT(m_remoteBackend);
+ m_moduleList = m_remoteBackend->moduleList();
+
+ // give the list to BTModuleTreeItem, create filter to remove
+ // those modules which are installed already
+ InstalledFilter alreadyInstalledFilter(m_sourceName);
+ QList<BTModuleTreeItem::Filter*> filterList;
+ filterList.append(&alreadyInstalledFilter);
+ BTModuleTreeItem rootItem(filterList, BTModuleTreeItem::CatLangMod, &m_moduleList);
+
+ addToTree(&rootItem, m_view->invisibleRootItem());
+ QCoreApplication::processEvents();
+ // receive signal when user checks modules
+ connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
+ QApplication::restoreOverrideCursor();
+ qDebug() << "BtSourceArea::createModuleTree end" << QTime::currentTime ();
}
-void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem)
-{
- //qDebug()<<"BtSourceArea::addToTree "<<item->text();
- //qDebug() << "BTMTItem type: " << item->type();
-
- foreach (BTModuleTreeItem* i, item->children()) {
- addToTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- CSwordModuleInfo* mInfo = item->moduleInfo();
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- //qDebug() << "item"<<item->text()<< "was cat or lang";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- //qDebug() << "item"<<item->text()<< "was a module";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- widgetItem->setCheckState(0, Qt::Unchecked);
-
- CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name());
- 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
- } else { // the module is already installed
- QBrush bg(QColor(255,153,153)); /// \bug Possible color conflict
- widgetItem->setBackground(0, bg);
- widgetItem->setBackground(1, bg);
- installedV = QString(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- // set the color for the parent items
- QTreeWidgetItem* parent1 = widgetItem->parent();
- if (parent1) {
- parent1->setBackground(0,bg);
- parent1->setBackground(1,bg);
- QTreeWidgetItem* parent2 = parent1->parent();
- if (parent2) {
- parent2->setBackground(0,bg);
- parent2->setBackground(1,bg);
- }
- }
- }
-
-
- QString descr(mInfo->config(CSwordModuleInfo::Description));
- QString toolTipText = CToolClass::remoteModuleToolTip(mInfo, installedV);
-
- widgetItem->setText(1, descr);
- widgetItem->setToolTip(0, toolTipText);
- widgetItem->setToolTip(1, toolTipText);
- }
- }
+void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
+ //qDebug()<<"BtSourceArea::addToTree "<<item->text();
+ //qDebug() << "BTMTItem type: " << item->type();
+
+ foreach (BTModuleTreeItem* i, item->children()) {
+ addToTree(i, new QTreeWidgetItem(widgetItem));
+ }
+ if (item->type() != BTModuleTreeItem::Root) {
+ CSwordModuleInfo* mInfo = item->moduleInfo();
+ widgetItem->setText(0, item->text());
+ if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
+ //qDebug() << "item"<<item->text()<< "was cat or lang";
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ }
+ if (item->type() == BTModuleTreeItem::Module) {
+ //qDebug() << "item"<<item->text()<< "was a module";
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ widgetItem->setCheckState(0, Qt::Unchecked);
+
+ CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name());
+ 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
+ } else { // the module is already installed
+ QBrush bg(QColor(255, 153, 153)); /// \bug Possible color conflict
+ widgetItem->setBackground(0, bg);
+ widgetItem->setBackground(1, bg);
+ installedV = QString(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
+ // set the color for the parent items
+ QTreeWidgetItem* parent1 = widgetItem->parent();
+ if (parent1) {
+ parent1->setBackground(0, bg);
+ parent1->setBackground(1, bg);
+ QTreeWidgetItem* parent2 = parent1->parent();
+ if (parent2) {
+ parent2->setBackground(0, bg);
+ parent2->setBackground(1, bg);
+ }
+ }
+ }
+
+
+ QString descr(mInfo->config(CSwordModuleInfo::Description));
+ QString toolTipText = CToolClass::remoteModuleToolTip(mInfo, installedV);
+
+ widgetItem->setText(1, descr);
+ widgetItem->setToolTip(0, toolTipText);
+ widgetItem->setToolTip(1, toolTipText);
+ }
+ }
}
-QTreeWidget* BtSourceArea::treeWidget()
-{
- return m_view;
+QTreeWidget* BtSourceArea::treeWidget() {
+ return m_view;
}
// return the selected modules
-QMap<QString, bool>* BtSourceArea::selectedModules()
-{
- return &m_checkedModules;
+QMap<QString, bool>* BtSourceArea::selectedModules() {
+ return &m_checkedModules;
}
// when a module is checked/unchecked
-void BtSourceArea::slotSelectionChanged(QTreeWidgetItem* item, int column)
-{
- //qDebug("BtSourceArea::slotSelectionChanged");
- // modify the internal list of selected (actually checked) modules
- // if() leaves groups away
- if (!item->childCount() && column == 0) {
- foreach (CSwordModuleInfo* module, m_moduleList) {
- if (module->name() == item->text(0)) {
- if (item->checkState(0) == Qt::Checked) {
- qDebug() << module->name() << "was checked";
- m_checkedModules.insert(module->name(), true);
- } else {
- qDebug() << module->name() << "was unchecked";
- m_checkedModules.remove(module->name());
- }
- emit signalSelectionChanged(m_sourceName, m_checkedModules.count());
- break;
- }
- }
- }
+void BtSourceArea::slotSelectionChanged(QTreeWidgetItem* item, int column) {
+ //qDebug("BtSourceArea::slotSelectionChanged");
+ // modify the internal list of selected (actually checked) modules
+ // if() leaves groups away
+ if (!item->childCount() && column == 0) {
+ foreach (CSwordModuleInfo* module, m_moduleList) {
+ if (module->name() == item->text(0)) {
+ if (item->checkState(0) == Qt::Checked) {
+ qDebug() << module->name() << "was checked";
+ m_checkedModules.insert(module->name(), true);
+ }
+ else {
+ qDebug() << module->name() << "was unchecked";
+ m_checkedModules.remove(module->name());
+ }
+ emit signalSelectionChanged(m_sourceName, m_checkedModules.count());
+ break;
+ }
+ }
+ }
}
-void BtSourceArea::slotItemDoubleClicked(QTreeWidgetItem* item, int /*column*/)
-{
- CSwordModuleInfo* mInfo = m_remoteBackend->findModuleByName(item->text(0));
- if (mInfo) {
- BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, mInfo);
- dialog->show();
- dialog->raise();
- }
+void BtSourceArea::slotItemDoubleClicked(QTreeWidgetItem* item, int /*column*/) {
+ CSwordModuleInfo* mInfo = m_remoteBackend->findModuleByName(item->text(0));
+ if (mInfo) {
+ BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, mInfo);
+ dialog->show();
+ dialog->raise();
+ }
}
BtSourceArea::InstalledFilter::InstalledFilter(QString sourceName)
- : BTModuleTreeItem::Filter(),
- m_source(instbackend::source(sourceName)),
- m_swordBackend(instbackend::backend(m_source))
-{
- // these are set once to optimize away repeated calls
- // m_source, m_swordBackend
+ : BTModuleTreeItem::Filter(),
+ m_source(instbackend::source(sourceName)),
+ m_swordBackend(instbackend::backend(m_source)) {
+ // these are set once to optimize away repeated calls
+ // m_source, m_swordBackend
}
//filter out already installed, not updateable modules
-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...");
- const sword::SWVersion installedVersion(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- const sword::SWVersion newVersion(mInfo->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- if (installedVersion >= newVersion) {
- return false;
- }
- }
- return true;
+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...");
+ const sword::SWVersion installedVersion(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
+ const sword::SWVersion newVersion(mInfo->config(CSwordModuleInfo::ModuleVersion).toLatin1());
+ if (installedVersion >= newVersion) {
+ return false;
+ }
+ }
+ return true;
}
-void BtSourceArea::slotSwordSetupChanged()
-{
- createModuleTree();
+void BtSourceArea::slotSwordSetupChanged() {
+ createModuleTree();
}
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.h b/src/frontend/bookshelfmanager/installpage/btsourcearea.h
index 814bde8..e39efef 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.h
+++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.h
@@ -37,59 +37,58 @@ class QPushButton;
* the cache and rebuilds the module tree. Sources are not refreshed
* automatically, only by the user action, one source at a time.
*/
-class BtSourceArea : public QWidget
-{
- Q_OBJECT
-
- friend class BtSourceWidget;
-public:
-
- struct InstalledFilter : BTModuleTreeItem::Filter {
- InstalledFilter(QString sourceName);
- bool filter(CSwordModuleInfo*);
- sword::InstallSource m_source;
- boost::scoped_ptr<CSwordBackend> m_swordBackend;
- };
-
- BtSourceArea(const QString& sourceName);
- ~BtSourceArea();
-
- void initView();
- /** Reimplemented from QWidget. */
- virtual QSize sizeHint() const;
- void initTreeFirstTime();
- QTreeWidget* treeWidget();
-
- QMap<QString, bool>* selectedModules();
-
-public slots:
- void slotSwordSetupChanged();
- /** Create a module tree for a tree widget */
- void createModuleTree();
-
-signals:
- void signalSelectionChanged(QString sourceName, int selectedCount);
- void signalCreateTree();
-
-private slots:
- void slotCreateTree();
- void slotSelectionChanged(QTreeWidgetItem* item, int column);
- void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
-private:
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
-
- QString m_sourceName;
- bool m_treeAlreadyInitialized;
- QMap<QString, bool> m_checkedModules;
- CSwordBackend* m_remoteBackend; // needed for the module list
- QList<CSwordModuleInfo*> m_moduleList;
-
- QTreeWidget* m_view;
- QLabel* m_refreshTimeLabel;
- QPushButton* m_refreshButton;
- QPushButton* m_editButton;
- QPushButton* m_deleteButton;
- QPushButton* m_addButton;
+class BtSourceArea : public QWidget {
+ Q_OBJECT
+
+ friend class BtSourceWidget;
+ public:
+
+ struct InstalledFilter : BTModuleTreeItem::Filter {
+ InstalledFilter(QString sourceName);
+ bool filter(CSwordModuleInfo*);
+ sword::InstallSource m_source;
+ boost::scoped_ptr<CSwordBackend> m_swordBackend;
+ };
+
+ BtSourceArea(const QString& sourceName);
+ ~BtSourceArea();
+
+ void initView();
+ /** Reimplemented from QWidget. */
+ virtual QSize sizeHint() const;
+ void initTreeFirstTime();
+ QTreeWidget* treeWidget();
+
+ QMap<QString, bool>* selectedModules();
+
+ public slots:
+ void slotSwordSetupChanged();
+ /** Create a module tree for a tree widget */
+ void createModuleTree();
+
+ signals:
+ void signalSelectionChanged(QString sourceName, int selectedCount);
+ void signalCreateTree();
+
+ private slots:
+ void slotCreateTree();
+ void slotSelectionChanged(QTreeWidgetItem* item, int column);
+ void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
+ private:
+ void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+
+ QString m_sourceName;
+ bool m_treeAlreadyInitialized;
+ QMap<QString, bool> m_checkedModules;
+ CSwordBackend* m_remoteBackend; // needed for the module list
+ QList<CSwordModuleInfo*> m_moduleList;
+
+ QTreeWidget* m_view;
+ QLabel* m_refreshTimeLabel;
+ QPushButton* m_refreshButton;
+ QPushButton* m_editButton;
+ QPushButton* m_deleteButton;
+ QPushButton* m_addButton;
};
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
index 586a680..f18935a 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
@@ -39,365 +39,352 @@
// ****************************************************************
BtSourceWidget::BtSourceWidget(BtInstallPage* parent)
- : QTabWidget(parent),
- m_page(parent)
-{
- qDebug("BtSourceWidget::BtSourceWidget start");
- initSources();
-
- // TODO: choose the page from config
-
+ : QTabWidget(parent),
+ m_page(parent) {
+ qDebug("BtSourceWidget::BtSourceWidget start");
+ initSources();
+
+ // TODO: choose the page from config
+
}
-BtSourceArea* BtSourceWidget::area()
-{
- return dynamic_cast<BtSourceArea*>(currentWidget());
+BtSourceArea* BtSourceWidget::area() {
+ return dynamic_cast<BtSourceArea*>(currentWidget());
}
-QString BtSourceWidget::currentSourceName()
-{
- qDebug() << "BtSourceWidget::currentSourceName: " << m_sourceNameList.at(currentIndex());
- return m_sourceNameList.at(currentIndex());
+QString BtSourceWidget::currentSourceName() {
+ qDebug() << "BtSourceWidget::currentSourceName: " << m_sourceNameList.at(currentIndex());
+ return m_sourceNameList.at(currentIndex());
}
-void BtSourceWidget::initSourceConnections()
-{
- 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_addButton, SIGNAL(clicked()), SLOT(slotAdd()));
- connect(area(), SIGNAL(signalSelectionChanged(QString, int)), SLOT(slotModuleSelectionChanged(QString, int)) );
- }
- qDebug("void BtSourceWidget::initSourceConnections() end");
+void BtSourceWidget::initSourceConnections() {
+ 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_addButton, SIGNAL(clicked()), SLOT(slotAdd()));
+ connect(area(), SIGNAL(signalSelectionChanged(QString, int)), SLOT(slotModuleSelectionChanged(QString, int)) );
+ }
+ qDebug("void BtSourceWidget::initSourceConnections() end");
}
-void BtSourceWidget::slotEdit()
-{
- qDebug("BtSourceWidget::slotEdit");
- // open the source editor dialog
-
- // if the source was changed, init the sources
-
+void BtSourceWidget::slotEdit() {
+ qDebug("BtSourceWidget::slotEdit");
+ // open the source editor dialog
+
+ // if the source was changed, init the sources
+
}
-void BtSourceWidget::slotDelete()
-{
- 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);
-
- if (ret == QMessageBox::Yes) {
- instbackend::deleteSource(currentSourceName());
-
- // remove the UI elements
- m_sourceNameList.removeAt(currentIndex());
- QWidget* w = currentWidget();
- removeTab(currentIndex());
- delete w;
- }
+void BtSourceWidget::slotDelete() {
+ 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);
+
+ if (ret == QMessageBox::Yes) {
+ instbackend::deleteSource(currentSourceName());
+
+ // remove the UI elements
+ m_sourceNameList.removeAt(currentIndex());
+ QWidget* w = currentWidget();
+ removeTab(currentIndex());
+ delete w;
+ }
}
-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()));
- }
+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()));
+ }
}
-void BtSourceWidget::slotRefresh()
-{
- qDebug("void BtSourceWidget::slotRefresh() start");
- // (re)build the module cache for the source
-
- QString sourceName = currentSourceName();
-
- // quick enough, make it modal so that we don't need to take care of anything else
- m_progressDialog = new QProgressDialog("", tr("Cancel"), 0 ,100, this);
- m_progressDialog->setWindowTitle(tr("Refreshing Source"));
- m_progressDialog->setMinimumDuration(0);
-
- // 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");
- BtInstallMgr iMgr;
- m_currentInstallMgr = &iMgr; //for the progress dialog
- sword::InstallSource is = instbackend::source(sourceName);
- bool success = false;
- 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)));
-
- if (instbackend::isRemote(is)) {
- m_progressDialog->show();
- qApp->processEvents();
- this->slotRefreshCompleted(0,0);
- 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");
- bool successful = iMgr.refreshRemoteSource( &is );
- if (!successful ) { //make sure the sources were updated sucessfully
- success = true;
- m_progressDialog->setValue(100); //make sure the dialog closes
- }
- else {
- qWarning("InstallMgr: refreshRemoteSources returned an error.");
- success = false;
- }
- }
- else {
- // Local source, update the list
- success = true;
- }
-
- delete m_progressDialog;
- m_progressDialog = 0;
-
- // rebuild the view tree and refresh the view
- if (success) {
- qDebug("void BtSourceWidget::slotRefresh 4");
- area()->createModuleTree();
- }
+void BtSourceWidget::slotRefresh() {
+ qDebug("void BtSourceWidget::slotRefresh() start");
+ // (re)build the module cache for the source
+
+ QString sourceName = currentSourceName();
+
+ // quick enough, make it modal so that we don't need to take care of anything else
+ m_progressDialog = new QProgressDialog("", tr("Cancel"), 0 , 100, this);
+ m_progressDialog->setWindowTitle(tr("Refreshing Source"));
+ m_progressDialog->setMinimumDuration(0);
+
+ // 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");
+ BtInstallMgr iMgr;
+ m_currentInstallMgr = &iMgr; //for the progress dialog
+ sword::InstallSource is = instbackend::source(sourceName);
+ bool success = false;
+ 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)));
+
+ if (instbackend::isRemote(is)) {
+ m_progressDialog->show();
+ qApp->processEvents();
+ this->slotRefreshCompleted(0, 0);
+ 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");
+ bool successful = iMgr.refreshRemoteSource( &is );
+ if (!successful ) { //make sure the sources were updated sucessfully
+ success = true;
+ m_progressDialog->setValue(100); //make sure the dialog closes
+ }
+ else {
+ qWarning("InstallMgr: refreshRemoteSources returned an error.");
+ success = false;
+ }
+ }
+ else {
+ // Local source, update the list
+ success = true;
+ }
+
+ delete m_progressDialog;
+ m_progressDialog = 0;
+
+ // rebuild the view tree and refresh the view
+ if (success) {
+ qDebug("void BtSourceWidget::slotRefresh 4");
+ area()->createModuleTree();
+ }
}
//TODO: try to move this to BtInstallMgr
-void BtSourceWidget::slotRefreshCanceled()
-{
- qDebug("BtSourceWidget::slotRefreshCanceled");
- Q_ASSERT(m_currentInstallMgr);
- if (m_currentInstallMgr) {
- m_currentInstallMgr->terminate();
- }
- qApp->processEvents();
+void BtSourceWidget::slotRefreshCanceled() {
+ qDebug("BtSourceWidget::slotRefreshCanceled");
+ Q_ASSERT(m_currentInstallMgr);
+ if (m_currentInstallMgr) {
+ m_currentInstallMgr->terminate();
+ }
+ qApp->processEvents();
}
//TODO: try to move this to progress dialog
-void BtSourceWidget::slotRefreshCompleted(const int, const int current)
-{
- qDebug("BtSourceWidget::slotRefreshCompleted");
- if (m_progressDialog) {
- if (m_progressDialog->labelText() != tr("Refreshing...")) {
- m_progressDialog->setLabelText(tr("Refreshing..."));
- }
- m_progressDialog->setValue(current);
- }
- qApp->processEvents();
+void BtSourceWidget::slotRefreshCompleted(const int, const int current) {
+ qDebug("BtSourceWidget::slotRefreshCompleted");
+ if (m_progressDialog) {
+ if (m_progressDialog->labelText() != tr("Refreshing...")) {
+ m_progressDialog->setLabelText(tr("Refreshing..."));
+ }
+ m_progressDialog->setValue(current);
+ }
+ qApp->processEvents();
}
// init the tabbar, setup the module tree for the current source
-void BtSourceWidget::initSources()
-{
- qDebug("void BtSourceWidget::initSources() start");
-
- // ***** Use the backend to get the list of sources *****
- instbackend::initPassiveFtpMode();
- QStringList sourceList = instbackend::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()) {
- sword::InstallSource is("FTP"); //default return value
- is.caption = "Crosswire";
- is.source = "ftp.crosswire.org";
- is.directory = "/pub/sword/raw";
- // passive ftp is not needed here, it's the default
-
- instbackend::addSource(is);
-
- sourceList = instbackend::sourceList();
- //Q_ASSERT( sourceList.count() > 0 );
- }
- qDebug("void BtSourceWidget::initSources 1");
- // Add the sources to the widget
- foreach (QString sourceName, sourceList) {
- addSource(sourceName);
- }
- // 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
- // 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
-
- if (sourceList.count() == 0) {
- QHBoxLayout* l = new QHBoxLayout(this);
- QLabel* message = new QLabel(QString("<i>") + tr("No sources were found in the SWORD configuration and BibleTime couldn't create a default source. Check your SWORD configuration and that the configuration path is writable. Then restart the Bookshelf Manager.") + QString("</i>"), this);
- message->setWordWrap(true);
- l->addWidget(message);
- }
+void BtSourceWidget::initSources() {
+ qDebug("void BtSourceWidget::initSources() start");
+
+ // ***** Use the backend to get the list of sources *****
+ instbackend::initPassiveFtpMode();
+ QStringList sourceList = instbackend::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()) {
+ sword::InstallSource is("FTP"); //default return value
+ is.caption = "Crosswire";
+ is.source = "ftp.crosswire.org";
+ is.directory = "/pub/sword/raw";
+ // passive ftp is not needed here, it's the default
+
+ instbackend::addSource(is);
+
+ sourceList = instbackend::sourceList();
+ //Q_ASSERT( sourceList.count() > 0 );
+ }
+ qDebug("void BtSourceWidget::initSources 1");
+ // Add the sources to the widget
+ foreach (QString sourceName, sourceList) {
+ addSource(sourceName);
+ }
+ // 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
+ // 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
+
+ if (sourceList.count() == 0) {
+ QHBoxLayout* l = new QHBoxLayout(this);
+ QLabel* message = new QLabel(QString("<i>") + tr("No sources were found in the SWORD configuration and BibleTime couldn't create a default source. Check your SWORD configuration and that the configuration path is writable. Then restart the Bookshelf Manager.") + QString("</i>"), this);
+ message->setWordWrap(true);
+ l->addWidget(message);
+ }
}
-void BtSourceWidget::addSource(const QString& sourceName)
-{
- qDebug("void BtSourceWidget::addSource(const QString& sourceName) start");
- // The source has already been added to the backend.
-
- QString type;
- QString server;
- QString path;
- sword::InstallSource is = instbackend::source(sourceName);
- if (instbackend::isRemote(is)) {
- type = tr("Remote:");
- server = is.source.c_str();
- path = is.directory.c_str();
- }
- else { // local source
- type = tr("Local:");
- QFileInfo fi( is.directory.c_str() );
- path = is.directory.c_str();
- if (!(fi.isDir() )) {
- path = path + QString(" ") + tr("Not a directory!"); //TODO: change this
- }
- if (!fi.isReadable()) {
- path = path + QString(" ") + tr("Not readable!"); //TODO: change this
- }
- }
-
- // Here the tab UI is created and added to the tab widget
- BtSourceArea* area = new BtSourceArea(sourceName);
- int tabNumber = this->addTab(area, sourceName);
-
- // 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);
-
- //select the new tab
- setCurrentIndex(tabNumber);
- m_sourceNameList.append(sourceName);
- initSourceConnections();
- qDebug("BtSourceWidget::addSource end");
+void BtSourceWidget::addSource(const QString& sourceName) {
+ qDebug("void BtSourceWidget::addSource(const QString& sourceName) start");
+ // The source has already been added to the backend.
+
+ QString type;
+ QString server;
+ QString path;
+ sword::InstallSource is = instbackend::source(sourceName);
+ if (instbackend::isRemote(is)) {
+ type = tr("Remote:");
+ server = is.source.c_str();
+ path = is.directory.c_str();
+ }
+ else { // local source
+ type = tr("Local:");
+ QFileInfo fi( is.directory.c_str() );
+ path = is.directory.c_str();
+ if (!(fi.isDir() )) {
+ path = path + QString(" ") + tr("Not a directory!"); //TODO: change this
+ }
+ if (!fi.isReadable()) {
+ path = path + QString(" ") + tr("Not readable!"); //TODO: change this
+ }
+ }
+
+ // Here the tab UI is created and added to the tab widget
+ BtSourceArea* area = new BtSourceArea(sourceName);
+ int tabNumber = this->addTab(area, sourceName);
+
+ // 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);
+
+ //select the new tab
+ setCurrentIndex(tabNumber);
+ m_sourceNameList.append(sourceName);
+ initSourceConnections();
+ qDebug("BtSourceWidget::addSource end");
}
//
-void BtSourceWidget::slotModuleSelectionChanged(QString sourceName, int selectedCount)
-{
- //TODO: editing sources should update the map also
- qDebug("BtSourceWidget::slotModuleSelectionChanged start");
-
- int overallCount = 0;
- m_selectedModulesCountMap.insert(sourceName, selectedCount);
- foreach (int count, m_selectedModulesCountMap) {
- qDebug() << "add" << count << "to overall count of selected modules";
- overallCount += count;
- }
-
- if (overallCount > 0) {
- m_page->setInstallEnabled(true);
- } else {
- m_page->setInstallEnabled(false);
- }
+void BtSourceWidget::slotModuleSelectionChanged(QString sourceName, int selectedCount) {
+ //TODO: editing sources should update the map also
+ qDebug("BtSourceWidget::slotModuleSelectionChanged start");
+
+ int overallCount = 0;
+ m_selectedModulesCountMap.insert(sourceName, selectedCount);
+ foreach (int count, m_selectedModulesCountMap) {
+ qDebug() << "add" << count << "to overall count of selected modules";
+ overallCount += count;
+ }
+
+ if (overallCount > 0) {
+ m_page->setInstallEnabled(true);
+ }
+ else {
+ m_page->setInstallEnabled(false);
+ }
}
-void BtSourceWidget::slotTabSelected(int /*index*/)
-{
- BtSourceArea* area = dynamic_cast<BtSourceArea*>(currentWidget());
- if (area) area->initTreeFirstTime();
+void BtSourceWidget::slotTabSelected(int /*index*/) {
+ BtSourceArea* area = dynamic_cast<BtSourceArea*>(currentWidget());
+ if (area) area->initTreeFirstTime();
}
-void BtSourceWidget::slotInstall()
-{
- 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());
- bool canWrite = true;
- if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (!fi.exists() || !fi.isWritable()) {
- canWrite = false;
- }
- } else {
- canWrite = false;
- }
- if (!canWrite) {
- const int result = 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);
- if (result != QMessageBox::Ignore) {
- return;
- }
- }
-
- // create the confirmation dialog
- // (module tree dialog, modules taken from all sources)
- QString dlgTitle(tr("Install/Update works?"));
- QString dlgLabel(tr("Do you really want to install these works?") +
- QString("<br/><br/><small>") +
- tr("Only one version of a work can be installed at the same time. Select only one if there are items marked with red.") +
- QString("</small>"));
-
- // with empty list we avoid creating the module tree inside the dialog code
- QList<CSwordModuleInfo*> emptyList;
- BtInstallModuleChooserDialog* dlg = new BtInstallModuleChooserDialog(this, dlgTitle, dlgLabel, &emptyList);
- //dlg->setGrouping(BTModuleTreeItem::Mod);
- QTreeWidget* treeWidget = dlg->treeWidget();
- QTreeWidgetItem* rootItem = treeWidget->invisibleRootItem();
-
- QStringList nameList;
-
- // loop through each tab
- for (int tab = 0; tab < count(); ++tab) {
- BtSourceArea* sArea = dynamic_cast<BtSourceArea*>(widget(tab));
- if (sArea && sArea->selectedModules()->count() > 0) {
- // there are selected modules in the source, create items for these
- QTreeWidgetItem* sourceItem = new QTreeWidgetItem(rootItem);
- sourceItem->setText(0, m_sourceNameList.at(tab));
- sourceItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsTristate|Qt::ItemIsEnabled);
- foreach (QString mName, sArea->selectedModules()->keys()) {
- dlg->initModuleItem(mName, sourceItem);
- }
- sourceItem->setExpanded(true);
- }
- }
-
- //user accepts the dialog
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), SLOT(slotInstallAccepted(QList<CSwordModuleInfo*>, QTreeWidget*)) );
- // user checks/unchecks an item, needed for preventing double items
- QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), dlg, SLOT(slotItemChecked(QTreeWidgetItem*, int)));
- dlg->exec();
- // The OK signal sent by the dialog is catched with slotInstallAccepted.
+void BtSourceWidget::slotInstall() {
+ 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());
+ bool canWrite = true;
+ if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (!fi.exists() || !fi.isWritable()) {
+ canWrite = false;
+ }
+ }
+ else {
+ canWrite = false;
+ }
+ if (!canWrite) {
+ const int result = 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);
+ if (result != QMessageBox::Ignore) {
+ return;
+ }
+ }
+
+ // create the confirmation dialog
+ // (module tree dialog, modules taken from all sources)
+ QString dlgTitle(tr("Install/Update works?"));
+ QString dlgLabel(tr("Do you really want to install these works?") +
+ QString("<br/><br/><small>") +
+ tr("Only one version of a work can be installed at the same time. Select only one if there are items marked with red.") +
+ QString("</small>"));
+
+ // with empty list we avoid creating the module tree inside the dialog code
+ QList<CSwordModuleInfo*> emptyList;
+ BtInstallModuleChooserDialog* dlg = new BtInstallModuleChooserDialog(this, dlgTitle, dlgLabel, &emptyList);
+ //dlg->setGrouping(BTModuleTreeItem::Mod);
+ QTreeWidget* treeWidget = dlg->treeWidget();
+ QTreeWidgetItem* rootItem = treeWidget->invisibleRootItem();
+
+ QStringList nameList;
+
+ // loop through each tab
+ for (int tab = 0; tab < count(); ++tab) {
+ BtSourceArea* sArea = dynamic_cast<BtSourceArea*>(widget(tab));
+ if (sArea && sArea->selectedModules()->count() > 0) {
+ // there are selected modules in the source, create items for these
+ /// \todo Use new bookshelf model instead
+ /// \bug Valgrind reports memory leak:
+ QTreeWidgetItem* sourceItem = new QTreeWidgetItem(rootItem);
+ sourceItem->setText(0, m_sourceNameList.at(tab));
+ sourceItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsTristate | Qt::ItemIsEnabled);
+ foreach (QString mName, sArea->selectedModules()->keys()) {
+ dlg->initModuleItem(mName, sourceItem);
+ }
+ sourceItem->setExpanded(true);
+ }
+ }
+
+ //user accepts the dialog
+ connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), SLOT(slotInstallAccepted(QList<CSwordModuleInfo*>, QTreeWidget*)) );
+ // user checks/unchecks an item, needed for preventing double items
+ QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), dlg, SLOT(slotItemChecked(QTreeWidgetItem*, int)));
+ dlg->exec();
+ // The OK signal sent by the dialog is catched with slotInstallAccepted.
}
-void BtSourceWidget::slotStopInstall(QTreeWidget* /*treeWidget*/)
-{
- qDebug() << "BtSourceWidget::slotStopInstall";
- // not needed?
+void BtSourceWidget::slotStopInstall(QTreeWidget* /*treeWidget*/) {
+ qDebug() << "BtSourceWidget::slotStopInstall";
+ // not needed?
}
-void BtSourceWidget::slotInstallAccepted(QList<CSwordModuleInfo*> /*modules*/, QTreeWidget* treeWidget)
-{
- qDebug() << "BtSourceWidget::slotInstallAccepted";
+void BtSourceWidget::slotInstallAccepted(QList<CSwordModuleInfo*> /*modules*/, QTreeWidget* treeWidget) {
+ qDebug() << "BtSourceWidget::slotInstallAccepted";
+
+ //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...)
- //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());
- BtModuleManagerDialog* parentDialog = dynamic_cast<BtModuleManagerDialog*>(dynamic_cast<BtInstallPage*>(parent())->parentDialog());
+ BtInstallProgressDialog* dlg = new BtInstallProgressDialog(parentDialog, treeWidget, dynamic_cast<BtInstallPage*>(parent())->selectedInstallPath());
- 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();
- 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 812c6ac..46b7d0a 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
@@ -27,60 +27,59 @@ class QTreeWidget;
* This widget implements the slots for the source action buttons and
* applies the actions to the proper source(s).
*/
-class BtSourceWidget : public QTabWidget
-{
- Q_OBJECT
-public:
- friend class BtInstallPage;
-
- BtSourceWidget(BtInstallPage* parent);
- virtual ~BtSourceWidget() {}
-
- BtSourceArea* area();
- QString currentSourceName();
-
-public slots:
- /** Install button has been clicked. */
- void slotInstall();
- /** "Stop All" button clicked */
- void slotStopInstall(QTreeWidget* treeWidget);
-
-private:
- void initSourceConnections();
- /** Add tabs/views for each source. */
- void initSources();
-
- /** Add one source to tabs/stack. */
- void addSource(const QString& sourceName);
-
-private slots:
-
- void slotRefresh();
-
- void slotRefreshCanceled();
-
- void slotRefreshCompleted(int, int);
-
- /** Edit button clicked. */
- void slotEdit();
- /** Delete button clicked. */
- void slotDelete();
- /** Add button clicked. */
- void slotAdd();
- /** Modules have been checked/unchecked in the view. */
- void slotModuleSelectionChanged(QString sourceName, int selectedCount);
-
- void slotTabSelected(int index);
- void slotInstallAccepted(QList<CSwordModuleInfo*> mi, QTreeWidget* treeWidget);
-
-
-
-private:
- QStringList m_sourceNameList;
- BtInstallPage* m_page;
- QProgressDialog* m_progressDialog; // for refreshing
- BtInstallMgr* m_currentInstallMgr; // for refreshing
- QMap<QString, int> m_selectedModulesCountMap;
+class BtSourceWidget : public QTabWidget {
+ Q_OBJECT
+ public:
+ friend class BtInstallPage;
+
+ BtSourceWidget(BtInstallPage* parent);
+ virtual ~BtSourceWidget() {}
+
+ BtSourceArea* area();
+ QString currentSourceName();
+
+ public slots:
+ /** Install button has been clicked. */
+ void slotInstall();
+ /** "Stop All" button clicked */
+ void slotStopInstall(QTreeWidget* treeWidget);
+
+ private:
+ void initSourceConnections();
+ /** Add tabs/views for each source. */
+ void initSources();
+
+ /** Add one source to tabs/stack. */
+ void addSource(const QString& sourceName);
+
+ private slots:
+
+ void slotRefresh();
+
+ void slotRefreshCanceled();
+
+ void slotRefreshCompleted(int, int);
+
+ /** Edit button clicked. */
+ void slotEdit();
+ /** Delete button clicked. */
+ void slotDelete();
+ /** Add button clicked. */
+ void slotAdd();
+ /** Modules have been checked/unchecked in the view. */
+ void slotModuleSelectionChanged(QString sourceName, int selectedCount);
+
+ void slotTabSelected(int index);
+ void slotInstallAccepted(QList<CSwordModuleInfo*> mi, QTreeWidget* treeWidget);
+
+
+
+ private:
+ QStringList m_sourceNameList;
+ BtInstallPage* m_page;
+ QProgressDialog* m_progressDialog; // for refreshing
+ BtInstallMgr* m_currentInstallMgr; // for refreshing
+ QMap<QString, int> m_selectedModulesCountMap;
};
#endif
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/frontend/bookshelfmanager/instbackend.cpp
index f981f54..caf1e08 100644
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ b/src/frontend/bookshelfmanager/instbackend.cpp
@@ -38,243 +38,231 @@ using namespace sword;
namespace instbackend {
/** Adds the source described by Source to the backend. */
-bool addSource(sword::InstallSource& source)
-{
- 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
- if (source.directory[ source.directory.length()-1 ] == '/') {
- source.directory--; //make one char shorter
- }
-
- config["Sources"].insert( std::make_pair(SWBuf("FTPSource"), source.getConfEnt()) );
- }
- else if (!strcmp(source.type, "DIR")) {
- config["Sources"].insert( std::make_pair(SWBuf("DIRSource"), source.getConfEnt()) );
- }
- config.Save();
- return true;
+bool addSource(sword::InstallSource& source) {
+ 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
+ if (source.directory[ source.directory.length()-1 ] == '/') {
+ source.directory--; //make one char shorter
+ }
+
+ config["Sources"].insert( std::make_pair(SWBuf("FTPSource"), source.getConfEnt()) );
+ }
+ else if (!strcmp(source.type, "DIR")) {
+ config["Sources"].insert( std::make_pair(SWBuf("DIRSource"), source.getConfEnt()) );
+ }
+ config.Save();
+ return true;
}
/** Returns the Source struct. */
-sword::InstallSource source(QString name)
-{
- qDebug("backend::source");
- BtInstallMgr mgr;
- InstallSourceMap::iterator source = mgr.sources.find(name.toLatin1().data());
- if (source != mgr.sources.end()) {
- return *(source->second);
- }
- else { //not found in Sword, may be a local DIR source
- SWConfig config(configFilename().toLatin1());
- SectionMap::iterator sourcesSection = config.Sections.find("Sources");
- if (sourcesSection != config.Sections.end()) {
- ConfigEntMap::iterator sourceBegin =
- sourcesSection->second.lower_bound("DIRSource");
- ConfigEntMap::iterator sourceEnd =
- sourcesSection->second.upper_bound("DIRSource");
-
- while (sourceBegin != sourceEnd) {
- InstallSource is("DIR", sourceBegin->second.c_str());
- if (!strcmp(is.caption, name.toLatin1()) ) { //found local dir source
- return is;
- }
-
- sourceBegin++;//next source
- }
- }
- }
-
- InstallSource is("EMPTY"); //default return value
- is.caption = "unknown caption";
- is.source = "unknown source";
- is.directory = "unknown dir";
- return is;
+sword::InstallSource source(QString name) {
+ qDebug("backend::source");
+ BtInstallMgr mgr;
+ InstallSourceMap::iterator source = mgr.sources.find(name.toLatin1().data());
+ if (source != mgr.sources.end()) {
+ return *(source->second);
+ }
+ else { //not found in Sword, may be a local DIR source
+ SWConfig config(configFilename().toLatin1());
+ SectionMap::iterator sourcesSection = config.Sections.find("Sources");
+ if (sourcesSection != config.Sections.end()) {
+ ConfigEntMap::iterator sourceBegin =
+ sourcesSection->second.lower_bound("DIRSource");
+ ConfigEntMap::iterator sourceEnd =
+ sourcesSection->second.upper_bound("DIRSource");
+
+ while (sourceBegin != sourceEnd) {
+ InstallSource is("DIR", sourceBegin->second.c_str());
+ if (!strcmp(is.caption, name.toLatin1()) ) { //found local dir source
+ return is;
+ }
+
+ sourceBegin++;//next source
+ }
+ }
+ }
+
+ InstallSource is("EMPTY"); //default return value
+ is.caption = "unknown caption";
+ is.source = "unknown source";
+ is.directory = "unknown dir";
+ return is;
}
/** Deletes the source. */
-bool deleteSource(QString name)
-{
- qDebug("backend::deleteSource");
- sword::InstallSource is = source(name );
-
- SWConfig config(configFilename().toLatin1());
-
- //this code can probably be shortened by using the stl remove_if functionality
- std::pair< ConfigEntMap::iterator, ConfigEntMap::iterator > range =
- isRemote(is)
- ? config["Sources"].equal_range("FTPSource")
- : config["Sources"].equal_range("DIRSource");
-
- ConfigEntMap::iterator it = range.first;
- while (it != range.second) {
- if (it->second == is.getConfEnt()) {
- // qWarning("found the source!");
- config["Sources"].erase(it);
- break;
- }
- ++it;
- }
-
- config.Save();
- return true; //TODO: dummy
+bool deleteSource(QString name) {
+ qDebug("backend::deleteSource");
+ sword::InstallSource is = source(name );
+
+ SWConfig config(configFilename().toLatin1());
+
+ //this code can probably be shortened by using the stl remove_if functionality
+ std::pair< ConfigEntMap::iterator, ConfigEntMap::iterator > range =
+ isRemote(is)
+ ? config["Sources"].equal_range("FTPSource")
+ : config["Sources"].equal_range("DIRSource");
+
+ ConfigEntMap::iterator it = range.first;
+ while (it != range.second) {
+ if (it->second == is.getConfEnt()) {
+ // qWarning("found the source!");
+ config["Sources"].erase(it);
+ break;
+ }
+ ++it;
+ }
+
+ config.Save();
+ 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
+bool refreshSource(QString /*name*/) {
+ // not possible until manager and progressdialog work together
+ return true; //TODO: dummy
}
/** Returns the moduleinfo list for the source. Delete the pointer after using. IS THIS POSSIBLE?*/
-QList<CSwordModuleInfo*> moduleList(QString /*name*/)
-{
- QList<CSwordModuleInfo*> list; //TODO: dummy
- return list;
+QList<CSwordModuleInfo*> moduleList(QString /*name*/) {
+ QList<CSwordModuleInfo*> list; //TODO: dummy
+ return list;
}
-bool isRemote(const sword::InstallSource& source)
-{
- return !strcmp(source.type, "FTP");
+bool isRemote(const sword::InstallSource& source) {
+ return !strcmp(source.type, "FTP");
}
const QString configPath() {
- const char *envhomedir = getenv("HOME");
- QString confPath = QString(envhomedir ? envhomedir : ".");
- confPath.append("/.sword/InstallMgr");
+ const char *envhomedir = getenv("HOME");
+ QString confPath = QString(envhomedir ? envhomedir : ".");
+ confPath.append("/.sword/InstallMgr");
- return confPath;
+ return confPath;
}
const QString configFilename() {
- return (configPath() + "/InstallMgr.conf");
+ return (configPath() + "/InstallMgr.conf");
}
-QStringList targetList()
-{
- qDebug("backend::targetList");
- QStringList names = CPointers::backend()->swordDirList();
- return names;
+QStringList targetList() {
+ qDebug("backend::targetList");
+ QStringList names = CPointers::backend()->swordDirList();
+ return names;
}
-bool setTargetList( const QStringList& targets )
-{
- 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");
- //bool directAccess = false;
- QString filename = swordConfigFilename();
- QFileInfo i(filename);
- QFileInfo dirInfo(i.absolutePath());
-
-
- if ( !i.exists() && dirInfo.isWritable() ) {
- // if the file doesn't exist but the parent is writable, create it
- qWarning() << "The Sword config file does not exist, it has to be created";
- QFile f(filename);
- f.open(QIODevice::WriteOnly);
- f.close();
- i.refresh();
- }
- if ( i.exists() && i.isWritable() ) { //we can write to the file ourself
- qDebug() << "The Sword config file is writable";
- } 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!"));
- return false;
- }
- SWConfig conf(filename.toLocal8Bit());
- conf.Sections.clear();
- 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") )) {
- //we don't want $HOME/.sword in the config
- continue;
- }
- else {
- qDebug() << "Add path to the conf file" << filename << ":" << t;
- conf["Install"].insert( std::make_pair(!setDataPath ? SWBuf("DataPath") : SWBuf("AugmentPath"), t.toLocal8Bit().data()) );
- setDataPath = true;
- }
- }
- qDebug() << "save the sword conf...";
- conf.Save();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
- return true;
+bool setTargetList( const QStringList& targets ) {
+ 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");
+ //bool directAccess = false;
+ QString filename = swordConfigFilename();
+ QFileInfo i(filename);
+ QFileInfo dirInfo(i.absolutePath());
+
+
+ if ( !i.exists() && dirInfo.isWritable() ) {
+ // if the file doesn't exist but the parent is writable, create it
+ qWarning() << "The Sword config file does not exist, it has to be created";
+ QFile f(filename);
+ f.open(QIODevice::WriteOnly);
+ f.close();
+ i.refresh();
+ }
+ if ( i.exists() && i.isWritable() ) { //we can write to the file ourself
+ qDebug() << "The Sword config file is writable";
+ }
+ 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!"));
+ return false;
+ }
+ SWConfig conf(filename.toLocal8Bit());
+ conf.Sections.clear();
+ 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") )) {
+ //we don't want $HOME/.sword in the config
+ continue;
+ }
+ else {
+ qDebug() << "Add path to the conf file" << filename << ":" << t;
+ conf["Install"].insert( std::make_pair(!setDataPath ? SWBuf("DataPath") : SWBuf("AugmentPath"), t.toLocal8Bit().data()) );
+ setDataPath = true;
+ }
+ }
+ qDebug() << "save the sword conf...";
+ conf.Save();
+ CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
+ return true;
}
-QStringList sourceList()
-{
- qDebug("backend::sourceList");
- BtInstallMgr mgr;
- Q_ASSERT(mgr.installConf);
+QStringList sourceList() {
+ qDebug("backend::sourceList");
+ BtInstallMgr mgr;
+ Q_ASSERT(mgr.installConf);
- QStringList names;
+ QStringList names;
- //add Sword remote sources
- for (InstallSourceMap::iterator it = mgr.sources.begin(); it != mgr.sources.end(); it++) {
- names << QString::fromLocal8Bit(it->second->caption);
- }
+ //add Sword remote sources
+ for (InstallSourceMap::iterator it = mgr.sources.begin(); it != mgr.sources.end(); it++) {
+ names << QString::fromLocal8Bit(it->second->caption);
+ }
- // Add local directory sources
- SWConfig config(configFilename().toLatin1());
- sword::SectionMap::iterator sourcesSection = config.Sections.find("Sources");
- if (sourcesSection != config.Sections.end()) {
- sword::ConfigEntMap::iterator sourceBegin = sourcesSection->second.lower_bound("DIRSource");
- sword::ConfigEntMap::iterator sourceEnd = sourcesSection->second.upper_bound("DIRSource");
+ // Add local directory sources
+ SWConfig config(configFilename().toLatin1());
+ sword::SectionMap::iterator sourcesSection = config.Sections.find("Sources");
+ if (sourcesSection != config.Sections.end()) {
+ sword::ConfigEntMap::iterator sourceBegin = sourcesSection->second.lower_bound("DIRSource");
+ sword::ConfigEntMap::iterator sourceEnd = sourcesSection->second.upper_bound("DIRSource");
- while (sourceBegin != sourceEnd) {
- InstallSource is("DIR", sourceBegin->second.c_str());
- names << QString::fromLatin1(is.caption.c_str());
+ while (sourceBegin != sourceEnd) {
+ InstallSource is("DIR", sourceBegin->second.c_str());
+ names << QString::fromLatin1(is.caption.c_str());
- sourceBegin++;
- }
- }
+ sourceBegin++;
+ }
+ }
- return names;
+ return names;
}
-void initPassiveFtpMode()
-{
- qDebug("backend::initPassiveFtpMode");
- SWConfig config(configFilename().toLatin1());
- config["General"]["PassiveFTP"] = "true";
- config.Save();
+void 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");
+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");
}
-const QDir swordDir()
-{
- return QDir(util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath().append("/.sword/"));
+const QDir swordDir() {
+ return QDir(util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath().append("/.sword/"));
}
-CSwordBackend* backend( const sword::InstallSource& is)
-{
- qDebug("backend::backend");
- CSwordBackend* ret = 0;
- if (isRemote(is)) {
- ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
- }
- else {
- ret = new CSwordBackend( QString(is.directory.c_str()), false);
- }
-
- Q_ASSERT(ret);
- if (ret) {
- ret->initModules(CSwordBackend::OtherChange);
- }
- return ret;
+CSwordBackend* backend( const sword::InstallSource& is) {
+ qDebug("backend::backend");
+ CSwordBackend* ret = 0;
+ if (isRemote(is)) {
+ ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
+ }
+ else {
+ ret = new CSwordBackend( QString(is.directory.c_str()), false);
+ }
+
+ Q_ASSERT(ret);
+ if (ret) {
+ ret->initModules(CSwordBackend::OtherChange);
+ }
+ return ret;
}
}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index c4324e3..cd8f687 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -38,192 +38,184 @@
BtRemovePage::BtRemovePage()
- : BtConfigPage()
-{
- QGridLayout* layout = new QGridLayout(this);
- layout->setMargin(5);
-
- layout->setSpacing(10);
- layout->setColumnStretch(1,1);
- layout->setRowStretch(2,1);
-
- m_view = new QTreeWidget(this);
- m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Install path"));
- m_view->setColumnWidth(0, CToolClass::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->setEnabled(false);
- layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
-
- connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
- connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveModules()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- populateModuleList();
+ : BtConfigPage() {
+ QGridLayout* layout = new QGridLayout(this);
+ layout->setMargin(5);
+
+ layout->setSpacing(10);
+ layout->setColumnStretch(1, 1);
+ layout->setRowStretch(2, 1);
+
+ m_view = new QTreeWidget(this);
+ m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Install path"));
+ m_view->setColumnWidth(0, CToolClass::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->setEnabled(false);
+ layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
+
+ connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
+ connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveModules()));
+ connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ populateModuleList();
}
-QString BtRemovePage::label()
-{
- return tr("Remove installed works. Select the works and click Remove button.");
+QString BtRemovePage::label() {
+ return tr("Remove installed works. Select the works and click Remove button.");
}
-QString BtRemovePage::iconName()
-{
- return CResMgr::bookshelfmgr::removepage::icon;
+QString BtRemovePage::iconName() {
+ return CResMgr::bookshelfmgr::removepage::icon;
}
-QString BtRemovePage::header()
-{
- return tr("Remove");
+QString BtRemovePage::header() {
+ return tr("Remove");
}
-void BtRemovePage::populateModuleList()
-{
+void BtRemovePage::populateModuleList() {
- m_view->clear();
- m_selectedModules.clear();
+ m_view->clear();
+ m_selectedModules.clear();
- // disconnect the signal so that we don't have to run functions for every module
- disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
+ // disconnect the signal so that we don't have to run functions for every module
+ disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- QList<BTModuleTreeItem::Filter*> empty;
- BTModuleTreeItem rootItem(empty, (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping));
- addToTree(&rootItem, m_view->invisibleRootItem());
+ QList<BTModuleTreeItem::Filter*> empty;
+ BTModuleTreeItem rootItem(empty, (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping));
+ addToTree(&rootItem, m_view->invisibleRootItem());
- // receive signal when user checks modules
- connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- qDebug("BtSourceArea::createModuleTree end");
+ // receive signal when user checks modules
+ connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
+ qDebug("BtSourceArea::createModuleTree end");
}
-void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem)
-{
- //qDebug()<<"BtRemovePage::addToTree "<<item->text();
- //qDebug() << "BTMTItem type: " << item->type();
-
- foreach (BTModuleTreeItem* i, item->children()) {
- addToTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- CSwordModuleInfo* mInfo = item->moduleInfo();
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- //qDebug() << "item"<<item->text()<< "was cat or lang";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- //qDebug() << "item"<<item->text()<< "was a module";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- widgetItem->setCheckState(0, Qt::Unchecked);
-
- //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);
- widgetItem->setText(1, descr);
- widgetItem->setToolTip(0, toolTipText);
- widgetItem->setToolTip(1, descr);
- }
- }
+void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
+ //qDebug()<<"BtRemovePage::addToTree "<<item->text();
+ //qDebug() << "BTMTItem type: " << item->type();
+
+ foreach (BTModuleTreeItem* i, item->children()) {
+ addToTree(i, new QTreeWidgetItem(widgetItem));
+ }
+ if (item->type() != BTModuleTreeItem::Root) {
+ CSwordModuleInfo* mInfo = item->moduleInfo();
+ widgetItem->setText(0, item->text());
+ if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
+ //qDebug() << "item"<<item->text()<< "was cat or lang";
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ }
+ if (item->type() == BTModuleTreeItem::Module) {
+ //qDebug() << "item"<<item->text()<< "was a module";
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ widgetItem->setCheckState(0, Qt::Unchecked);
+
+ //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);
+ widgetItem->setText(1, descr);
+ widgetItem->setToolTip(0, toolTipText);
+ widgetItem->setToolTip(1, descr);
+ }
+ }
}
-void BtRemovePage::slotRemoveModules()
-{
- if ( m_selectedModules.empty() ) {
- return; //no message, just do nothing
- }
-
- QStringList moduleNames;
- foreach (CSwordModuleInfo* m, m_selectedModules) {
- moduleNames.append(m->name());
- }
- const QString message = tr("You selected the following work(s): ")
- .append(moduleNames.join(", "))
- .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.
-
- // Update the module list before really removing. Remember deleting the pointers later.
- QList<CSwordModuleInfo*> toBeDeleted = CPointers::backend()->takeModulesFromList(moduleNames);
-
- sword::InstallMgr installMgr;
- QMap<QString, sword::SWMgr*> mgrDict; //maps config paths to SWMgr objects
- foreach ( CSwordModuleInfo* mInfo, toBeDeleted ) {
- Q_ASSERT(mInfo); // Only installed modules could have been selected and returned by takeModulesFromList
- // Find the install path for the sword manager
- QString prefixPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
- QString dataPath = mInfo->config(CSwordModuleInfo::DataPath);
- if (dataPath.left(2) == "./") {
- dataPath = dataPath.mid(2);
- }
- if (prefixPath.contains(dataPath)) { //remove module part to get the prefix path
- prefixPath = prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
- }
- else { //This is an error, should not happen
- qWarning() << "Removing" << mInfo->name() << "didn't succeed because the absolute path" << prefixPath << "didn't contain the data path" << dataPath;
- continue; // don't remove this, go to next of the for loop
- }
-
- // Create the sword manager and remove the module
- sword::SWMgr* mgr = mgrDict[ prefixPath ];
- if (!mgr) { //create new mgr if it's not yet available
- mgrDict.insert(prefixPath, new sword::SWMgr(prefixPath.toLocal8Bit()));
- mgr = mgrDict[ prefixPath ];
- }
- qDebug() << "Removing the module"<< mInfo->name() << "...";
- installMgr.removeModule(mgr, mInfo->module()->Name());
- }
- //delete the removed moduleinfo pointers
- qDeleteAll(toBeDeleted);
- //delete all mgrs which were created above
- qDeleteAll(mgrDict);
- mgrDict.clear();
- }
+void BtRemovePage::slotRemoveModules() {
+ if ( m_selectedModules.empty() ) {
+ return; //no message, just do nothing
+ }
+
+ QStringList moduleNames;
+ foreach (CSwordModuleInfo* m, m_selectedModules) {
+ moduleNames.append(m->name());
+ }
+ const QString message = tr("You selected the following work(s): ")
+ .append(moduleNames.join(", "))
+ .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.
+
+ // Update the module list before really removing. Remember deleting the pointers later.
+ QList<CSwordModuleInfo*> toBeDeleted = CPointers::backend()->takeModulesFromList(moduleNames);
+
+ sword::InstallMgr installMgr;
+ QMap<QString, sword::SWMgr*> mgrDict; //maps config paths to SWMgr objects
+ foreach ( CSwordModuleInfo* mInfo, toBeDeleted ) {
+ Q_ASSERT(mInfo); // Only installed modules could have been selected and returned by takeModulesFromList
+ // Find the install path for the sword manager
+ QString prefixPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
+ QString dataPath = mInfo->config(CSwordModuleInfo::DataPath);
+ if (dataPath.left(2) == "./") {
+ dataPath = dataPath.mid(2);
+ }
+ if (prefixPath.contains(dataPath)) { //remove module part to get the prefix path
+ prefixPath = prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
+ }
+ else { //This is an error, should not happen
+ qWarning() << "Removing" << mInfo->name() << "didn't succeed because the absolute path" << prefixPath << "didn't contain the data path" << dataPath;
+ continue; // don't remove this, go to next of the for loop
+ }
+
+ // Create the sword manager and remove the module
+ sword::SWMgr* mgr = mgrDict[ prefixPath ];
+ if (!mgr) { //create new mgr if it's not yet available
+ mgrDict.insert(prefixPath, new sword::SWMgr(prefixPath.toLocal8Bit()));
+ mgr = mgrDict[ prefixPath ];
+ }
+ qDebug() << "Removing the module" << mInfo->name() << "...";
+ installMgr.removeModule(mgr, mInfo->module()->Name());
+ }
+ //delete the removed moduleinfo pointers
+ qDeleteAll(toBeDeleted);
+ //delete all mgrs which were created above
+ qDeleteAll(mgrDict);
+ mgrDict.clear();
+ }
}
-void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column)
-{
- //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");
- foreach (CSwordModuleInfo* module, CPointers::backend()->moduleList()) {
- if (module->name() == item->text(0) && module->config(CSwordModuleInfo::AbsoluteDataPath) == item->text(1)) {
- mInfo = module;
- break;
- }
- }
- Q_ASSERT(mInfo); // this should have been found
- if (item->checkState(0) == Qt::Checked) {
- //qDebug() << item->text(0) << "in" << item->text(1) << "was checked";
- m_selectedModules.append(mInfo);
- } else {
- //qDebug() << mInfo->name() << "was unchecked";
- m_selectedModules.removeAll(mInfo); // there is only one, it's a pointer
- }
-
- if (m_selectedModules.count() > 0) {
- m_removeButton->setEnabled(true);
- } else {
- m_removeButton->setEnabled(false);
- }
- }
+void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column) {
+ //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");
+ foreach (CSwordModuleInfo* module, CPointers::backend()->moduleList()) {
+ if (module->name() == item->text(0) && module->config(CSwordModuleInfo::AbsoluteDataPath) == item->text(1)) {
+ mInfo = module;
+ break;
+ }
+ }
+ Q_ASSERT(mInfo); // this should have been found
+ if (item->checkState(0) == Qt::Checked) {
+ //qDebug() << item->text(0) << "in" << item->text(1) << "was checked";
+ m_selectedModules.append(mInfo);
+ }
+ else {
+ //qDebug() << mInfo->name() << "was unchecked";
+ m_selectedModules.removeAll(mInfo); // there is only one, it's a pointer
+ }
+
+ if (m_selectedModules.count() > 0) {
+ m_removeButton->setEnabled(true);
+ }
+ else {
+ m_removeButton->setEnabled(false);
+ }
+ }
}
-void BtRemovePage::slotItemDoubleClicked(QTreeWidgetItem* /*item*/, int /*column*/)
-{
- // TODO: Open the About dialog.
+void BtRemovePage::slotItemDoubleClicked(QTreeWidgetItem* /*item*/, int /*column*/) {
+ // TODO: Open the About dialog.
}
-void BtRemovePage::slotSwordSetupChanged()
-{
- populateModuleList();
+void BtRemovePage::slotSwordSetupChanged() {
+ populateModuleList();
}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 046534c..782fcc0 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -24,44 +24,43 @@ class QTreeWidgetItem;
class QPushButton;
-class BtRemovePage : public BtConfigPage
-{
- Q_OBJECT
+class BtRemovePage : public BtConfigPage {
+ Q_OBJECT
-public:
- BtRemovePage();
+ public:
+ BtRemovePage();
- ~BtRemovePage(){}
+ ~BtRemovePage() {}
- // BtConfigPage methods
- QString header();
- QString iconName();
- QString label();
+ // BtConfigPage methods
+ QString header();
+ QString iconName();
+ QString label();
- void populateModuleList();
+ void populateModuleList();
//signals:
- //void swordSetupChanged();
+ //void swordSetupChanged();
-public slots:
- void slotSwordSetupChanged();
+ public slots:
+ void slotSwordSetupChanged();
-private slots:
+ private slots:
- void slotRemoveModules();
- /** Handles activating the Remove button. */
- void slotSelectionChanged(QTreeWidgetItem* item, int column);
- void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
+ void slotRemoveModules();
+ /** Handles activating the Remove button. */
+ void slotSelectionChanged(QTreeWidgetItem* item, int column);
+ void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
-private: // methods
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+ private: // methods
+ void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+
+ private: // data
+ QTreeWidget* m_view;
+ QPushButton* m_removeButton;
+ /** Map of module name and install path (absolute path from the moduleinfo config entry).*/
+ QList<CSwordModuleInfo*> m_selectedModules;
-private: // data
- QTreeWidget* m_view;
- QPushButton* m_removeButton;
- /** Map of module name and install path (absolute path from the moduleinfo config entry).*/
- QList<CSwordModuleInfo*> m_selectedModules;
-
};
#endif
diff --git a/src/frontend/btaboutmoduledialog.cpp b/src/frontend/btaboutmoduledialog.cpp
index 1cb326e..e67d42b 100644
--- a/src/frontend/btaboutmoduledialog.cpp
+++ b/src/frontend/btaboutmoduledialog.cpp
@@ -18,11 +18,10 @@
#include <QDialogButtonBox>
BTAboutModuleDialog::BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info)
- : QDialog(parent)
-{
- //Set the flag to destroy when closed - otherwise eats memory
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(tr("Information About %1").arg(info->name()));
+ : QDialog(parent) {
+ //Set the flag to destroy when closed - otherwise eats memory
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(tr("Information About %1").arg(info->name()));
resize(650, 400);
QVBoxLayout* vboxLayout = new QVBoxLayout(this);
@@ -30,12 +29,12 @@ BTAboutModuleDialog::BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info
textEdit->setReadOnly(true);
textEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
vboxLayout->addWidget(textEdit);
- textEdit->setHtml(info->aboutText());
+ textEdit->setHtml(info->aboutText());
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Close);
- util::prepareDialogBox(buttonBox);
+ util::prepareDialogBox(buttonBox);
vboxLayout->addWidget(buttonBox);
diff --git a/src/frontend/btaboutmoduledialog.h b/src/frontend/btaboutmoduledialog.h
index b705893..c5ee7ca 100644
--- a/src/frontend/btaboutmoduledialog.h
+++ b/src/frontend/btaboutmoduledialog.h
@@ -17,14 +17,13 @@ class QWidget;
/**
Dialog to show the information about a module.
-
+
@author The BibleTime team <info@bibletime.info>
*/
-class BTAboutModuleDialog : public QDialog
-{
- Q_OBJECT
-public:
- BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info);
+class BTAboutModuleDialog : public QDialog {
+ Q_OBJECT
+ public:
+ BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info);
};
#endif
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index 4b73c3a..9c6877d 100644
--- a/src/frontend/btbookshelfdockwidget.cpp
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -20,6 +20,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
+#include <QSettings>
#include <QToolBar>
#include <QToolButton>
#include <QVBoxLayout>
@@ -27,6 +28,7 @@
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/bookshelfmodel/btcheckstatefilterproxymodel.h"
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/btaboutmoduledialog.h"
@@ -36,16 +38,25 @@
#include "util/directoryutil.h"
BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
- : QDockWidget(parent, f)
-{
+ : QDockWidget(parent, f) {
+ QSettings *settings(CBTConfig::getConfig());
+
setObjectName("BookshelfDock");
// Setup models:
- m_bookshelfModel = new BtBookshelfModel(this);
- m_bookshelfModel->addModules(CPointers::backend()->moduleList());
- m_bookshelfTreeModel = new BtBookshelfTreeModel(this);
+ settings->beginGroup("GUI/MainWindow/Docks/Bookshelf");
+ {
+ QVariant v(settings->value("grouping"));
+ if (v.canConvert<BtBookshelfTreeModel::Grouping>()) {
+ m_bookshelfTreeModel = new BtBookshelfTreeModel(v.value<BtBookshelfTreeModel::Grouping>(), this);
+ } else {
+ m_bookshelfTreeModel = new BtBookshelfTreeModel(this);
+ }
+ }
+ settings->endGroup();
m_bookshelfTreeModel->setDefaultChecked(true);
- m_bookshelfTreeModel->setSourceModel(m_bookshelfModel);
+ m_bookshelfTreeModel->setSourceModel(CPointers::backend()->model());
+
m_filterProxyModel = new BtCheckStateFilterProxyModel(this);
m_filterProxyModel->setFilterRole(BtBookshelfTreeModel::CheckStateRole);
m_filterProxyModel->setSourceModel(m_bookshelfTreeModel);
@@ -59,44 +70,41 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
m_widget = new QWidget(this);
QVBoxLayout *layout(new QVBoxLayout);
layout->setContentsMargins(0, 0, 0, 0);
- QHBoxLayout *toolBar(new QHBoxLayout);
- m_nameFilterLabel = new QLabel(this);
- toolBar->addWidget(m_nameFilterLabel);
-
- m_nameFilterEdit = new QLineEdit(this);
- m_nameFilterEdit->installEventFilter(this);
- m_nameFilterLabel->setBuddy(m_nameFilterEdit);
- toolBar->addWidget(m_nameFilterEdit);
-
- m_groupingButton = new QToolButton(this);
- m_groupingButton->setPopupMode(QToolButton::InstantPopup);
- m_groupingButton->setMenu(m_groupingMenu);
- m_groupingButton->setIcon(m_groupingMenu->icon());
- m_groupingButton->setAutoRaise(true);
- toolBar->addWidget(m_groupingButton);
-
- m_showHideButton = new QToolButton(this);
- m_showHideButton->setDefaultAction(m_showHideAction);
- m_showHideButton->setAutoRaise(true);
- toolBar->addWidget(m_showHideButton);
- layout->addLayout(toolBar);
-
- m_view = new BtBookshelfView(this);
- m_view->setModel(m_nameFilterProxyModel);
- layout->addWidget(m_view);
+ QHBoxLayout *toolBar(new QHBoxLayout);
+ m_nameFilterLabel = new QLabel(this);
+ toolBar->addWidget(m_nameFilterLabel);
+
+ m_nameFilterEdit = new QLineEdit(this);
+ m_nameFilterEdit->installEventFilter(this);
+ m_nameFilterLabel->setBuddy(m_nameFilterEdit);
+ toolBar->addWidget(m_nameFilterEdit);
+
+ m_groupingButton = new QToolButton(this);
+ m_groupingButton->setPopupMode(QToolButton::InstantPopup);
+ m_groupingButton->setMenu(m_groupingMenu);
+ m_groupingButton->setIcon(m_groupingMenu->icon());
+ m_groupingButton->setAutoRaise(true);
+ toolBar->addWidget(m_groupingButton);
+
+ m_showHideButton = new QToolButton(this);
+ m_showHideButton->setDefaultAction(m_showHideAction);
+ m_showHideButton->setAutoRaise(true);
+ toolBar->addWidget(m_showHideButton);
+ layout->addLayout(toolBar);
+
+ m_view = new BtBookshelfView(this);
+ m_view->setModel(m_nameFilterProxyModel);
+ layout->addWidget(m_view);
m_widget->setLayout(layout);
setWidget(m_widget);
- connect(CPointers::backend(),
- SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
- this, SLOT(swordSetupChanged()));
connect(m_nameFilterEdit, SIGNAL(textEdited(QString)),
m_nameFilterProxyModel, SLOT(setFilterFixedString(QString)));
connect(m_view, SIGNAL(contextMenuActivated(QPoint)),
this, SLOT(showContextMenu(QPoint)));
connect(m_view,
- SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*,QPoint)),
- this, SLOT(showItemContextMenu(CSwordModuleInfo*,QPoint)));
+ SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*, QPoint)),
+ this, SLOT(showItemContextMenu(CSwordModuleInfo*, QPoint)));
connect(m_view, SIGNAL(moduleActivated(CSwordModuleInfo*)),
this, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)));
@@ -126,82 +134,82 @@ void BtBookshelfDockWidget::initMenus() {
namespace RM = CResMgr::mainIndex;
m_contextMenu = new QMenu(this);
- m_groupingMenu = new QMenu(this);
- m_contextMenu->addMenu(m_groupingMenu);
- m_groupingMenu->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup = new QActionGroup(this);
- connect(m_groupingActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(groupingActionTriggered(QAction*)));
-
- m_groupingCatLangAction = new QAction(this);
- m_groupingCatLangAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingCatLangAction->setChecked(true);
- m_groupingActionGroup->addAction(m_groupingCatLangAction);
- m_groupingMenu->addAction(m_groupingCatLangAction);
-
- m_groupingCatAction = new QAction(this);
- m_groupingCatAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingCatAction);
- m_groupingMenu->addAction(m_groupingCatAction);
-
- m_groupingLangCatAction = new QAction(this);
- m_groupingLangCatAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingLangCatAction);
- m_groupingMenu->addAction(m_groupingLangCatAction);
-
- m_groupingLangAction = new QAction(this);
- m_groupingLangAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingLangAction);
- m_groupingMenu->addAction(m_groupingLangAction);
-
- m_groupingNoneAction = new QAction(this);
- m_groupingNoneAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingNoneAction);
- m_groupingMenu->addAction(m_groupingNoneAction);
-
- m_showHideAction = new QAction(this);
- m_showHideAction->setIcon(DU::getIcon(RM::search::icon));
- m_showHideAction->setCheckable(true);
- connect(m_showHideAction, SIGNAL(toggled(bool)),
- this, SLOT(showHideEnabled(bool)));
- m_contextMenu->addAction(m_showHideAction);
+ m_groupingMenu = new QMenu(this);
+ m_contextMenu->addMenu(m_groupingMenu);
+ m_groupingMenu->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup = new QActionGroup(this);
+ connect(m_groupingActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(groupingActionTriggered(QAction*)));
+
+ m_groupingCatLangAction = new QAction(this);
+ m_groupingCatLangAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingCatLangAction->setChecked(true);
+ m_groupingActionGroup->addAction(m_groupingCatLangAction);
+ m_groupingMenu->addAction(m_groupingCatLangAction);
+
+ m_groupingCatAction = new QAction(this);
+ m_groupingCatAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingCatAction);
+ m_groupingMenu->addAction(m_groupingCatAction);
+
+ m_groupingLangCatAction = new QAction(this);
+ m_groupingLangCatAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingLangCatAction);
+ m_groupingMenu->addAction(m_groupingLangCatAction);
+
+ m_groupingLangAction = new QAction(this);
+ m_groupingLangAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingLangAction);
+ m_groupingMenu->addAction(m_groupingLangAction);
+
+ m_groupingNoneAction = new QAction(this);
+ m_groupingNoneAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingNoneAction);
+ m_groupingMenu->addAction(m_groupingNoneAction);
+
+ m_showHideAction = new QAction(this);
+ m_showHideAction->setIcon(DU::getIcon(RM::search::icon));
+ m_showHideAction->setCheckable(true);
+ connect(m_showHideAction, SIGNAL(toggled(bool)),
+ this, SLOT(showHideEnabled(bool)));
+ m_contextMenu->addAction(m_showHideAction);
m_itemContextMenu = new QMenu(this);
- m_itemActionGroup = new QActionGroup(this);
- connect(m_itemActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(itemActionTriggered(QAction*)));
-
- m_itemOpenAction = new QAction(this);
- m_itemActionGroup->addAction(m_itemOpenAction);
- m_itemContextMenu->addAction(m_itemOpenAction);
-
- m_itemSearchAction = new QAction(this);
- m_itemSearchAction->setIcon(DU::getIcon(RM::search::icon));
- m_itemActionGroup->addAction(m_itemSearchAction);
- m_itemContextMenu->addAction(m_itemSearchAction);
-
- m_itemEditMenu = new QMenu(this);
- m_itemEditMenu->setIcon(DU::getIcon(RM::editModuleMenu::icon));
- m_itemContextMenu->addMenu(m_itemEditMenu);
- m_itemEditPlainAction = new QAction(this);
- m_itemEditPlainAction->setIcon(DU::getIcon(RM::editModulePlain::icon));
- m_itemActionGroup->addAction(m_itemEditPlainAction);
- m_itemEditMenu->addAction(m_itemEditPlainAction);
-
- m_itemEditHtmlAction = new QAction(this);
- m_itemEditHtmlAction->setIcon(DU::getIcon(RM::editModuleHTML::icon));
- m_itemActionGroup->addAction(m_itemEditHtmlAction);
- m_itemEditMenu->addAction(m_itemEditHtmlAction);
-
- m_itemUnlockAction = new QAction(this);
- m_itemUnlockAction->setIcon(DU::getIcon(RM::unlockModule::icon));
- m_itemActionGroup->addAction(m_itemUnlockAction);
- m_itemContextMenu->addAction(m_itemUnlockAction);
-
- m_itemAboutAction = new QAction(this);
- m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
- m_itemActionGroup->addAction(m_itemAboutAction);
- m_itemContextMenu->addAction(m_itemAboutAction);
+ m_itemActionGroup = new QActionGroup(this);
+ connect(m_itemActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(itemActionTriggered(QAction*)));
+
+ m_itemOpenAction = new QAction(this);
+ m_itemActionGroup->addAction(m_itemOpenAction);
+ m_itemContextMenu->addAction(m_itemOpenAction);
+
+ m_itemSearchAction = new QAction(this);
+ m_itemSearchAction->setIcon(DU::getIcon(RM::search::icon));
+ m_itemActionGroup->addAction(m_itemSearchAction);
+ m_itemContextMenu->addAction(m_itemSearchAction);
+
+ m_itemEditMenu = new QMenu(this);
+ m_itemEditMenu->setIcon(DU::getIcon(RM::editModuleMenu::icon));
+ m_itemContextMenu->addMenu(m_itemEditMenu);
+ m_itemEditPlainAction = new QAction(this);
+ m_itemEditPlainAction->setIcon(DU::getIcon(RM::editModulePlain::icon));
+ m_itemActionGroup->addAction(m_itemEditPlainAction);
+ m_itemEditMenu->addAction(m_itemEditPlainAction);
+
+ m_itemEditHtmlAction = new QAction(this);
+ m_itemEditHtmlAction->setIcon(DU::getIcon(RM::editModuleHTML::icon));
+ m_itemActionGroup->addAction(m_itemEditHtmlAction);
+ m_itemEditMenu->addAction(m_itemEditHtmlAction);
+
+ m_itemUnlockAction = new QAction(this);
+ m_itemUnlockAction->setIcon(DU::getIcon(RM::unlockModule::icon));
+ m_itemActionGroup->addAction(m_itemUnlockAction);
+ m_itemContextMenu->addAction(m_itemUnlockAction);
+
+ m_itemAboutAction = new QAction(this);
+ m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
+ m_itemActionGroup->addAction(m_itemAboutAction);
+ m_itemContextMenu->addAction(m_itemAboutAction);
}
void BtBookshelfDockWidget::retranslateInterface() {
@@ -212,31 +220,21 @@ void BtBookshelfDockWidget::retranslateInterface() {
m_groupingButton->setToolTip(tr("Change the grouping of items in the bookshelf."));
m_groupingMenu->setTitle(tr("Grouping"));
- m_groupingCatLangAction->setText(tr("Category/Language"));
- m_groupingCatAction->setText(tr("Category"));
- m_groupingLangCatAction->setText(tr("Language/Category"));
- m_groupingLangAction->setText(tr("Language"));
- m_groupingNoneAction->setText(tr("No grouping"));
+ m_groupingCatLangAction->setText(tr("Category/Language"));
+ m_groupingCatAction->setText(tr("Category"));
+ m_groupingLangCatAction->setText(tr("Language/Category"));
+ m_groupingLangAction->setText(tr("Language"));
+ m_groupingNoneAction->setText(tr("No grouping"));
m_showHideAction->setText(tr("Show/hide works"));
m_itemOpenAction->setText(tr("&Open"));
m_itemEditMenu->setTitle(tr("&Edit"));
- m_itemEditPlainAction->setText(tr("&Plain text"));
- m_itemEditHtmlAction->setText(tr("&HTML"));
+ m_itemEditPlainAction->setText(tr("&Plain text"));
+ m_itemEditHtmlAction->setText(tr("&HTML"));
m_itemUnlockAction->setText(tr("&Unlock..."));
m_itemAboutAction->setText(tr("&About..."));
}
-void BtBookshelfDockWidget::swordSetupChanged() {
- QSet<CSwordModuleInfo*> added(CPointers::backend()->moduleList().toSet());
- QSet<CSwordModuleInfo*> removed(m_bookshelfModel->modules().toSet());
- QSet<CSwordModuleInfo*> t(removed);
- removed.subtract(added);
- added.subtract(t);
- m_bookshelfModel->removeModules(removed);
- m_bookshelfModel->addModules(added);
-}
-
void BtBookshelfDockWidget::showContextMenu(QPoint pos) {
m_contextMenu->popup(pos);
}
@@ -245,32 +243,40 @@ void BtBookshelfDockWidget::groupingActionTriggered(QAction *action) {
BtBookshelfTreeModel::Grouping g;
if (action == m_groupingCatAction) {
g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
- } else if (action == m_groupingCatLangAction) {
+ }
+ else if (action == m_groupingCatLangAction) {
g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
- } else if (action == m_groupingLangAction) {
+ }
+ else if (action == m_groupingLangAction) {
g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
- } else if (action == m_groupingLangCatAction) {
+ }
+ else if (action == m_groupingLangCatAction) {
g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
}
m_bookshelfTreeModel->setGroupingOrder(g);
m_view->setRootIsDecorated(!g.isEmpty());
+
+ QSettings *settings(CBTConfig::getConfig());
+ settings->beginGroup("GUI/MainWindow/Docks/Bookshelf");
+ settings->setValue("grouping", QVariant::fromValue(g));
+ settings->endGroup();
}
void BtBookshelfDockWidget::showHideEnabled(bool enable) {
if (enable) {
m_bookshelfTreeModel->setCheckable(true);
m_filterProxyModel->setEnabled(false);
- } else {
+ }
+ else {
m_filterProxyModel->setEnabled(true);
m_bookshelfTreeModel->setCheckable(false);
}
}
void BtBookshelfDockWidget::showItemContextMenu(CSwordModuleInfo *module,
- QPoint pos)
-{
+ QPoint pos) {
m_itemContextMenu->setProperty("BtModule", qVariantFromValue((void*) module));
m_itemSearchAction->setText(tr("&Search in %1...").arg(module->name()));
m_itemOpenAction->setEnabled(!module->isLocked());
@@ -286,15 +292,20 @@ void BtBookshelfDockWidget::itemActionTriggered(QAction *action) {
if (action == m_itemOpenAction) {
emit moduleOpenTriggered(module);
- } else if (action == m_itemSearchAction) {
+ }
+ else if (action == m_itemSearchAction) {
emit moduleSearchTriggered(module);
- } else if (action == m_itemEditPlainAction) {
+ }
+ else if (action == m_itemEditPlainAction) {
emit moduleEditPlainTriggered(module);
- } else if (action == m_itemEditHtmlAction) {
+ }
+ else if (action == m_itemEditHtmlAction) {
emit moduleEditHtmlTriggered(module);
- } else if (action == m_itemUnlockAction) {
+ }
+ else if (action == m_itemUnlockAction) {
emit moduleUnlockTriggered(module);
- } else if (action == m_itemAboutAction) {
+ }
+ else if (action == m_itemAboutAction) {
emit moduleAboutTriggered(module);
}
}
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index d437c92..988bb3c 100644
--- a/src/frontend/btbookshelfdockwidget.h
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -17,7 +17,6 @@
class CSwordModuleInfo;
class BtBookshelfView;
-class BtBookshelfModel;
class BtBookshelfTreeModel;
class BtCheckStateFilterProxyModel;
class BtModuleNameFilterProxyModel;
@@ -30,7 +29,7 @@ class QToolBar;
class QToolButton;
class BtBookshelfDockWidget: public QDockWidget {
- Q_OBJECT
+ Q_OBJECT
public:
BtBookshelfDockWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
@@ -48,16 +47,14 @@ class BtBookshelfDockWidget: public QDockWidget {
void retranslateInterface();
protected slots:
- void swordSetupChanged();
void showContextMenu(QPoint pos);
- void groupingActionTriggered(QAction *action);
- void showHideEnabled(bool enable);
+ void groupingActionTriggered(QAction *action);
+ void showHideEnabled(bool enable);
void showItemContextMenu(CSwordModuleInfo *module, QPoint pos);
- void itemActionTriggered(QAction *action);
+ void itemActionTriggered(QAction *action);
protected:
// Models:
- BtBookshelfModel *m_bookshelfModel;
BtBookshelfTreeModel *m_bookshelfTreeModel;
BtCheckStateFilterProxyModel *m_filterProxyModel;
BtModuleNameFilterProxyModel *m_nameFilterProxyModel;
@@ -72,23 +69,23 @@ class BtBookshelfDockWidget: public QDockWidget {
// Popup menus:
QMenu *m_contextMenu;
- QMenu *m_groupingMenu;
- QActionGroup *m_groupingActionGroup;
- QAction *m_groupingCatLangAction;
- QAction *m_groupingCatAction;
- QAction *m_groupingLangCatAction;
- QAction *m_groupingLangAction;
- QAction *m_groupingNoneAction;
- QAction *m_showHideAction;
+ QMenu *m_groupingMenu;
+ QActionGroup *m_groupingActionGroup;
+ QAction *m_groupingCatLangAction;
+ QAction *m_groupingCatAction;
+ QAction *m_groupingLangCatAction;
+ QAction *m_groupingLangAction;
+ QAction *m_groupingNoneAction;
+ QAction *m_showHideAction;
QMenu *m_itemContextMenu;
- QActionGroup *m_itemActionGroup;
- QAction *m_itemOpenAction;
- QAction *m_itemSearchAction;
- QMenu *m_itemEditMenu;
- QAction *m_itemEditPlainAction;
- QAction *m_itemEditHtmlAction;
- QAction *m_itemUnlockAction;
- QAction *m_itemAboutAction;
+ QActionGroup *m_itemActionGroup;
+ QAction *m_itemOpenAction;
+ QAction *m_itemSearchAction;
+ QMenu *m_itemEditMenu;
+ QAction *m_itemEditPlainAction;
+ QAction *m_itemEditHtmlAction;
+ QAction *m_itemUnlockAction;
+ QAction *m_itemAboutAction;
};
#endif // BTBOOKSHELFDOCKWIDGET_H
diff --git a/src/frontend/cdragdrop.cpp b/src/frontend/cdragdrop.cpp
index 84d6376..c217d51 100644
--- a/src/frontend/cdragdrop.cpp
+++ b/src/frontend/cdragdrop.cpp
@@ -15,43 +15,36 @@
#include <QMimeData>
#include <QList>
-BTMimeData::BTMimeData()
-{}
+BTMimeData::BTMimeData() {}
-BTMimeData::~BTMimeData()
-{}
+BTMimeData::~BTMimeData() {}
/** Creates a new BTMimeData.
* Creates a new bookmark item and appends it to the list.
*/
-BTMimeData::BTMimeData(QString module, QString key, QString description)
-{
- appendBookmark(module, key, description);
+BTMimeData::BTMimeData(QString module, QString key, QString description) {
+ appendBookmark(module, key, description);
}
/** Creates a new BTMimeData, setting the text MIME type (see QMimeData::setText()). */
-BTMimeData::BTMimeData(QString text)
-{
- setText(text);
+BTMimeData::BTMimeData(QString text) {
+ setText(text);
}
/** Appends a new bookmark item into the list.*/
-void BTMimeData::appendBookmark(QString module, QString key, QString description)
-{
- BookmarkItem bm = BookmarkItem(module, key, description);
- m_bookmarkList.append(bm);
- setData("BibleTime/Bookmark", QByteArray());
+void BTMimeData::appendBookmark(QString module, QString key, QString description) {
+ BookmarkItem bm = BookmarkItem(module, key, description);
+ m_bookmarkList.append(bm);
+ setData("BibleTime/Bookmark", QByteArray());
}
/** Returns the first bookmark item in the list. */
-const BookmarkItem& BTMimeData::bookmark() const
-{
- return m_bookmarkList.first();
+const BookmarkItem& BTMimeData::bookmark() const {
+ return m_bookmarkList.first();
}
/** Creates a new bookmark item. */
BookmarkItem::BookmarkItem(QString module, QString key, QString description)
-: m_moduleName(module), m_key(key), m_description(description)
-{}
+ : m_moduleName(module), m_key(key), m_description(description) {}
diff --git a/src/frontend/cdragdrop.h b/src/frontend/cdragdrop.h
index 2804544..0380808 100644
--- a/src/frontend/cdragdrop.h
+++ b/src/frontend/cdragdrop.h
@@ -22,19 +22,25 @@
* Can be created only through BTMimeData object.
*/
class BookmarkItem {
-public:
- /** Returns the key */
- const QString& key() const {return m_key;} ;
- /** Returns the module name */
- const QString& module() const {return m_moduleName;} ;
- /** Returns the bookmark description */
- const QString& description() const {return m_description;};
-protected:
- friend class BTMimeData;
- BookmarkItem(QString, QString, QString);
- QString m_moduleName; //the module which is used by this item
- QString m_key; //the key of a bookmark
- QString m_description; //the description of a bookmark
+ public:
+ /** Returns the key */
+ const QString& key() const {
+ return m_key;
+ } ;
+ /** Returns the module name */
+ const QString& module() const {
+ return m_moduleName;
+ } ;
+ /** Returns the bookmark description */
+ const QString& description() const {
+ return m_description;
+ };
+ protected:
+ friend class BTMimeData;
+ BookmarkItem(QString, QString, QString);
+ QString m_moduleName; //the module which is used by this item
+ QString m_key; //the key of a bookmark
+ QString m_description; //the description of a bookmark
};
@@ -47,39 +53,41 @@ protected:
* For further documentation see http://doc.trolltech.com/4.3/dnd.html
*/
class BTMimeData : public QMimeData {
- Q_OBJECT
-public:
-
- /** Type for bookmark item list. Usage: BTMimeData::ItemList. */
- typedef QList<BookmarkItem> ItemList;
-
- /** Creates a new empty BTMimeData. */
- BTMimeData();
-
- virtual ~BTMimeData();
-
- /** Creates a new BTMimeData.
- * Creates a new bookmark item and appends it to the list.
- * MIME type "BibleTime/Bookmark" is added.
- * Bookmarks can not be reached by data() method, use bookmark() or bookmarks() instead.
- */
- BTMimeData(QString module, QString key, QString description);
- /** Creates a new BTMimeData, setting the text MIME type (see QMimeData::setText()). */
- BTMimeData(QString text);
-
-
- /** Appends a new bookmark item into the list.
- * Creates the item using the arguments.
- * MIME type "BibleTime/Bookmark" is added.
- */
- virtual void appendBookmark(QString module, QString key, QString description);
- /** Returns the bookmarks list. */
- virtual const ItemList& bookmarks() const {return m_bookmarkList;} ;
- /** Returns the first bookmark item in the list. */
- virtual const BookmarkItem& bookmark() const;
-
-private:
- ItemList m_bookmarkList;
+ Q_OBJECT
+ public:
+
+ /** Type for bookmark item list. Usage: BTMimeData::ItemList. */
+ typedef QList<BookmarkItem> ItemList;
+
+ /** Creates a new empty BTMimeData. */
+ BTMimeData();
+
+ virtual ~BTMimeData();
+
+ /** Creates a new BTMimeData.
+ * Creates a new bookmark item and appends it to the list.
+ * MIME type "BibleTime/Bookmark" is added.
+ * Bookmarks can not be reached by data() method, use bookmark() or bookmarks() instead.
+ */
+ BTMimeData(QString module, QString key, QString description);
+ /** Creates a new BTMimeData, setting the text MIME type (see QMimeData::setText()). */
+ BTMimeData(QString text);
+
+
+ /** Appends a new bookmark item into the list.
+ * Creates the item using the arguments.
+ * MIME type "BibleTime/Bookmark" is added.
+ */
+ virtual void appendBookmark(QString module, QString key, QString description);
+ /** Returns the bookmarks list. */
+ virtual const ItemList& bookmarks() const {
+ return m_bookmarkList;
+ } ;
+ /** Returns the first bookmark item in the list. */
+ virtual const BookmarkItem& bookmark() const;
+
+ private:
+ ItemList m_bookmarkList;
};
#endif
diff --git a/src/frontend/cdragdropmgr.cpp b/src/frontend/cdragdropmgr.cpp
index 11dab79..d2e2d00 100644
--- a/src/frontend/cdragdropmgr.cpp
+++ b/src/frontend/cdragdropmgr.cpp
@@ -30,101 +30,101 @@
CDragDropMgr::BTDrag::BTDrag( const QString& xml, QWidget* dragSource, const char* name)
-: Q3TextDrag(xml, dragSource, 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
+ 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
+ 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;
+ 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;
+ 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);
+ 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
+ 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) {}
+ : 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());
- }
- }
+ : 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 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;
+ // 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;
+ // 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;
+ // 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;
+ // Q_ASSERT(!m_bookmarkDescription.isEmpty());
+ return m_bookmarkDescription;
}
////////////////////////////////// NEW CLASS //////////////////////////
@@ -134,129 +134,129 @@ 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;
+ 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;
+ 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;
+ //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;
+ 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
index 5abad6c..c57514d 100644
--- a/src/frontend/cdragdropmgr.h
+++ b/src/frontend/cdragdropmgr.h
@@ -43,118 +43,118 @@ class QWidget;
* @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();
+ 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 5c94c39..f1ceed6 100644
--- a/src/frontend/cexportmanager.cpp
+++ b/src/frontend/cexportmanager.cpp
@@ -44,503 +44,503 @@ using namespace Rendering;
using namespace Printing;
CExportManager::CExportManager(const QString& caption, const bool showProgress, const QString& progressLabel, const CSwordBackend::FilterOptions filterOptions, const CSwordBackend::DisplayOptions displayOptions) {
- m_caption = !caption.isEmpty() ? caption : QString::fromLatin1("BibleTime");
- m_progressLabel = progressLabel;
- m_filterOptions = filterOptions;
- m_displayOptions = displayOptions;
- m_showProgress = showProgress;
- m_progressDialog = 0;
+ m_caption = !caption.isEmpty() ? caption : QString::fromLatin1("BibleTime");
+ m_progressLabel = progressLabel;
+ m_filterOptions = filterOptions;
+ m_displayOptions = displayOptions;
+ m_showProgress = showProgress;
+ m_progressDialog = 0;
}
bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool addText) {
- if (!key) {
- return false;
- }
- if (!key->module()) {
- return false;
- }
- const QString filename = getSaveFileName(format);
- if (filename.isEmpty()) {
- return false;
- }
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- QString text;
- QString startKey;
- QString stopKey;
-
- QList<CSwordModuleInfo*> modules;
- modules.append(key->module());
-
- CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
- if (vk && vk->isBoundSet()) {
- text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules );
- }
- else { //no range supported
- text = render->renderSingleKey(key->key(), modules);
- }
-
- if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format==HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
- closeProgressDialog();
- return true;
- }
- return false;
+ if (!key) {
+ return false;
+ }
+ if (!key->module()) {
+ return false;
+ }
+ const QString filename = getSaveFileName(format);
+ if (filename.isEmpty()) {
+ return false;
+ }
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ QString text;
+ QString startKey;
+ QString stopKey;
+
+ QList<CSwordModuleInfo*> modules;
+ modules.append(key->module());
+
+ CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
+ if (vk && vk->isBoundSet()) {
+ text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules );
+ }
+ else { //no range supported
+ text = render->renderSingleKey(key->key(), modules);
+ }
+
+ if (!progressWasCancelled()) {
+ CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ closeProgressDialog();
+ return true;
+ }
+ return false;
}
bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) {
- if (!list->Count())
- return false;
-
- const QString filename = getSaveFileName(format);
- if (filename.isEmpty()) {
- return false;
- }
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- CTextRendering::KeyTree tree;
-
- setProgressRange(list->Count());
- CTextRendering::KeyTreeItem::Settings itemSettings;
- itemSettings.highlight = false;
-
- *list = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
- incProgress();
-
- (*list)++;
- }
-
- const QString text = render->renderKeyTree(tree);
-
- if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format==HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
- closeProgressDialog();
- return true;
- }
- return false;
+ if (!list->Count())
+ return false;
+
+ const QString filename = getSaveFileName(format);
+ if (filename.isEmpty()) {
+ return false;
+ }
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ CTextRendering::KeyTree tree;
+
+ setProgressRange(list->Count());
+ CTextRendering::KeyTreeItem::Settings itemSettings;
+ itemSettings.highlight = false;
+
+ *list = sword::TOP;
+ while (!list->Error() && !progressWasCancelled()) {
+ tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
+ incProgress();
+
+ (*list)++;
+ }
+
+ const QString text = render->renderKeyTree(tree);
+
+ if (!progressWasCancelled()) {
+ CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ closeProgressDialog();
+ return true;
+ }
+ return false;
}
bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) {
- if (!list.count())
- return false;
-
- const QString filename = getSaveFileName(format);
- if (filename.isEmpty()) {
- return false;
- }
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- CTextRendering::KeyTree tree;
-
- setProgressRange(list.count());
- CTextRendering::KeyTreeItem::Settings itemSettings;
- itemSettings.highlight = false;
-
- QListIterator<CSwordKey*> it(list);
- while (it.hasNext() && !progressWasCancelled()){
- CSwordKey* k = it.next();
- tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) );
- incProgress();
- };
-
- const QString text = render->renderKeyTree(tree);
-
- if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format==HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
- closeProgressDialog();
- return true;
- }
- return false;
+ if (!list.count())
+ return false;
+
+ const QString filename = getSaveFileName(format);
+ if (filename.isEmpty()) {
+ return false;
+ }
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ CTextRendering::KeyTree tree;
+
+ setProgressRange(list.count());
+ CTextRendering::KeyTreeItem::Settings itemSettings;
+ itemSettings.highlight = false;
+
+ QListIterator<CSwordKey*> it(list);
+ while (it.hasNext() && !progressWasCancelled()) {
+ CSwordKey* k = it.next();
+ tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) );
+ incProgress();
+ };
+
+ const QString text = render->renderKeyTree(tree);
+
+ if (!progressWasCancelled()) {
+ CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ closeProgressDialog();
+ return true;
+ }
+ return false;
}
bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool addText) {
- if (!key) {
- return false;
- }
- if (!key->module()) {
- return false;
- }
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- QString text;
- QString startKey;
- QString stopKey;
-
- QList<CSwordModuleInfo*> modules;
- modules.append(key->module());
-
- CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
- if (vk && vk->isBoundSet()) {
- text = render->renderKeyRange(
- QString::fromUtf8(vk->LowerBound()),
- QString::fromUtf8(vk->UpperBound()),
- modules
- );
- }
- else { //no range supported
- text = render->renderSingleKey(key->key(), modules);
- }
-
- QApplication::clipboard()->setText(text);
- return true;
+ if (!key) {
+ return false;
+ }
+ if (!key->module()) {
+ return false;
+ }
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ QString text;
+ QString startKey;
+ QString stopKey;
+
+ QList<CSwordModuleInfo*> modules;
+ modules.append(key->module());
+
+ CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
+ if (vk && vk->isBoundSet()) {
+ text = render->renderKeyRange(
+ QString::fromUtf8(vk->LowerBound()),
+ QString::fromUtf8(vk->UpperBound()),
+ modules
+ );
+ }
+ else { //no range supported
+ text = render->renderSingleKey(key->key(), modules);
+ }
+
+ QApplication::clipboard()->setText(text);
+ return true;
}
bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) {
- if (!list->Count())
- return false;
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- CTextRendering::KeyTree tree;
- CTextRendering::KeyTreeItem::Settings itemSettings;
- itemSettings.highlight = false;
-
- *list = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
-
- (*list)++;
- }
-
- const QString text = render->renderKeyTree(tree);
- QApplication::clipboard()->setText(text);
- return true;
+ if (!list->Count())
+ return false;
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ CTextRendering::KeyTree tree;
+ CTextRendering::KeyTreeItem::Settings itemSettings;
+ itemSettings.highlight = false;
+
+ *list = sword::TOP;
+ while (!list->Error() && !progressWasCancelled()) {
+ tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
+
+ (*list)++;
+ }
+
+ const QString text = render->renderKeyTree(tree);
+ QApplication::clipboard()->setText(text);
+ return true;
}
bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) {
- if (!list.count())
- return false;
-
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
- (format == HTML)
- ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
- : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
- );
-
- CTextRendering::KeyTree tree;
-
- CTextRendering::KeyTreeItem::Settings itemSettings;
- itemSettings.highlight = false;
-
- QListIterator<CSwordKey*> it(list);
- while (it.hasNext() && !progressWasCancelled()){
- CSwordKey* k = it.next();
- tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) );
- incProgress();
- };
-
- const QString text = render->renderKeyTree(tree);
- QApplication::clipboard()->setText(text);
- if (!progressWasCancelled()){
- closeProgressDialog();
- }
- return true;
+ if (!list.count())
+ return false;
+
+ CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CHTMLExportRendering::Settings settings(addText);
+ boost::scoped_ptr<CTextRendering> render (
+ (format == HTML)
+ ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
+ : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
+ );
+
+ CTextRendering::KeyTree tree;
+
+ CTextRendering::KeyTreeItem::Settings itemSettings;
+ itemSettings.highlight = false;
+
+ QListIterator<CSwordKey*> it(list);
+ while (it.hasNext() && !progressWasCancelled()) {
+ CSwordKey* k = it.next();
+ tree.append( new CTextRendering::KeyTreeItem(k->key(), k->module(), itemSettings) );
+ incProgress();
+ };
+
+ const QString text = render->renderKeyTree(tree);
+ QApplication::clipboard()->setText(text);
+ if (!progressWasCancelled()) {
+ closeProgressDialog();
+ }
+ return true;
}
bool CExportManager::printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- CPrinter::KeyTreeItem::Settings settings;
- CPrinter::KeyTree tree;
-
- QString startKey, stopKey;
- setProgressRange(list->Count());
-
- (*list) = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(list);
- if (vk) {
- startKey = QString::fromUtf8((const char*)(vk->LowerBound()) );
- stopKey = QString::fromUtf8((const char*)(vk->UpperBound()) );
- tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
- }
- else {
- startKey = QString::fromUtf8((const char*)*list);
- tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
- }
-
- (*list)++;
- incProgress();
- }
-
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
-
- if (!progressWasCancelled()) {
- printer->printKeyTree(tree);
- closeProgressDialog();
- return true;
- }
-
- return false;
+ CPrinter::KeyTreeItem::Settings settings;
+ CPrinter::KeyTree tree;
+
+ QString startKey, stopKey;
+ setProgressRange(list->Count());
+
+ (*list) = sword::TOP;
+ while (!list->Error() && !progressWasCancelled()) {
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(list);
+ if (vk) {
+ startKey = QString::fromUtf8((const char*)(vk->LowerBound()) );
+ stopKey = QString::fromUtf8((const char*)(vk->UpperBound()) );
+ tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
+ }
+ else {
+ startKey = QString::fromUtf8((const char*) * list);
+ tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
+ }
+
+ (*list)++;
+ incProgress();
+ }
+
+ boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+
+ if (!progressWasCancelled()) {
+ printer->printKeyTree(tree);
+ closeProgressDialog();
+ return true;
+ }
+
+ return false;
}
bool CExportManager::printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) {
- CPrinter::KeyTreeItem::Settings settings;
- settings.keyRenderingFace =
- displayOptions.verseNumbers
- ? CPrinter::KeyTreeItem::Settings::SimpleKey
- : CPrinter::KeyTreeItem::Settings::NoKey;
-
- CPrinter::KeyTree tree;
- if (startKey != stopKey) {
- tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
- }
- else {
- tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
- }
-
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
- printer->printKeyTree(tree);
- return true;
+ CPrinter::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace =
+ displayOptions.verseNumbers
+ ? CPrinter::KeyTreeItem::Settings::SimpleKey
+ : CPrinter::KeyTreeItem::Settings::NoKey;
+
+ CPrinter::KeyTree tree;
+ if (startKey != stopKey) {
+ tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
+ }
+ else {
+ tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
+ }
+
+ boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ printer->printKeyTree(tree);
+ return true;
}
bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- CPrinter::KeyTreeItem::Settings settings;
- settings.keyRenderingFace =
- displayOptions.verseNumbers
- ? CPrinter::KeyTreeItem::Settings::SimpleKey
- : CPrinter::KeyTreeItem::Settings::NoKey;
-
- CPrinter::KeyTree tree;
- tree.append( new CPrinter::KeyTreeItem(key->key(), key->module(), settings) );
-
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
- printer->printKeyTree(tree);
- return true;
+ CPrinter::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace =
+ displayOptions.verseNumbers
+ ? CPrinter::KeyTreeItem::Settings::SimpleKey
+ : CPrinter::KeyTreeItem::Settings::NoKey;
+
+ CPrinter::KeyTree tree;
+ tree.append( new CPrinter::KeyTreeItem(key->key(), key->module(), settings) );
+
+ boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ printer->printKeyTree(tree);
+ return true;
}
/** Prints a key using the hyperlink created by CReferenceManager. */
bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
-
- CReferenceManager::decodeHyperlink(hyperlink, moduleName, keyName, type);
- if (moduleName.isEmpty()) {
- moduleName = CReferenceManager::preferredModule(type);
- }
-
- CPrinter::KeyTree tree;
- CPrinter::KeyTreeItem::Settings settings;
- settings.keyRenderingFace =
- displayOptions.verseNumbers
- ? CPrinter::KeyTreeItem::Settings::SimpleKey
- : CPrinter::KeyTreeItem::Settings::NoKey;
-
- CSwordModuleInfo* module = backend()->findModuleByName(moduleName);
- Q_ASSERT(module);
-
- if (module) {
- //check if we have a range of entries or a single one
- if ((module->type() == CSwordModuleInfo::Bible) || (module->type() == CSwordModuleInfo::Commentary)) {
- sword::ListKey verses = sword::VerseKey().ParseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
-
- for (int i = 0; i < verses.Count(); ++i) {
- sword::VerseKey* element = dynamic_cast<sword::VerseKey*>(verses.GetElement(i));
- if (element) {
- const QString startKey = QString::fromUtf8(element->LowerBound().getText());
- const QString stopKey = QString::fromUtf8(element->UpperBound().getText());
-
- tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
- }
- else if (verses.GetElement(i)) {
- const QString key = QString::fromUtf8(verses.GetElement(i)->getText());
-
- tree.append( new CPrinter::KeyTreeItem(key, module, settings) );
- }
- }
- }
- else {
- tree.append( new CPrinter::KeyTreeItem(keyName, module, settings) );
- }
- }
-
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
- printer->printKeyTree(tree);
- return true;
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+
+ CReferenceManager::decodeHyperlink(hyperlink, moduleName, keyName, type);
+ if (moduleName.isEmpty()) {
+ moduleName = CReferenceManager::preferredModule(type);
+ }
+
+ CPrinter::KeyTree tree;
+ CPrinter::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace =
+ displayOptions.verseNumbers
+ ? CPrinter::KeyTreeItem::Settings::SimpleKey
+ : CPrinter::KeyTreeItem::Settings::NoKey;
+
+ CSwordModuleInfo* module = backend()->findModuleByName(moduleName);
+ Q_ASSERT(module);
+
+ if (module) {
+ //check if we have a range of entries or a single one
+ if ((module->type() == CSwordModuleInfo::Bible) || (module->type() == CSwordModuleInfo::Commentary)) {
+ sword::ListKey verses = sword::VerseKey().ParseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
+
+ for (int i = 0; i < verses.Count(); ++i) {
+ sword::VerseKey* element = dynamic_cast<sword::VerseKey*>(verses.GetElement(i));
+ if (element) {
+ const QString startKey = QString::fromUtf8(element->LowerBound().getText());
+ const QString stopKey = QString::fromUtf8(element->UpperBound().getText());
+
+ tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
+ }
+ else if (verses.GetElement(i)) {
+ const QString key = QString::fromUtf8(verses.GetElement(i)->getText());
+
+ tree.append( new CPrinter::KeyTreeItem(key, module, settings) );
+ }
+ }
+ }
+ else {
+ tree.append( new CPrinter::KeyTreeItem(keyName, module, settings) );
+ }
+ }
+
+ boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ printer->printKeyTree(tree);
+ return true;
}
-bool CExportManager::printKeyList(const QStringList& list,CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- CPrinter::KeyTreeItem::Settings settings;
- settings.keyRenderingFace =
- displayOptions.verseNumbers
- ? CPrinter::KeyTreeItem::Settings::SimpleKey
- : CPrinter::KeyTreeItem::Settings::NoKey;
+bool CExportManager::printKeyList(const QStringList& list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+ CPrinter::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace =
+ displayOptions.verseNumbers
+ ? CPrinter::KeyTreeItem::Settings::SimpleKey
+ : CPrinter::KeyTreeItem::Settings::NoKey;
- CPrinter::KeyTree tree;
- setProgressRange(list.count());
+ CPrinter::KeyTree tree;
+ setProgressRange(list.count());
- const QStringList::const_iterator end = list.constEnd();
- for (QStringList::const_iterator it = list.constBegin(); (it != end) && !progressWasCancelled(); ++it) {
- tree.append( new CPrinter::KeyTreeItem(*it, module, settings) );
- incProgress();
- }
+ const QStringList::const_iterator end = list.constEnd();
+ for (QStringList::const_iterator it = list.constBegin(); (it != end) && !progressWasCancelled(); ++it) {
+ tree.append( new CPrinter::KeyTreeItem(*it, module, settings) );
+ incProgress();
+ }
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
- if (!progressWasCancelled()) {
- printer->printKeyTree(tree);
- closeProgressDialog();
- return true;
- }
+ if (!progressWasCancelled()) {
+ printer->printKeyTree(tree);
+ closeProgressDialog();
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the string for the filedialogs to show the correct files. */
const QString CExportManager::filterString( const Format format ) {
- switch (format) {
- case HTML:
- return QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
- case Text:
- return QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
- default:
- return QObject::tr("All files") + QString(" (*.*)");
- }
+ switch (format) {
+ case HTML:
+ return QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
+ case Text:
+ return QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
+ default:
+ return QObject::tr("All files") + QString(" (*.*)");
+ }
}
/** Returns a filename to save a file. */
const QString CExportManager::getSaveFileName(const Format format) {
- return QFileDialog::getSaveFileName(0, QObject::tr("Save file"), "", filterString(format), 0);
+ return QFileDialog::getSaveFileName(0, QObject::tr("Save file"), "", filterString(format), 0);
}
/** Returns a string containing the linebreak for the current format. */
const QString CExportManager::lineBreak(const Format format) {
- if (static_cast<bool>(m_displayOptions.lineBreaks))
- return (format == HTML) ? QString::fromLatin1("<br/>\n") : QString::fromLatin1("\n");
+ if (static_cast<bool>(m_displayOptions.lineBreaks))
+ return (format == HTML) ? QString::fromLatin1("<br/>\n") : QString::fromLatin1("\n");
- return QString::null;
+ return QString::null;
}
/** No descriptions */
void CExportManager::setProgressRange( const int items ) {
- if (QProgressDialog* dlg = progressDialog()) {
- dlg->setMaximum(items);
- dlg->setValue(0);
- dlg->setMinimumDuration(0);
- dlg->show();
- // dlg->repaint();
- qApp->processEvents(); //do not lock the GUI!
- }
+ if (QProgressDialog* dlg = progressDialog()) {
+ dlg->setMaximum(items);
+ dlg->setValue(0);
+ dlg->setMinimumDuration(0);
+ dlg->show();
+ // dlg->repaint();
+ qApp->processEvents(); //do not lock the GUI!
+ }
}
/** Creates the progress dialog with the correct settings. */
QProgressDialog* CExportManager::progressDialog() {
- if (!m_showProgress) {
- return 0;
- }
+ if (!m_showProgress) {
+ return 0;
+ }
- if (!m_progressDialog) {
- m_progressDialog = new QProgressDialog(0, Qt::Dialog );
- m_progressDialog->setLabelText(m_progressLabel);
+ if (!m_progressDialog) {
+ m_progressDialog = new QProgressDialog(0, Qt::Dialog );
+ m_progressDialog->setLabelText(m_progressLabel);
- m_progressDialog->setWindowTitle("BibleTime");
- }
+ m_progressDialog->setWindowTitle("BibleTime");
+ }
- return m_progressDialog;
+ return m_progressDialog;
}
/** Increments the progress by one item. */
void CExportManager::incProgress() {
- if (QProgressDialog* dlg = progressDialog()) {
- dlg->setValue( dlg->value() + 1 );
- }
+ if (QProgressDialog* dlg = progressDialog()) {
+ dlg->setValue( dlg->value() + 1 );
+ }
}
/** No descriptions */
bool CExportManager::progressWasCancelled() {
- if (QProgressDialog* dlg = progressDialog()) {
- return dlg->wasCanceled();
- }
+ if (QProgressDialog* dlg = progressDialog()) {
+ return dlg->wasCanceled();
+ }
- return true;
+ return true;
}
/** Closes the progress dialog immediatly. */
void CExportManager::closeProgressDialog() {
- if (QProgressDialog* dlg = progressDialog()) {
- dlg->close();
- dlg->reset();
- }
+ if (QProgressDialog* dlg = progressDialog()) {
+ dlg->close();
+ dlg->reset();
+ }
- qApp->processEvents(); //do not lock the GUI!
+ qApp->processEvents(); //do not lock the GUI!
}
diff --git a/src/frontend/cexportmanager.h b/src/frontend/cexportmanager.h
index 210bb2b..013cd88 100644
--- a/src/frontend/cexportmanager.h
+++ b/src/frontend/cexportmanager.h
@@ -26,70 +26,70 @@ class QProgressDialog;
* @author The BibleTime team
*/
class CExportManager : CPointers {
-public:
- /** The format the export actions should have
- */
- enum Format {
- HTML,
- Text
- };
+ public:
+ /** The format the export actions should have
+ */
+ enum Format {
+ HTML,
+ Text
+ };
- CExportManager(const QString& caption, const bool showProgress = true, const QString& progressLabel = QString::null, const CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults(), const CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults());
+ CExportManager(const QString& caption, const bool showProgress = true, const QString& progressLabel = QString::null, const CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults(), const CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults());
- bool saveKey(CSwordKey* key, const Format format, const bool addText);
- bool saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
- bool saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
+ bool saveKey(CSwordKey* key, const Format format, const bool addText);
+ bool saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
+ bool saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
- bool copyKey(CSwordKey* key, const Format format, const bool addText);
- bool copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
- bool copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
+ bool copyKey(CSwordKey* key, const Format format, const bool addText);
+ bool copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
+ bool copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
- bool printKey(CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
- bool printByHyperlink(const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKeyList(const QStringList& list,CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ bool printKey(CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ bool printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
+ bool printByHyperlink(const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ bool printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ bool printKeyList(const QStringList& list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
-protected: // Protected methods
- /**
- * Returns the string for the filedialogs to show the correct files.
- */
- const QString filterString( const Format format );
- /**
- * Returns a filename to save a file.
- */
- const QString getSaveFileName(const Format format);
- /**
- * Returns a string containing the linebreak for the current format.
- */
- const QString lineBreak( const Format format );
+ protected: // Protected methods
+ /**
+ * Returns the string for the filedialogs to show the correct files.
+ */
+ const QString filterString( const Format format );
+ /**
+ * Returns a filename to save a file.
+ */
+ const QString getSaveFileName(const Format format);
+ /**
+ * Returns a string containing the linebreak for the current format.
+ */
+ const QString lineBreak( const Format format );
-private:
- QString m_caption;
- QString m_progressLabel;
- bool m_showProgress;
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
+ private:
+ QString m_caption;
+ QString m_progressLabel;
+ bool m_showProgress;
+ CSwordBackend::FilterOptions m_filterOptions;
+ CSwordBackend::DisplayOptions m_displayOptions;
- QProgressDialog* m_progressDialog;
+ QProgressDialog* m_progressDialog;
- /**
- * Creates the progress dialog with the correct settings.
- */
- QProgressDialog* progressDialog();
- /**
- * Returns the CSS string used in HTML pages.
- */
- void setProgressRange( const int item );
- /**
- * Increments the progress by one item.
- */
- inline void incProgress();
- bool progressWasCancelled();
- /**
- * Closes the progress dialog immediately.
- */
- void closeProgressDialog();
+ /**
+ * Creates the progress dialog with the correct settings.
+ */
+ QProgressDialog* progressDialog();
+ /**
+ * Returns the CSS string used in HTML pages.
+ */
+ void setProgressRange( const int item );
+ /**
+ * Increments the progress by one item.
+ */
+ inline void incProgress();
+ bool progressWasCancelled();
+ /**
+ * Closes the progress dialog immediately.
+ */
+ void closeProgressDialog();
};
#endif
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index ff93287..e9c2811 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -41,27 +41,26 @@ using namespace sword;
namespace InfoDisplay {
-CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent)
-{
- QVBoxLayout* layout = new QVBoxLayout(this);
+CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
+ QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(2, 2, 2, 2); // Leave small border
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- m_htmlPart = CDisplay::createReadInstance(0, this);
- m_htmlPart->setMouseTracking(false); //we don't want strong/lemma/note mouse infos
- m_htmlPart->view()->setAcceptDrops(false);
+ m_htmlPart = CDisplay::createReadInstance(0, this);
+ m_htmlPart->setMouseTracking(false); //we don't want strong/lemma/note mouse infos
+ m_htmlPart->view()->setAcceptDrops(false);
- m_copyAction = new QAction(tr("Copy"), this);
- m_copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
- QObject::connect(m_copyAction, SIGNAL(triggered()), m_htmlPart->connectionsProxy(), SLOT(copySelection()) );
+ m_copyAction = new QAction(tr("Copy"), this);
+ m_copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
+ QObject::connect(m_copyAction, SIGNAL(triggered()), m_htmlPart->connectionsProxy(), SLOT(copySelection()) );
- connect(
- m_htmlPart->connectionsProxy(),
- SIGNAL(referenceClicked(const QString&, const QString&)),
- SLOT(lookupInfo(const QString&, const QString&))
- );
+ connect(
+ m_htmlPart->connectionsProxy(),
+ SIGNAL(referenceClicked(const QString&, const QString&)),
+ SLOT(lookupInfo(const QString&, const QString&))
+ );
- layout->addWidget(m_htmlPart->view());
+ layout->addWidget(m_htmlPart->view());
CDisplayTemplateMgr *mgr(CPointers::displayTemplateManager());
CDisplayTemplateMgr::Settings settings;
@@ -76,411 +75,421 @@ CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent)
QString content(mgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle),
divText.arg(initialMagText),
settings)
- );
+ );
m_htmlPart->setText(content);
}
CInfoDisplay::~CInfoDisplay() {
- delete m_copyAction;
+ delete m_copyAction;
}
void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) {
- qDebug("CInfoDisplay::lookup");
- qDebug() << mod_name << key_text;
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName(mod_name);
- Q_ASSERT(m);
- if (!m)
- return;
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(m) );
- key->key( key_text );
-
- CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
- CDisplayTemplateMgr::Settings settings;
- settings.pageCSS_ID = "infodisplay";
+ qDebug("CInfoDisplay::lookup");
+ qDebug() << mod_name << key_text;
+ CSwordModuleInfo* m = CPointers::backend()->findModuleByName(mod_name);
+ Q_ASSERT(m);
+ if (!m)
+ return;
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(m) );
+ key->key( key_text );
+
+ CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr::Settings settings;
+ settings.pageCSS_ID = "infodisplay";
// lookup text and wrap in a "div" with language set to module language
QString lang = m->language()->abbrev();
QString renderedText = key->renderedText();
QString divText = "<div class=\"infodisplay\" lang=\"";
- divText.append(lang);
- divText.append("\">");
- divText.append(renderedText);
- divText.append("</div>");
+ divText.append(lang);
+ divText.append("\">");
+ divText.append(renderedText);
+ divText.append("</div>");
- QString content = mgr->fillTemplate(CBTConfig::get
- (CBTConfig::displayStyle), divText, settings);
+ QString content = mgr->fillTemplate(CBTConfig::get
+ (CBTConfig::displayStyle), divText, settings);
- m_htmlPart->setText(content);
+ m_htmlPart->setText(content);
}
void CInfoDisplay::setInfo(const InfoType type, const QString& data) {
- ListInfoData list;
- list.append( qMakePair(type, data) );
+ ListInfoData list;
+ list.append( qMakePair(type, data) );
- setInfo(list);
+ setInfo(list);
}
void CInfoDisplay::setInfo(const ListInfoData& list) {
- //if the widget is hidden it would be inefficient to render and display the data
- if (!isVisible()) {
- return;
- }
-
- if (list.count() == 0) {
- m_htmlPart->setText("<html></html>");
- return;
- }
-
- QString text;
-
- ListInfoData::const_iterator end = list.end();
- for (ListInfoData::const_iterator it = list.begin(); it != end; ++it) {
- switch ( (*it).first ) {
- case Lemma:
- text.append( decodeStrongs( (*it).second ) );
- continue;
- case Morph:
- text.append( decodeMorph( (*it).second ) );
- continue;
- case CrossReference:
- text.append( decodeCrossReference( (*it).second ) );
- continue;
- case Footnote:
- text.append( decodeFootnote( (*it).second ) );
- continue;
- case WordTranslation:
- text.append( getWordTranslation( (*it).second ) );
- continue;
- case WordGloss:
- //text.append( getWordTranslation( (*it).second ) );
- continue;
- case Abbreviation:
- text.append( decodeAbbreviation( (*it).second ) );
- continue;
- case Text:
- text.append( (*it).second );
- continue;
- default:
- continue;
- };
- }
-
- CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
- CDisplayTemplateMgr::Settings settings;
- settings.pageCSS_ID = "infodisplay";
- // settings.langAbbrev = "";
- QString content = mgr->fillTemplate(CBTConfig::get
- (CBTConfig::displayStyle), text, settings);
-
- // qWarning("setting text:\n%s", content.latin1());
-
- m_htmlPart->setText(content);
+ //if the widget is hidden it would be inefficient to render and display the data
+ if (!isVisible()) {
+ return;
+ }
+
+ if (list.count() == 0) {
+ m_htmlPart->setText("<html></html>");
+ return;
+ }
+
+ QString text;
+
+ ListInfoData::const_iterator end = list.end();
+ for (ListInfoData::const_iterator it = list.begin(); it != end; ++it) {
+ switch ( (*it).first ) {
+ case Lemma:
+ text.append( decodeStrongs( (*it).second ) );
+ continue;
+ case Morph:
+ text.append( decodeMorph( (*it).second ) );
+ continue;
+ case CrossReference:
+ text.append( decodeCrossReference( (*it).second ) );
+ continue;
+ case Footnote:
+ text.append( decodeFootnote( (*it).second ) );
+ continue;
+ case WordTranslation:
+ text.append( getWordTranslation( (*it).second ) );
+ continue;
+ case WordGloss:
+ //text.append( getWordTranslation( (*it).second ) );
+ continue;
+ case Abbreviation:
+ text.append( decodeAbbreviation( (*it).second ) );
+ continue;
+ case Text:
+ text.append( (*it).second );
+ continue;
+ default:
+ continue;
+ };
+ }
+
+ CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr::Settings settings;
+ settings.pageCSS_ID = "infodisplay";
+ // settings.langAbbrev = "";
+ QString content = mgr->fillTemplate(CBTConfig::get
+ (CBTConfig::displayStyle), text, settings);
+
+ // qWarning("setting text:\n%s", content.latin1());
+
+ m_htmlPart->setText(content);
}
const QString CInfoDisplay::decodeAbbreviation( const QString& data ) {
- // QStringList strongs = QStringList::split("|", data);
- QString ret;
- QString text = data;
+ // QStringList strongs = QStringList::split("|", data);
+ QString ret;
+ QString text = data;
- ret.append(
- QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
- .arg(tr("Abbreviation"))
- .arg("text")
- .arg(text));
+ ret.append(
+ QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
+ .arg(tr("Abbreviation"))
+ .arg("text")
+ .arg(text));
- return ret;
+ return ret;
}
const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
- Q_ASSERT(!data.isEmpty());
- if (data.isEmpty()) {
- return QString("<div class=\"crossrefinfo\"><h3>%1</h3></div>")
- .arg(tr("Cross references"));
- }
-
- // qWarning("setting crossref %s", data.latin1());
-
- CSwordBackend::DisplayOptions dispOpts;
- dispOpts.lineBreaks = false;
- dispOpts.verseNumbers = true;
-
- CSwordBackend::FilterOptions filterOpts;
- filterOpts.headings = false;
- filterOpts.strongNumbers = false;
- filterOpts.morphTags = false;
- filterOpts.lemmas = false;
- filterOpts.footnotes = false;
- filterOpts.scriptureReferences = false;
-
- CrossRefRendering renderer(dispOpts, filterOpts);
- CTextRendering::KeyTree tree;
-
- // const bool isBible = true;
- CSwordModuleInfo* module = CBTConfig::get
- (CBTConfig::standardBible);
-
- //a prefixed module gives the module to look into
- QRegExp re("^[^ ]+:");
- // re.setMinimal(true);
- int pos = re.indexIn(data);
- if (pos != -1) {
- pos += re.matchedLength()-1;
- }
-
- if (pos > 0) {
- const QString moduleName = data.left(pos);
- // qWarning("found module %s", moduleName.latin1());
- module = CPointers::backend()->findModuleByName(moduleName);
- if (!module) {
- module = CBTConfig::get
- (CBTConfig::standardBible);
- }
- // Q_ASSERT(module);
- }
-
- //Q_ASSERT(module); //why? the existense of the module is tested later
- CTextRendering::KeyTreeItem::Settings settings (
- false,
- CTextRendering::KeyTreeItem::Settings::CompleteShort
- );
-
- if (module && (module->type() == CSwordModuleInfo::Bible)) {
- VerseKey vk;
- sword::ListKey refs = vk.ParseVerseList((const char*)data.mid((pos == -1) ? 0 : pos+1).toUtf8(), "Gen 1:1", true);
-
- for (int i = 0; i < refs.Count(); ++i) {
- SWKey* key = refs.getElement(i);
- Q_ASSERT(key);
- VerseKey* vk = dynamic_cast<VerseKey*>(key);
-
- CTextRendering::KeyTreeItem* itm = (CTextRendering::KeyTreeItem*)0; //explicit conversion for MS VS
- if (vk && vk->isBoundSet()) { //render a range of keys
- itm = new CTextRendering::KeyTreeItem(
- QString::fromUtf8(vk->LowerBound().getText()),
- QString::fromUtf8(vk->UpperBound().getText()),
- module,
- settings
- );
- }
- else {
- itm = new CTextRendering::KeyTreeItem(
- QString::fromUtf8(key->getText()),
- QString::fromUtf8(key->getText()),
- module,
- settings
- );
- }
-
- Q_ASSERT(itm);
-
- tree.append( itm );
- }
- }
- else if (module) {
- CTextRendering::KeyTreeItem* itm = new CTextRendering::KeyTreeItem(
- data.mid((pos == -1) ? 0 : pos+1),
- module,
- settings
- );
- tree.append( itm );
- }
-
- // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
- //spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
+ Q_ASSERT(!data.isEmpty());
+ if (data.isEmpty()) {
+ return QString("<div class=\"crossrefinfo\"><h3>%1</h3></div>")
+ .arg(tr("Cross references"));
+ }
+
+ // qWarning("setting crossref %s", data.latin1());
+
+ CSwordBackend::DisplayOptions dispOpts;
+ dispOpts.lineBreaks = false;
+ dispOpts.verseNumbers = true;
+
+ CSwordBackend::FilterOptions filterOpts;
+ filterOpts.headings = false;
+ filterOpts.strongNumbers = false;
+ filterOpts.morphTags = false;
+ filterOpts.lemmas = false;
+ filterOpts.footnotes = false;
+ filterOpts.scriptureReferences = false;
+
+ CrossRefRendering renderer(dispOpts, filterOpts);
+ CTextRendering::KeyTree tree;
+
+ // const bool isBible = true;
+ CSwordModuleInfo* module = CBTConfig::get(CBTConfig::standardBible);
+
+ //a prefixed module gives the module to look into
+ QRegExp re("^[^ ]+:");
+ // re.setMinimal(true);
+ int pos = re.indexIn(data);
+ if (pos != -1) {
+ pos += re.matchedLength() - 1;
+ }
+
+ if (pos > 0) {
+ const QString moduleName = data.left(pos);
+ // qWarning("found module %s", moduleName.latin1());
+ module = CPointers::backend()->findModuleByName(moduleName);
+ if (!module) {
+ module = CBTConfig::get(CBTConfig::standardBible);
+ }
+ // Q_ASSERT(module);
+ }
+
+ //Q_ASSERT(module); //why? the existense of the module is tested later
+ CTextRendering::KeyTreeItem::Settings settings (
+ false,
+ CTextRendering::KeyTreeItem::Settings::CompleteShort
+ );
+
+ if (module && (module->type() == CSwordModuleInfo::Bible)) {
+ VerseKey vk;
+ sword::ListKey refs = vk.ParseVerseList((const char*)data.mid((pos == -1) ? 0 : pos + 1).toUtf8(), "Gen 1:1", true);
+
+ for (int i = 0; i < refs.Count(); ++i) {
+ SWKey* key = refs.getElement(i);
+ Q_ASSERT(key);
+ VerseKey* vk = dynamic_cast<VerseKey*>(key);
+
+ CTextRendering::KeyTreeItem* itm = (CTextRendering::KeyTreeItem*)0; //explicit conversion for MS VS
+ if (vk && vk->isBoundSet()) { //render a range of keys
+ itm = new CTextRendering::KeyTreeItem(
+ QString::fromUtf8(vk->LowerBound().getText()),
+ QString::fromUtf8(vk->UpperBound().getText()),
+ module,
+ settings
+ );
+ }
+ else {
+ itm = new CTextRendering::KeyTreeItem(
+ QString::fromUtf8(key->getText()),
+ QString::fromUtf8(key->getText()),
+ module,
+ settings
+ );
+ }
+
+ Q_ASSERT(itm);
+
+ tree.append( itm );
+ }
+ }
+ else if (module) {
+ CTextRendering::KeyTreeItem* itm = new CTextRendering::KeyTreeItem(
+ data.mid((pos == -1) ? 0 : pos + 1),
+ module,
+ settings
+ );
+ tree.append( itm );
+ }
+
+ // 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)
lang = module->language()->abbrev();
- 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));
+ 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));
}
/*!
\fn CInfoDisplay::decodeFootnote( const QString& data )
*/
const QString CInfoDisplay::decodeFootnote( const QString& data ) {
- QStringList list = data.split("/");
- Q_ASSERT(list.count() >= 3);
- if (!list.count()) {
- return QString::null;
- }
-
- const QString modulename = list.first();
- const QString swordFootnote = list.last();
-
- // remove the first and the last and then rejoin it to get a key
- list.pop_back(); list.pop_front();
- const QString keyname = list.join("/");
-
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(modulename);
- if (!module) {
- return QString::null;
- }
-
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key(keyname);
- key->renderedText(); //force entryAttributes
-
- const char* note =
- module->module()->getEntryAttributes()
- ["Footnote"][swordFootnote.toLatin1().data()]["body"].c_str();
-
- QString text = module->isUnicode() ? QString::fromUtf8(note) : QString(note);
- text = QString::fromUtf8(module->module()->RenderText(
- module->isUnicode()
- ? (const char*)text.toUtf8()
- : (const char*)text.toLatin1()
- ));
-
- return QString("<div class=\"footnoteinfo\" lang=\"%1\"><h3>%2</h3><p>%3</p></div>")
- .arg(module->language()->abbrev())
- .arg(tr("Footnote"))
- .arg(text);
+ QStringList list = data.split("/");
+ Q_ASSERT(list.count() >= 3);
+ if (!list.count()) {
+ return QString::null;
+ }
+
+ CSwordBackend::FilterOptions filterOpts;
+ filterOpts.headings = false;
+ filterOpts.strongNumbers = false;
+ filterOpts.morphTags = false;
+ filterOpts.lemmas = false;
+ filterOpts.footnotes = true;
+ // turn scripRefs off, so that they do not show up as footnotes in the OSIS filter's EntryAttributes
+ filterOpts.scriptureReferences = false;
+
+ CPointers::backend()->setFilterOptions(filterOpts);
+
+ const QString modulename = list.first();
+ const QString swordFootnote = list.last();
+
+ // remove the first and the last and then rejoin it to get a key
+ list.pop_back();
+ list.pop_front();
+ const QString keyname = list.join("/");
+
+ CSwordModuleInfo* module = CPointers::backend()->findModuleByName(modulename);
+ if (!module) {
+ return QString::null;
+ }
+
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key(keyname);
+ key->renderedText(CSwordKey::ProcessEntryAttributesOnly); //force entryAttributes
+
+ const char* note =
+ module->module()->getEntryAttributes()
+ ["Footnote"][swordFootnote.toLatin1().data()]["body"].c_str();
+
+ QString text = module->isUnicode() ? QString::fromUtf8(note) : QString(note);
+ text = QString::fromUtf8(module->module()->RenderText(
+ module->isUnicode()
+ ? (const char*)text.toUtf8()
+ : (const char*)text.toLatin1()
+ ));
+
+ return QString("<div class=\"footnoteinfo\" lang=\"%1\"><h3>%2</h3><p>%3</p></div>")
+ .arg(module->language()->abbrev())
+ .arg(tr("Footnote"))
+ .arg(text);
}
const QString CInfoDisplay::decodeStrongs( const QString& data ) {
- QStringList strongs = data.split("|");
- QString ret;
-
- QStringList::const_iterator end = strongs.end();
- for (QStringList::const_iterator it = strongs.begin(); it != end; ++it) {
- CSwordModuleInfo* const module = CBTConfig::get
- (
- ((*it).left(1) == QString("H")) ?
- CBTConfig::standardHebrewStrongsLexicon :
- CBTConfig::standardGreekStrongsLexicon
- );
-
- QString text;
- if (module) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( (*it).mid(1) ); //skip H or G (language sign), will have to change later if we have better modules
- text = key->renderedText();
- }
- //if the module could not be found just display an empty lemma info
+ QStringList strongs = data.split("|");
+ QString ret;
+
+ QStringList::const_iterator end = strongs.end();
+ for (QStringList::const_iterator it = strongs.begin(); it != end; ++it) {
+ CSwordModuleInfo* const module = CBTConfig::get
+ (
+ ((*it).left(1) == QString("H")) ?
+ CBTConfig::standardHebrewStrongsLexicon :
+ CBTConfig::standardGreekStrongsLexicon
+ );
+
+ QString text;
+ if (module) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( (*it).mid(1) ); //skip H or G (language sign), will have to change later if we have better modules
+ text = key->renderedText();
+ }
+ //if the module could not be found just display an empty lemma info
QString lang = "en"; // default english
- if(module)
+ if (module)
lang = module->language()->abbrev();
- ret.append(
- QString("<div class=\"strongsinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ ret.append(
+ QString("<div class=\"strongsinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(lang)
- .arg(tr("Strongs"))
- .arg(*it)
- .arg(text)
- );
- }
+ .arg(tr("Strongs"))
+ .arg(*it)
+ .arg(text)
+ );
+ }
- return ret;
+ return ret;
}
const QString CInfoDisplay::decodeMorph( const QString& data ) {
- QStringList morphs = data.split("|");
- QString ret;
-
- foreach(QString morph, morphs) {
- //qDebug() << "CInfoDisplay::decodeMorph, morph: " << morph;
- CSwordModuleInfo* module = 0;
- bool skipFirstChar = false;
- QString value = "";
- QString valueClass = "";
-
- int valStart = morph.indexOf(':');
- if (valStart > -1) {
- valueClass = morph.mid(0, valStart);
- //qDebug() << "valueClass: " << valueClass;
- module = CPointers::backend()->findModuleByName( valueClass );
- }
- value = morph.mid(valStart+1); //works for prepended module and without (-1 +1 == 0).
-
- // if we don't have a class assigned or desired one isn't installed...
- if (!module) {
- // Morphs usually don't have [GH] prepended, but some old OLB
- // codes do. We should check if we're digit after first char
- // to better guess this.
- if (value.size() > 1 && value.at(1).isDigit()) {
- switch (value.at(0).toLatin1()) {
- case 'G':
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
- skipFirstChar = true;
- break;
- case 'H':
- module = CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon);
- skipFirstChar = true;
- break;
- default:
- skipFirstChar = false;
- //TODO: we can't tell here if it's a greek or hebrew moprh code, that's a problem we have to solve
- // module = CBTConfig::get(CBTConfig::standardGreekMorphLexicon);
- break;
- }
- }
- //if it is still not set use the default
- if (!module) {
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
- }
- }
-
- QString text;
- //Q_ASSERT(module);
- if (module) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
-
- //skip H or G (language sign) if we have to skip it
- const bool isOk = key->key( skipFirstChar ? value.mid(1) : value );
- //Q_ASSERT(isOk);
- if (!isOk) { //try to use the other morph lexicon, because this one failed with the current morph code
- key->module(CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon));
- key->key( skipFirstChar ? value.mid(1) : value );
- }
-
- text = key->renderedText();
- }
-
- //if the module wasn't found just display an empty morph info
+ QStringList morphs = data.split("|");
+ QString ret;
+
+ foreach(QString morph, morphs) {
+ //qDebug() << "CInfoDisplay::decodeMorph, morph: " << morph;
+ CSwordModuleInfo* module = 0;
+ bool skipFirstChar = false;
+ QString value = "";
+ QString valueClass = "";
+
+ int valStart = morph.indexOf(':');
+ if (valStart > -1) {
+ valueClass = morph.mid(0, valStart);
+ //qDebug() << "valueClass: " << valueClass;
+ module = CPointers::backend()->findModuleByName( valueClass );
+ }
+ value = morph.mid(valStart + 1); //works for prepended module and without (-1 +1 == 0).
+
+ // if we don't have a class assigned or desired one isn't installed...
+ if (!module) {
+ // Morphs usually don't have [GH] prepended, but some old OLB
+ // codes do. We should check if we're digit after first char
+ // to better guess this.
+ if (value.size() > 1 && value.at(1).isDigit()) {
+ switch (value.at(0).toLatin1()) {
+ case 'G':
+ module = CBTConfig::get
+ (CBTConfig::standardGreekMorphLexicon);
+ skipFirstChar = true;
+ break;
+ case 'H':
+ module = CBTConfig::get
+ (CBTConfig::standardHebrewMorphLexicon);
+ skipFirstChar = true;
+ break;
+ default:
+ skipFirstChar = false;
+ //TODO: we can't tell here if it's a greek or hebrew moprh code, that's a problem we have to solve
+ // module = CBTConfig::get(CBTConfig::standardGreekMorphLexicon);
+ break;
+ }
+ }
+ //if it is still not set use the default
+ if (!module) {
+ module = CBTConfig::get
+ (CBTConfig::standardGreekMorphLexicon);
+ }
+ }
+
+ QString text;
+ //Q_ASSERT(module);
+ if (module) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+
+ //skip H or G (language sign) if we have to skip it
+ const bool isOk = key->key( skipFirstChar ? value.mid(1) : value );
+ //Q_ASSERT(isOk);
+ if (!isOk) { //try to use the other morph lexicon, because this one failed with the current morph code
+ key->module(CBTConfig::get
+ (CBTConfig::standardHebrewMorphLexicon));
+ key->key( skipFirstChar ? value.mid(1) : value );
+ }
+
+ text = key->renderedText();
+ }
+
+ //if the module wasn't found just display an empty morph info
QString lang = "en"; // default to english
if (module)
lang = module->language()->abbrev();
- ret.append( QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ ret.append( QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(lang)
- .arg(tr("Morphology"))
- .arg(value)
- .arg(text)
- );
- }
+ .arg(tr("Morphology"))
+ .arg(value)
+ .arg(text)
+ );
+ }
- return ret;
+ return ret;
}
const QString CInfoDisplay::getWordTranslation( const QString& data ) {
- CSwordModuleInfo* const module = CBTConfig::get
- (CBTConfig::standardLexicon);
- if (!module) {
- return QString::null;
- }
-
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( data );
- if (key->key().toUpper() != data.toUpper()) { //key not present in the lexicon
- return QString::null;
- }
-
- QString ret = QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
- .arg(module->language()->abbrev())
- .arg(tr("Word lookup"))
- .arg(data)
- .arg(key->renderedText());
-
- return ret;
+ CSwordModuleInfo* const module = CBTConfig::get
+ (CBTConfig::standardLexicon);
+ if (!module) {
+ return QString::null;
+ }
+
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( data );
+ if (key->key().toUpper() != data.toUpper()) { //key not present in the lexicon
+ return QString::null;
+ }
+
+ QString ret = QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ .arg(module->language()->abbrev())
+ .arg(tr("Word lookup"))
+ .arg(data)
+ .arg(key->renderedText());
+
+ return ret;
}
@@ -488,16 +497,15 @@ const QString CInfoDisplay::getWordTranslation( const QString& data ) {
\fn CInfoDisplay::clearInfo()
*/
void CInfoDisplay::clearInfo() {
- CDisplayTemplateMgr* tmgr = CPointers::displayTemplateManager();
- CDisplayTemplateMgr::Settings settings;
- settings.pageCSS_ID = "infodisplay";
+ CDisplayTemplateMgr* tmgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr::Settings settings;
+ settings.pageCSS_ID = "infodisplay";
- m_htmlPart->setText( tmgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), QString::null, settings) );
+ m_htmlPart->setText( tmgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), QString::null, settings) );
}
-QSize CInfoDisplay::sizeHint() const
-{
- return QSize(100,150);
+QSize CInfoDisplay::sizeHint() const {
+ return QSize(100, 150);
}
} //end of namespace InfoDisplay
diff --git a/src/frontend/cinfodisplay.h b/src/frontend/cinfodisplay.h
index 040667f..18ffa96 100644
--- a/src/frontend/cinfodisplay.h
+++ b/src/frontend/cinfodisplay.h
@@ -26,44 +26,44 @@ class QSize;
namespace InfoDisplay {
class CInfoDisplay : public QWidget {
- Q_OBJECT
-public:
- enum InfoType {
- Abbreviation,
- CrossReference,
- Footnote,
- Lemma,
- Morph,
- WordTranslation,
- WordGloss,
- Text
- };
+ Q_OBJECT
+ public:
+ enum InfoType {
+ Abbreviation,
+ CrossReference,
+ Footnote,
+ Lemma,
+ Morph,
+ WordTranslation,
+ WordGloss,
+ Text
+ };
- typedef QPair<InfoType, QString> InfoData;
- typedef QList<InfoData> ListInfoData;
+ typedef QPair<InfoType, QString> InfoData;
+ typedef QList<InfoData> ListInfoData;
- CInfoDisplay(QWidget *parent = 0);
- virtual ~CInfoDisplay();
+ CInfoDisplay(QWidget *parent = 0);
+ virtual ~CInfoDisplay();
- void setInfo(const InfoType, const QString& data);
- void setInfo(const ListInfoData&);
- void clearInfo();
- QSize sizeHint() const;
+ void setInfo(const InfoType, const QString& data);
+ void setInfo(const ListInfoData&);
+ void clearInfo();
+ QSize sizeHint() const;
-protected:
- const QString decodeAbbreviation( const QString& data );
- const QString decodeCrossReference( const QString& data );
- const QString decodeFootnote( const QString& data );
- const QString decodeStrongs( const QString& data );
- const QString decodeMorph( const QString& data );
- const QString getWordTranslation( const QString& data );
+ protected:
+ const QString decodeAbbreviation( const QString& data );
+ const QString decodeCrossReference( const QString& data );
+ const QString decodeFootnote( const QString& data );
+ const QString decodeStrongs( const QString& data );
+ const QString decodeMorph( const QString& data );
+ const QString getWordTranslation( const QString& data );
-protected slots:
- void lookupInfo(const QString &, const QString &);
+ protected slots:
+ void lookupInfo(const QString &, const QString &);
-private:
- CReadDisplay* m_htmlPart;
- QAction* m_copyAction;
+ private:
+ CReadDisplay* m_htmlPart;
+ QAction* m_copyAction;
};
} //end of InfoDisplay namespace
diff --git a/src/frontend/cinputdialog.cpp b/src/frontend/cinputdialog.cpp
index 59b178d..b44113a 100644
--- a/src/frontend/cinputdialog.cpp
+++ b/src/frontend/cinputdialog.cpp
@@ -27,69 +27,67 @@
CInputDialog::CInputDialog
- (const QString& caption, const QString& description, const QString& text, QWidget *parent, Qt::WindowFlags wflags )
- : QDialog(parent, wflags)
-{
- QVBoxLayout *vboxLayout;
- QLabel *label;
- QHBoxLayout *hboxLayout;
- QPushButton *clearButton;
- QSpacerItem *spacerItem;
- QDialogButtonBox *buttonBox;
-
- setWindowTitle(caption);
-
- resize(400, 300);
- vboxLayout = new QVBoxLayout(this);
- label = new QLabel(description, this);
- vboxLayout->addWidget(label);
-
- m_textEdit = new QTextEdit(this);
- vboxLayout->addWidget(m_textEdit);
- m_textEdit->setWordWrapMode( QTextOption::WordWrap );
- m_textEdit->setText(text);
- if (!text.isEmpty())
- m_textEdit->selectAll();
-
- hboxLayout = new QHBoxLayout();
- clearButton = new QPushButton(this);
- clearButton->setText(tr("Clear"));
- hboxLayout->addWidget(clearButton);
- spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hboxLayout->addItem(spacerItem);
- buttonBox = new QDialogButtonBox(this);
- buttonBox->setOrientation(Qt::Horizontal);
- buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
- hboxLayout->addWidget(buttonBox);
-
- vboxLayout->addLayout(hboxLayout);
-
- QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- QObject::connect(clearButton, SIGNAL(clicked()), m_textEdit, SLOT(clear()));
-
- m_textEdit->setFocus();
+(const QString& caption, const QString& description, const QString& text, QWidget *parent, Qt::WindowFlags wflags )
+ : QDialog(parent, wflags) {
+ QVBoxLayout *vboxLayout;
+ QLabel *label;
+ QHBoxLayout *hboxLayout;
+ QPushButton *clearButton;
+ QSpacerItem *spacerItem;
+ QDialogButtonBox *buttonBox;
+
+ setWindowTitle(caption);
+
+ resize(400, 300);
+ vboxLayout = new QVBoxLayout(this);
+ label = new QLabel(description, this);
+ vboxLayout->addWidget(label);
+
+ m_textEdit = new QTextEdit(this);
+ vboxLayout->addWidget(m_textEdit);
+ m_textEdit->setWordWrapMode( QTextOption::WordWrap );
+ m_textEdit->setText(text);
+ if (!text.isEmpty())
+ m_textEdit->selectAll();
+
+ hboxLayout = new QHBoxLayout();
+ clearButton = new QPushButton(this);
+ clearButton->setText(tr("Clear"));
+ hboxLayout->addWidget(clearButton);
+ spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hboxLayout->addItem(spacerItem);
+ buttonBox = new QDialogButtonBox(this);
+ buttonBox->setOrientation(Qt::Horizontal);
+ buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
+ util::prepareDialogBox(buttonBox);
+ hboxLayout->addWidget(buttonBox);
+
+ vboxLayout->addLayout(hboxLayout);
+
+ QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ QObject::connect(clearButton, SIGNAL(clicked()), m_textEdit, SLOT(clear()));
+
+ m_textEdit->setFocus();
}
/** Returns the text entered at the moment. */
const QString CInputDialog::text() {
- return m_textEdit->toPlainText();
+ return m_textEdit->toPlainText();
}
/** A static function to get some using CInputDialog. */
const QString CInputDialog::getText
- ( const QString& caption, const QString& description, const QString& text, bool* ok, QWidget* parent, Qt::WindowFlags wflags)
-{
- CInputDialog* dlg = new CInputDialog(caption, description, text, parent, wflags);
-
- QString ret = QString::null;
- *ok = (dlg->exec() == QDialog::Accepted)?true:false;
- if (*ok) {
- //qDebug() << "dialog was accepted, return text: " << dlg->text();
- ret = dlg->text();
- }
-
- delete dlg;
- return ret;
+( const QString& caption, const QString& description, const QString& text, bool* ok, QWidget* parent, Qt::WindowFlags wflags) {
+ CInputDialog* dlg = new CInputDialog(caption, description, text, parent, wflags);
+
+ QString ret = QString::null;
+ *ok = (dlg->exec() == QDialog::Accepted) ? true : false;
+ if (*ok) {
+ //qDebug() << "dialog was accepted, return text: " << dlg->text();
+ ret = dlg->text();
+ }
+
+ delete dlg;
+ return ret;
}
diff --git a/src/frontend/cinputdialog.h b/src/frontend/cinputdialog.h
index 7cd30b2..209dc78 100644
--- a/src/frontend/cinputdialog.h
+++ b/src/frontend/cinputdialog.h
@@ -23,21 +23,21 @@ class QWidget;
* @author The BibleTime team
*/
class CInputDialog : public QDialog {
- Q_OBJECT
-public:
- CInputDialog(const QString& caption, const QString& description, const QString& text, QWidget *parent=0, Qt::WindowFlags wflags = Qt::Dialog);
- /**
- * A static function to get some using CInputDialog.
- */
- static const QString getText( const QString& caption, const QString& description, const QString& text = QString::null, bool* ok = 0, QWidget* parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- /**
- * Returns the text entered at the moment.
- */
- const QString text();
- // ~CInputDialog();
-
-private:
- QTextEdit* m_textEdit;
+ Q_OBJECT
+ public:
+ CInputDialog(const QString& caption, const QString& description, const QString& text, QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ /**
+ * A static function to get some using CInputDialog.
+ */
+ static const QString getText( const QString& caption, const QString& description, const QString& text = QString::null, bool* ok = 0, QWidget* parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ /**
+ * Returns the text entered at the moment.
+ */
+ const QString text();
+ // ~CInputDialog();
+
+ private:
+ QTextEdit* m_textEdit;
};
#endif
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index 69f3e7a..91f3eae 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -17,228 +17,223 @@
#include <QDebug>
CMDIArea::CMDIArea(QWidget *parent) : QMdiArea(parent),
- m_mdiArrangementMode(ArrangementModeManual)
-{
- setActivationOrder( CreationOrder ); //keep window order consistent
- connect(this, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(slotClientActivated(QMdiSubWindow*)));
+ m_mdiArrangementMode(ArrangementModeManual) {
+ setActivationOrder( CreationOrder ); //keep window order consistent
+ connect(this, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(slotClientActivated(QMdiSubWindow*)));
}
-QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags)
-{
- QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
- subWindow->installEventFilter(this);
-
- //If we do have a maximized Window, set it to normal so that the new window can be seen
- if (activeSubWindow() && activeSubWindow()->isMaximized()){
- activeSubWindow()->showNormal();
- }
-
- if (m_mdiArrangementMode == ArrangementModeManual)
- {
- subWindow->resize(400, 400); //set the window to be big enough
- subWindow->raise();
- }
- else
- {
- triggerWindowUpdate();
- }
- return subWindow;
+QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
+ QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
+ subWindow->installEventFilter(this);
+
+ //If we do have a maximized Window, set it to normal so that the new window can be seen
+ if (activeSubWindow() && activeSubWindow()->isMaximized()) {
+ activeSubWindow()->showNormal();
+ }
+
+ if (m_mdiArrangementMode == ArrangementModeManual) {
+ subWindow->resize(400, 400); //set the window to be big enough
+ subWindow->raise();
+ }
+ else {
+ triggerWindowUpdate();
+ }
+ return subWindow;
}
void CMDIArea::deleteAll() {
- closeAllSubWindows();
+ closeAllSubWindows();
}
void CMDIArea::setMDIArrangementMode( const MDIArrangementMode newArrangementMode ) {
- m_mdiArrangementMode = newArrangementMode;
- triggerWindowUpdate();
+ m_mdiArrangementMode = newArrangementMode;
+ triggerWindowUpdate();
}
CMDIArea::MDIArrangementMode CMDIArea::getMDIArrangementMode(void) const {
- return m_mdiArrangementMode;
+ return m_mdiArrangementMode;
}
void CMDIArea::myTileVertical() {
- if (!updatesEnabled() || !usableWindowList().count() ) {
- return;
- }
-
- QList<QMdiSubWindow*> windows = usableWindowList();
- if (activeSubWindow() && activeSubWindow()->isMaximized()){
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
- windows.at(0)->showMaximized();
- }
- else {
- setUpdatesEnabled(false);
- QMdiSubWindow* active = activeSubWindow();
- QMdiArea::tileSubWindows();
- if (active) active->setFocus();
- setUpdatesEnabled(true);
- }
- emitWindowCaptionChanged();
+ if (!updatesEnabled() || !usableWindowList().count() ) {
+ return;
+ }
+
+ QList<QMdiSubWindow*> windows = usableWindowList();
+ if (activeSubWindow() && activeSubWindow()->isMaximized()) {
+ if (activeSubWindow()->size() != this->size()) {
+ activeSubWindow()->resize(this->size());
+ }
+ }
+ else if (windows.count() == 1) {
+ windows.at(0)->showMaximized();
+ }
+ else {
+ setUpdatesEnabled(false);
+ QMdiSubWindow* active = activeSubWindow();
+ QMdiArea::tileSubWindows();
+ if (active) active->setFocus();
+ setUpdatesEnabled(true);
+ }
+ emitWindowCaptionChanged();
}
void CMDIArea::myTileHorizontal() {
- if (!updatesEnabled() || !usableWindowList().count() ) {
- return;
- }
-
- QList<QMdiSubWindow*> windows = usableWindowList();
-
- if (activeSubWindow() && activeSubWindow()->isMaximized()){
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
- windows.at(0)->showMaximized();
- }
- else {
- setUpdatesEnabled(false);
-
- QMdiSubWindow* active = activeSubWindow();
-
- const int heightForEach = height() / windows.count();
- unsigned int y = 0;
- foreach (QMdiSubWindow *window, windows) {
- window->showNormal();
-
- const int preferredHeight = window->minimumHeight() + window->baseSize().height();
- const int actHeight = qMax(heightForEach, preferredHeight);
-
- window->setGeometry( 0, y, width(), actHeight );
- y += actHeight;
- }
- active->setFocus();
- setUpdatesEnabled(true);
- }
- emitWindowCaptionChanged();
+ if (!updatesEnabled() || !usableWindowList().count() ) {
+ return;
+ }
+
+ QList<QMdiSubWindow*> windows = usableWindowList();
+
+ if (activeSubWindow() && activeSubWindow()->isMaximized()) {
+ if (activeSubWindow()->size() != this->size()) {
+ activeSubWindow()->resize(this->size());
+ }
+ }
+ else if (windows.count() == 1) {
+ windows.at(0)->showMaximized();
+ }
+ else {
+ setUpdatesEnabled(false);
+
+ QMdiSubWindow* active = activeSubWindow();
+
+ const int heightForEach = height() / windows.count();
+ unsigned int y = 0;
+ foreach (QMdiSubWindow *window, windows) {
+ window->showNormal();
+
+ const int preferredHeight = window->minimumHeight() + window->baseSize().height();
+ const int actHeight = qMax(heightForEach, preferredHeight);
+
+ window->setGeometry( 0, y, width(), actHeight );
+ y += actHeight;
+ }
+ active->setFocus();
+ setUpdatesEnabled(true);
+ }
+ emitWindowCaptionChanged();
}
void CMDIArea::myCascade() {
- if (!updatesEnabled() || !usableWindowList().count() ) {
- return;
- }
-
- QList<QMdiSubWindow*> windows = usableWindowList();
-
- if (activeSubWindow() && activeSubWindow()->isMaximized()){
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
- windows.at(0)->showMaximized();
- }
- else {
- setUpdatesEnabled(false);
-
- QMdiSubWindow* active = activeSubWindow();
-
- const unsigned int offsetX = 40;
- const unsigned int offsetY = 40;
- const unsigned int windowWidth = width() - (windows.count()-1)*offsetX;
- const unsigned int windowHeight = height() - (windows.count()-1)*offsetY;
- unsigned int x = 0;
- unsigned int y = 0;
-
- foreach (QMdiSubWindow* window, windows) {
- if (window == active) { //leave out the active window which should be the top window
- continue;
- }
- window->raise(); //make it the on-top-of-window-stack window to make sure they're in the right order
- window->setGeometry(x, y, windowWidth, windowHeight);
- x += offsetX;
- y += offsetY;
- }
- active->setGeometry(x, y, windowWidth, windowHeight);
- active->raise();
- active->activateWindow();
-
- setUpdatesEnabled(true);
- }
- emitWindowCaptionChanged();
+ if (!updatesEnabled() || !usableWindowList().count() ) {
+ return;
+ }
+
+ QList<QMdiSubWindow*> windows = usableWindowList();
+
+ if (activeSubWindow() && activeSubWindow()->isMaximized()) {
+ if (activeSubWindow()->size() != this->size()) {
+ activeSubWindow()->resize(this->size());
+ }
+ }
+ else if (windows.count() == 1) {
+ windows.at(0)->showMaximized();
+ }
+ else {
+ setUpdatesEnabled(false);
+
+ QMdiSubWindow* active = activeSubWindow();
+
+ const unsigned int offsetX = 40;
+ const unsigned int offsetY = 40;
+ const unsigned int windowWidth = width() - (windows.count() - 1) * offsetX;
+ const unsigned int windowHeight = height() - (windows.count() - 1) * offsetY;
+ unsigned int x = 0;
+ unsigned int y = 0;
+
+ foreach (QMdiSubWindow* window, windows) {
+ if (window == active) { //leave out the active window which should be the top window
+ continue;
+ }
+ window->raise(); //make it the on-top-of-window-stack window to make sure they're in the right order
+ window->setGeometry(x, y, windowWidth, windowHeight);
+ x += offsetX;
+ y += offsetY;
+ }
+ active->setGeometry(x, y, windowWidth, windowHeight);
+ active->raise();
+ active->activateWindow();
+
+ setUpdatesEnabled(true);
+ }
+ emitWindowCaptionChanged();
}
void CMDIArea::emitWindowCaptionChanged() {
- QString appCaption;
- if (activeSubWindow()) {
- appCaption = activeSubWindow()->windowTitle();
- }
- emit sigSetToplevelCaption(appCaption);
+ QString appCaption;
+ if (activeSubWindow()) {
+ appCaption = activeSubWindow()->windowTitle();
+ }
+ emit sigSetToplevelCaption(appCaption);
}
QList<QMdiSubWindow*> CMDIArea::usableWindowList() {
- //Take care: when new windows are added, they will not appear
- //in subWindowList() when their ChildAdded-Event is triggered
- QList<QMdiSubWindow*> ret;
- foreach(QMdiSubWindow* w, subWindowList())
- {
- if (w->isMinimized() || w->isHidden()) { //not usable for us
- continue;
- }
- ret.append( w );
- }
- return ret;
+ //Take care: when new windows are added, they will not appear
+ //in subWindowList() when their ChildAdded-Event is triggered
+ QList<QMdiSubWindow*> ret;
+ foreach(QMdiSubWindow* w, subWindowList()) {
+ if (w->isMinimized() || w->isHidden()) { //not usable for us
+ continue;
+ }
+ ret.append( w );
+ }
+ return ret;
}
void CMDIArea::slotClientActivated(QMdiSubWindow* client) {
- if (!client || !updatesEnabled()) {
- return;
- }
- emit sigSetToplevelCaption( client->windowTitle().trimmed() );
+ if (!client || !updatesEnabled()) {
+ return;
+ }
+ emit sigSetToplevelCaption( client->windowTitle().trimmed() );
}
//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
- if (updatesEnabled()) triggerWindowUpdate();
+ //do not call QMdiArea::resizeEvent(e), this would mess up our layout
+ if (updatesEnabled()) triggerWindowUpdate();
}
//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.
-
- 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();
- }
- return false; //let the event be handled by other filters too
+ 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.
+
+ 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();
+ }
+ return false; //let the event be handled by other filters too
}
void CMDIArea::triggerWindowUpdate() {
- if (updatesEnabled()) {
- switch (m_mdiArrangementMode) {
- case ArrangementModeTileVertical:
- QTimer::singleShot(0, this, SLOT(myTileVertical()));
- break;
- case ArrangementModeTileHorizontal:
- QTimer::singleShot(0, this, SLOT(myTileHorizontal()));
- break;
- case ArrangementModeCascade:
- QTimer::singleShot(0, this, SLOT(myCascade()));
- break;
- default:
- break;
- }
- }
+ if (updatesEnabled()) {
+ switch (m_mdiArrangementMode) {
+ case ArrangementModeTileVertical:
+ QTimer::singleShot(0, this, SLOT(myTileVertical()));
+ break;
+ case ArrangementModeTileHorizontal:
+ QTimer::singleShot(0, this, SLOT(myTileHorizontal()));
+ break;
+ case ArrangementModeCascade:
+ QTimer::singleShot(0, this, SLOT(myCascade()));
+ break;
+ default:
+ break;
+ }
+ }
}
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 682ca12..1420007 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -23,93 +23,93 @@ class QMdiSubWindow;
* Enhances QMdiArea.
*/
class CMDIArea : public QMdiArea {
- Q_OBJECT
- Q_PROPERTY(MDIArrangementMode m_mdiArrangementMode READ getMDIArrangementMode WRITE setMDIArrangementMode)
+ Q_OBJECT
+ Q_PROPERTY(MDIArrangementMode m_mdiArrangementMode READ getMDIArrangementMode WRITE setMDIArrangementMode)
-public:
- /**
- * The options you can set for this widget.
- */
- enum MDIArrangementMode {
- ArrangementModeTileVertical = 1,
- ArrangementModeTileHorizontal = 2,
- ArrangementModeCascade = 3,
- ArrangementModeManual = 4,
- MDIArrangementModeMIN = ArrangementModeTileVertical,
- MDIArrangementModeMAX = ArrangementModeManual
- };
- CMDIArea(QWidget *parent);
- /** Reimplementation
- */
- virtual QMdiSubWindow* addSubWindow(QWidget* widget, Qt::WindowFlags windowFlags = 0);
- /**
- */
- void setMDIArrangementMode( const MDIArrangementMode );
- /** */
- MDIArrangementMode getMDIArrangementMode(void) const;
- /**
- */
- void emitWindowCaptionChanged();
- /**
- * Forces an update of the currently chosen window arrangement.
- */
- void triggerWindowUpdate();
- /** Lists all subWindows which are not minimized or hidden
- */
- QList<QMdiSubWindow*> usableWindowList();
+ public:
+ /**
+ * The options you can set for this widget.
+ */
+ enum MDIArrangementMode {
+ ArrangementModeTileVertical = 1,
+ ArrangementModeTileHorizontal = 2,
+ ArrangementModeCascade = 3,
+ ArrangementModeManual = 4,
+ MDIArrangementModeMIN = ArrangementModeTileVertical,
+ MDIArrangementModeMAX = ArrangementModeManual
+ };
+ CMDIArea(QWidget *parent);
+ /** Reimplementation
+ */
+ virtual QMdiSubWindow* addSubWindow(QWidget* widget, Qt::WindowFlags windowFlags = 0);
+ /**
+ */
+ void setMDIArrangementMode( const MDIArrangementMode );
+ /** */
+ MDIArrangementMode getMDIArrangementMode(void) const;
+ /**
+ */
+ void emitWindowCaptionChanged();
+ /**
+ * 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
- */
- void slotClientActivated(QMdiSubWindow* client);
- /**
- * 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
- */
- void myCascade();
- /** 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.
- */
- void myTileHorizontal();
- /**
- * Emits the signal to create a new display window in the MDI area.
- */
- inline void emitCreateDisplayWindow(QList<CSwordModuleInfo*> modules, const QString keyName);
+ public slots:
+ /**
+ * Called whan a client window was activated
+ */
+ void slotClientActivated(QMdiSubWindow* client);
+ /**
+ * 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
+ */
+ void myCascade();
+ /** 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.
+ */
+ 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
- /**
- * Emits a signal to set the acption of the toplevel widget.
- */
- void sigSetToplevelCaption(const QString&);
- /**
- */
- void createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& keyName);
+ 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:
- /**
- * Reimplementation
- */
- virtual void resizeEvent(QResizeEvent* e);
- /**
- * Used to handle Events of MDI windows
- * */
- bool eventFilter( QObject *o, QEvent *e );
- /**
- */
- MDIArrangementMode m_mdiArrangementMode;
+ private:
+ /**
+ * Reimplementation
+ */
+ virtual void resizeEvent(QResizeEvent* e);
+ /**
+ * Used to handle Events of MDI windows
+ * */
+ bool eventFilter( QObject *o, QEvent *e );
+ /**
+ */
+ 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);
+ emit createReadDisplayWindow(modules, keyName);
}
diff --git a/src/frontend/cmodulechooserdialog.cpp b/src/frontend/cmodulechooserdialog.cpp
index e7b96c8..2107b2c 100644
--- a/src/frontend/cmodulechooserdialog.cpp
+++ b/src/frontend/cmodulechooserdialog.cpp
@@ -34,123 +34,116 @@
CModuleChooserDialog::CModuleChooserDialog( QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules)
- : QDialog(parent),
- m_title(title),
- m_labelText(label)
-{
- m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
- m_filters = QList<BTModuleTreeItem::Filter*>();
- if (!allModules) {
- m_moduleList = CPointers::backend()->moduleList();
- }
- else m_moduleList = *allModules;
+ : QDialog(parent),
+ m_title(title),
+ m_labelText(label) {
+ m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
+ m_filters = QList<BTModuleTreeItem::Filter*>();
+ if (!allModules) {
+ m_moduleList = CPointers::backend()->moduleList();
+ }
+ else m_moduleList = *allModules;
}
/**
* Call init() after the constructor, either in the end of your own constructor or from outside.
*/
-void CModuleChooserDialog::init()
-{
- //Set the flag to destroy when closed - otherwise eats memory
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(m_title);
- initView();
- initTree();
+void CModuleChooserDialog::init() {
+ //Set the flag to destroy when closed - otherwise eats memory
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(m_title);
+ initView();
+ initTree();
}
/** Initializes the view of this dialog */
-void CModuleChooserDialog::initView()
-{
- //TODO: choose the button text?
-
- QVBoxLayout *vboxLayout;
- QHBoxLayout *hboxLayout;
- QSpacerItem *spacerItem;
+void CModuleChooserDialog::initView() {
+ //TODO: choose the button text?
- vboxLayout = new QVBoxLayout(this);
+ QVBoxLayout *vboxLayout;
+ QHBoxLayout *hboxLayout;
+ QSpacerItem *spacerItem;
- QLabel* label = CToolClass::explanationLabel(this, QString::null, m_labelText);
- vboxLayout->addWidget(label);
+ vboxLayout = new QVBoxLayout(this);
- m_moduleChooser = new QTreeWidget(this);
- m_moduleChooser->header()->hide();
+ QLabel* label = CToolClass::explanationLabel(this, QString::null, m_labelText);
+ vboxLayout->addWidget(label);
- vboxLayout->addWidget(m_moduleChooser);
+ m_moduleChooser = new QTreeWidget(this);
+ m_moduleChooser->header()->hide();
- hboxLayout = new QHBoxLayout();
+ vboxLayout->addWidget(m_moduleChooser);
- spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hboxLayout->addItem(spacerItem);
+ hboxLayout = new QHBoxLayout();
- m_buttonBox = new QDialogButtonBox(this);
- m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
- util::prepareDialogBox(m_buttonBox);
- hboxLayout->addWidget(m_buttonBox);
+ spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hboxLayout->addItem(spacerItem);
- vboxLayout->addLayout(hboxLayout);
-
- QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()) );
- //The QDialog doc is a bit unclear but calling reject also destroys the dialog
- // in this situation.
- QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
+ m_buttonBox = new QDialogButtonBox(this);
+ m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
+ util::prepareDialogBox(m_buttonBox);
+ hboxLayout->addWidget(m_buttonBox);
+
+ vboxLayout->addLayout(hboxLayout);
+
+ QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()) );
+ //The QDialog doc is a bit unclear but calling reject also destroys the dialog
+ // in this situation.
+ QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
}
-void CModuleChooserDialog::initTree()
-{
- //qDebug("CModuleChooserDialog::initTree");
+void CModuleChooserDialog::initTree() {
+ //qDebug("CModuleChooserDialog::initTree");
+
+ // See BTModuleTreeItem documentation.
+ BTModuleTreeItem root(m_filters, m_grouping, &m_moduleList);
+ createModuleTree(&root, m_moduleChooser->invisibleRootItem());
- // See BTModuleTreeItem documentation.
- BTModuleTreeItem root(m_filters, m_grouping, &m_moduleList);
- createModuleTree(&root, m_moduleChooser->invisibleRootItem());
-
}
-void CModuleChooserDialog::createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem)
-{
- foreach (BTModuleTreeItem* i, item->children()) {
- createModuleTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- initModuleItem(item, widgetItem);
- }
- }
+void CModuleChooserDialog::createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
+ foreach (BTModuleTreeItem* i, item->children()) {
+ createModuleTree(i, new QTreeWidgetItem(widgetItem));
+ }
+ if (item->type() != BTModuleTreeItem::Root) {
+ widgetItem->setText(0, item->text());
+ if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ }
+ if (item->type() == BTModuleTreeItem::Module) {
+ initModuleItem(item, widgetItem);
+ }
+ }
}
-
+
/** Emits the signal with the list of the selected modules. */
-void CModuleChooserDialog::slotOk()
-{
- Q_ASSERT(m_moduleChooser);
- //create the list of selected modules
- QList<CSwordModuleInfo*> mods;
- QTreeWidgetItemIterator it( m_moduleChooser );
- for ( ; *it; ++it ) {
- //add the module to list if the box is checked
- if ((*it)->checkState(0) == Qt::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");
- mods.append(*all_iter);
- break;
- }
- }
-
- }
- }
-
- // The selection is handled first, then the dialog is closed and destroyed.
- emit modulesChanged(mods, m_moduleChooser);
- QDialog::done(QDialog::Accepted);
+void CModuleChooserDialog::slotOk() {
+ Q_ASSERT(m_moduleChooser);
+ //create the list of selected modules
+ QList<CSwordModuleInfo*> mods;
+ QTreeWidgetItemIterator it( m_moduleChooser );
+ for ( ; *it; ++it ) {
+ //add the module to list if the box is checked
+ if ((*it)->checkState(0) == Qt::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");
+ mods.append(*all_iter);
+ break;
+ }
+ }
+
+ }
+ }
+
+ // The selection is handled first, then the dialog is closed and destroyed.
+ emit modulesChanged(mods, m_moduleChooser);
+ QDialog::done(QDialog::Accepted);
}
-QPushButton* CModuleChooserDialog::okButton()
-{
- return m_buttonBox->button(QDialogButtonBox::Ok);
+QPushButton* CModuleChooserDialog::okButton() {
+ return m_buttonBox->button(QDialogButtonBox::Ok);
}
diff --git a/src/frontend/cmodulechooserdialog.h b/src/frontend/cmodulechooserdialog.h
index 2f1e93c..1e5a777 100644
--- a/src/frontend/cmodulechooserdialog.h
+++ b/src/frontend/cmodulechooserdialog.h
@@ -26,77 +26,82 @@ class QDialogButtonBox;
* The dialog will be destroyed after closing. Connect the modulesChanged() signal
* to handle the selection before the dialog is destroyed.
*/
-class CModuleChooserDialog : public QDialog
-{
- Q_OBJECT
-public:
-
- /**
- * Use your own constructor to set extra members.
- * Filters list is given to the module tree creator, see BTModuleTreeItem.
- * For module list see BTModuleTreeItem constructor documentation.
- * Call init() after the constructor, either in the end of your own constructor or from outside.
- */
- CModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules = 0);
-
- virtual ~CModuleChooserDialog() {}
-
- /** Call this after/from the constructor.*/
- void init();
-
- /** Set the module tree grouping.
- * Initially it's taken from the CBTConfig so it needs to be set only if that default is not adequate.
- * This must be called before the tree is initialized, i.e. before init().
- */
- void setGrouping(BTModuleTreeItem::Grouping grouping) {m_grouping = grouping;}
-
- /** Set the module tree filters. See setGrouping() for the calling convention and
- * BTModuleTreeItem for the filters. By default the filters list is empty.
- */
- void setFilters(QList<BTModuleTreeItem::Filter*> filters) {m_filters = filters;}
-
- QTreeWidget* treeWidget() {return m_moduleChooser;}
-
- QPushButton* okButton();
-
-signals:
-
- /** The signal is sent when the OK button is clicked. The list includes the selected (checked) modules. The tree widget can be used through the pointer for more complicated actions. */
- void modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*);
-
-protected:
-
- /**
- * Initialize one tree widget item.
- * To be overridden. This is called for each QTreeWidgetItem when it is created.
- * Here you can set for example the checked status of the item.
- */
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) = 0;
-
-
-
-private slots:
-
- /** Emits the signal modulesChanged() with the list of the selected modules. */
- void slotOk();
-
-private:
- /** Initialize the module tree. */
- void initTree();
-
- /** Initializes the view of this dialog.*/
- void initView();
-
- /** Call this from initTree(). */
- void createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
-
- QTreeWidget *m_moduleChooser;
- QDialogButtonBox *m_buttonBox;
- QString m_title;
- QString m_labelText;
- QList<BTModuleTreeItem::Filter*> m_filters;
- BTModuleTreeItem::Grouping m_grouping;
- QList<CSwordModuleInfo*> m_moduleList;
+class CModuleChooserDialog : public QDialog {
+ Q_OBJECT
+ public:
+
+ /**
+ * Use your own constructor to set extra members.
+ * Filters list is given to the module tree creator, see BTModuleTreeItem.
+ * For module list see BTModuleTreeItem constructor documentation.
+ * Call init() after the constructor, either in the end of your own constructor or from outside.
+ */
+ CModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules = 0);
+
+ virtual ~CModuleChooserDialog() {}
+
+ /** Call this after/from the constructor.*/
+ void init();
+
+ /** Set the module tree grouping.
+ * Initially it's taken from the CBTConfig so it needs to be set only if that default is not adequate.
+ * This must be called before the tree is initialized, i.e. before init().
+ */
+ void setGrouping(BTModuleTreeItem::Grouping grouping) {
+ m_grouping = grouping;
+ }
+
+ /** Set the module tree filters. See setGrouping() for the calling convention and
+ * BTModuleTreeItem for the filters. By default the filters list is empty.
+ */
+ void setFilters(QList<BTModuleTreeItem::Filter*> filters) {
+ m_filters = filters;
+ }
+
+ QTreeWidget* treeWidget() {
+ return m_moduleChooser;
+ }
+
+ QPushButton* okButton();
+
+ signals:
+
+ /** The signal is sent when the OK button is clicked. The list includes the selected (checked) modules. The tree widget can be used through the pointer for more complicated actions. */
+ void modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*);
+
+ protected:
+
+ /**
+ * Initialize one tree widget item.
+ * To be overridden. This is called for each QTreeWidgetItem when it is created.
+ * Here you can set for example the checked status of the item.
+ */
+ virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) = 0;
+
+
+
+ private slots:
+
+ /** Emits the signal modulesChanged() with the list of the selected modules. */
+ void slotOk();
+
+ private:
+ /** Initialize the module tree. */
+ void initTree();
+
+ /** Initializes the view of this dialog.*/
+ void initView();
+
+ /** Call this from initTree(). */
+ void createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+
+ QTreeWidget *m_moduleChooser;
+ QDialogButtonBox *m_buttonBox;
+ QString m_title;
+ QString m_labelText;
+ QList<BTModuleTreeItem::Filter*> m_filters;
+ BTModuleTreeItem::Grouping m_grouping;
+ QList<CSwordModuleInfo*> m_moduleList;
};
diff --git a/src/frontend/cmoduleindexdialog.cpp b/src/frontend/cmoduleindexdialog.cpp
index 7edcd8c..d85e6b7 100644
--- a/src/frontend/cmoduleindexdialog.cpp
+++ b/src/frontend/cmoduleindexdialog.cpp
@@ -22,83 +22,81 @@
#include <QMessageBox>
CModuleIndexDialog* CModuleIndexDialog::getInstance() {
- qDebug("CModuleIndexDialog::getInstance");
- static CModuleIndexDialog* instance = 0;
- if (instance == 0) {
- instance = new CModuleIndexDialog();
- }
- qDebug("CModuleIndexDialog::getInstance end");
- return instance;
+ qDebug("CModuleIndexDialog::getInstance");
+ static CModuleIndexDialog* instance = 0;
+ if (instance == 0) {
+ instance = new CModuleIndexDialog();
+ }
+ qDebug("CModuleIndexDialog::getInstance end");
+ return instance;
}
-void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& modules )
-{
- static bool indexing = false;
- if (!indexing) {
- indexing = true;
- if (modules.count() < 1) return;
-
- m_currentModuleIndex = 0;
- m_progress = new QProgressDialog(QString(""), tr("Cancel"), 0, modules.count()*100);
- m_progress->setWindowModality(Qt::WindowModal); // not useful actually, should have parent for this
- m_progress->setWindowTitle(tr("Creating indices"));
- m_progress->show();
- m_progress->raise();
-
- foreach (CSwordModuleInfo* info, modules) {
- //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()));
- connect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
- connect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
- 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
- info->buildIndex(); //waits until this module is finished
-
- m_currentModuleIndex++;
- disconnect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
- disconnect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
- disconnect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
- if (m_progress->wasCanceled()) break;
- }
-
- delete m_progress;
- m_progress = 0;
- indexing = false;
- }
+void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& modules ) {
+ static bool indexing = false;
+ if (!indexing) {
+ indexing = true;
+ if (modules.count() < 1) return;
+
+ m_currentModuleIndex = 0;
+ m_progress = new QProgressDialog(QString(""), tr("Cancel"), 0, modules.count()*100);
+ m_progress->setWindowModality(Qt::WindowModal); // not useful actually, should have parent for this
+ m_progress->setWindowTitle(tr("Creating indices"));
+ m_progress->show();
+ m_progress->raise();
+
+ foreach (CSwordModuleInfo* info, modules) {
+ //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()));
+ connect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
+ connect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
+ 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
+ info->buildIndex(); //waits until this module is finished
+
+ m_currentModuleIndex++;
+ disconnect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
+ disconnect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
+ disconnect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
+ if (m_progress->wasCanceled()) break;
+ }
+
+ delete m_progress;
+ m_progress = 0;
+ indexing = false;
+ }
}
void CModuleIndexDialog::indexUnindexedModules( const QList<CSwordModuleInfo*>& modules ) {
- QList<CSwordModuleInfo*> unindexedMods;
-
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
- if ((*it)->hasIndex()) {
- continue;
- }
-
- unindexedMods << (*it);
- }
- indexAllModules(unindexedMods);
+ QList<CSwordModuleInfo*> unindexedMods;
+
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for ( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
+ if ((*it)->hasIndex()) {
+ continue;
+ }
+
+ unindexedMods << (*it);
+ }
+ indexAllModules(unindexedMods);
}
void CModuleIndexDialog::slotModuleProgress( int percentage ) {
- m_progress->setValue(m_currentModuleIndex * 100 + percentage);
- qApp->processEvents();
+ m_progress->setValue(m_currentModuleIndex * 100 + percentage);
+ qApp->processEvents();
}
void CModuleIndexDialog::slotFinished( ) {
- m_progress->setValue(m_currentModuleIndex * 100 + 100);
- qApp->processEvents();
+ m_progress->setValue(m_currentModuleIndex * 100 + 100);
+ qApp->processEvents();
}
// 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."));
- emit sigCancel();
+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."));
+ emit sigCancel();
}
diff --git a/src/frontend/cmoduleindexdialog.h b/src/frontend/cmoduleindexdialog.h
index 63c14b5..3a19be2 100644
--- a/src/frontend/cmoduleindexdialog.h
+++ b/src/frontend/cmoduleindexdialog.h
@@ -1,7 +1,7 @@
//
// C++ Interface: cmoduleindexdialog
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2006-2007
@@ -29,33 +29,33 @@ class QProgressDialog;
* @author The BibleTime team <info@bibletime.info>
*/
class CModuleIndexDialog : public QObject {
- Q_OBJECT
-public:
- /** Get the singleton instance.
- *
- */
- static CModuleIndexDialog* getInstance();
-
- /** Starts the actual indexing. It shows the dialog with progress information.
- */
- void indexAllModules( const QList<CSwordModuleInfo*>& modules );
-
- /** Indexes all modules in the list which don't have an index yet.
- */
- void indexUnindexedModules( const QList<CSwordModuleInfo*>& modules );
-
-signals:
- /** Indexing is cancelled programmatically. */
- void sigCancel();
-
-private:
- QProgressDialog* m_progress;
- int m_currentModuleIndex;
-
-protected slots:
- void slotModuleProgress( int percentage );
- void slotFinished();
- void slotSwordSetupChanged();
+ Q_OBJECT
+ public:
+ /** Get the singleton instance.
+ *
+ */
+ static CModuleIndexDialog* getInstance();
+
+ /** Starts the actual indexing. It shows the dialog with progress information.
+ */
+ void indexAllModules( const QList<CSwordModuleInfo*>& modules );
+
+ /** Indexes all modules in the list which don't have an index yet.
+ */
+ void indexUnindexedModules( const QList<CSwordModuleInfo*>& modules );
+
+ signals:
+ /** Indexing is cancelled programmatically. */
+ void sigCancel();
+
+ private:
+ QProgressDialog* m_progress;
+ int m_currentModuleIndex;
+
+ protected slots:
+ void slotModuleProgress( int percentage );
+ void slotFinished();
+ void slotSwordSetupChanged();
};
#endif
diff --git a/src/frontend/cprinter.cpp b/src/frontend/cprinter.cpp
index 92699af..0a05a55 100644
--- a/src/frontend/cprinter.cpp
+++ b/src/frontend/cprinter.cpp
@@ -18,119 +18,104 @@
#include <QPrinter>
#include <QPrintDialog>
-namespace Printing
-{
+namespace Printing {
CPrinter::CPrinter(QObject*, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
- : QObject(0),
- CDisplayRendering(displayOptions, filterOptions),
- m_htmlPage(new QWebPage())
-{
- m_htmlPage->setParent(this);
-
- //override the filteroptions set in the c-tor of CDisplayRendering
- m_filterOptions.footnotes = false;
- m_filterOptions.scriptureReferences = false;
- m_filterOptions.strongNumbers = false;
- m_filterOptions.morphTags = false;
- m_filterOptions.headings = false;
+ : QObject(0),
+ CDisplayRendering(displayOptions, filterOptions),
+ m_htmlPage(new QWebPage()) {
+ m_htmlPage->setParent(this);
+
+ //override the filteroptions set in the c-tor of CDisplayRendering
+ m_filterOptions.footnotes = false;
+ m_filterOptions.scriptureReferences = false;
+ m_filterOptions.strongNumbers = false;
+ m_filterOptions.morphTags = false;
+ m_filterOptions.headings = false;
}
-CPrinter::~CPrinter()
-{
- delete m_htmlPage;
- m_htmlPage = 0;
+CPrinter::~CPrinter() {
+ delete m_htmlPage;
+ m_htmlPage = 0;
}
-void CPrinter::printKeyTree( KeyTree& tree )
-{
- m_htmlPage->mainFrame()->setHtml(renderKeyTree(tree));
+void CPrinter::printKeyTree( KeyTree& tree ) {
+ m_htmlPage->mainFrame()->setHtml(renderKeyTree(tree));
- QPrinter printer;
- QPrintDialog printDialog(&printer);
- if (printDialog.exec() == QDialog::Accepted)
- {
- m_htmlPage->mainFrame()->print(&printer);
- }
+ QPrinter printer;
+ QPrintDialog printDialog(&printer);
+ if (printDialog.exec() == QDialog::Accepted) {
+ m_htmlPage->mainFrame()->print(&printer);
+ }
}
-const QString CPrinter::entryLink(const KeyTreeItem& item, CSwordModuleInfo* module)
-{
- Q_ASSERT(module);
- if (module->type() == CSwordModuleInfo::Bible)
- {
- CSwordVerseKey vk(module);
- vk.key(item.key());
- switch (item.settings().keyRenderingFace)
- {
- case KeyTreeItem::Settings::CompleteShort:
- return QString::fromUtf8(vk.getShortText());
-
- case KeyTreeItem::Settings::CompleteLong:
- return vk.key();
-
- case KeyTreeItem::Settings::NoKey:
- return QString::null;
-
- case KeyTreeItem::Settings::SimpleKey: //fall through
- default:
- return QString::number(vk.Verse());
- }
- }
- return item.key();
+const QString CPrinter::entryLink(const KeyTreeItem& item, CSwordModuleInfo* module) {
+ Q_ASSERT(module);
+ if (module->type() == CSwordModuleInfo::Bible) {
+ CSwordVerseKey vk(module);
+ vk.key(item.key());
+ switch (item.settings().keyRenderingFace) {
+ case KeyTreeItem::Settings::CompleteShort:
+ return QString::fromUtf8(vk.getShortText());
+
+ case KeyTreeItem::Settings::CompleteLong:
+ return vk.key();
+
+ case KeyTreeItem::Settings::NoKey:
+ return QString::null;
+
+ case KeyTreeItem::Settings::SimpleKey: //fall through
+ default:
+ return QString::number(vk.Verse());
+ }
+ }
+ return item.key();
}
-const QString CPrinter::renderEntry( const KeyTreeItem& i, CSwordKey* )
-{
- const CPrinter::KeyTreeItem* printItem = dynamic_cast<const CPrinter::KeyTreeItem*>(&i);
- Q_ASSERT(printItem);
-
- if (printItem && printItem->hasAlternativeContent())
- {
- QString ret = QString::fromLatin1("<div class=\"entry\"><div class=\"rangeheading\">%1</div>").arg(printItem->getAlternativeContent());
-
- if (!i.childList()->isEmpty())
- {
- KeyTree const * tree = i.childList();
-
- foreach ( KeyTreeItem* c, (*tree))
- {
- ret.append( CDisplayRendering::renderEntry( *c ) );
- }
- }
-
- ret.append("</div>");
- return ret;
- }
- return CDisplayRendering::renderEntry(i);
+const QString CPrinter::renderEntry( const KeyTreeItem& i, CSwordKey* ) {
+ const CPrinter::KeyTreeItem* printItem = dynamic_cast<const CPrinter::KeyTreeItem*>(&i);
+ Q_ASSERT(printItem);
+
+ if (printItem && printItem->hasAlternativeContent()) {
+ QString ret = QString::fromLatin1("<div class=\"entry\"><div class=\"rangeheading\">%1</div>").arg(printItem->getAlternativeContent());
+
+ if (!i.childList()->isEmpty()) {
+ KeyTree const * tree = i.childList();
+
+ foreach ( KeyTreeItem* c, (*tree)) {
+ ret.append( CDisplayRendering::renderEntry( *c ) );
+ }
+ }
+
+ ret.append("</div>");
+ return ret;
+ }
+ return CDisplayRendering::renderEntry(i);
}
-const QString CPrinter::finishText(const QString& text, KeyTree& tree)
-{
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
- Q_ASSERT(modules.count() > 0);
-
- const CLanguageMgr::Language* const lang = modules.first()->language();
- Q_ASSERT(lang);
-
- CDisplayTemplateMgr::Settings settings;
- //settings.modules = modules;
- settings.pageCSS_ID = "printer";
- settings.langAbbrev = ( lang && (modules.count() == 1) && lang->isValid() ) ? lang->abbrev() : "unknown";
-
- //the previous version gave compiler error for some strange reason
- //(well, I don't like ?: anyway, let alone nested)
- if (modules.count() != 1)
- {
- settings.pageDirection = QString::null;
- }
- else
- {
- settings.pageDirection = ( modules.first()->textDirection() == CSwordModuleInfo::LeftToRight ) ? "ltr" : "rtl";
- }
-
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
- return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), text, settings);
+const QString CPrinter::finishText(const QString& text, KeyTree& tree) {
+ QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ Q_ASSERT(modules.count() > 0);
+
+ const CLanguageMgr::Language* const lang = modules.first()->language();
+ Q_ASSERT(lang);
+
+ CDisplayTemplateMgr::Settings settings;
+ //settings.modules = modules;
+ settings.pageCSS_ID = "printer";
+ settings.langAbbrev = ( lang && (modules.count() == 1) && lang->isValid() ) ? lang->abbrev() : "unknown";
+
+ //the previous version gave compiler error for some strange reason
+ //(well, I don't like ?: anyway, let alone nested)
+ if (modules.count() != 1) {
+ settings.pageDirection = QString::null;
+ }
+ else {
+ settings.pageDirection = ( modules.first()->textDirection() == CSwordModuleInfo::LeftToRight ) ? "ltr" : "rtl";
+ }
+
+ CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), text, settings);
}
} //end of namespace
diff --git a/src/frontend/cprinter.h b/src/frontend/cprinter.h
index 8b85691..d97563e 100644
--- a/src/frontend/cprinter.h
+++ b/src/frontend/cprinter.h
@@ -18,26 +18,24 @@
class QWebPage;
-namespace Printing
-{
-
- // The CPrinter class manages the print item queue and the printing of them to the printer.
-
-class CPrinter : public QObject, public Rendering::CDisplayRendering
-{
- Q_OBJECT
-public:
- CPrinter(QObject* parent, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- virtual ~CPrinter();
- void printKeyTree( KeyTree& );
-
-protected:
- virtual const QString entryLink(const KeyTreeItem& item, CSwordModuleInfo* const module);
- virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
- virtual const QString finishText(const QString& arg1, KeyTree& tree);
-
-private:
- QWebPage* m_htmlPage;
+namespace Printing {
+
+// The CPrinter class manages the print item queue and the printing of them to the printer.
+
+class CPrinter : public QObject, public Rendering::CDisplayRendering {
+ Q_OBJECT
+ public:
+ CPrinter(QObject* parent, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ virtual ~CPrinter();
+ void printKeyTree( KeyTree& );
+
+ protected:
+ virtual const QString entryLink(const KeyTreeItem& item, CSwordModuleInfo* const module);
+ virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
+ virtual const QString finishText(const QString& arg1, KeyTree& tree);
+
+ private:
+ QWebPage* m_htmlPage;
};
} //namespace Printing
diff --git a/src/frontend/crossrefrendering.cpp b/src/frontend/crossrefrendering.cpp
index 3aa8130..9785ee7 100644
--- a/src/frontend/crossrefrendering.cpp
+++ b/src/frontend/crossrefrendering.cpp
@@ -20,71 +20,70 @@ namespace InfoDisplay {
/**
*/
CrossRefRendering::CrossRefRendering( CSwordBackend::DisplayOptions displayOptions,
- CSwordBackend::FilterOptions filterOptions
- )
- : CHTMLExportRendering(Settings(), displayOptions, filterOptions)
-{}
+ CSwordBackend::FilterOptions filterOptions
+ )
+ : CHTMLExportRendering(Settings(), displayOptions, filterOptions) {}
const QString CrossRefRendering::finishText( const QString& text, KeyTree& ) {
- // qDebug("CrossRefRendering::finishText");
- return text;
+ // qDebug("CrossRefRendering::finishText");
+ return text;
}
const QString CrossRefRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) {
- QString linkText;
+ QString linkText;
- const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
- CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
- if (isBible) {
- vk.key(item.key());
- }
+ const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
+ CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
+ if (isBible) {
+ vk.key(item.key());
+ }
- switch (item.settings().keyRenderingFace) {
- case KeyTreeItem::Settings::NoKey: {
- linkText = QString::null;
- break; //no key is valid for all modules
- }
- case KeyTreeItem::Settings::CompleteShort: {
- if (isBible) {
- linkText = QString::fromUtf8(vk.getShortText());
- break;
- }
- //fall through for non-Bible modules
- }
- case KeyTreeItem::Settings::CompleteLong: {
- if (isBible) {
- linkText = vk.key();
- break;
- }
- //fall through for non-Bible modules
- }
- case KeyTreeItem::Settings::SimpleKey: {
- if (isBible) {
- linkText = QString::number(vk.Verse());
- break;
- }
- //fall through for non-Bible modules
- }
- default: { //default behaviour to return the passed key
- linkText = item.key();
- break;
- }
- }
+ switch (item.settings().keyRenderingFace) {
+ case KeyTreeItem::Settings::NoKey: {
+ linkText = QString::null;
+ break; //no key is valid for all modules
+ }
+ case KeyTreeItem::Settings::CompleteShort: {
+ if (isBible) {
+ linkText = QString::fromUtf8(vk.getShortText());
+ break;
+ }
+ //fall through for non-Bible modules
+ }
+ case KeyTreeItem::Settings::CompleteLong: {
+ if (isBible) {
+ linkText = vk.key();
+ break;
+ }
+ //fall through for non-Bible modules
+ }
+ case KeyTreeItem::Settings::SimpleKey: {
+ if (isBible) {
+ linkText = QString::number(vk.Verse());
+ break;
+ }
+ //fall through for non-Bible modules
+ }
+ default: { //default behaviour to return the passed key
+ linkText = item.key();
+ break;
+ }
+ }
- if (!linkText.isEmpty()) { //if we have a valid link text
- // qWarning("rendering");
- return QString("<a href=\"%1\">%2</a>")
- .arg(
- CReferenceManager::encodeHyperlink(
- module->name(),
- item.key(),
- CReferenceManager::typeFromModule(module->type())
- )
- )
- .arg(linkText);
- }
+ if (!linkText.isEmpty()) { //if we have a valid link text
+ // qWarning("rendering");
+ return QString("<a href=\"%1\">%2</a>")
+ .arg(
+ CReferenceManager::encodeHyperlink(
+ module->name(),
+ item.key(),
+ CReferenceManager::typeFromModule(module->type())
+ )
+ )
+ .arg(linkText);
+ }
- return QString::null;
+ return QString::null;
}
}
diff --git a/src/frontend/crossrefrendering.h b/src/frontend/crossrefrendering.h
index 99fdd7c..a1e5607 100644
--- a/src/frontend/crossrefrendering.h
+++ b/src/frontend/crossrefrendering.h
@@ -17,18 +17,17 @@
namespace InfoDisplay {
-class CrossRefRendering : public Rendering::CHTMLExportRendering
-{
-protected:
- friend class CInfoDisplay;
-
- CrossRefRendering(
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
- );
-
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
- virtual const QString finishText( const QString&, KeyTree& tree );
+class CrossRefRendering : public Rendering::CHTMLExportRendering {
+ protected:
+ friend class CInfoDisplay;
+
+ CrossRefRendering(
+ CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ );
+
+ virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
+ virtual const QString finishText( const QString&, KeyTree& tree );
};
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index f807b05..735f23f 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -14,52 +14,44 @@
#include <QColorDialog>
BtColorWidget::BtColorWidget(QWidget* parent)
- : QFrame(parent)
-{
- setFrameShadow(QFrame::Sunken);
- setFrameShape(QFrame::StyledPanel);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setAutoFillBackground(true);
+ : QFrame(parent) {
+ setFrameShadow(QFrame::Sunken);
+ setFrameShape(QFrame::StyledPanel);
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ setAutoFillBackground(true);
}
-BtColorWidget::~BtColorWidget()
-{
+BtColorWidget::~BtColorWidget() {
}
-QSize BtColorWidget::sizeHint() const
-{
- return QSize(35,18);
+QSize BtColorWidget::sizeHint() const {
+ return QSize(35, 18);
}
-void BtColorWidget::setColor(const QColor& color)
-{
- QPalette p = palette();
- p.setColor(QPalette::Normal, QPalette::Window, color);
- setPalette(p);
-
- if (color.isValid())
- m_color = color;
- else
- m_color = QColor(0,0,0);
- update();
+void BtColorWidget::setColor(const QColor& color) {
+ QPalette p = palette();
+ p.setColor(QPalette::Normal, QPalette::Window, color);
+ setPalette(p);
+
+ if (color.isValid())
+ m_color = color;
+ else
+ m_color = QColor(0, 0, 0);
+ update();
}
-void BtColorWidget::mouseReleaseEvent(QMouseEvent* event)
-{
- if (event->button() == Qt::LeftButton)
- {
- event->accept();
- showColorDialog();
- return;
- }
+void BtColorWidget::mouseReleaseEvent(QMouseEvent* event) {
+ if (event->button() == Qt::LeftButton) {
+ event->accept();
+ showColorDialog();
+ return;
+ }
}
-void BtColorWidget::showColorDialog()
-{
- QColor color = QColorDialog::getColor(m_color, this);
- if (color.isValid())
- {
- m_color = color;
- emit changed(m_color);
- }
+void BtColorWidget::showColorDialog() {
+ QColor color = QColorDialog::getColor(m_color, this);
+ if (color.isValid()) {
+ m_color = color;
+ emit changed(m_color);
+ }
}
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 0309832..aac8615 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -16,27 +16,26 @@
#include <QFrame>
class QPaintEvent;
-class BtColorWidget : public QFrame
-{
- Q_OBJECT
+class BtColorWidget : public QFrame {
+ Q_OBJECT
-public:
- BtColorWidget(QWidget* parent=0);
- ~BtColorWidget();
- QSize sizeHint() const;
- void setColor(const QColor& color);
+ public:
+ BtColorWidget(QWidget* parent = 0);
+ ~BtColorWidget();
+ QSize sizeHint() const;
+ void setColor(const QColor& color);
-protected:
+ protected:
// void paintEvent( QPaintEvent* );
- void mouseReleaseEvent(QMouseEvent* event);
+ void mouseReleaseEvent(QMouseEvent* event);
-private:
- void showColorDialog();
+ private:
+ void showColorDialog();
- QColor m_color;
-
-signals:
- void changed(const QColor& color);
+ QColor m_color;
+
+ signals:
+ void changed(const QColor& color);
};
#endif
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index 3f03693..9d45a6a 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -12,40 +12,35 @@
#include <QCompleter>
BtFontSizeWidget::BtFontSizeWidget(QWidget* parent)
- : QComboBox(parent)
-{
- setEditable(true);
- completer()->setCompletionMode(QCompleter::PopupCompletion);
-
- QFontDatabase database;
- const QList<int> sizes = database.standardSizes();
- QStringList list;
- for ( QList<int>::ConstIterator it = sizes.begin(); it != sizes.end(); ++it )
- list.append( QString::number( *it ) );
- addItems(list);
-
- bool ok = connect(this, SIGNAL(currentIndexChanged(const QString&)),
- this, SLOT(changed(const QString&)));
- Q_ASSERT(ok);
+ : QComboBox(parent) {
+ setEditable(true);
+ completer()->setCompletionMode(QCompleter::PopupCompletion);
+
+ QFontDatabase database;
+ const QList<int> sizes = database.standardSizes();
+ QStringList list;
+ for ( QList<int>::ConstIterator it = sizes.begin(); it != sizes.end(); ++it )
+ list.append( QString::number( *it ) );
+ addItems(list);
+
+ bool ok = connect(this, SIGNAL(currentIndexChanged(const QString&)),
+ this, SLOT(changed(const QString&)));
+ Q_ASSERT(ok);
}
-BtFontSizeWidget::~BtFontSizeWidget()
-{
+BtFontSizeWidget::~BtFontSizeWidget() {
}
-void BtFontSizeWidget::changed(const QString& text)
-{
- emit fontSizeChanged(text.toInt());
+void BtFontSizeWidget::changed(const QString& text) {
+ emit fontSizeChanged(text.toInt());
}
-void BtFontSizeWidget::setFontSize(int size)
-{
- int index = findText(QString::number(size));
- if (index >= 0)
- setCurrentIndex(index);
+void BtFontSizeWidget::setFontSize(int size) {
+ int index = findText(QString::number(size));
+ if (index >= 0)
+ setCurrentIndex(index);
}
-int BtFontSizeWidget::fontSize() const
-{
- return currentText().toInt();
+int BtFontSizeWidget::fontSize() const {
+ return currentText().toInt();
}
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index 2366744..81cfa86 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -16,21 +16,20 @@
#include <QComboBox>
-class BtFontSizeWidget : public QComboBox
-{
- Q_OBJECT
-
-public:
- BtFontSizeWidget(QWidget* parent=0);
- ~BtFontSizeWidget();
- void setFontSize(int size);
- int fontSize() const;
-
-private slots:
- virtual void changed(const QString& text);
-
-signals:
- void fontSizeChanged( int );
+class BtFontSizeWidget : public QComboBox {
+ Q_OBJECT
+
+ public:
+ BtFontSizeWidget(QWidget* parent = 0);
+ ~BtFontSizeWidget();
+ void setFontSize(int size);
+ int fontSize() const;
+
+ private slots:
+ virtual void changed(const QString& text);
+
+ signals:
+ void fontSizeChanged( int );
};
#endif
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
index 9041173..9e0feff 100644
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ b/src/frontend/display/bthtmlfindtext.cpp
@@ -16,86 +16,77 @@
static BtHtmlFindText* dialog = 0;
-void showBtHtmlFindText(CMDIArea* mdiArea)
-{
- if (dialog == 0)
- dialog = new BtHtmlFindText(mdiArea, mdiArea);
- dialog->show();
+void showBtHtmlFindText(CMDIArea* mdiArea) {
+ if (dialog == 0)
+ dialog = new BtHtmlFindText(mdiArea, mdiArea);
+ dialog->show();
}
BtHtmlFindText::BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent,f), m_mdiArea(mdiArea)
-{
- ui.setupUi(this);
- bool ok;
- ok = connect(ui.nextButton,SIGNAL(clicked()), this, SLOT(findNext()));
- Q_ASSERT(ok);
- ok = connect(ui.previousButton,SIGNAL(clicked()), this, SLOT(findPrevious()));
- Q_ASSERT(ok);
+ : QDialog(parent, f), m_mdiArea(mdiArea) {
+ ui.setupUi(this);
+ bool ok;
+ ok = connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
+ Q_ASSERT(ok);
+ ok = connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
+ Q_ASSERT(ok);
}
-BtHtmlFindText::~BtHtmlFindText()
-{
+BtHtmlFindText::~BtHtmlFindText() {
}
-void BtHtmlFindText::findNext()
-{
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0)
- {
- QWebPage::FindFlags options = 0;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
+void BtHtmlFindText::findNext() {
+ QWebView* webView = getActiveWindowWebView();
+ if (webView != 0) {
+ QWebPage::FindFlags options = 0;
+ if (ui.caseBox->checkState() == Qt::Checked)
+ options |= QWebPage::FindCaseSensitively;
+ QString searchText = ui.findTextComboBox->currentText();
+ if (!searchText.isEmpty())
+ webView->findText(searchText, options);
+ }
}
-void BtHtmlFindText::doHide()
-{
- hide();
+void BtHtmlFindText::doHide() {
+ hide();
}
-void BtHtmlFindText::findPrevious()
-{
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0)
- {
- QWebPage::FindFlags options = QWebPage::FindBackward;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText,options);
- }
+void BtHtmlFindText::findPrevious() {
+ QWebView* webView = getActiveWindowWebView();
+ if (webView != 0) {
+ QWebPage::FindFlags options = QWebPage::FindBackward;
+ if (ui.caseBox->checkState() == Qt::Checked)
+ options |= QWebPage::FindCaseSensitively;
+ QString searchText = ui.findTextComboBox->currentText();
+ if (!searchText.isEmpty())
+ webView->findText(searchText, options);
+ }
}
-QWebView* BtHtmlFindText::getActiveWindowWebView()
-{
- QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
- if (activeSubWindow == 0)
- return 0;
+QWebView* BtHtmlFindText::getActiveWindowWebView() {
+ QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
+ if (activeSubWindow == 0)
+ return 0;
- QWidget* activeWindowWidget = activeSubWindow->widget();
- if (activeWindowWidget == 0)
- return 0;
+ QWidget* activeWindowWidget = activeSubWindow->widget();
+ if (activeWindowWidget == 0)
+ return 0;
- CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
- if (cDisplayWindow == 0)
- return 0;
+ CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
+ if (cDisplayWindow == 0)
+ return 0;
- CDisplay* cDisplay = cDisplayWindow->displayWidget();
- if (cDisplay == 0)
- return 0;
+ CDisplay* cDisplay = cDisplayWindow->displayWidget();
+ if (cDisplay == 0)
+ return 0;
- QWidget* textView = cDisplay->view();
- if (textView == 0)
- return 0;
+ QWidget* textView = cDisplay->view();
+ if (textView == 0)
+ return 0;
- QWebView* webView = qobject_cast<QWebView*>(textView);
- return webView;
+ QWebView* webView = qobject_cast<QWebView*>(textView);
+ return webView;
}
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
index d6a1fe9..0500247 100644
--- a/src/frontend/display/bthtmlfindtext.h
+++ b/src/frontend/display/bthtmlfindtext.h
@@ -14,22 +14,21 @@
class CMDIArea;
class QWebView;
-class BtHtmlFindText : public QDialog
-{
- Q_OBJECT
+class BtHtmlFindText : public QDialog {
+ Q_OBJECT
-public:
- BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent=0, Qt::WindowFlags f=0);
- ~BtHtmlFindText();
-public slots:
- void findNext();
- void findPrevious();
- void doHide();
-private:
- QWebView* getActiveWindowWebView();
- Ui_findTextDialog ui;
- CMDIArea* m_mdiArea;
+ public:
+ BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent = 0, Qt::WindowFlags f = 0);
+ ~BtHtmlFindText();
+ public slots:
+ void findNext();
+ void findPrevious();
+ void doHide();
+ private:
+ QWebView* getActiveWindowWebView();
+ Ui_findTextDialog ui;
+ CMDIArea* m_mdiArea;
};
-#endif
+#endif
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index 823a07c..b1b97a6 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -24,159 +24,135 @@ using namespace InfoDisplay;
// so that Javascript can call this class, or this class can call Javascript.
// Access to DOM objects is implemented in Javascript and is communicated back to c++ through this class
-BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display)
- : m_display(display)
-{
+BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display)
+ : m_display(display) {
}
-void BtHtmlJsObject::moveToAnchor(const QString& anchor)
-{
- // Call gotoAnchor in Javascript
- emit gotoAnchor(anchor);
+void BtHtmlJsObject::moveToAnchor(const QString& anchor) {
+ // Call gotoAnchor in Javascript
+ emit gotoAnchor(anchor);
}
-void BtHtmlJsObject::setBodyEditable(bool editable)
-{
- if (editable)
- emit setDocumentEditable();
- else
- emit setDocumentNotEditable();
+void BtHtmlJsObject::setBodyEditable(bool editable) {
+ if (editable)
+ emit setDocumentEditable();
+ else
+ emit setDocumentNotEditable();
}
-void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int& y)
-{
- m_dndData.mousePressed = true;
- m_dndData.isDragging = false;
- m_dndData.startPos = QPoint(x,y);
- m_dndData.url = url;
+void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int& y) {
+ m_dndData.mousePressed = true;
+ m_dndData.isDragging = false;
+ m_dndData.startPos = QPoint(x, y);
+ m_dndData.url = url;
}
-
-void BtHtmlJsObject::mouseClick(const QString& url)
-{
- m_dndData.mousePressed = false;
- if (!url.isEmpty() && CReferenceManager::isHyperlink(url))
- {
- QString module;
- QString key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(url, module, key, type);
- if (module.isEmpty())
- {
- module = CReferenceManager::preferredModule( type );
- }
- m_display->connectionsProxy()->emitReferenceClicked(module,key);
- }
+void BtHtmlJsObject::mouseClick(const QString& url) {
+ m_dndData.mousePressed = false;
+ if (!url.isEmpty() && CReferenceManager::isHyperlink(url)) {
+ QString module;
+ QString key;
+ CReferenceManager::Type type;
+
+ CReferenceManager::decodeHyperlink(url, module, key, type);
+ if (module.isEmpty()) {
+ module = CReferenceManager::preferredModule( type );
+ }
+ m_display->connectionsProxy()->emitReferenceClicked(module, key);
+ }
}
-void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma)
-{
- m_display->setActiveAnchor(url);
- if (lemma.isEmpty())
- m_display->setLemma(QString::null);
- else
- m_display->setLemma(lemma);
+void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma) {
+ m_display->setActiveAnchor(url);
+ if (lemma.isEmpty())
+ m_display->setLemma(QString::null);
+ else
+ m_display->setLemma(lemma);
}
// The mouse move event starts in the javascript function "mouseMoveHandler" in bthtml.js. It calls this function
-void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey)
-{
- if(!m_dndData.isDragging && m_dndData.mousePressed)
- {
+void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey) {
+ /// \bug Valgrind reports uninitialized m_dndData or m_dndData member:
+ if (!m_dndData.isDragging && m_dndData.mousePressed) {
// If we have not started dragging, but the mouse button is down, create a the mime data
- QPoint current(x,y);
- if ((current - m_dndData.startPos).manhattanLength() > 4 /*qApp->startDragDistance()*/ )
- {
- QDrag* drag = 0;
- if (m_dndData.url.size() != 0 )
- {
- // 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) )
- return;
- drag = new QDrag(m_display->view());
- BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null);
- drag->setMimeData(mimedata);
- //add real Bible text from module/key
- if (CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName))
- {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
- mimedata->setText(key->strippedText()); // This works across applications!
- }
- }
- if (drag)
- {
- m_dndData.isDragging = true;
- m_dndData.mousePressed = false;
- drag->exec(Qt::CopyAction, Qt::CopyAction);
- }
- }
- }
- else if (m_display->getMouseTracking() && !shiftKey)
- {
- // no mouse button pressed and tracking enabled
+ QPoint current(x, y);
+ if ((current - m_dndData.startPos).manhattanLength() > 4 /*qApp->startDragDistance()*/ ) {
+ QDrag* drag = 0;
+ if (m_dndData.url.size() != 0 ) {
+ // 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) )
+ return;
+ drag = new QDrag(m_display->view());
+ BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null);
+ drag->setMimeData(mimedata);
+ //add real Bible text from module/key
+ if (CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName)) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( keyName );
+ mimedata->setText(key->strippedText()); // This works across applications!
+ }
+ }
+ if (drag) {
+ m_dndData.isDragging = true;
+ m_dndData.mousePressed = false;
+ drag->exec(Qt::CopyAction, Qt::CopyAction);
+ }
+ }
+ }
+ else if (m_display->getMouseTracking() && !shiftKey) {
+ // no mouse button pressed and tracking enabled
// start timer that updates the mag window
// Sets timer in javascript. See bthtml.js startTimer()
- emit startTimer(CBTConfig::get(CBTConfig::magDelay));
+ emit startTimer(CBTConfig::get(CBTConfig::magDelay));
m_prev_attributes = attributes;
// When the javascript timer interupts, the see timerEvent() in bthtml.js
// will call the timeOutEvent in this class
- }
+ }
}
// called from javascript timerEvent() in bthtml.js
-void BtHtmlJsObject::timeOutEvent(const QString& attributes)
-{
+void BtHtmlJsObject::timeOutEvent(const QString& attributes) {
if (m_prev_attributes != attributes)
return;
m_prev_attributes = "";
- CInfoDisplay::ListInfoData infoList;
- QStringList attrList = attributes.split("||");
- for (int i=0; i<attrList.count(); i++)
- {
- QString attrPair = attrList[i];
- QStringList attr = attrPair.split("=");
- if (attr.count() == 2)
- {
- QString attrName = attr[0];
- QString attrValue= attr[1];
- if (attrName == "note")
- {
- infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
- }
- if (attrName == "lemma")
- {
- infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
- }
- if (attrName == "morph")
- {
- infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
- }
- if (attrName == "expansion")
- {
- infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
- }
- if (attrName == "crossrefs")
- {
- infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
- }
- }
- }
- // Update the mag if valid attributes were found
- if (!(infoList.isEmpty()))
- {
- CPointers::infoDisplay()->setInfo(infoList);
- }
+ CInfoDisplay::ListInfoData infoList;
+ QStringList attrList = attributes.split("||");
+ for (int i = 0; i < attrList.count(); i++) {
+ QString attrPair = attrList[i];
+ QStringList attr = attrPair.split("=");
+ if (attr.count() == 2) {
+ QString attrName = attr[0];
+ QString attrValue = attr[1];
+ if (attrName == "note") {
+ infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
+ }
+ if (attrName == "lemma") {
+ infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
+ }
+ if (attrName == "morph") {
+ infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
+ }
+ if (attrName == "expansion") {
+ infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
+ }
+ if (attrName == "crossrefs") {
+ infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
+ }
+ }
+ }
+ // Update the mag if valid attributes were found
+ if (!(infoList.isEmpty())) {
+ CPointers::infoDisplay()->setInfo(infoList);
+ }
}
-// clearing the previous attribute effectively stops any time out event
+// clearing the previous attribute effectively stops any time out event
// that is in progress
-void BtHtmlJsObject::clearPrevAttribute()
-{
+void BtHtmlJsObject::clearPrevAttribute() {
m_prev_attributes = "";
}
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index eeba3af..d418b71 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -14,48 +14,46 @@
class BtHtmlReadDisplay;
-class BtHtmlJsObject: public QObject
-{
- Q_OBJECT
-
-public:
- BtHtmlJsObject(BtHtmlReadDisplay* display);
- ~BtHtmlJsObject(){}
- void moveToAnchor(const QString& anchor);
- void setBodyEditable(bool editable);
- void clearPrevAttribute();
-
-public slots: void mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey);
- void mouseClick(const QString& url);
- void mouseDownLeft(const QString& url, const int& X, const int& Y);
- void mouseDownRight(const QString& url, const QString& lemma);
- void timeOutEvent(const QString& attributes);
-
-signals:
- void startTimer(int time);
- void mouseMoveAttribute(const QString& attrName, const QString& attrValue);
- void gotoAnchor(const QString& anchor);
- void selectAll();
- void setDocumentEditable();
- void setDocumentNotEditable();
-
-private:
- int m_int;
- BtHtmlReadDisplay* m_display;
- QString m_prev_attributes;
-
- struct DNDData
- {
- bool mousePressed;
- bool isDragging;
- QPoint startPos;
- QString url;
- enum DragType
- {
- Link,
- Text
- } dragType;
- } m_dndData;
+class BtHtmlJsObject: public QObject {
+ Q_OBJECT
+
+ public:
+ BtHtmlJsObject(BtHtmlReadDisplay* display);
+ ~BtHtmlJsObject() {}
+ void moveToAnchor(const QString& anchor);
+ void setBodyEditable(bool editable);
+ void clearPrevAttribute();
+
+ public slots:
+ void mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey);
+ void mouseClick(const QString& url);
+ void mouseDownLeft(const QString& url, const int& X, const int& Y);
+ void mouseDownRight(const QString& url, const QString& lemma);
+ void timeOutEvent(const QString& attributes);
+
+ signals:
+ void startTimer(int time);
+ void mouseMoveAttribute(const QString& attrName, const QString& attrValue);
+ void gotoAnchor(const QString& anchor);
+ void selectAll();
+ void setDocumentEditable();
+ void setDocumentNotEditable();
+
+ private:
+ int m_int;
+ BtHtmlReadDisplay* m_display;
+ QString m_prev_attributes;
+
+ struct DNDData {
+ bool mousePressed;
+ bool isDragging;
+ QPoint startPos;
+ QString url;
+ enum DragType {
+ Link,
+ Text
+ } dragType;
+ } m_dndData;
};
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 53d10e7..7ce6f40 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -34,261 +34,231 @@ static QString javascript; // Initialized from file bthtml.js
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
- : QWebPage(parentWidget),CReadDisplay(readWindow), m_magTimerId(0), m_view(0), m_jsObject(0)
+ : QWebPage(parentWidget), CReadDisplay(readWindow), m_magTimerId(0), m_view(0), m_jsObject(0)
{
- settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
- m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow);
- m_view->setAcceptDrops(true);
- m_view->setPage(this);
- setParent(m_view);
- m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- m_view->setHtml("");
- initJavascript();
- bool ok = connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
- Q_ASSERT(ok);
+ settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
+ m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow);
+ m_view->setAcceptDrops(true);
+ m_view->setPage(this);
+ setParent(m_view);
+ m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_view->setHtml("");
+ initJavascript();
+ bool ok = connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
+ Q_ASSERT(ok);
}
-BtHtmlReadDisplay::~BtHtmlReadDisplay()
-{
- setView(0);
+BtHtmlReadDisplay::~BtHtmlReadDisplay() {
+ setView(0);
}
// Read javascript into memory once and create the c++ javascript object
-void BtHtmlReadDisplay::initJavascript()
-{
- // read bthtml.js javascript file once
- if (javascript.size() == 0)
- {
- QString jsFile = util::filesystem::DirectoryUtil::getJavascriptDir().canonicalPath() + "/bthtml.js";
- QFile file(jsFile);
- if (file.open(QFile::ReadOnly))
- {
- while (!file.atEnd())
- {
- QByteArray line = file.readLine();
- javascript = javascript + line;
- }
- file.close();
- }
- }
-
- // Setup BtHtmlJsObject which will be called from javascript
- m_jsObject = new BtHtmlJsObject(this);
- m_jsObject->setObjectName("btHtmlJsObject");
+void BtHtmlReadDisplay::initJavascript() {
+ // read bthtml.js javascript file once
+ if (javascript.size() == 0) {
+ QString jsFile = util::filesystem::DirectoryUtil::getJavascriptDir().canonicalPath() + "/bthtml.js";
+ QFile file(jsFile);
+ if (file.open(QFile::ReadOnly)) {
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ javascript = javascript + line;
+ }
+ file.close();
+ }
+ }
+
+ // Setup BtHtmlJsObject which will be called from javascript
+ m_jsObject = new BtHtmlJsObject(this);
+ m_jsObject->setObjectName("btHtmlJsObject");
}
-// When the QWebFrame is cleared, this function is called to install the
+// When the QWebFrame is cleared, this function is called to install the
// javascript object (BtHtmlJsObject class) into the Javascript model
-void BtHtmlReadDisplay::loadJSObject()
-{
- mainFrame()->addToJavaScriptWindowObject(m_jsObject->objectName(), m_jsObject);
+void BtHtmlReadDisplay::loadJSObject() {
+ mainFrame()->addToJavaScriptWindowObject(m_jsObject->objectName(), m_jsObject);
}
-const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CDisplay::TextPart part)
-{
- switch (part)
- {
- case Document:
- {
- if (format == HTMLText)
- {
- return mainFrame()->toHtml();
- }
- else
- {
- CDisplayWindow* window = parentWindow();
- CSwordKey* const key = window->key();
- CSwordModuleInfo* module = key->module();
- //This is never used for Bibles, so it is not implemented for
- //them. If it should be, see CReadDisplay::print() for example
- //code.
- Q_ASSERT(module->type() == CSwordModuleInfo::Lexicon ||
- module->type() == CSwordModuleInfo::Commentary ||
- module->type() == CSwordModuleInfo::GenericBook);
- 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
- CSwordBackend::FilterOptions filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CPointers::backend()->setFilterOptions(filterOptions);
-
- return QString(key->strippedText()).append("\n(")
- .append(key->key())
- .append(", ")
- .append(key->module()->name())
- .append(")");
- }
- }
- }
-
- case SelectedText:
- {
- if (!hasSelection())
- {
- return QString::null;
- }
- else if (format == HTMLText)
- {
- // TODO: It does not appear this is ever called
- }
- else
- { //plain text requested
- return selectedText();
- }
- }
-
- case AnchorOnly:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
-
- return keyName;
- }
-
- case AnchorTextOnly:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
-
- if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName))
- {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
-
- return key->strippedText();
- }
- return QString::null;
- }
-
- case AnchorWithText:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::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
- CSwordBackend::FilterOptions filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CPointers::backend()->setFilterOptions(filterOptions);
-
- return QString(key->strippedText()).append("\n(")
- .append(key->key())
- .append(", ")
- .append(key->module()->name())
- .append(")");
- /* ("%1\n(%2, %3)")
- .arg()
- .arg(key->key())
- .arg(key->module()->name());*/
- }
- return QString::null;
- }
- default:
- return QString::null;
- }
- return QString();
+const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CDisplay::TextPart part) {
+ switch (part) {
+ case Document: {
+ if (format == HTMLText) {
+ return mainFrame()->toHtml();
+ }
+ else {
+ CDisplayWindow* window = parentWindow();
+ CSwordKey* const key = window->key();
+ CSwordModuleInfo* module = key->module();
+ //This is never used for Bibles, so it is not implemented for
+ //them. If it should be, see CReadDisplay::print() for example
+ //code.
+ Q_ASSERT(module->type() == CSwordModuleInfo::Lexicon ||
+ module->type() == CSwordModuleInfo::Commentary ||
+ module->type() == CSwordModuleInfo::GenericBook);
+ 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
+ CSwordBackend::FilterOptions filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CPointers::backend()->setFilterOptions(filterOptions);
+
+ return QString(key->strippedText()).append("\n(")
+ .append(key->key())
+ .append(", ")
+ .append(key->module()->name())
+ .append(")");
+ }
+ }
+ }
+
+ case SelectedText: {
+ if (!hasSelection()) {
+ return QString::null;
+ }
+ else if (format == HTMLText) {
+ // TODO: It does not appear this is ever called
+ }
+ else { //plain text requested
+ return selectedText();
+ }
+ }
+
+ case AnchorOnly: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+
+ return keyName;
+ }
+
+ case AnchorTextOnly: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+
+ if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( keyName );
+
+ return key->strippedText();
+ }
+ return QString::null;
+ }
+
+ case AnchorWithText: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::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
+ CSwordBackend::FilterOptions filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CPointers::backend()->setFilterOptions(filterOptions);
+
+ return QString(key->strippedText()).append("\n(")
+ .append(key->key())
+ .append(", ")
+ .append(key->module()->name())
+ .append(")");
+ /* ("%1\n(%2, %3)")
+ .arg()
+ .arg(key->key())
+ .arg(key->module()->name());*/
+ }
+ return QString::null;
+ }
+ default:
+ return QString::null;
+ }
+ return QString();
}
// Puts html text and javascript into QWebView
-void BtHtmlReadDisplay::setText( const QString& newText )
-{
- QString jsText = newText;
+void BtHtmlReadDisplay::setText( const QString& newText ) {
+ QString jsText = newText;
- jsText.replace(body,jsBegin+javascript+jsEnd+body);
+ jsText.replace(body, jsBegin + javascript + jsEnd + body);
- // Disconnect any previous connect and connect to slot that loads the javascript object
- QWebFrame* frame = mainFrame();
- disconnect(frame,SIGNAL(javaScriptWindowObjectCleared()),0,0);
- bool ok = connect(frame,SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(loadJSObject()));
- Q_ASSERT(ok);
+ // Disconnect any previous connect and connect to slot that loads the javascript object
+ QWebFrame* frame = mainFrame();
+ disconnect(frame, SIGNAL(javaScriptWindowObjectCleared()), 0, 0);
+ bool ok = connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(loadJSObject()));
+ Q_ASSERT(ok);
- // Send text to the html viewer
- m_view->setHtml(jsText);
+ // Send text to the html viewer
+ m_view->setHtml(jsText);
}
// See if any text is selected
-bool BtHtmlReadDisplay::hasSelection()
-{
- if (selectedText().isEmpty())
- return false;
- return true;
+bool BtHtmlReadDisplay::hasSelection() {
+ if (selectedText().isEmpty())
+ return false;
+ return true;
}
// Reimplementation
// Returns the BtHtmlReadDisplayView object
-QWidget* BtHtmlReadDisplay::view()
-{
- return m_view;
+QWidget* BtHtmlReadDisplay::view() {
+ return m_view;
}
// Select all text in the viewer
-void BtHtmlReadDisplay::selectAll()
-{
- m_jsObject->setBodyEditable(true);
+void BtHtmlReadDisplay::selectAll() {
+ m_jsObject->setBodyEditable(true);
m_view->triggerPageAction( QWebPage::MoveToStartOfDocument, true );
m_view->triggerPageAction( QWebPage::SelectEndOfDocument, true );
- m_jsObject->setBodyEditable(false);
+ m_jsObject->setBodyEditable(false);
}
// Scroll QWebView to the correct location as specified by the anchor
-void BtHtmlReadDisplay::moveToAnchor( const QString& anchor )
-{
- slotGoToAnchor(anchor);
+void BtHtmlReadDisplay::moveToAnchor( const QString& anchor ) {
+ slotGoToAnchor(anchor);
}
// Scroll the QWebView to the correct location specified by anchor
-void BtHtmlReadDisplay::slotGoToAnchor(const QString& anchor)
-{
- m_jsObject->moveToAnchor(anchor);
+void BtHtmlReadDisplay::slotGoToAnchor(const QString& anchor) {
+ m_jsObject->moveToAnchor(anchor);
}
-// Save the Lemma (Strongs number) attribute
-void BtHtmlReadDisplay::setLemma(const QString& lemma)
-{
- m_nodeInfo[ CDisplay::Lemma ] = lemma;
+// Save the Lemma (Strongs number) attribute
+void BtHtmlReadDisplay::setLemma(const QString& lemma) {
+ m_nodeInfo[ CDisplay::Lemma ] = lemma;
}
// Open the Find text dialog
-void BtHtmlReadDisplay::openFindTextDialog()
-{
- CMDIArea* mdiArea = parentWindow()->mdi();
- showBtHtmlFindText(mdiArea);
+void BtHtmlReadDisplay::openFindTextDialog() {
+ CMDIArea* mdiArea = parentWindow()->mdi();
+ showBtHtmlFindText(mdiArea);
}
// Send "completed" signal when the text is finished loading into the viewer
-void BtHtmlReadDisplay::slotLoadFinished(bool)
-{
- emit completed();
+void BtHtmlReadDisplay::slotLoadFinished(bool) {
+ emit completed();
}
// For debugging javascript - set breakpoint in this function to catch javascript error messages
#if DEBUG_JS
-void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int lineNumber, const QString& sourceID )
-{
+void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int lineNumber, const QString& sourceID ) {
}
#endif
@@ -297,77 +267,64 @@ void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int li
// ----------------- BtHtmlReadDisplayView -------------------------------------
-BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent)
- : QWebView(parent), m_display(displayWidget)
-{
+BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent)
+ : QWebView(parent), m_display(displayWidget) {
}
-BtHtmlReadDisplayView::~BtHtmlReadDisplayView()
- {
- setPage(0);
- }
+BtHtmlReadDisplayView::~BtHtmlReadDisplayView() {
+ setPage(0);
+}
// Create the right mouse context menus
-void BtHtmlReadDisplayView::contextMenuEvent(QContextMenuEvent* event)
-{
- if (QMenu* popup = m_display->installedPopup())
- {
- popup->exec(event->globalPos());
- }
+void BtHtmlReadDisplayView::contextMenuEvent(QContextMenuEvent* event) {
+ if (QMenu* popup = m_display->installedPopup()) {
+ popup->exec(event->globalPos());
+ }
}
// Reimplementation from QWidget
-void BtHtmlReadDisplayView::dropEvent( QDropEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- //see docs for BTMimeData and QMimeData
- const QMimeData* mimedata = e->mimeData();
- if (mimedata != 0)
- {
- const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata);
- if (btmimedata != 0)
- {
- BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark();
- m_display->connectionsProxy()->emitReferenceDropped(item.key());
- e->acceptProposedAction();
- return;
- }
- }
- };
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dropEvent( QDropEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ //see docs for BTMimeData and QMimeData
+ const QMimeData* mimedata = e->mimeData();
+ if (mimedata != 0) {
+ const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata);
+ if (btmimedata != 0) {
+ BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark();
+ m_display->connectionsProxy()->emitReferenceDropped(item.key());
+ e->acceptProposedAction();
+ return;
+ }
+ }
+ };
+ //don't accept the action!
+ e->ignore();
}
// Reimplementation from QWebView
-void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- e->acceptProposedAction();
- return;
- }
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ e->acceptProposedAction();
+ return;
+ }
+ //don't accept the action!
+ e->ignore();
}
// Reimplementation from QWebView
-void BtHtmlReadDisplayView::dragMoveEvent( QDragMoveEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- e->acceptProposedAction();
- return;
- }
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dragMoveEvent( QDragMoveEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ e->acceptProposedAction();
+ return;
+ }
+ //don't accept the action!
+ e->ignore();
}
-bool BtHtmlReadDisplayView::event(QEvent* e)
-{
+bool BtHtmlReadDisplayView::event(QEvent* e) {
// If the mouse leaves the widget clear the previous attribute
// in bthtmljsobject. This cancels any time out event that
- // is in progress.
+ // is in progress.
if ( e->type() == QEvent::Leave )
m_display->m_jsObject->clearPrevAttribute();
return QWidget::event(e);
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index 8a832bc..020a685 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -33,92 +33,87 @@ class QEvent;
/** The implementation for the HTML read display.
* @author The BibleTime team
*/
-class BtHtmlReadDisplay : public QWebPage, public CReadDisplay
-{
- Q_OBJECT
-
- friend class BtHtmlReadDisplayView;
-
-public:
- //reimplemented functions from CDisplay
- // Returns the right text part in the specified format.
- virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
- const CDisplay::TextPart part = CDisplay::Document );
-
- // Sets the new text for this display widget.
- virtual void setText( const QString& newText );
- virtual bool hasSelection();
-
- // Reimplementation.
- virtual void selectAll();
- virtual void moveToAnchor( const QString& anchor );
- virtual void openFindTextDialog();
- virtual QMap<CDisplay::NodeInfoType, QString> getCurrentNodeInfo()
- {
- return m_nodeInfo;
- }
- QWidget* view();
- void setLemma(const QString& lemma);
-
-public slots:
- void loadJSObject();
- void slotLoadFinished(bool);
-
-signals:
- void completed();
-
-protected:
- friend class CDisplay;
- BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
- virtual ~BtHtmlReadDisplay();
- void slotGoToAnchor(const QString& anchor);
- struct DNDData
- {
- bool mousePressed;
- bool isDragging;
- QString selection;
- QPoint startPos;
- enum DragType
- {
- Link,
- Text
- } dragType;
- }
- m_dndData;
-
- QMap<NodeInfoType, QString> m_nodeInfo;
- int m_magTimerId;
+class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
+ Q_OBJECT
+
+ friend class BtHtmlReadDisplayView;
+
+ public:
+ //reimplemented functions from CDisplay
+ // Returns the right text part in the specified format.
+ virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
+ const CDisplay::TextPart part = CDisplay::Document );
+
+ // Sets the new text for this display widget.
+ virtual void setText( const QString& newText );
+ virtual bool hasSelection();
+
+ // Reimplementation.
+ virtual void selectAll();
+ virtual void moveToAnchor( const QString& anchor );
+ virtual void openFindTextDialog();
+ virtual QMap<CDisplay::NodeInfoType, QString> getCurrentNodeInfo() {
+ return m_nodeInfo;
+ }
+ QWidget* view();
+ void setLemma(const QString& lemma);
+
+ public slots:
+ void loadJSObject();
+ void slotLoadFinished(bool);
+
+ signals:
+ void completed();
+
+ protected:
+ friend class CDisplay;
+ BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
+ virtual ~BtHtmlReadDisplay();
+ void slotGoToAnchor(const QString& anchor);
+ struct DNDData {
+ bool mousePressed;
+ bool isDragging;
+ QString selection;
+ QPoint startPos;
+ enum DragType {
+ Link,
+ Text
+ } dragType;
+ }
+ m_dndData;
+
+ QMap<NodeInfoType, QString> m_nodeInfo;
+ int m_magTimerId;
// For debugging javascript - setbreakpoint in this function to catch javascript error messages
//#define DEBUG_JS
#ifdef DEBUG_JS
- void javaScriptConsoleMessage (const QString & message, int lineNumber, const QString & sourceID );
+ void javaScriptConsoleMessage (const QString & message, int lineNumber, const QString & sourceID );
#endif
-private:
- void initJavascript();
- BtHtmlReadDisplayView* m_view;
- BtHtmlJsObject* m_jsObject;
- QString m_currentAnchorCache;
+ private:
+ void initJavascript();
+ BtHtmlReadDisplayView* m_view;
+ BtHtmlJsObject* m_jsObject;
+ QString m_currentAnchorCache;
};
-class BtHtmlReadDisplayView : public QWebView, public CPointers
-{
- Q_OBJECT
-protected:
- friend class BtHtmlReadDisplay;
- void contextMenuEvent(QContextMenuEvent* event);
- BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent);
- ~BtHtmlReadDisplayView();
- bool event(QEvent* e);
-
-private:
- BtHtmlReadDisplay* m_display;
- void dropEvent( QDropEvent* e );
- void dragEnterEvent( QDragEnterEvent* e );
- void dragMoveEvent( QDragMoveEvent* e );
+class BtHtmlReadDisplayView : public QWebView, public CPointers {
+ Q_OBJECT
+ protected:
+ friend class BtHtmlReadDisplay;
+ void contextMenuEvent(QContextMenuEvent* event);
+ BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent);
+ ~BtHtmlReadDisplayView();
+ bool event(QEvent* e);
+
+ private:
+ BtHtmlReadDisplay* m_display;
+ void dropEvent( QDropEvent* e );
+ void dragEnterEvent( QDragEnterEvent* e );
+ void dragMoveEvent( QDragMoveEvent* e );
};
#endif
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 9333bd9..b66f8af 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -34,175 +34,174 @@ typedef BtHtmlReadDisplay HTMLREADDISPLAY;
CDisplayConnections::CDisplayConnections( CDisplay* display ) : m_display(display) {}
void CDisplayConnections::selectAll() {
- m_display->selectAll();
+ m_display->selectAll();
}
void CDisplayConnections::saveAsHTML() {
- m_display->save(CDisplay::HTMLText, CDisplay::Document);
+ m_display->save(CDisplay::HTMLText, CDisplay::Document);
}
void CDisplayConnections::saveAsPlain() {
- m_display->save(CDisplay::PlainText, CDisplay::Document);
+ m_display->save(CDisplay::PlainText, CDisplay::Document);
}
/** Emits the signal. */
void CDisplayConnections::emitReferenceClicked( const QString& module, const QString& key) {
- qDebug("CDisplayConnections::emitReferenceClicked");
- qDebug() << "Module: " << module << " key: " << key;
- emit referenceClicked( module, key );
+ qDebug("CDisplayConnections::emitReferenceClicked");
+ qDebug() << "Module: " << module << " key: " << key;
+ emit referenceClicked( module, key );
}
/** Emits the signal. */
void CDisplayConnections::emitReferenceDropped( const QString& key) {
- emit referenceDropped(key);
+ emit referenceDropped(key);
}
/** Emits the signal. */
void CDisplayConnections::emitTextChanged() {
- emit textChanged();
+ emit textChanged();
}
void CDisplayConnections::copyAll() {
- m_display->copy(CDisplay::PlainText, CDisplay::Document);
+ m_display->copy(CDisplay::PlainText, CDisplay::Document);
}
/** No descriptions */
void CDisplayConnections::copySelection() {
- qWarning("copyign the selected text");
- m_display->copy(CDisplay::PlainText, CDisplay::SelectedText);
+ qWarning("copyign the selected text");
+ m_display->copy(CDisplay::PlainText, CDisplay::SelectedText);
}
void CDisplayConnections::printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- m_display->print(CDisplay::Document, displayOptions, filterOptions);
+ m_display->print(CDisplay::Document, displayOptions, filterOptions);
}
void CDisplayConnections::printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions);
+ m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions);
}
void CDisplayConnections::copyAnchorOnly() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorOnly);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorOnly);
}
void CDisplayConnections::copyAnchorTextOnly() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorTextOnly);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorTextOnly);
}
void CDisplayConnections::copyAnchorWithText() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorWithText);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorWithText);
}
void CDisplayConnections::saveAnchorWithText() {
- m_display->save(CDisplay::PlainText, CDisplay::AnchorWithText);
+ m_display->save(CDisplay::PlainText, CDisplay::AnchorWithText);
}
void CDisplayConnections::clear() {
- m_display->setText(QString::null);
+ m_display->setText(QString::null);
}
void CDisplayConnections::zoomIn() {
- m_display->zoomIn();
+ m_display->zoomIn();
}
void CDisplayConnections::zoomOut() {
- m_display->zoomOut();
+ m_display->zoomOut();
}
void CDisplayConnections::openFindTextDialog() {
- m_display->openFindTextDialog();
+ m_display->openFindTextDialog();
}
/*----------------------*/
-CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent )
-{
- return new HTMLREADDISPLAY(readWindow, parent);
+CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
+ return new HTMLREADDISPLAY(readWindow, parent);
}
CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
- // qWarning("CDisplay::createWriteInstance");
- if (type == PlainTextDisplay) {
- return new CPlainWriteDisplay(writeWindow, parent);
- }
- else {
- return new CHTMLWriteDisplay(writeWindow, parent);
- };
+ // qWarning("CDisplay::createWriteInstance");
+ if (type == PlainTextDisplay) {
+ return new CPlainWriteDisplay(writeWindow, parent);
+ }
+ else {
+ return new CHTMLWriteDisplay(writeWindow, parent);
+ };
}
CDisplay::CDisplay(CDisplayWindow* parent) :
-m_parentWindow(parent),
-m_connections( new CDisplayConnections( this ) ),
-m_popup(0) {}
+ m_parentWindow(parent),
+ m_connections( new CDisplayConnections( this ) ),
+ m_popup(0) {}
CDisplay::~CDisplay() {
- delete m_connections;
+ delete m_connections;
}
bool CDisplay::copy( const CDisplay::TextType format, const CDisplay::TextPart part ) {
- QApplication::clipboard()->setText( this->text(format, part) );
- return true;
+ QApplication::clipboard()->setText( this->text(format, part) );
+ return true;
}
bool CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part ) {
- // qWarning("CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part )");
- const QString content = text(format, part);
- QString filter = QString::null;
+ // qWarning("CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part )");
+ const QString content = text(format, part);
+ QString filter = QString::null;
- switch (format) {
- case HTMLText:
- filter = QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
- break;
- case PlainText:
- filter = QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
- break;
- }
+ switch (format) {
+ case HTMLText:
+ filter = QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
+ break;
+ case PlainText:
+ filter = QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
+ break;
+ }
- const QString filename = QFileDialog::getSaveFileName(0, QObject::tr("Save document ..."), "", filter);
+ const QString filename = QFileDialog::getSaveFileName(0, QObject::tr("Save document ..."), "", filter);
- if (!filename.isEmpty()) {
- CToolClass::savePlainFile(filename, content);
- }
- return true;
+ if (!filename.isEmpty()) {
+ CToolClass::savePlainFile(filename, content);
+ }
+ return true;
}
/** 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);
- if (module.isEmpty()) {
- module = CReferenceManager::preferredModule( type );
- }
- m_connections->emitReferenceClicked(module, key);
+ QString module, key;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(reference, module, key, type);
+ if (module.isEmpty()) {
+ module = CReferenceManager::preferredModule( type );
+ }
+ m_connections->emitReferenceClicked(module, key);
}
/** Used when a reference was dropped onto the widget. */
void CDisplay::emitReferenceDropped( const QString& reference ) {
- QString module;
- QString key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(reference, module, key, type);
- m_connections->emitReferenceDropped(key);
+ QString module;
+ QString key;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(reference, module, key, type);
+ m_connections->emitReferenceDropped(key);
}
/** Returns the connections obect used for signas and slots. */
CDisplayConnections* CDisplay::connectionsProxy() const {
- return m_connections;
+ return m_connections;
}
CDisplayWindow* CDisplay::parentWindow() const {
- return m_parentWindow;
+ return m_parentWindow;
}
/** Installs the popup which should be opened when the right mouse button was pressed. */
void CDisplay::installPopup( QMenu* popup ) {
- m_popup = popup;
+ m_popup = popup;
}
/** Returns the popup menu which was set by installPopupMenu() */
QMenu* CDisplay::installedPopup() {
- return m_popup;
+ return m_popup;
}
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index 59a6a37..0fdaa0e 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -34,153 +34,153 @@ class QMenu;
* @author The BibleTime team
*/
class CDisplay : public CPointers {
-public:
- enum WriteDisplayType {
- HTMLDisplay = 0,
- PlainTextDisplay
- };
-
- static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow, const WriteDisplayType& type = PlainTextDisplay, QWidget* parent = 0 );
-
- enum TextType {
- HTMLText, /* Used for HTML markup */
- PlainText /* Plain text without links etc. */
- };
- enum TextPart {
- Document, /* All text */
- SelectedText, /* Only the selected text */
- AnchorOnly,
- AnchorTextOnly,
- AnchorWithText
- };
-
- /**
- * Copies the given text with the specified format into the applications clipboard.
- */
- virtual bool copy( const CDisplay::TextType format, const CDisplay::TextPart part );
- /**
- * Saves the given text with the specified format into the applications clipboard.
- */
- virtual bool save( const CDisplay::TextType format, const CDisplay::TextPart part );
-
- //the pure virtual methods of this base class
-
- /** Returns the text in the given format.
- *
- */
- virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ) = 0;
- /**
- * Sets the new text for this display widget.
- */
- virtual void setText( const QString& newText ) = 0;
- /**
- * Returns true if the display widget has a selection. Otherwise false.
- */
- virtual bool hasSelection() = 0;
- /**
- * Returns the view of this display widget.
- */
- virtual QWidget* view() = 0;
- /**
- * Selects the document text.
- */
- virtual void selectAll() = 0;
- /**
- * Returns the connections obect used for signas and slots.
- */
- virtual CDisplayConnections* connectionsProxy() const;
- /**
- * Returns the parent window used for this display widget.
- */
- CDisplayWindow* parentWindow() const;
- virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) = 0;
- /**
- * Installs the popup which should be opened when the right mouse button was pressed.
- */
- void installPopup( QMenu* popup );
- /**
- * Returns the popup menu which was set by installPopupMenu()
- */
- QMenu* installedPopup();
-
- virtual void zoomIn() {}
- virtual void zoomOut() {}
- virtual void openFindTextDialog() {}
-
- enum NodeInfoType {
- Lemma
- };
-
-
- virtual QMap<NodeInfoType, QString> getCurrentNodeInfo() {
- return QMap<NodeInfoType, QString>();
- }
-
-protected:
- /**
- * Used when a reference was dropped onto the widget.
- */
- void emitReferenceDropped( const QString& reference );
- /**
- * Emits the signal which used when a reference was clicked.
- */
- void emitReferenceClicked( const QString& reference );
-
-protected:
- CDisplay(CDisplayWindow* parent);
- virtual ~CDisplay();
-
-private:
- CDisplayWindow* m_parentWindow;
- CDisplayConnections* m_connections;
- QMenu* m_popup;
+ public:
+ enum WriteDisplayType {
+ HTMLDisplay = 0,
+ PlainTextDisplay
+ };
+
+ static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
+ static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow, const WriteDisplayType& type = PlainTextDisplay, QWidget* parent = 0 );
+
+ enum TextType {
+ HTMLText, /* Used for HTML markup */
+ PlainText /* Plain text without links etc. */
+ };
+ enum TextPart {
+ Document, /* All text */
+ SelectedText, /* Only the selected text */
+ AnchorOnly,
+ AnchorTextOnly,
+ AnchorWithText
+ };
+
+ /**
+ * Copies the given text with the specified format into the applications clipboard.
+ */
+ virtual bool copy( const CDisplay::TextType format, const CDisplay::TextPart part );
+ /**
+ * Saves the given text with the specified format into the applications clipboard.
+ */
+ virtual bool save( const CDisplay::TextType format, const CDisplay::TextPart part );
+
+ //the pure virtual methods of this base class
+
+ /** Returns the text in the given format.
+ *
+ */
+ virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ) = 0;
+ /**
+ * Sets the new text for this display widget.
+ */
+ virtual void setText( const QString& newText ) = 0;
+ /**
+ * Returns true if the display widget has a selection. Otherwise false.
+ */
+ virtual bool hasSelection() = 0;
+ /**
+ * Returns the view of this display widget.
+ */
+ virtual QWidget* view() = 0;
+ /**
+ * Selects the document text.
+ */
+ virtual void selectAll() = 0;
+ /**
+ * Returns the connections obect used for signas and slots.
+ */
+ virtual CDisplayConnections* connectionsProxy() const;
+ /**
+ * Returns the parent window used for this display widget.
+ */
+ CDisplayWindow* parentWindow() const;
+ virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) = 0;
+ /**
+ * Installs the popup which should be opened when the right mouse button was pressed.
+ */
+ void installPopup( QMenu* popup );
+ /**
+ * Returns the popup menu which was set by installPopupMenu()
+ */
+ QMenu* installedPopup();
+
+ virtual void zoomIn() {}
+ virtual void zoomOut() {}
+ virtual void openFindTextDialog() {}
+
+ enum NodeInfoType {
+ Lemma
+ };
+
+
+ virtual QMap<NodeInfoType, QString> getCurrentNodeInfo() {
+ return QMap<NodeInfoType, QString>();
+ }
+
+ protected:
+ /**
+ * Used when a reference was dropped onto the widget.
+ */
+ void emitReferenceDropped( const QString& reference );
+ /**
+ * Emits the signal which used when a reference was clicked.
+ */
+ void emitReferenceClicked( const QString& reference );
+
+ protected:
+ CDisplay(CDisplayWindow* parent);
+ virtual ~CDisplay();
+
+ private:
+ CDisplayWindow* m_parentWindow;
+ CDisplayConnections* m_connections;
+ QMenu* m_popup;
};
class CDisplayConnections : public QObject {
- Q_OBJECT
-public:
- CDisplayConnections( CDisplay* parent );
+ Q_OBJECT
+ public:
+ CDisplayConnections( CDisplay* parent );
-public slots:
- virtual void selectAll();
- void emitReferenceClicked( const QString& module, const QString& key);
- void emitReferenceDropped( const QString& key );
- void emitTextChanged();
+ public slots:
+ virtual void selectAll();
+ void emitReferenceClicked( const QString& module, const QString& key);
+ void emitReferenceDropped( const QString& key );
+ void emitTextChanged();
- //stuff which works in every CDisplay
- void saveAsPlain();
- void saveAsHTML();
- void saveAnchorWithText();
+ //stuff which works in every CDisplay
+ void saveAsPlain();
+ void saveAsHTML();
+ void saveAnchorWithText();
- void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void copySelection();
- void copyAll();
- void copyAnchorWithText();
- void copyAnchorTextOnly();
- void copyAnchorOnly();
+ void copySelection();
+ void copyAll();
+ void copyAnchorWithText();
+ void copyAnchorTextOnly();
+ void copyAnchorOnly();
- void clear();
+ void clear();
- void zoomIn();
- void zoomOut();
+ void zoomIn();
+ void zoomOut();
- void openFindTextDialog();
+ void openFindTextDialog();
-signals:
- void referenceClicked(const QString& module, const QString& key);
- void referenceDropped(const QString& key);
- void textChanged();
+ signals:
+ void referenceClicked(const QString& module, const QString& key);
+ void referenceDropped(const QString& key);
+ void textChanged();
-private:
- CDisplay* m_display;
+ private:
+ CDisplay* m_display;
- struct {
- QString module;
- QString key;
- } m_referenceClickedCache;
+ struct {
+ QString module;
+ QString key;
+ } m_referenceClickedCache;
};
#endif
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index 4b9246e..d238b0d 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -27,259 +27,233 @@
class BtActionCollection;
CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
-: CPlainWriteDisplay(parentWindow,parent), m_fontFamilyChooser(0),
- m_fontSizeChooser(0), m_colorChooser(0)
-{
- m_actions.bold = 0;
- m_actions.italic = 0;
- m_actions.underline = 0;
- m_actions.selectAll = 0;
-
- setAcceptRichText(true);
- setAcceptDrops(true);
- viewport()->setAcceptDrops(true);
+ : CPlainWriteDisplay(parentWindow, parent), m_fontFamilyChooser(0),
+ m_fontSizeChooser(0), m_colorChooser(0) {
+ m_actions.bold = 0;
+ m_actions.italic = 0;
+ m_actions.underline = 0;
+ m_actions.selectAll = 0;
+
+ setAcceptRichText(true);
+ setAcceptDrops(true);
+ viewport()->setAcceptDrops(true);
}
-CHTMLWriteDisplay::~CHTMLWriteDisplay()
-{
+CHTMLWriteDisplay::~CHTMLWriteDisplay() {
}
-void CHTMLWriteDisplay::setText( const QString& newText )
-{
- QTextEdit::setHtml(newText);
+void CHTMLWriteDisplay::setText( const QString& newText ) {
+ QTextEdit::setHtml(newText);
}
-const QString CHTMLWriteDisplay::plainText()
-{
- return QTextEdit::toPlainText();
+const QString CHTMLWriteDisplay::plainText() {
+ return QTextEdit::toPlainText();
}
-void CHTMLWriteDisplay::toggleBold(bool)
-{
- setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
+void CHTMLWriteDisplay::toggleBold(bool) {
+ setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
}
-void CHTMLWriteDisplay::toggleItalic(bool)
-{
- setFontItalic( m_actions.italic->isChecked() );
+void CHTMLWriteDisplay::toggleItalic(bool) {
+ setFontItalic( m_actions.italic->isChecked() );
}
-void CHTMLWriteDisplay::toggleUnderline(bool)
-{
- setFontUnderline( m_actions.underline->isChecked() );
+void CHTMLWriteDisplay::toggleUnderline(bool) {
+ setFontUnderline( m_actions.underline->isChecked() );
}
-void CHTMLWriteDisplay::alignLeft(bool set)
-{
- if (set && (alignment() != Qt::AlignLeft))
- {
- setAlignment(Qt::AlignLeft);
- slotAlignmentChanged(Qt::AlignLeft);
- }
+void CHTMLWriteDisplay::alignLeft(bool set) {
+ if (set && (alignment() != Qt::AlignLeft)) {
+ setAlignment(Qt::AlignLeft);
+ slotAlignmentChanged(Qt::AlignLeft);
+ }
}
-void CHTMLWriteDisplay::alignCenter(bool set)
-{
- if (set && (alignment() != Qt::AlignHCenter))
- {
- setAlignment(Qt::AlignHCenter);
- slotAlignmentChanged(Qt::AlignHCenter);
- }
+void CHTMLWriteDisplay::alignCenter(bool set) {
+ if (set && (alignment() != Qt::AlignHCenter)) {
+ setAlignment(Qt::AlignHCenter);
+ slotAlignmentChanged(Qt::AlignHCenter);
+ }
}
-void CHTMLWriteDisplay::alignRight(bool set)
-{
- if (set && (alignment() != Qt::AlignRight))
- {
- setAlignment(Qt::AlignRight);
- slotAlignmentChanged(Qt::AlignRight);
- }
+void CHTMLWriteDisplay::alignRight(bool set) {
+ if (set && (alignment() != Qt::AlignRight)) {
+ setAlignment(Qt::AlignRight);
+ slotAlignmentChanged(Qt::AlignRight);
+ }
}
/** The text's alignment changed. Enable the right buttons. */
-void CHTMLWriteDisplay::slotAlignmentChanged( int a )
-{
- bool alignLeft = false;
- bool alignCenter = false;
- bool alignRight = false;
-
- if (a & Qt::AlignLeft)
- {
- alignLeft = true;
- }
- else if ((a & Qt::AlignHCenter) || (a & Qt::AlignCenter))
- {
- alignCenter = true;
- }
- else if (a & Qt::AlignRight)
- {
- alignRight = true;
- }
- else
- {
- alignLeft = true;
- qWarning("unknown alignment %i", a);
- }
-
- m_actions.alignLeft->setChecked( alignLeft );
- m_actions.alignCenter->setChecked( alignCenter );
- m_actions.alignRight->setChecked( alignRight );
+void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
+ bool alignLeft = false;
+ bool alignCenter = false;
+ bool alignRight = false;
+
+ if (a & Qt::AlignLeft) {
+ alignLeft = true;
+ }
+ else if ((a & Qt::AlignHCenter) || (a & Qt::AlignCenter)) {
+ alignCenter = true;
+ }
+ else if (a & Qt::AlignRight) {
+ alignRight = true;
+ }
+ else {
+ alignLeft = true;
+ qWarning("unknown alignment %i", a);
+ }
+
+ m_actions.alignLeft->setChecked( alignLeft );
+ m_actions.alignCenter->setChecked( alignCenter );
+ m_actions.alignRight->setChecked( alignRight );
}
-void CHTMLWriteDisplay::changeFontSize(int newSize)
-{
- setFontPointSize((qreal)newSize);
+void CHTMLWriteDisplay::changeFontSize(int newSize) {
+ setFontPointSize((qreal)newSize);
}
/** Is called when a new color was selected. */
-void CHTMLWriteDisplay::slotColorSelected( const QColor& c)
-{
- setTextColor( c );
+void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
+ setTextColor( c );
}
/** Is called when a text with another color was selected. */
-void CHTMLWriteDisplay::slotColorChanged(const QColor& c)
-{
- m_colorChooser->setColor(c);
+void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
+ m_colorChooser->setColor(c);
}
-void CHTMLWriteDisplay::slotFontChanged( const QFont& font )
-{
- m_fontFamilyChooser->setCurrentFont(font);
- m_fontSizeChooser->setFontSize( font.pointSize() );
+void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
+ m_fontFamilyChooser->setCurrentFont(font);
+ m_fontSizeChooser->setFontSize( font.pointSize() );
- m_actions.bold->setChecked( font.bold() );
- m_actions.italic->setChecked( font.italic() );
- m_actions.underline->setChecked( font.underline() );
+ m_actions.bold->setChecked( font.bold() );
+ m_actions.italic->setChecked( font.italic() );
+ m_actions.underline->setChecked( font.underline() );
}
-void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font)
-{
- setFontFamily(font.family());
+void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
+ setFontFamily(font.family());
}
-void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions)
-{
- //--------------------font chooser-------------------------
- m_fontFamilyChooser = new QFontComboBox(this);
- actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser);
- m_fontFamilyChooser->setToolTip( tr("Font") );
- bar->addWidget(m_fontFamilyChooser);
- bool ok = connect(m_fontFamilyChooser, SIGNAL(currentFontChanged(const QFont&)),
- this, SLOT(slotFontFamilyChoosen(const QFont&)));
- Q_ASSERT(ok);
-
- //--------------------font size chooser-------------------------
- m_fontSizeChooser = new BtFontSizeWidget(this);
- m_fontSizeChooser->setToolTip( tr("Font size") );
- bar->addWidget(m_fontSizeChooser);
- ok = connect(m_fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
- Q_ASSERT(ok);
-
- //--------------------color button-------------------------
- m_colorChooser = new BtColorWidget();
- m_colorChooser->setToolTip(tr("Font color"));
- bar->addWidget(m_colorChooser);
- ok = connect(m_colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
- Q_ASSERT(ok);
-
- bar->addSeparator();
-
- //--------------------bold toggle-------------------------
- m_actions.bold = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
- tr("Bold"),
- actions);
- m_actions.bold->setCheckable(true);
- m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::boldText::actionName, m_actions.bold);
- m_actions.bold->setToolTip( tr("Bold") );
- connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
-
- bar->addAction(m_actions.bold);
-
- //--------------------italic toggle-------------------------
- m_actions.italic = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
- tr("Italic"),
- actions );
- m_actions.italic->setCheckable(true);
- m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::italicText::actionName, m_actions.italic);
- connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
- m_actions.italic->setToolTip( tr("Italic") );
- bar->addAction(m_actions.italic);
-
- //--------------------underline toggle-------------------------
- m_actions.underline = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
- tr("Underline"),
- actions );
- m_actions.underline->setCheckable(true);
- m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::underlinedText::actionName, m_actions.underline);
- connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
- m_actions.underline->setToolTip( tr("Underline") );
- bar->addAction(m_actions.underline);
-
- //seperate formatting from alignment buttons
- bar->addSeparator();
-
- //--------------------align left toggle-------------------------
- m_actions.alignLeft = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
- tr("Left"), actions);
- m_actions.alignLeft->setCheckable(true);
- m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignLeft::actionName, m_actions.alignLeft);
- connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
- m_actions.alignLeft->setToolTip( tr("Align left") );
- bar->addAction(m_actions.alignLeft);
-
- //--------------------align center toggle-------------------------
- m_actions.alignCenter = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
- tr("Center"), actions);
- m_actions.alignCenter->setCheckable(true);
- m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignCenter::actionName, m_actions.alignCenter);
- connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
- m_actions.alignCenter->setToolTip( tr("Center") );
- bar->addAction(m_actions.alignCenter);
-
- //--------------------align right toggle-------------------------
- m_actions.alignRight = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
- tr("Right"), actions);
- m_actions.alignRight->setCheckable(true);
- m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignRight::actionName, m_actions.alignRight);
- connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
- m_actions.alignRight->setToolTip( tr("Align right") );
- bar->addAction(m_actions.alignRight);
-
- connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
- connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
- connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
-
- //set initial values for toolbar items
- slotFontChanged( font() );
- slotAlignmentChanged( alignment() );
- slotColorChanged( textColor() );
+void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ //--------------------font chooser-------------------------
+ m_fontFamilyChooser = new QFontComboBox(this);
+ actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser);
+ m_fontFamilyChooser->setToolTip( tr("Font") );
+ bar->addWidget(m_fontFamilyChooser);
+ bool ok = connect(m_fontFamilyChooser, SIGNAL(currentFontChanged(const QFont&)),
+ this, SLOT(slotFontFamilyChoosen(const QFont&)));
+ Q_ASSERT(ok);
+
+ //--------------------font size chooser-------------------------
+ m_fontSizeChooser = new BtFontSizeWidget(this);
+ m_fontSizeChooser->setToolTip( tr("Font size") );
+ bar->addWidget(m_fontSizeChooser);
+ ok = connect(m_fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ Q_ASSERT(ok);
+
+ //--------------------color button-------------------------
+ m_colorChooser = new BtColorWidget();
+ m_colorChooser->setToolTip(tr("Font color"));
+ bar->addWidget(m_colorChooser);
+ ok = connect(m_colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ Q_ASSERT(ok);
+
+ bar->addSeparator();
+
+ //--------------------bold toggle-------------------------
+ m_actions.bold = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ tr("Bold"),
+ actions);
+ m_actions.bold->setCheckable(true);
+ m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::boldText::actionName, m_actions.bold);
+ m_actions.bold->setToolTip( tr("Bold") );
+ connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
+
+ bar->addAction(m_actions.bold);
+
+ //--------------------italic toggle-------------------------
+ m_actions.italic = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ tr("Italic"),
+ actions );
+ m_actions.italic->setCheckable(true);
+ m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::italicText::actionName, m_actions.italic);
+ connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
+ m_actions.italic->setToolTip( tr("Italic") );
+ bar->addAction(m_actions.italic);
+
+ //--------------------underline toggle-------------------------
+ m_actions.underline = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ tr("Underline"),
+ actions );
+ m_actions.underline->setCheckable(true);
+ m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::underlinedText::actionName, m_actions.underline);
+ connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
+ m_actions.underline->setToolTip( tr("Underline") );
+ bar->addAction(m_actions.underline);
+
+ //seperate formatting from alignment buttons
+ bar->addSeparator();
+
+ //--------------------align left toggle-------------------------
+ m_actions.alignLeft = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
+ tr("Left"), actions);
+ m_actions.alignLeft->setCheckable(true);
+ m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::alignLeft::actionName, m_actions.alignLeft);
+ connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
+ m_actions.alignLeft->setToolTip( tr("Align left") );
+ bar->addAction(m_actions.alignLeft);
+
+ //--------------------align center toggle-------------------------
+ m_actions.alignCenter = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
+ tr("Center"), actions);
+ m_actions.alignCenter->setCheckable(true);
+ m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::alignCenter::actionName, m_actions.alignCenter);
+ connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
+ m_actions.alignCenter->setToolTip( tr("Center") );
+ bar->addAction(m_actions.alignCenter);
+
+ //--------------------align right toggle-------------------------
+ m_actions.alignRight = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
+ tr("Right"), actions);
+ m_actions.alignRight->setCheckable(true);
+ m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
+ actions->addAction(CResMgr::displaywindows::writeWindow::alignRight::actionName, m_actions.alignRight);
+ connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
+ m_actions.alignRight->setToolTip( tr("Align right") );
+ bar->addAction(m_actions.alignRight);
+
+ connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
+ connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
+ connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
+
+ //set initial values for toolbar items
+ slotFontChanged( font() );
+ slotAlignmentChanged( alignment() );
+ slotColorChanged( textColor() );
}
/** Reimplementation to show a popup menu if the right mouse button was clicked. */
-QMenu* CHTMLWriteDisplay::createPopupMenu( const QPoint& )
-{
- if (!m_actions.selectAll)
- {
- m_actions.selectAll = new QAction(tr("Select all"), this);
- connect(m_actions.selectAll, SIGNAL(triggered(bool)), SLOT(selectAll()));
- }
-
- QMenu* popup = new QMenu(this);
- popup->setTitle(tr("HTML editor window"));
- popup->addAction(m_actions.selectAll);
- return popup;
+QMenu* CHTMLWriteDisplay::createPopupMenu( const QPoint& ) {
+ if (!m_actions.selectAll) {
+ m_actions.selectAll = new QAction(tr("Select all"), this);
+ connect(m_actions.selectAll, SIGNAL(triggered(bool)), SLOT(selectAll()));
+ }
+
+ QMenu* popup = new QMenu(this);
+ popup->setTitle(tr("HTML editor window"));
+ popup->addAction(m_actions.selectAll);
+ return popup;
}
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index 155966a..5ea7527 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -26,81 +26,79 @@ class BtActionCollection;
/** The WYSIWYG implementation of the write display interface.
* @author The BibleTime team
*/
-class CHTMLWriteDisplay : public CPlainWriteDisplay
-{
- Q_OBJECT
-public:
- /**
- * Sets the new text for this display widget. (CPlainWriteDisplay).
- */
- virtual void setText( const QString& newText );
- /**
- * Returns the text of this edit widget. (CPlainWriteDisplay).
- */
- virtual const QString plainText();
-
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- * (CPlainWriteDisplay)
- */
- virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
-
-protected:
- friend class CDisplay;
- CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- ~CHTMLWriteDisplay();
- /**
- * Reimplementation to show a popup menu if the right mouse button was clicked.
- * (CPlainWriteDisplay)
- */
- virtual QMenu* createPopupMenu( const QPoint& pos );
-
-protected slots:
- void toggleBold(bool);
- void toggleItalic(bool);
- void toggleUnderline(bool);
-
- void alignLeft(bool);
- void alignCenter(bool);
- void alignRight(bool);
-
- void changeFontSize(int);
-
- void slotFontChanged( const QFont& );
- void slotFontFamilyChoosen(const QFont&);
-
- /**
- * The text's alignment changed. Enable the right buttons.
- */
- void slotAlignmentChanged( int );
- /**
- * Is called when a new color was selected.
- */
- void slotColorSelected( const QColor& );
- /**
- * Is called when a text with another color was selected.
- */
- void slotColorChanged( const QColor& );
-
-private:
- struct
- {
- QAction* bold;
- QAction* italic;
- QAction* underline;
-
- QAction* alignLeft;
- QAction* alignCenter;
- QAction* alignRight;
-
- //popup menu
- QAction* selectAll;
- }
- m_actions;
-
- QFontComboBox* m_fontFamilyChooser;
- BtFontSizeWidget* m_fontSizeChooser;
- BtColorWidget* m_colorChooser;
+class CHTMLWriteDisplay : public CPlainWriteDisplay {
+ Q_OBJECT
+ public:
+ /**
+ * Sets the new text for this display widget. (CPlainWriteDisplay).
+ */
+ virtual void setText( const QString& newText );
+ /**
+ * Returns the text of this edit widget. (CPlainWriteDisplay).
+ */
+ virtual const QString plainText();
+
+ /**
+ * Creates the necessary action objects and puts them on the toolbar.
+ * (CPlainWriteDisplay)
+ */
+ virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
+
+ protected:
+ friend class CDisplay;
+ CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
+ ~CHTMLWriteDisplay();
+ /**
+ * Reimplementation to show a popup menu if the right mouse button was clicked.
+ * (CPlainWriteDisplay)
+ */
+ virtual QMenu* createPopupMenu( const QPoint& pos );
+
+ protected slots:
+ void toggleBold(bool);
+ void toggleItalic(bool);
+ void toggleUnderline(bool);
+
+ void alignLeft(bool);
+ void alignCenter(bool);
+ void alignRight(bool);
+
+ void changeFontSize(int);
+
+ void slotFontChanged( const QFont& );
+ void slotFontFamilyChoosen(const QFont&);
+
+ /**
+ * The text's alignment changed. Enable the right buttons.
+ */
+ void slotAlignmentChanged( int );
+ /**
+ * Is called when a new color was selected.
+ */
+ void slotColorSelected( const QColor& );
+ /**
+ * Is called when a text with another color was selected.
+ */
+ void slotColorChanged( const QColor& );
+
+ private:
+ struct {
+ QAction* bold;
+ QAction* italic;
+ QAction* underline;
+
+ QAction* alignLeft;
+ QAction* alignCenter;
+ QAction* alignRight;
+
+ //popup menu
+ QAction* selectAll;
+ }
+ m_actions;
+
+ QFontComboBox* m_fontFamilyChooser;
+ BtFontSizeWidget* m_fontSizeChooser;
+ BtColorWidget* m_colorChooser;
};
#endif
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index 3880f35..ff70c0a 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -25,42 +25,42 @@
CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
- setAcceptRichText(false);
- setAcceptDrops(true);
- viewport()->setAcceptDrops(true);
+ setAcceptRichText(false);
+ setAcceptDrops(true);
+ viewport()->setAcceptDrops(true);
- connect(this, SIGNAL(textChanged()),
- connectionsProxy(), SLOT(emitTextChanged()));
+ connect(this, SIGNAL(textChanged()),
+ connectionsProxy(), SLOT(emitTextChanged()));
}
CPlainWriteDisplay::~CPlainWriteDisplay() {}
/** Reimplementation. */
void CPlainWriteDisplay::selectAll() {
- QTextEdit::selectAll();
+ QTextEdit::selectAll();
}
void CPlainWriteDisplay::setText( const QString& newText ) {
- //make sure the text has been converted to show \n instead of <br/>
- QString text = newText;
+ //make sure the text has been converted to show \n instead of <br/>
+ QString text = newText;
// text.replace("\n<br /><!-- BT newline -->\n", "\n");
- text.replace("<br />", "\n"); //inserted by BT or the Qt textedit widget
+ text.replace("<br />", "\n"); //inserted by BT or the Qt textedit widget
- QTextEdit::setText(text);
+ QTextEdit::setText(text);
}
bool CPlainWriteDisplay::hasSelection() {
- //TODO: test this
- return textCursor().hasSelection();
+ //TODO: test this
+ return textCursor().hasSelection();
}
QWidget* CPlainWriteDisplay::view() {
- qDebug("CPlainWriteDisplay::view()");
- return this;
+ qDebug("CPlainWriteDisplay::view()");
+ return this;
}
const QString CPlainWriteDisplay::text( const CDisplay::TextType /*format*/, const CDisplay::TextPart /*part*/) {
- return QString::null;
+ return QString::null;
}
void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::DisplayOptions, CSwordBackend::FilterOptions) {
@@ -68,28 +68,28 @@ void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::Display
/** Sets the current status of the edit widget. */
void CPlainWriteDisplay::setModified( const bool modified ) {
- document()->setModified(modified);
+ document()->setModified(modified);
}
/** Reimplementation. */
bool CPlainWriteDisplay::isModified() const {
- return document()->isModified();
+ return document()->isModified();
}
/** Returns the text of this edit widget. */
const QString CPlainWriteDisplay::plainText() {
- QString ret = QTextEdit::toPlainText();
+ QString ret = QTextEdit::toPlainText();
- //in plain text mode the text just contains newlines, convert them into <br/> before we return the text for display in a HTML widget
- ret.replace("\n", "<br />");
+ //in plain text mode the text just contains newlines, convert them into <br/> before we return the text for display in a HTML widget
+ ret.replace("\n", "<br />");
- return ret;
+ return ret;
}
/** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
QMenu* CPlainWriteDisplay::createPopupMenu( const QPoint& /*pos*/ ) {
- return installedPopup();
+ return installedPopup();
}
//
///** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
@@ -102,59 +102,58 @@ void CPlainWriteDisplay::setupToolbar(QToolBar*, BtActionCollection*) {}
/** Reimplementation to insert the text of a dragged reference into the edit view. */
void CPlainWriteDisplay::dragEnterEvent( QDragEnterEvent* e ) {
- //if (CDragDropMgr::canDecode(e)) {
- if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
- e->acceptProposedAction();
- }
- else {
- //e->accept(false);
- e->ignore();
- }
+ //if (CDragDropMgr::canDecode(e)) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
+ e->acceptProposedAction();
+ }
+ else {
+ //e->accept(false);
+ e->ignore();
+ }
}
/** Reimplementation to insert the text of a dragged reference into the edit view. */
void CPlainWriteDisplay::dragMoveEvent( QDragMoveEvent* e ) {
- if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
- //placeCursor(e->pos());
- setTextCursor(cursorForPosition(e->pos()));
- ensureCursorVisible();
- e->acceptProposedAction();
- }
- else {
- //e->accept(false);
- e->ignore();
- }
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
+ //placeCursor(e->pos());
+ setTextCursor(cursorForPosition(e->pos()));
+ ensureCursorVisible();
+ e->acceptProposedAction();
+ }
+ else {
+ //e->accept(false);
+ e->ignore();
+ }
}
/** Reimplementation to manage drops of our drag and drop objects. */
-void CPlainWriteDisplay::dropEvent( QDropEvent* e )
-{
- //qDebug("CPlainWriteDisplay::dropEvent");
- const BTMimeData* mimedata = qobject_cast<const BTMimeData*>(e->mimeData());
-
- if ( mimedata && mimedata->hasFormat("BibleTime/Bookmark") ) {
- //qDebug("format was bookmark");
- e->acceptProposedAction();
-
- BTMimeData::ItemList items = mimedata->bookmarks();
- BTMimeData::ItemList::iterator it;
- for (it = items.begin(); it != items.end(); ++it) {
-
- CSwordModuleInfo* module = backend()->findModuleByName((*it).module());
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( (*it).key() );
- QString moduleText = key->strippedText();
-
- const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module());
-
- setTextCursor(cursorForPosition(e->pos()));
- textCursor().insertText( text );
- }
- }
- else if ( e->mimeData()->hasFormat("text/plain")) {
- //qDebug("format was plain text");
- e->acceptProposedAction();
- setTextCursor(cursorForPosition(e->pos()));
- textCursor().insertText( e->mimeData()->text() );
- }
+void CPlainWriteDisplay::dropEvent( QDropEvent* e ) {
+ //qDebug("CPlainWriteDisplay::dropEvent");
+ const BTMimeData* mimedata = qobject_cast<const BTMimeData*>(e->mimeData());
+
+ if ( mimedata && mimedata->hasFormat("BibleTime/Bookmark") ) {
+ //qDebug("format was bookmark");
+ e->acceptProposedAction();
+
+ BTMimeData::ItemList items = mimedata->bookmarks();
+ BTMimeData::ItemList::iterator it;
+ for (it = items.begin(); it != items.end(); ++it) {
+
+ CSwordModuleInfo* module = backend()->findModuleByName((*it).module());
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( (*it).key() );
+ QString moduleText = key->strippedText();
+
+ const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module());
+
+ setTextCursor(cursorForPosition(e->pos()));
+ textCursor().insertText( text );
+ }
+ }
+ else if ( e->mimeData()->hasFormat("text/plain")) {
+ //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 eca0a3a..3968f74 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -32,68 +32,68 @@ class BtActionCollection;
* @author The BibleTime team
*/
class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
-public:
- /**
- * Reimplementation.
- */
- virtual void selectAll();
- /**
- * Sets the new text for this display widget.
- */
- virtual void setText( const QString& newText );
- /**
- * Returns true if the display widget has a selection. Otherwise false.
- */
- virtual bool hasSelection();
- /**
- * Returns the view of this display widget.
- */
- virtual QWidget* view();
- virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document );
- virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
- /**
- * Reimplementation (CWriteDisplay).
- */
- virtual bool isModified() const;
- /**
- * Sets the current status of the edit widget (CWriteDisplay).
- */
- virtual void setModified( const bool modified );
- /**
- * Returns the text of this edit widget (CWriteDisplay).
- */
- virtual const QString plainText();
- /**
- * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
- */
- virtual void setupToolbar(QToolBar*, BtActionCollection*);
+ public:
+ /**
+ * Reimplementation.
+ */
+ virtual void selectAll();
+ /**
+ * Sets the new text for this display widget.
+ */
+ virtual void setText( const QString& newText );
+ /**
+ * Returns true if the display widget has a selection. Otherwise false.
+ */
+ virtual bool hasSelection();
+ /**
+ * Returns the view of this display widget.
+ */
+ virtual QWidget* view();
+ virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document );
+ virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
+ /**
+ * Reimplementation (CWriteDisplay).
+ */
+ virtual bool isModified() const;
+ /**
+ * Sets the current status of the edit widget (CWriteDisplay).
+ */
+ virtual void setModified( const bool modified );
+ /**
+ * Returns the text of this edit widget (CWriteDisplay).
+ */
+ virtual const QString plainText();
+ /**
+ * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
+ */
+ virtual void setupToolbar(QToolBar*, BtActionCollection*);
-protected:
- friend class CDisplay;
- friend class CHTMLWriteDisplay;
+ protected:
+ friend class CDisplay;
+ friend class CHTMLWriteDisplay;
- CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- virtual ~CPlainWriteDisplay();
- /**
- * Reimplementation from QTextEdit. Provides an popup menu for the given position.
- */
- virtual QMenu* createPopupMenu( const QPoint& pos );
+ CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
+ virtual ~CPlainWriteDisplay();
+ /**
+ * Reimplementation from QTextEdit. Provides an popup menu for the given position.
+ */
+ virtual QMenu* createPopupMenu( const QPoint& pos );
// /**
// * Reimplementation from QTextEdit. Provides an popup menu.
// */
// virtual QMenu* createPopupMenu();
- /**
- * Reimplementation from QTextEdit to manage drops of our drag and drop objects.
- */
- virtual void dropEvent( QDropEvent* e );
- /**
- * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
- */
- virtual void dragEnterEvent( QDragEnterEvent* e );
- /**
- * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
- */
- virtual void dragMoveEvent( QDragMoveEvent* e );
+ /**
+ * Reimplementation from QTextEdit to manage drops of our drag and drop objects.
+ */
+ virtual void dropEvent( QDropEvent* e );
+ /**
+ * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
+ */
+ virtual void dragEnterEvent( QDragEnterEvent* e );
+ /**
+ * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
+ */
+ virtual void dragMoveEvent( QDragMoveEvent* e );
};
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index 383d332..afe00cd 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -32,81 +32,81 @@
CReadDisplay::CReadDisplay(CReadWindow* readWindow) :
-CDisplay(readWindow),
-m_activeAnchor(QString::null),
-m_useMouseTracking(true) {}
+ CDisplay(readWindow),
+ m_activeAnchor(QString::null),
+ m_useMouseTracking(true) {}
CReadDisplay::~CReadDisplay() {}
/** Returns the current active anchor. */
const QString& CReadDisplay::activeAnchor() {
- return m_activeAnchor;
+ return m_activeAnchor;
}
/** Sets the current anchor to the parameter. */
void CReadDisplay::setActiveAnchor( const QString& anchor ) {
- m_activeAnchor = anchor;
+ m_activeAnchor = anchor;
}
/** Returns true if the display has an active anchor. */
bool CReadDisplay::hasActiveAnchor() {
- return !activeAnchor().isEmpty();
+ return !activeAnchor().isEmpty();
}
void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- CDisplayWindow* window = parentWindow();
- CSwordKey* const key = window->key();
- CSwordModuleInfo* module = key->module();
-
-
- CExportManager mgr(QObject::tr("Print keys"),false, QString::null, parentWindow()->filterOptions(), parentWindow()->displayOptions());
-
- switch (type) {
- case Document: {
- if (module->type() == CSwordModuleInfo::Bible) {
- CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>(key);
-
- CSwordVerseKey startKey(*vk);
- startKey.Verse(1);
-
- CSwordVerseKey stopKey(*vk);
-
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
- if (bible) {
- stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) );
- }
-
- mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
- }
- else if (module->type() == CSwordModuleInfo::Lexicon || module->type() == CSwordModuleInfo::Commentary ) {
- mgr.printKey(module, key->key(), key->key(), displayOptions, filterOptions);
- }
- else if (module->type() == CSwordModuleInfo::GenericBook) {
- CSwordTreeKey* tree = dynamic_cast<CSwordTreeKey*>(key);
-
- CSwordTreeKey startKey(*tree);
- // while (startKey.previousSibling()) { // go to first sibling on this level!
- // }
-
- CSwordTreeKey stopKey(*tree);
- // if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(module)) {
- // while ( stopKey.nextSibling() ) { //go to last displayed sibling!
- // }
- // }
- mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
- }
- }
-
- case AnchorWithText: {
- if (hasActiveAnchor()) {
- mgr.printByHyperlink( activeAnchor(), displayOptions, filterOptions );
- }
- }
-
- default:
- break;
- }
+ CDisplayWindow* window = parentWindow();
+ CSwordKey* const key = window->key();
+ CSwordModuleInfo* module = key->module();
+
+
+ CExportManager mgr(QObject::tr("Print keys"), false, QString::null, parentWindow()->filterOptions(), parentWindow()->displayOptions());
+
+ switch (type) {
+ case Document: {
+ if (module->type() == CSwordModuleInfo::Bible) {
+ CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>(key);
+
+ CSwordVerseKey startKey(*vk);
+ startKey.Verse(1);
+
+ CSwordVerseKey stopKey(*vk);
+
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
+ if (bible) {
+ stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) );
+ }
+
+ mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
+ }
+ else if (module->type() == CSwordModuleInfo::Lexicon || module->type() == CSwordModuleInfo::Commentary ) {
+ mgr.printKey(module, key->key(), key->key(), displayOptions, filterOptions);
+ }
+ else if (module->type() == CSwordModuleInfo::GenericBook) {
+ CSwordTreeKey* tree = dynamic_cast<CSwordTreeKey*>(key);
+
+ CSwordTreeKey startKey(*tree);
+ // while (startKey.previousSibling()) { // go to first sibling on this level!
+ // }
+
+ CSwordTreeKey stopKey(*tree);
+ // if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(module)) {
+ // while ( stopKey.nextSibling() ) { //go to last displayed sibling!
+ // }
+ // }
+ mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
+ }
+ }
+
+ case AnchorWithText: {
+ if (hasActiveAnchor()) {
+ mgr.printByHyperlink( activeAnchor(), displayOptions, filterOptions );
+ }
+ }
+
+ default:
+ break;
+ }
}
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index f4a00c4..c94bd41 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -22,52 +22,52 @@
*/
class CReadDisplay : public CDisplay {
-public:
- /**
- * Returns true if the display has an active anchor.
- */
- bool hasActiveAnchor();
- /**
- * Returns the current active anchor.
- */
- const QString& activeAnchor();
- /**
- * Moves the widget to the given anchor.
- */
- virtual void moveToAnchor( const QString& ) = 0;
- virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ public:
+ /**
+ * Returns true if the display has an active anchor.
+ */
+ bool hasActiveAnchor();
+ /**
+ * Returns the current active anchor.
+ */
+ const QString& activeAnchor();
+ /**
+ * Moves the widget to the given anchor.
+ */
+ virtual void moveToAnchor( const QString& ) = 0;
+ virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void setMouseTracking(const bool trackingEnabled) {
- m_useMouseTracking = trackingEnabled;
- };
- bool getMouseTracking() const {
- return m_useMouseTracking;
- };
+ void setMouseTracking(const bool trackingEnabled) {
+ m_useMouseTracking = trackingEnabled;
+ };
+ bool getMouseTracking() const {
+ return m_useMouseTracking;
+ };
-protected: // Protected methods
- friend class BtHtmlReadDisplay;
- friend class BtHtmlReadDisplayView;
- friend class BtHtmlJsObject;
- friend class CDisplay;
- friend class CHTMLReadDisplay;
- friend class CHTMLReadDisplayView;
+ protected: // Protected methods
+ friend class BtHtmlReadDisplay;
+ friend class BtHtmlReadDisplayView;
+ friend class BtHtmlJsObject;
+ friend class CDisplay;
+ friend class CHTMLReadDisplay;
+ friend class CHTMLReadDisplayView;
- CReadDisplay( CReadWindow* readWindow );
- ~CReadDisplay();
+ CReadDisplay( CReadWindow* readWindow );
+ ~CReadDisplay();
- /**
- * Sets the current anchor to the parameter.
- */
- void setActiveAnchor( const QString& );
+ /**
+ * Sets the current anchor to the parameter.
+ */
+ void setActiveAnchor( const QString& );
-private: // Public attributes
- /**
- * The member which hols the current anchor.
- */
+ private: // Public attributes
+ /**
+ * The member which hols the current anchor.
+ */
- QString m_activeAnchor;
+ QString m_activeAnchor;
- bool m_useMouseTracking;
+ bool m_useMouseTracking;
};
#endif
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
index eaa2d9d..24dd29f 100644
--- a/src/frontend/display/cwritedisplay.h
+++ b/src/frontend/display/cwritedisplay.h
@@ -23,29 +23,29 @@ class BtActionCollection;
*/
class CWriteDisplay : public CDisplay {
-protected:
- friend class CDisplay;
- friend class CPlainWriteDisplay;
- CWriteDisplay( CWriteWindow* writeWindow );
- ~CWriteDisplay();
-
-public: // Public methods
- /**
- * Sets the current modified status of the widget.
- */
- virtual void setModified( const bool modified ) = 0;
- /**
- * Returns true if the current text was modified.
- */
- virtual bool isModified() const = 0;
- /**
- * Returns the text of this edit widget.
- */
- virtual const QString plainText() = 0;
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- */
- virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
+ protected:
+ friend class CDisplay;
+ friend class CPlainWriteDisplay;
+ CWriteDisplay( CWriteWindow* writeWindow );
+ ~CWriteDisplay();
+
+ public: // Public methods
+ /**
+ * Sets the current modified status of the widget.
+ */
+ virtual void setModified( const bool modified ) = 0;
+ /**
+ * Returns true if the current text was modified.
+ */
+ virtual bool isModified() const = 0;
+ /**
+ * Returns the text of this edit widget.
+ */
+ virtual const QString plainText() = 0;
+ /**
+ * Creates the necessary action objects and puts them on the toolbar.
+ */
+ virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
};
#endif
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index fc1a412..c9d5dd8 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -17,139 +17,117 @@
#include <QStringList>
#include <QDebug>
-class BtActionItem : public QObject
-{
-public:
- BtActionItem(QObject* parent)
- : QObject(parent)
- {
- }
- QKeySequence defaultKeys;
- QAction* action;
+class BtActionItem : public QObject {
+ public:
+ BtActionItem(QObject* parent)
+ : QObject(parent) {
+ }
+ QKeySequence defaultKeys;
+ QAction* action;
};
BtActionCollection::BtActionCollection(QObject* parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
-BtActionCollection::~BtActionCollection()
-{
+BtActionCollection::~BtActionCollection() {
}
-QList<QAction*> BtActionCollection::actions()
-{
- QList<QAction*> actionList;
+QList<QAction*> BtActionCollection::actions() {
+ QList<QAction*> actionList;
- QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
- while (iter != m_actions.constEnd())
- {
- QAction* action = iter.value()->action;
- actionList.append(action);
- ++iter;
- }
- return actionList;
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd()) {
+ QAction* action = iter.value()->action;
+ actionList.append(action);
+ ++iter;
+ }
+ return actionList;
}
-QAction* BtActionCollection::action(const QString& name)
-{
- if (m_actions.contains(name))
- return m_actions[name]->action;
- qWarning() << "A QAction for a shortcut named" << name << "was requested but it is not defined.";
- return (new QAction(this)); // dummy QAction*
+QAction* BtActionCollection::action(const QString& name) {
+ if (m_actions.contains(name))
+ return m_actions[name]->action;
+ qWarning() << "A QAction for a shortcut named" << name << "was requested but it is not defined.";
+ return (new QAction(this)); // dummy QAction*
}
-QAction* BtActionCollection::addAction(const QString& name, QAction* action)
-{
- Q_ASSERT(action != 0);
- Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
- int count;
- count = m_actions.count();
- BtActionItem* item = new BtActionItem(this);
- item->action = action;
- item->defaultKeys = action->shortcut();
- m_actions[name] = item;
- return action;
+QAction* BtActionCollection::addAction(const QString& name, QAction* action) {
+ Q_ASSERT(action != 0);
+ Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
+ int count;
+ count = m_actions.count();
+ BtActionItem* item = new BtActionItem(this);
+ item->action = action;
+ item->defaultKeys = action->shortcut();
+ m_actions[name] = item;
+ return action;
}
-QAction* BtActionCollection::addAction(const QString &name, const QObject *receiver, const char* member)
-{
- QAction* action = new QAction(name, this);
- if (receiver && member)
- {
- bool ok = connect(action, SIGNAL(triggered()), receiver, SLOT(triggered()));
- Q_ASSERT(ok);
- }
- return addAction(name, action);
+QAction* BtActionCollection::addAction(const QString &name, const QObject *receiver, const char* member) {
+ QAction* action = new QAction(name, this);
+ if (receiver && member) {
+ bool ok = connect(action, SIGNAL(triggered()), receiver, SLOT(triggered()));
+ Q_ASSERT(ok);
+ }
+ return addAction(name, action);
}
-QKeySequence BtActionCollection::getDefaultShortcut(QAction* action)
-{
- QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
- while (iter != m_actions.constEnd())
- {
- if ( iter.value()->action == action)
- {
- return iter.value()->defaultKeys;
- }
- iter++;
- }
- return QKeySequence();
+QKeySequence BtActionCollection::getDefaultShortcut(QAction* action) {
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd()) {
+ if ( iter.value()->action == action) {
+ return iter.value()->defaultKeys;
+ }
+ iter++;
+ }
+ return QKeySequence();
}
-void BtActionCollection::setConfigGroup(const QString &group)
-{
- m_groupName = group;
+void BtActionCollection::setConfigGroup(const QString &group) {
+ m_groupName = group;
}
-void BtActionCollection::readSettings()
-{
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
- QStringList keyList = settings->childKeys();
- for (int i=0; i<keyList.size(); i++)
- {
- QString key = keyList.at(i);
- QVariant variant = settings->value(key);
- QList<QKeySequence> shortcuts;
- if ( variant != QVariant())
- {
- QList<QVariant> varShortcuts = variant.toList();
- for (int i=0; i<varShortcuts.count(); i++)
- {
- QString keys = varShortcuts.at(i).toString();
- QKeySequence shortcut(keys);
- shortcuts.append(shortcut);
- }
- }
- action(key)->setShortcuts(shortcuts);
- }
- settings->endGroup();
+void BtActionCollection::readSettings() {
+ QSettings* settings = CBTConfig::getConfig();
+ settings->beginGroup(m_groupName);
+ QStringList keyList = settings->childKeys();
+ for (int i = 0; i < keyList.size(); i++) {
+ QString key = keyList.at(i);
+ QVariant variant = settings->value(key);
+ QList<QKeySequence> shortcuts;
+ if ( variant != QVariant()) {
+ QList<QVariant> varShortcuts = variant.toList();
+ for (int i = 0; i < varShortcuts.count(); i++) {
+ QString keys = varShortcuts.at(i).toString();
+ QKeySequence shortcut(keys);
+ shortcuts.append(shortcut);
+ }
+ }
+ action(key)->setShortcuts(shortcuts);
+ }
+ settings->endGroup();
}
-static QList<QVariant> keyListToVariantList(const QList<QKeySequence>& keyList)
-{
- QList<QVariant> varList;
- for (int i=0; i<keyList.count(); i++)
- {
- QKeySequence keySeq = keyList.at(i);
- varList.append(keySeq.toString());
- }
- return varList;
+static QList<QVariant> keyListToVariantList(const QList<QKeySequence>& keyList) {
+ QList<QVariant> varList;
+ for (int i = 0; i < keyList.count(); i++) {
+ QKeySequence keySeq = keyList.at(i);
+ varList.append(keySeq.toString());
+ }
+ return varList;
}
-void BtActionCollection::writeSettings()
-{
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
- QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
- while (iter != m_actions.constEnd())
- {
- QString actionName = iter.key();
- QList<QKeySequence> keyList = iter.value()->action->shortcuts();
- QList<QVariant> varList = keyListToVariantList(keyList);
- settings->setValue(actionName, varList);
- iter++;
- }
- settings->endGroup();
+void BtActionCollection::writeSettings() {
+ QSettings* settings = CBTConfig::getConfig();
+ settings->beginGroup(m_groupName);
+ QMap<QString, BtActionItem*>::const_iterator iter = m_actions.constBegin();
+ while (iter != m_actions.constEnd()) {
+ QString actionName = iter.key();
+ QList<QKeySequence> keyList = iter.value()->action->shortcuts();
+ QList<QVariant> varList = keyListToVariantList(keyList);
+ settings->setValue(actionName, varList);
+ iter++;
+ }
+ settings->endGroup();
}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index 48e6b10..4dde538 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -19,24 +19,23 @@ class QAction;
class QKeySequence;
class BtActionItem;
-class BtActionCollection : public QObject
-{
- Q_OBJECT
-public:
- BtActionCollection(QObject* parent);
- ~BtActionCollection();
- QAction* addAction(const QString& name, QAction* action);
- QAction* addAction(const QString &name, const QObject *receiver, const char* member=0);
- QList<QAction*> actions();
- QAction* action(const QString& name);
- void setConfigGroup(const QString &group);
- void readSettings();
- void writeSettings();
- QKeySequence getDefaultShortcut(QAction* action);
+class BtActionCollection : public QObject {
+ Q_OBJECT
+ public:
+ BtActionCollection(QObject* parent);
+ ~BtActionCollection();
+ QAction* addAction(const QString& name, QAction* action);
+ QAction* addAction(const QString &name, const QObject *receiver, const char* member = 0);
+ QList<QAction*> actions();
+ QAction* action(const QString& name);
+ void setConfigGroup(const QString &group);
+ void readSettings();
+ void writeSettings();
+ QKeySequence getDefaultShortcut(QAction* action);
-private:
- QMap<QString, BtActionItem*> m_actions;
- QString m_groupName;
+ private:
+ QMap<QString, BtActionItem*> m_actions;
+ QString m_groupName;
};
#endif
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index ffa672a..5a7fd8c 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -13,66 +13,56 @@
#include <QAction>
#include <QEvent>
-class BtToolButton : public QToolButton
-{
-public:
- BtToolButton(QWidget* parent=0) : QToolButton(parent)
- {
- }
-private:
- void nextCheckState()
- {
- }
+class BtToolButton : public QToolButton {
+ public:
+ BtToolButton(QWidget* parent = 0) : QToolButton(parent) {
+ }
+ private:
+ void nextCheckState() {
+ }
};
// This class provides a toolbar widget that has a icon plus a right side down arrow
-// The icon is typically set to a back or forward arrow and the down arrow has a popup
-// menu when clicked. The menu is typicallly populated with history actions.
+// The icon is typically set to a back or forward arrow and the down arrow has a popup
+// menu when clicked. The menu is typicallly populated with history actions.
BtToolBarPopupAction::BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent)
- : QWidgetAction(parent), m_icon(icon), m_text(text)
-{
- setText(text);
- m_menu = new QMenu();
+ : QWidgetAction(parent), m_icon(icon), m_text(text) {
+ setText(text);
+ m_menu = new QMenu();
}
-BtToolBarPopupAction::~BtToolBarPopupAction()
-{
- delete m_menu;
+BtToolBarPopupAction::~BtToolBarPopupAction() {
+ delete m_menu;
}
// return the QMenu object so a popup menu can be constructed
-QMenu* BtToolBarPopupAction::popupMenu() const
-{
- return m_menu;
+QMenu* BtToolBarPopupAction::popupMenu() const {
+ return m_menu;
}
-QWidget* BtToolBarPopupAction::createWidget(QWidget* parent)
-{
- m_button = new BtToolButton(parent);
- setIcon(m_icon);
- setToolTip(m_text);
- m_button->setDefaultAction(this);
- m_button->setPopupMode(QToolButton::MenuButtonPopup);
- m_button->setMenu(m_menu);
- bool ok = connect(m_button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
- Q_ASSERT(ok);;
- return m_button;
+QWidget* BtToolBarPopupAction::createWidget(QWidget* parent) {
+ m_button = new BtToolButton(parent);
+ setIcon(m_icon);
+ setToolTip(m_text);
+ m_button->setDefaultAction(this);
+ m_button->setPopupMode(QToolButton::MenuButtonPopup);
+ m_button->setMenu(m_menu);
+ bool ok = connect(m_button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
+ Q_ASSERT(ok);;
+ return m_button;
}
// Slot to emit a triggered signal when the toolbar button is pressed
-void BtToolBarPopupAction::buttonPressed()
-{
- emit triggered();
+void BtToolBarPopupAction::buttonPressed() {
+ emit triggered();
}
// Function to catch the Shortcut event and emit the triggered signal
-bool BtToolBarPopupAction::event(QEvent *event)
-{
- if (event->type() == QEvent::Shortcut)
- {
- emit triggered();
- return true;
- }
- return QWidgetAction::event(event);
+bool BtToolBarPopupAction::event(QEvent *event) {
+ if (event->type() == QEvent::Shortcut) {
+ emit triggered();
+ return true;
+ }
+ return QWidgetAction::event(event);
}
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index 7615c02..06eb660 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -17,36 +17,35 @@ class QIcon;
class QToolButton;
// This class manages the toolbar display for going forward and backward in history.
-class BtToolBarPopupAction : public QWidgetAction
-{
- Q_OBJECT
-public:
+class BtToolBarPopupAction : public QWidgetAction {
+ Q_OBJECT
+ public:
- BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent);
- ~BtToolBarPopupAction();
+ BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent);
+ ~BtToolBarPopupAction();
// return the QMenu object so a popup menu can be constructed
- QMenu* popupMenu() const;
+ QMenu* popupMenu() const;
// Function to catch the Shortcut event and emit the triggered signal
- virtual bool event(QEvent* e);
-
-signals:
- void triggered();
+ virtual bool event(QEvent* e);
-protected:
- QWidget* createWidget(QWidget* parent);
+ signals:
+ void triggered();
-private slots:
+ protected:
+ QWidget* createWidget(QWidget* parent);
+
+ private slots:
// Slot to emit a triggered signal when the toolbar button is pressed
- void buttonPressed();
+ void buttonPressed();
-private:
- QMenu* m_menu;
- QToolButton* m_button;
- QIcon m_icon;
- QString m_text;
+ private:
+ QMenu* m_menu;
+ QToolButton* m_button;
+ QIcon m_icon;
+ QString m_text;
};
#endif
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 9b59544..2da6360 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -40,94 +40,85 @@
using namespace Profile;
CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
- : CLexiconReadWindow(moduleList, parent)
-{
- qDebug("CBibleReadWindow::CBibleReadWindow");
+ : CLexiconReadWindow(moduleList, parent) {
+ qDebug("CBibleReadWindow::CBibleReadWindow");
}
-CBibleReadWindow::~CBibleReadWindow()
-{
+CBibleReadWindow::~CBibleReadWindow() {
}
-void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings )
-{
- CLexiconReadWindow::applyProfileSettings(settings);
-
- const int count = displaySettingsButton()->menuItemCount();
- int result = settings->windowSettings();
- for (int i = count-1; i>=1; i--)
- {
- if (result-(int)pow((double)2,i-1)>= 0)
- { //2^i was added before, so item with index i is set
- result -= (int)pow((double)2,i-1);
- displaySettingsButton()->setItemStatus(i,true);
- }
- else
- {
- displaySettingsButton()->setItemStatus(i,false);
- }
- }
- displaySettingsButton()->setChanged();
+void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings ) {
+ CLexiconReadWindow::applyProfileSettings(settings);
+
+ const int count = displaySettingsButton()->menuItemCount();
+ int result = settings->windowSettings();
+ for (int i = count - 1; i >= 1; i--) {
+ if (result - (int)pow((double)2, i - 1) >= 0) { //2^i was added before, so item with index i is set
+ result -= (int)pow((double)2, i - 1);
+ displaySettingsButton()->setItemStatus(i, true);
+ }
+ else {
+ displaySettingsButton()->setItemStatus(i, false);
+ }
+ }
+ displaySettingsButton()->setChanged();
}
-void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings )
-{
- CLexiconReadWindow::storeProfileSettings(settings);
-
- const int count = displaySettingsButton()->menuItemCount();
- int result = 0;
- //now check every item
- for (int i = 1; i < count; i++)
- { //first item is a title
- if (displaySettingsButton()->itemStatus(i)) //item is checked
- result += (int)pow((double)2,i-1);//add 2^i (the i. digit in binary)
- }
- settings->setWindowSettings(result);
+void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings ) {
+ CLexiconReadWindow::storeProfileSettings(settings);
+
+ const int count = displaySettingsButton()->menuItemCount();
+ int result = 0;
+ //now check every item
+ for (int i = 1; i < count; i++) { //first item is a title
+ if (displaySettingsButton()->itemStatus(i)) //item is checked
+ result += (int)pow((double)2, i - 1);//add 2^i (the i. digit in binary)
+ }
+ settings->setWindowSettings(result);
}
/** Reimplementation. */
-void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a )
-{
- QAction* qaction;
-
- qaction = new QAction(tr("Next book"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
- a->addAction("nextBook", qaction);
-
- qaction = new QAction(tr("Previous book"), a);
- qaction->setShortcut( CResMgr::displaywindows::bibleWindow::previousBook::accel);
- a->addAction("previousBook", qaction);
-
- qaction = new QAction(tr("Next chapter"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
- a->addAction("nextChapter", qaction);
-
- qaction = new QAction(tr("Previous chapter"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
- a->addAction("previousChapter", qaction);
-
- qaction = new QAction(tr("Next verse"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
- a->addAction("nextVerse", qaction);
-
- qaction = new QAction(tr("Previous verse"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
- a->addAction("previousVerse", qaction);
-
- //popup menu items
- qaction = new QAction(tr("Copy chapter"), a);
- a->addAction("copyChapter", qaction);
-
- qaction = new QAction(tr("Save chapter as plain text"), a);
- a->addAction("saveChapterAsPlainText", qaction);
-
- qaction = new QAction(tr("Save chapter as HTML"), a);
- a->addAction("saveChapterAsHTML", qaction);
-
- qaction = new QAction(tr("Print chapter"), a);
- qaction->setShortcut(QKeySequence::Print);
- a->addAction("printChapter", qaction);
+void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+ QAction* qaction;
+
+ qaction = new QAction(tr("Next book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ a->addAction("nextBook", qaction);
+
+ qaction = new QAction(tr("Previous book"), a);
+ qaction->setShortcut( CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ a->addAction("previousBook", qaction);
+
+ qaction = new QAction(tr("Next chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ a->addAction("nextChapter", qaction);
+
+ qaction = new QAction(tr("Previous chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ a->addAction("previousChapter", qaction);
+
+ qaction = new QAction(tr("Next verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ a->addAction("nextVerse", qaction);
+
+ qaction = new QAction(tr("Previous verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ a->addAction("previousVerse", qaction);
+
+ //popup menu items
+ qaction = new QAction(tr("Copy chapter"), a);
+ a->addAction("copyChapter", qaction);
+
+ qaction = new QAction(tr("Save chapter as plain text"), a);
+ a->addAction("saveChapterAsPlainText", qaction);
+
+ qaction = new QAction(tr("Save chapter as HTML"), a);
+ a->addAction("saveChapterAsHTML", qaction);
+
+ qaction = new QAction(tr("Print chapter"), a);
+ qaction->setShortcut(QKeySequence::Print);
+ a->addAction("printChapter", qaction);
// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
@@ -137,356 +128,327 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a )
// qaction = new QAction(tr("Reference only"), a );
// a->addAction("copyReferenceOnly", qaction);
- qaction = new QAction(tr("Text of reference"), a);
- a->addAction("copyTextOfReference", qaction);
+ qaction = new QAction(tr("Text of reference"), a);
+ a->addAction("copyTextOfReference", qaction);
- qaction = new QAction(tr("Reference with text"), a);
- a->addAction( "copyReferenceWithText", qaction);
+ qaction = new QAction(tr("Reference with text"), a);
+ a->addAction( "copyReferenceWithText", qaction);
- qaction = new QAction(tr("Reference with text"), a);
- a->addAction("saveReferenceWithText", qaction);
+ qaction = new QAction(tr("Reference with text"), a);
+ a->addAction("saveReferenceWithText", qaction);
}
-void CBibleReadWindow::initActions()
-{
- qDebug("CBibleReadWindow::initActions");
+void CBibleReadWindow::initActions() {
+ qDebug("CBibleReadWindow::initActions");
- BtActionCollection* ac = actionCollection();
+ BtActionCollection* ac = actionCollection();
- CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+ CLexiconReadWindow::initActions(); //make sure the predefined actions are available
- CBibleReadWindow::insertKeyboardActions(ac);
+ CBibleReadWindow::insertKeyboardActions(ac);
- //cleanup, not a clean oo-solution
- ac->action("nextEntry")->setEnabled(false);
- ac->action("previousEntry")->setEnabled(false);
+ //cleanup, not a clean oo-solution
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
- QAction* qaction;
+ QAction* qaction;
- qaction = m_actionCollection->action("nextBook");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("nextBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
+ addAction(qaction);
- qaction = m_actionCollection->action("previousBook");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("previousBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
+ addAction(qaction);
- qaction = m_actionCollection->action("nextChapter");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("nextChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
+ addAction(qaction);
- qaction = m_actionCollection->action("previousChapter");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("previousChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
+ addAction(qaction);
- qaction = m_actionCollection->action("nextVerse");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("nextVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
+ addAction(qaction);
- qaction = m_actionCollection->action("previousVerse");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
- addAction(qaction);
+ qaction = m_actionCollection->action("previousVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
+ addAction(qaction);
- m_actions.selectAll = ac->action("selectAll");
- Q_ASSERT(m_actions.selectAll);
+ m_actions.selectAll = ac->action("selectAll");
+ Q_ASSERT(m_actions.selectAll);
- m_actions.findText = ac->action("findText");
- Q_ASSERT(m_actions.findText);
+ m_actions.findText = ac->action("findText");
+ Q_ASSERT(m_actions.findText);
- m_actions.findStrongs = m_actionCollection->action(CResMgr::displaywindows::general::findStrongs::actionName);
+ m_actions.findStrongs = m_actionCollection->action(CResMgr::displaywindows::general::findStrongs::actionName);
- m_actions.copy.referenceOnly = m_actionCollection->action("copyReferenceOnly");
+ m_actions.copy.referenceOnly = m_actionCollection->action("copyReferenceOnly");
- m_actions.copy.referenceTextOnly = m_actionCollection->action("copyTextOfReference");
- QObject::connect(m_actions.copy.referenceTextOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorTextOnly()) );
- addAction(m_actions.copy.referenceTextOnly);
+ m_actions.copy.referenceTextOnly = m_actionCollection->action("copyTextOfReference");
+ QObject::connect(m_actions.copy.referenceTextOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorTextOnly()) );
+ addAction(m_actions.copy.referenceTextOnly);
- m_actions.copy.referenceAndText = m_actionCollection->action("copyReferenceWithText");
- QObject::connect(m_actions.copy.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorWithText()) );
- addAction(m_actions.copy.referenceAndText);
+ m_actions.copy.referenceAndText = m_actionCollection->action("copyReferenceWithText");
+ QObject::connect(m_actions.copy.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorWithText()) );
+ addAction(m_actions.copy.referenceAndText);
- m_actions.copy.chapter = m_actionCollection->action("copyChapter");
- QObject::connect(m_actions.copy.chapter, SIGNAL(triggered()), this, SLOT(copyDisplayedText()) );
- addAction(m_actions.copy.chapter);
+ m_actions.copy.chapter = m_actionCollection->action("copyChapter");
+ QObject::connect(m_actions.copy.chapter, SIGNAL(triggered()), this, SLOT(copyDisplayedText()) );
+ addAction(m_actions.copy.chapter);
- m_actions.copy.selectedText = ac->action("copySelectedText");
- Q_ASSERT(m_actions.copy.selectedText);
+ m_actions.copy.selectedText = ac->action("copySelectedText");
+ Q_ASSERT(m_actions.copy.selectedText);
- m_actions.save.referenceAndText = m_actionCollection->action("saveReferenceWithText");
- QObject::connect(m_actions.save.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(saveAnchorWithText()) );
- addAction(m_actions.copy.chapter);
+ m_actions.save.referenceAndText = m_actionCollection->action("saveReferenceWithText");
+ QObject::connect(m_actions.save.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(saveAnchorWithText()) );
+ addAction(m_actions.copy.chapter);
- m_actions.save.chapterAsPlain = m_actionCollection->action("saveChapterAsPlainText");
- QObject::connect(m_actions.save.chapterAsPlain, SIGNAL(triggered()), this, SLOT(saveChapterPlain()) );
- addAction(m_actions.save.referenceAndText);
+ m_actions.save.chapterAsPlain = m_actionCollection->action("saveChapterAsPlainText");
+ QObject::connect(m_actions.save.chapterAsPlain, SIGNAL(triggered()), this, SLOT(saveChapterPlain()) );
+ addAction(m_actions.save.referenceAndText);
- m_actions.save.chapterAsHTML = m_actionCollection->action("saveChapterAsHTML");
- QObject::connect(m_actions.save.chapterAsHTML, SIGNAL(triggered()), this, SLOT(saveChapterHTML()) );
- addAction(m_actions.save.chapterAsHTML);
+ m_actions.save.chapterAsHTML = m_actionCollection->action("saveChapterAsHTML");
+ QObject::connect(m_actions.save.chapterAsHTML, SIGNAL(triggered()), this, SLOT(saveChapterHTML()) );
+ addAction(m_actions.save.chapterAsHTML);
- m_actions.print.reference = m_actionCollection->action("saveReferenceWithText");
- QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()) );
- addAction(m_actions.print.reference);
+ m_actions.print.reference = m_actionCollection->action("saveReferenceWithText");
+ QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()) );
+ addAction(m_actions.print.reference);
- m_actions.print.chapter = m_actionCollection->action("printChapter");
- QObject::connect(m_actions.print.chapter, SIGNAL(triggered()), this, SLOT(printAll()) );
- addAction(m_actions.print.chapter);
+ m_actions.print.chapter = m_actionCollection->action("printChapter");
+ QObject::connect(m_actions.print.chapter, SIGNAL(triggered()), this, SLOT(printAll()) );
+ addAction(m_actions.print.chapter);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
}
-void CBibleReadWindow::initConnections()
-{
- CLexiconReadWindow::initConnections();
+void CBibleReadWindow::initConnections() {
+ CLexiconReadWindow::initConnections();
}
-void CBibleReadWindow::initToolbars()
-{
- CLexiconReadWindow::initToolbars();
+void CBibleReadWindow::initToolbars() {
+ CLexiconReadWindow::initToolbars();
}
-void CBibleReadWindow::initView()
-{
- CLexiconReadWindow::initView();
+void CBibleReadWindow::initView() {
+ CLexiconReadWindow::initView();
- parentWidget()->installEventFilter(this);
+ parentWidget()->installEventFilter(this);
}
/** Reimplementation. */
-void CBibleReadWindow::setupPopupMenu()
-{
- popup()->setTitle(tr("Bible window"));
- popup()->setIcon(CToolClass::getIconForModule(modules().first()) );
- popup()->addAction(m_actions.findText);
- QKeySequence ks = m_actions.findText->shortcut();
- QString keys = ks.toString();
- popup()->addAction(m_actions.findStrongs);
- popup()->addAction(m_actions.selectAll);
-
- popup()->addSeparator();
-
- m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
- m_actions.copyMenu->addAction(m_actions.copy.referenceOnly);
- m_actions.copyMenu->addAction(m_actions.copy.referenceTextOnly);
- m_actions.copyMenu->addAction(m_actions.copy.referenceAndText);
- m_actions.copyMenu->addAction(m_actions.copy.chapter);
-
- m_actions.copyMenu->addSeparator();
-
- m_actions.copyMenu->addAction(m_actions.copy.selectedText);
- popup()->addMenu(m_actions.copyMenu);
-
- m_actions.saveMenu = new QMenu(tr("Save..."), popup());
- m_actions.saveMenu->addAction(m_actions.save.referenceAndText);
- m_actions.saveMenu->addAction(m_actions.save.chapterAsPlain);
- m_actions.saveMenu->addAction(m_actions.save.chapterAsHTML);
-
- // Save raw HTML action for debugging purposes
- if (qApp->property("--debug").toBool())
- {
- QAction* debugAction = new QAction("Raw HTML", this);
- QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
- m_actions.saveMenu->addAction(debugAction);
- } // end of Save Raw HTML
- popup()->addMenu(m_actions.saveMenu);
-
- m_actions.printMenu = new QMenu(tr("Print..."), popup());
- m_actions.printMenu->addAction(m_actions.print.reference);
- m_actions.printMenu->addAction(m_actions.print.chapter);
- popup()->addMenu(m_actions.printMenu);
+void CBibleReadWindow::setupPopupMenu() {
+ popup()->setTitle(tr("Bible window"));
+ popup()->setIcon(CToolClass::getIconForModule(modules().first()) );
+ popup()->addAction(m_actions.findText);
+ QKeySequence ks = m_actions.findText->shortcut();
+ QString keys = ks.toString();
+ popup()->addAction(m_actions.findStrongs);
+ popup()->addAction(m_actions.selectAll);
+
+ popup()->addSeparator();
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
+ m_actions.copyMenu->addAction(m_actions.copy.referenceOnly);
+ m_actions.copyMenu->addAction(m_actions.copy.referenceTextOnly);
+ m_actions.copyMenu->addAction(m_actions.copy.referenceAndText);
+ m_actions.copyMenu->addAction(m_actions.copy.chapter);
+
+ m_actions.copyMenu->addSeparator();
+
+ m_actions.copyMenu->addAction(m_actions.copy.selectedText);
+ popup()->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(tr("Save..."), popup());
+ m_actions.saveMenu->addAction(m_actions.save.referenceAndText);
+ m_actions.saveMenu->addAction(m_actions.save.chapterAsPlain);
+ m_actions.saveMenu->addAction(m_actions.save.chapterAsHTML);
+
+ // Save raw HTML action for debugging purposes
+ if (qApp->property("--debug").toBool()) {
+ QAction* debugAction = new QAction("Raw HTML", this);
+ QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
+ m_actions.saveMenu->addAction(debugAction);
+ } // end of Save Raw HTML
+ popup()->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(tr("Print..."), popup());
+ m_actions.printMenu->addAction(m_actions.print.reference);
+ m_actions.printMenu->addAction(m_actions.print.chapter);
+ popup()->addMenu(m_actions.printMenu);
}
/** Reimplemented. */
-void CBibleReadWindow::updatePopupMenu()
-{
- qWarning("CBibleReadWindow::updatePopupMenu()");
+void CBibleReadWindow::updatePopupMenu() {
+ qWarning("CBibleReadWindow::updatePopupMenu()");
+
+ m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
- m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
-
- m_actions.copy.referenceOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
- m_actions.copy.referenceTextOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
- m_actions.copy.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
- m_actions.copy.selectedText->setEnabled( ((CReadDisplay*)displayWidget())->hasSelection() );
+ m_actions.copy.referenceOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.referenceTextOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.selectedText->setEnabled( ((CReadDisplay*)displayWidget())->hasSelection() );
- m_actions.save.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.save.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
- m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
}
/** Moves to the next book. */
-void CBibleReadWindow::nextBook()
-{
- if (verseKey()->next(CSwordVerseKey::UseBook))
- {
- keyChooser()->setKey(key());
- }
+void CBibleReadWindow::nextBook() {
+ if (verseKey()->next(CSwordVerseKey::UseBook)) {
+ keyChooser()->setKey(key());
+ }
}
/** Moves one book behind. */
void CBibleReadWindow::previousBook() {
- if (verseKey()->previous(CSwordVerseKey::UseBook))
- {
- keyChooser()->setKey(key());
- }
+ if (verseKey()->previous(CSwordVerseKey::UseBook)) {
+ keyChooser()->setKey(key());
+ }
}
/** Moves to the next book. */
-void CBibleReadWindow::nextChapter()
-{
- if (verseKey()->next(CSwordVerseKey::UseChapter))
- {
- keyChooser()->setKey(key());
- }
+void CBibleReadWindow::nextChapter() {
+ if (verseKey()->next(CSwordVerseKey::UseChapter)) {
+ keyChooser()->setKey(key());
+ }
}
/** Moves one book behind. */
-void CBibleReadWindow::previousChapter()
-{
- if (verseKey()->previous(CSwordVerseKey::UseChapter))
- {
- keyChooser()->setKey(key());
- }
+void CBibleReadWindow::previousChapter() {
+ if (verseKey()->previous(CSwordVerseKey::UseChapter)) {
+ keyChooser()->setKey(key());
+ }
}
/** Moves to the next book. */
-void CBibleReadWindow::nextVerse()
-{
- if (verseKey()->next(CSwordVerseKey::UseVerse))
- {
- keyChooser()->setKey(key());
- }
+void CBibleReadWindow::nextVerse() {
+ if (verseKey()->next(CSwordVerseKey::UseVerse)) {
+ keyChooser()->setKey(key());
+ }
}
/** Moves one book behind. */
-void CBibleReadWindow::previousVerse()
-{
- if (verseKey()->previous(CSwordVerseKey::UseVerse))
- {
- keyChooser()->setKey(key());
- }
+void CBibleReadWindow::previousVerse() {
+ if (verseKey()->previous(CSwordVerseKey::UseVerse)) {
+ keyChooser()->setKey(key());
+ }
}
/** rapper around key() to return the right type of key. */
-CSwordVerseKey* CBibleReadWindow::verseKey()
-{
- CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
- Q_ASSERT(k);
-
- return k;
+CSwordVerseKey* CBibleReadWindow::verseKey() {
+ CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
+ Q_ASSERT(k);
+
+ return k;
}
/** Copies the current chapter into the clipboard. */
-void CBibleReadWindow::copyDisplayedText()
-{
- CSwordVerseKey dummy(*verseKey());
- dummy.Verse(1);
+void CBibleReadWindow::copyDisplayedText() {
+ CSwordVerseKey dummy(*verseKey());
+ dummy.Verse(1);
- CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ CSwordVerseKey vk(*verseKey());
+ vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
- dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
- vk.UpperBound(dummy);
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
- CExportManager mgr(tr("Copy chapter to clipboard ..."), false, tr("Copying"), filterOptions(), displayOptions());
- mgr.copyKey(&vk, CExportManager::Text, true);
+ CExportManager mgr(tr("Copy chapter to clipboard ..."), false, tr("Copying"), filterOptions(), displayOptions());
+ mgr.copyKey(&vk, CExportManager::Text, true);
}
/** Saves the chapter as valid HTML page. */
-void CBibleReadWindow::saveChapterHTML()
-{
- //saves the complete chapter to disk
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
- Q_ASSERT(bible);
- if (!bible) //shouldn't happen
- return;
+void CBibleReadWindow::saveChapterHTML() {
+ //saves the complete chapter to disk
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ Q_ASSERT(bible);
+ if (!bible) //shouldn't happen
+ return;
- CSwordVerseKey dummy(*verseKey());
- dummy.Verse(1);
+ CSwordVerseKey dummy(*verseKey());
+ dummy.Verse(1);
- CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ CSwordVerseKey vk(*verseKey());
+ vk.LowerBound(dummy);
- dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
- vk.UpperBound(dummy);
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
- CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(), displayOptions());
- mgr.saveKey(&vk, CExportManager::HTML, true);
+ CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(&vk, CExportManager::HTML, true);
}
/** Saves the chapter as valid HTML page. */
-void CBibleReadWindow::saveChapterPlain()
-{
- //saves the complete chapter to disk
+void CBibleReadWindow::saveChapterPlain() {
+ //saves the complete chapter to disk
- CSwordVerseKey vk(*verseKey());
- CSwordVerseKey dummy(*verseKey());
+ CSwordVerseKey vk(*verseKey());
+ CSwordVerseKey dummy(*verseKey());
- dummy.Verse(1);
- vk.LowerBound(dummy);
+ dummy.Verse(1);
+ vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
- dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
- vk.UpperBound(dummy);
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
- CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(),displayOptions());
- mgr.saveKey(&vk, CExportManager::Text, true);
+ CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(&vk, CExportManager::Text, true);
}
-void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason)
-{
- CLexiconReadWindow::reload(reason);
+void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CLexiconReadWindow::reload(reason);
- if (m_modules.count() == 0)
- {
- close();
- return;
- }
+ if (m_modules.count() == 0) {
+ close();
+ return;
+ }
- //refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
- keyChooser()->refreshContent();
+ //refresh the book lists
+ verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
}
/** No descriptions */
-bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e)
-{
- const bool ret = CLexiconReadWindow::eventFilter(o,e);
-
- // Q_ASSERT(o->inherits("CDisplayWindow"));
- // qWarning("class: %s", o->className());
- if (e && (e->type() == QEvent::FocusIn))
- { //sync other windows to this active
-
- /* This is a hack to work around a KHTML problem (similair to the Drag&Drop problem we had):
- * If new HTML content is loaded from inside a kHTML event handler
- * the widget's state will be confused, i.e. it's scrolling without having
- * the mousebutton clicked.
- *
- * This is not really in a KHTML event handler but works anyway.
- * Sometime KDE/Qt is hard to use ...
- */
- QTimer::singleShot(0, this, SLOT(syncWindows()));
- }
-
- return ret;
+bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e) {
+ const bool ret = CLexiconReadWindow::eventFilter(o, e);
+
+ // Q_ASSERT(o->inherits("CDisplayWindow"));
+ // qWarning("class: %s", o->className());
+ if (e && (e->type() == QEvent::FocusIn)) { //sync other windows to this active
+
+ /* This is a hack to work around a KHTML problem (similair to the Drag&Drop problem we had):
+ * If new HTML content is loaded from inside a kHTML event handler
+ * the widget's state will be confused, i.e. it's scrolling without having
+ * the mousebutton clicked.
+ *
+ * This is not really in a KHTML event handler but works anyway.
+ * Sometime KDE/Qt is hard to use ...
+ */
+ QTimer::singleShot(0, this, SLOT(syncWindows()));
+ }
+
+ return ret;
}
-void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey )
-{
- CLexiconReadWindow::lookupSwordKey(newKey);
- syncWindows();
+void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey ) {
+ CLexiconReadWindow::lookupSwordKey(newKey);
+ syncWindows();
}
-void CBibleReadWindow::syncWindows()
-{
- foreach (QMdiSubWindow* subWindow, mdi()->subWindowList())
- {
- CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget());
- if (w && w->syncAllowed()) {
- w->lookupKey( key()->key() );
- }
- }
+void CBibleReadWindow::syncWindows() {
+ foreach (QMdiSubWindow* subWindow, mdi()->subWindowList()) {
+ CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget());
+ if (w && w->syncAllowed()) {
+ w->lookupKey( key()->key() );
+ }
+ }
}
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 3a5f64f..3b779e2 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -35,110 +35,110 @@ class QEvent;
*/
class CBibleReadWindow : public CLexiconReadWindow {
- Q_OBJECT
-public:
- CBibleReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CBibleReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Reimplementation.
- */
- static void insertKeyboardActions( BtActionCollection* const a );
-
-protected:
- virtual void initActions();
- virtual void initToolbars();
- virtual void initConnections();
- virtual void initView();
- /**
- * Reimplementation.
- */
- virtual void setupPopupMenu();
- /**
- * Reimplemented.
- */
- virtual void updatePopupMenu();
- /** Event filter.
- * Reimplementation of the event filter to filter out events like focus in.
- */
- virtual bool eventFilter( QObject* o, QEvent* e);
-
- struct {
- QAction* selectAll;
- QAction* findText;
- QAction* findStrongs;
-
- QMenu* copyMenu;
- struct {
- QAction* referenceOnly;
- QAction* referenceTextOnly;
- QAction* referenceAndText;
- QAction* chapter;
- QAction* selectedText;
- }
- copy;
-
- QMenu* saveMenu;
- struct {
- QAction* referenceAndText;
- QAction* chapterAsPlain;
- QAction* chapterAsHTML;
- }
- save;
-
- QMenu* printMenu;
- struct {
- QAction* reference;
- QAction* chapter;
- }
- print;
- }
- m_actions;
-
-
-public slots:
- void nextBook();
- void previousBook();
- void nextChapter();
- void previousChapter();
- void nextVerse();
- void previousVerse();
- /**
- * Refreshes the content of this display window and the content of the keychooser.
- */
- virtual void reload(CSwordBackend::SetupChangedReason reason);
-
-protected slots: // Protected slots
- /**
- * Copies the current chapter into the clipboard.
- */
- void copyDisplayedText();
- /**
- * Saves the chapter as valid HTML page.
- */
- void saveChapterHTML();
- /**
- * Saves the chapter as valid HTML page.
- */
- void saveChapterPlain();
- virtual void lookupSwordKey( CSwordKey* newKey );
- void syncWindows();
-
-private:
- friend class CCommentaryReadWindow;
- /**
- * Wrapper around key() to return the right type of key.
- */
- CSwordVerseKey* verseKey();
-
- // CTransliterationButton* m_transliterationButton;
+ Q_OBJECT
+ public:
+ CBibleReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CBibleReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* const settings );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* const settings );
+ /**
+ * Reimplementation.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+ /**
+ * Reimplementation.
+ */
+ virtual void setupPopupMenu();
+ /**
+ * Reimplemented.
+ */
+ virtual void updatePopupMenu();
+ /** Event filter.
+ * Reimplementation of the event filter to filter out events like focus in.
+ */
+ virtual bool eventFilter( QObject* o, QEvent* e);
+
+ struct {
+ QAction* selectAll;
+ QAction* findText;
+ QAction* findStrongs;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* referenceOnly;
+ QAction* referenceTextOnly;
+ QAction* referenceAndText;
+ QAction* chapter;
+ QAction* selectedText;
+ }
+ copy;
+
+ QMenu* saveMenu;
+ struct {
+ QAction* referenceAndText;
+ QAction* chapterAsPlain;
+ QAction* chapterAsHTML;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* reference;
+ QAction* chapter;
+ }
+ print;
+ }
+ m_actions;
+
+
+ public slots:
+ void nextBook();
+ void previousBook();
+ void nextChapter();
+ void previousChapter();
+ void nextVerse();
+ void previousVerse();
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
+ protected slots: // Protected slots
+ /**
+ * Copies the current chapter into the clipboard.
+ */
+ void copyDisplayedText();
+ /**
+ * Saves the chapter as valid HTML page.
+ */
+ void saveChapterHTML();
+ /**
+ * Saves the chapter as valid HTML page.
+ */
+ void saveChapterPlain();
+ virtual void lookupSwordKey( CSwordKey* newKey );
+ void syncWindows();
+
+ private:
+ friend class CCommentaryReadWindow;
+ /**
+ * Wrapper around key() to return the right type of key.
+ */
+ CSwordVerseKey* verseKey();
+
+ // CTransliterationButton* m_transliterationButton;
};
#endif
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 465eec9..1865a98 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -27,151 +27,137 @@
using namespace Profile;
-CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CLexiconReadWindow(modules, parent), m_treeAction(0), m_treeChooser(0)
-{
+CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+ : CLexiconReadWindow(modules, parent), m_treeAction(0), m_treeChooser(0) {
}
-CBookReadWindow::~CBookReadWindow()
-{
+CBookReadWindow::~CBookReadWindow() {
}
-void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow )
-{
- CLexiconReadWindow::applyProfileSettings(profileWindow);
+void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::applyProfileSettings(profileWindow);
- const bool enable = static_cast<bool>( profileWindow->windowSettings() );
- if (enable) {
- m_treeAction->activate(QAction::Trigger);
- }
+ const bool enable = static_cast<bool>( profileWindow->windowSettings() );
+ if (enable) {
+ m_treeAction->activate(QAction::Trigger);
+ }
}
-void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow )
-{
- CLexiconReadWindow::storeProfileSettings(profileWindow);
+void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::storeProfileSettings(profileWindow);
- //store information about our show tree structure button
- profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
+ //store information about our show tree structure button
+ profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
}
-void CBookReadWindow::initActions()
-{
- CLexiconReadWindow::initActions();
- BtActionCollection* ac = actionCollection();
- insertKeyboardActions(ac);
+void CBookReadWindow::initActions() {
+ CLexiconReadWindow::initActions();
+ BtActionCollection* ac = actionCollection();
+ insertKeyboardActions(ac);
- //cleanup, not a clean oo-solution
- Q_ASSERT(ac->action("nextEntry"));
- Q_ASSERT(ac->action("previousEntry"));
- ac->action("nextEntry")->setEnabled(false);
- ac->action("previousEntry")->setEnabled(false);
+ //cleanup, not a clean oo-solution
+ Q_ASSERT(ac->action("nextEntry"));
+ Q_ASSERT(ac->action("previousEntry"));
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
- m_treeAction = ac->action("toggleTree");
- QObject::connect(m_treeAction, SIGNAL(triggered()), this, SLOT(treeToggled()) );
- addAction(m_treeAction);
+ m_treeAction = ac->action("toggleTree");
+ QObject::connect(m_treeAction, SIGNAL(triggered()), this, SLOT(treeToggled()) );
+ addAction(m_treeAction);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
+ CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
}
-void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a )
-{
- QAction* qaction;
+void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+ QAction* qaction;
- qaction = new QAction( /* QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon), */
- tr("Toggle tree view"), a);
- qaction->setCheckable(true);
- qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
- a->addAction("toggleTree", qaction);
+ qaction = new QAction( /* QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon), */
+ tr("Toggle tree view"), a);
+ qaction->setCheckable(true);
+ qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
+ a->addAction("toggleTree", qaction);
}
/** No descriptions */
-void CBookReadWindow::initConnections()
-{
- CLexiconReadWindow::initConnections();
+void CBookReadWindow::initConnections() {
+ CLexiconReadWindow::initConnections();
- connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), keyChooser(), SLOT(updateKey(CSwordKey*)));
- connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), m_treeChooser, SLOT(updateKey(CSwordKey*)));
+ connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), keyChooser(), SLOT(updateKey(CSwordKey*)));
+ connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), m_treeChooser, SLOT(updateKey(CSwordKey*)));
}
/** Init the view */
-void CBookReadWindow::initView()
-{
- QSplitter* splitter = new QSplitter(this);
+void CBookReadWindow::initView() {
+ QSplitter* splitter = new QSplitter(this);
- setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
+ setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
- addToolBar(mainToolBar());
+ addToolBar(mainToolBar());
- m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
- setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+ m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
+ setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
- moduleChooserBar()->setButtonLimit(1);
- addToolBar(moduleChooserBar());
+ setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
+ moduleChooserBar()->setButtonLimit(1);
+ addToolBar(moduleChooserBar());
- setButtonsToolBar( new QToolBar(this) );
- buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- buttonsToolBar()->setFloatable(false);
- setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
- addToolBar(buttonsToolBar());
- m_treeChooser->hide();
+ setButtonsToolBar( new QToolBar(this) );
+ buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ buttonsToolBar()->setFloatable(false);
+ setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+ addToolBar(buttonsToolBar());
+ m_treeChooser->hide();
- setCentralWidget( splitter );
- setWindowIcon(CToolClass::getIconForModule(modules().first()));
+ setCentralWidget( splitter );
+ setWindowIcon(CToolClass::getIconForModule(modules().first()));
}
-void CBookReadWindow::initToolbars()
-{
- Q_ASSERT(m_treeAction);
- Q_ASSERT(m_actions.backInHistory);
+void CBookReadWindow::initToolbars() {
+ Q_ASSERT(m_treeAction);
+ Q_ASSERT(m_actions.backInHistory);
- mainToolBar()->addAction(m_actions.backInHistory);
- mainToolBar()->addAction(m_actions.forwardInHistory);
+ mainToolBar()->addAction(m_actions.backInHistory);
+ mainToolBar()->addAction(m_actions.forwardInHistory);
- mainToolBar()->addWidget(keyChooser());
+ mainToolBar()->addWidget(keyChooser());
- buttonsToolBar()->addAction(m_treeAction);
- m_treeAction->setChecked(false);
+ buttonsToolBar()->addAction(m_treeAction);
+ m_treeAction->setChecked(false);
- buttonsToolBar()->addWidget(displaySettingsButton());
+ buttonsToolBar()->addWidget(displaySettingsButton());
- QAction* action = qobject_cast<QAction*>(actionCollection()->action(
- CResMgr::displaywindows::general::search::actionName ));
- if (action) {
- buttonsToolBar()->addAction(action);
- }
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName ));
+ if (action) {
+ buttonsToolBar()->addAction(action);
+ }
}
/** Is called when the action was executed to toggle the tree view. */
-void CBookReadWindow::treeToggled()
-{
- if (m_treeAction->isChecked())
- {
- m_treeChooser->show();
- }
- else {
- m_treeChooser->hide();
- }
+void CBookReadWindow::treeToggled() {
+ if (m_treeAction->isChecked()) {
+ m_treeChooser->show();
+ }
+ else {
+ m_treeChooser->hide();
+ }
}
/** Reimplementation to take care of the tree chooser. */
-void CBookReadWindow::modulesChanged()
-{
- CLexiconReadWindow::modulesChanged();
- m_treeChooser->setModules(modules());
+void CBookReadWindow::modulesChanged() {
+ CLexiconReadWindow::modulesChanged();
+ m_treeChooser->setModules(modules());
}
-void CBookReadWindow::setupPopupMenu()
-{
- CLexiconReadWindow::setupPopupMenu();
+void CBookReadWindow::setupPopupMenu() {
+ CLexiconReadWindow::setupPopupMenu();
}
-void CBookReadWindow::reload(CSwordBackend::SetupChangedReason reason)
-{
- CLexiconReadWindow::reload(reason);
+void CBookReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CLexiconReadWindow::reload(reason);
}
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index a2a2219..62d788d 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -25,51 +25,51 @@ class BtActionCollection;
* @author The BibleTime team
*/
class CBookReadWindow : public CLexiconReadWindow {
- Q_OBJECT
-public:
- static void insertKeyboardActions( BtActionCollection* const a );
-
- CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
-
- virtual ~CBookReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
-
-public slots:
- /**
- * Refreshes the content of this display window and the content of the keychooser.
- */
- virtual void reload(CSwordBackend::SetupChangedReason reason);
-
-protected:
- virtual void initActions();
- virtual void initToolbars();
- virtual void initConnections();
- virtual void initView();
-
- virtual void setupPopupMenu();
-
- protected slots: // Protected slots
- /**
- * Reimplementation to take care of the tree chooser.
- */
- virtual void modulesChanged();
-
-private:
- QAction* m_treeAction;
- CBookTreeChooser* m_treeChooser;
-
-private slots: // Private slots
- /**
- * Is called when the action was executed to toggle the tree view.
- */
- void treeToggled();
+ Q_OBJECT
+ public:
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+
+ virtual ~CBookReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+
+ public slots:
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
+ protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+
+ virtual void setupPopupMenu();
+
+ protected slots: // Protected slots
+ /**
+ * Reimplementation to take care of the tree chooser.
+ */
+ virtual void modulesChanged();
+
+ private:
+ QAction* m_treeAction;
+ CBookTreeChooser* m_treeChooser;
+
+ private slots: // Private slots
+ /**
+ * Is called when the action was executed to toggle the tree view.
+ */
+ void treeToggled();
};
#endif
diff --git a/src/frontend/displaywindow/cbuttons.cpp b/src/frontend/displaywindow/cbuttons.cpp
index 582e5de..fbe2443 100644
--- a/src/frontend/displaywindow/cbuttons.cpp
+++ b/src/frontend/displaywindow/cbuttons.cpp
@@ -26,166 +26,166 @@
-CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules,QWidget *parent )
-: QToolButton(parent) {
- // qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
- QToolButton::setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::displaySettings::icon));
-
- m_displaySettings = displaySettings;
- m_moduleSettings = moduleSettings;
- m_modules = useModules;
-
- m_popup = new QMenu(this);
- setMenu(m_popup);
- setPopupMode(QToolButton::InstantPopup);
- setToolTip(tr("Display options"));
-
- connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(optionToggled(QAction*)));
- populateMenu();
+CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent )
+ : QToolButton(parent) {
+ // qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
+ QToolButton::setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::displaySettings::icon));
+
+ m_displaySettings = displaySettings;
+ m_moduleSettings = moduleSettings;
+ m_modules = useModules;
+
+ m_popup = new QMenu(this);
+ setMenu(m_popup);
+ setPopupMode(QToolButton::InstantPopup);
+ setToolTip(tr("Display options"));
+
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(optionToggled(QAction*)));
+ populateMenu();
}
void CDisplaySettingsButton::reset(const QList<CSwordModuleInfo*>& useModules) {
- m_modules = useModules;
- populateMenu();
- //disable the settings button if no options are available
- if (!populateMenu()) {
- setEnabled(false);
- setToolTip(tr("Display settings: No options available"));
- }
- else {
- setEnabled(true);
- setToolTip(tr("Display settings"));
- }
+ m_modules = useModules;
+ populateMenu();
+ //disable the settings button if no options are available
+ if (!populateMenu()) {
+ setEnabled(false);
+ setToolTip(tr("Display settings: No options available"));
+ }
+ else {
+ setEnabled(true);
+ setToolTip(tr("Display settings"));
+ }
}
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().
- foreach (QAction* act, m_popup->actions()) {
- int optionType = act->property("OptionType").toInt();
- bool checked = act->isChecked();
- switch(optionType) {
- case Linebreak:
- m_displaySettings->lineBreaks = checked;
- break;
- case Versenum:
- m_displaySettings->verseNumbers = checked;
- break;
- case Variant:
- m_moduleSettings->textualVariants = checked;
- break;
- case Vowel:
- m_moduleSettings->hebrewPoints = checked;
- break;
- case Accents:
- m_moduleSettings->greekAccents = checked;
- break;
- case Cantillation:
- m_moduleSettings->hebrewCantillation = checked;
- break;
- case Headings:
- m_moduleSettings->headings = checked;
- break;
- case Morphseg:
- m_moduleSettings->morphSegmentation = checked;
- break;
- case Xref:
- m_moduleSettings->scriptureReferences = checked;
- break;
- case WordsofJ:
- m_moduleSettings->redLetterWords = checked;
- break;
- }
- }
-
- emit sigChanged();
+ 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().
+ foreach (QAction* act, m_popup->actions()) {
+ int optionType = act->property("OptionType").toInt();
+ bool checked = act->isChecked();
+ switch (optionType) {
+ case Linebreak:
+ m_displaySettings->lineBreaks = checked;
+ break;
+ case Versenum:
+ m_displaySettings->verseNumbers = checked;
+ break;
+ case Variant:
+ m_moduleSettings->textualVariants = checked;
+ break;
+ case Vowel:
+ m_moduleSettings->hebrewPoints = checked;
+ break;
+ case Accents:
+ m_moduleSettings->greekAccents = checked;
+ break;
+ case Cantillation:
+ m_moduleSettings->hebrewCantillation = checked;
+ break;
+ case Headings:
+ m_moduleSettings->headings = checked;
+ break;
+ case Morphseg:
+ m_moduleSettings->morphSegmentation = checked;
+ break;
+ case Xref:
+ m_moduleSettings->scriptureReferences = checked;
+ break;
+ case WordsofJ:
+ m_moduleSettings->redLetterWords = checked;
+ break;
+ }
+ }
+
+ emit sigChanged();
}
/** No descriptions */
int CDisplaySettingsButton::populateMenu() {
- int ret = 0;
+ int ret = 0;
- m_popup->clear();
+ m_popup->clear();
- // See also optionToggled()
+ // See also optionToggled()
- ret += addMenuEntry(tr("Use linebreaks after each verse"), Linebreak, &m_displaySettings->lineBreaks, (m_modules.first()->type() == CSwordModuleInfo::Bible));
+ ret += addMenuEntry(tr("Use linebreaks after each verse"), Linebreak, &m_displaySettings->lineBreaks, (m_modules.first()->type() == CSwordModuleInfo::Bible));
- //show the verse numbers option only for bible modules
- ret += addMenuEntry(tr("Show verse numbers"), Versenum, &m_displaySettings->verseNumbers, (m_modules.first()->type() == CSwordModuleInfo::Bible));
+ //show the verse numbers option only for bible modules
+ ret += addMenuEntry(tr("Show verse numbers"), Versenum, &m_displaySettings->verseNumbers, (m_modules.first()->type() == CSwordModuleInfo::Bible));
- ret += addMenuEntry(tr("Show headings"), Headings, &m_moduleSettings->headings,
- isOptionAvailable(CSwordModuleInfo::headings));
+ ret += addMenuEntry(tr("Show headings"), Headings, &m_moduleSettings->headings,
+ isOptionAvailable(CSwordModuleInfo::headings));
- ret += addMenuEntry(tr("Highlight words of Jesus"), WordsofJ, &m_moduleSettings->redLetterWords,
- isOptionAvailable(CSwordModuleInfo::redLetterWords ));
+ ret += addMenuEntry(tr("Highlight words of Jesus"), WordsofJ, &m_moduleSettings->redLetterWords,
+ isOptionAvailable(CSwordModuleInfo::redLetterWords ));
- ret += addMenuEntry(tr("Show Hebrew vowel points"), Vowel, &m_moduleSettings->hebrewPoints,
- isOptionAvailable(CSwordModuleInfo::hebrewPoints ));
+ ret += addMenuEntry(tr("Show Hebrew vowel points"), Vowel, &m_moduleSettings->hebrewPoints,
+ isOptionAvailable(CSwordModuleInfo::hebrewPoints ));
- ret += addMenuEntry(tr("Show Hebrew cantillation marks"), Cantillation, &m_moduleSettings->hebrewCantillation,
- isOptionAvailable(CSwordModuleInfo::hebrewCantillation ));
+ ret += addMenuEntry(tr("Show Hebrew cantillation marks"), Cantillation, &m_moduleSettings->hebrewCantillation,
+ isOptionAvailable(CSwordModuleInfo::hebrewCantillation ));
- ret += addMenuEntry(tr("Show Greek accents"), Accents, &m_moduleSettings->greekAccents,
- isOptionAvailable(CSwordModuleInfo::greekAccents ));
+ ret += addMenuEntry(tr("Show Greek accents"), Accents, &m_moduleSettings->greekAccents,
+ isOptionAvailable(CSwordModuleInfo::greekAccents ));
- ret += addMenuEntry(tr("Use alternative textual variant"), Variant, &m_moduleSettings->textualVariants,
- isOptionAvailable(CSwordModuleInfo::textualVariants ));
+ ret += addMenuEntry(tr("Use alternative textual variant"), Variant, &m_moduleSettings->textualVariants,
+ isOptionAvailable(CSwordModuleInfo::textualVariants ));
- ret += addMenuEntry(tr("Show scripture cross-references"), Xref, &m_moduleSettings->scriptureReferences,
- isOptionAvailable(CSwordModuleInfo::scriptureReferences ));
+ ret += addMenuEntry(tr("Show scripture cross-references"), Xref, &m_moduleSettings->scriptureReferences,
+ isOptionAvailable(CSwordModuleInfo::scriptureReferences ));
- ret += addMenuEntry(tr("Show morph segmentation"), Morphseg, &m_moduleSettings->morphSegmentation,
- isOptionAvailable(CSwordModuleInfo::morphSegmentation ));
+ ret += addMenuEntry(tr("Show morph segmentation"), Morphseg, &m_moduleSettings->morphSegmentation,
+ isOptionAvailable(CSwordModuleInfo::morphSegmentation ));
- return ret;
+ return ret;
}
/** Adds an entry to m_popup. */
int CDisplaySettingsButton::addMenuEntry( const QString name, OptionType type, const int* option, const bool available) {
- int ret = 0;
-
- if (available) {
- QAction* a = m_popup->addAction(name);
- //see optionToggled()
- a->setProperty("OptionType", type);
- a->setCheckable(true);
- a->setChecked(*option);
- ret = 1;
- }
-
- return ret;
+ int ret = 0;
+
+ if (available) {
+ QAction* a = m_popup->addAction(name);
+ //see optionToggled()
+ a->setProperty("OptionType", type);
+ a->setCheckable(true);
+ a->setChecked(*option);
+ ret = 1;
+ }
+
+ return ret;
}
bool CDisplaySettingsButton::isOptionAvailable( const CSwordModuleInfo::FilterTypes option ) {
- bool ret = false;
- QList<CSwordModuleInfo*>::iterator end_it = m_modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_modules.begin()); it != end_it; ++it) {
- ret = ret || (*it)->has(option);
- }
- return ret;
+ bool ret = false;
+ QList<CSwordModuleInfo*>::iterator end_it = m_modules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(m_modules.begin()); it != end_it; ++it) {
+ ret = ret || (*it)->has(option);
+ }
+ return ret;
}
/** Returns the number of usable menu items in the settings menu. */
int CDisplaySettingsButton::menuItemCount() {
- return m_popup->actions().count();
+ return m_popup->actions().count();
}
/** Sets the item at position pos to the state given as 2nd paramter. */
void CDisplaySettingsButton::setItemStatus( const int index, const bool checked ) {
- QAction* action = m_popup->actions().at(index);
- action->setChecked(checked);
+ QAction* action = m_popup->actions().at(index);
+ action->setChecked(checked);
}
/** Returns the status of the item at position "index" */
bool CDisplaySettingsButton::itemStatus( const int index ) {
- return m_popup->actions().at(index)->isChecked();
+ return m_popup->actions().at(index)->isChecked();
}
/** Sets the status to changed. The signal changed will be emitted. */
void CDisplaySettingsButton::setChanged() {
- emit sigChanged();
+ emit sigChanged();
}
diff --git a/src/frontend/displaywindow/cbuttons.h b/src/frontend/displaywindow/cbuttons.h
index 6d94c53..5f1d599 100644
--- a/src/frontend/displaywindow/cbuttons.h
+++ b/src/frontend/displaywindow/cbuttons.h
@@ -26,52 +26,53 @@ class QMenu;
* @author The BibleTime team
*/
class CDisplaySettingsButton : public QToolButton {
- Q_OBJECT
-public:
-
- CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *settings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent=0);
- void reset(const QList<CSwordModuleInfo*>& useModules);
- /**
- * Sets the item at position pos to the satet given as 2nd paramter.
- */
- void setItemStatus( const int pos, const bool checked );
- /**
- * Returns the number of usable menu items in the setttings menu.
- */
- int menuItemCount();
- /**
- * Returns the status of the item at position "index"
- */
- bool itemStatus( const int index );
- /**
- * Sets the status to changed. The signal changed will be emitted.
- */
- void setChanged();
-
-signals:
- void sigChanged(void);
-
-protected slots:
- void optionToggled(QAction* action);
-
-protected:
-
- /** This enum marks the option types for a display. Used internally.*/
- enum OptionType {Linebreak, Versenum, Headings, WordsofJ, Vowel, Cantillation, Accents,
- Variant, Xref, Morphseg};
-
- CSwordBackend::FilterOptions* m_moduleSettings;
- CSwordBackend::DisplayOptions* m_displaySettings;
- CSwordBackend::FilterOptions m_available;
- QList<CSwordModuleInfo*> m_modules;
-
- QHash<QString, int> m_dict;
-
- QMenu* m_popup;
-
- int populateMenu();
- bool isOptionAvailable( const CSwordModuleInfo::FilterTypes option);
- int addMenuEntry( const QString name, OptionType type, const int* option, const bool available);
+ Q_OBJECT
+ public:
+
+ CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *settings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent = 0);
+ void reset(const QList<CSwordModuleInfo*>& useModules);
+ /**
+ * Sets the item at position pos to the satet given as 2nd paramter.
+ */
+ void setItemStatus( const int pos, const bool checked );
+ /**
+ * Returns the number of usable menu items in the setttings menu.
+ */
+ int menuItemCount();
+ /**
+ * Returns the status of the item at position "index"
+ */
+ bool itemStatus( const int index );
+ /**
+ * Sets the status to changed. The signal changed will be emitted.
+ */
+ void setChanged();
+
+ signals:
+ void sigChanged(void);
+
+ protected slots:
+ void optionToggled(QAction* action);
+
+ protected:
+
+ /** This enum marks the option types for a display. Used internally.*/
+ enum OptionType {Linebreak, Versenum, Headings, WordsofJ, Vowel, Cantillation, Accents,
+ Variant, Xref, Morphseg
+ };
+
+ CSwordBackend::FilterOptions* m_moduleSettings;
+ CSwordBackend::DisplayOptions* m_displaySettings;
+ CSwordBackend::FilterOptions m_available;
+ QList<CSwordModuleInfo*> m_modules;
+
+ QHash<QString, int> m_dict;
+
+ QMenu* m_popup;
+
+ int populateMenu();
+ bool isOptionAvailable( const CSwordModuleInfo::FilterTypes option);
+ int addMenuEntry( const QString name, OptionType type, const int* option, const bool available);
};
#endif
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index 7ead206..fdd345e 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -27,180 +27,164 @@
using namespace Profile;
-CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent)
-{
+CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {
}
-void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a)
-{
- QAction* qaction;
+void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
+ QAction* qaction;
- qaction = new QAction(tr("Next book"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
- a->addAction("nextBook", qaction);
+ qaction = new QAction(tr("Next book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ a->addAction("nextBook", qaction);
- qaction = new QAction(tr("Previous book"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
- a->addAction( "previousBook", qaction);
+ qaction = new QAction(tr("Previous book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ a->addAction( "previousBook", qaction);
- qaction = new QAction(tr("Next chapter"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
- a->addAction("nextChapter", qaction);
+ qaction = new QAction(tr("Next chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ a->addAction("nextChapter", qaction);
- qaction = new QAction(tr("Previous chapter"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
- a->addAction("previousChapter", qaction);
+ qaction = new QAction(tr("Previous chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ a->addAction("previousChapter", qaction);
- qaction = new QAction(tr("Next verse"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
- a->addAction("nextVerse", qaction);
+ qaction = new QAction(tr("Next verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ a->addAction("nextVerse", qaction);
- qaction = new QAction(tr("Previous verse"), a);
- qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
- a->addAction("previousVerse", qaction);
+ qaction = new QAction(tr("Previous verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ a->addAction("previousVerse", qaction);
}
-void CCommentaryReadWindow::initActions()
-{
- CLexiconReadWindow::initActions(); //make sure the predefined actions are available
- BtActionCollection* ac = actionCollection();
- insertKeyboardActions(ac);
+void CCommentaryReadWindow::initActions() {
+ CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+ BtActionCollection* ac = actionCollection();
+ insertKeyboardActions(ac);
- //cleanup, not a clean oo-solution
- ac->action("nextEntry")->setEnabled(false);
- ac->action("previousEntry")->setEnabled(false);
+ //cleanup, not a clean oo-solution
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
- QAction* qaction;
+ QAction* qaction;
- qaction = ac->action("nextBook");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
- addAction(qaction);
+ qaction = ac->action("nextBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
+ addAction(qaction);
- qaction = ac->action("previousBook");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
- addAction(qaction);
+ qaction = ac->action("previousBook");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
+ addAction(qaction);
- qaction = ac->action("nextChapter");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
- addAction(qaction);
+ qaction = ac->action("nextChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
+ addAction(qaction);
- qaction = ac->action("previousChapter");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
- addAction(qaction);
+ qaction = ac->action("previousChapter");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
+ addAction(qaction);
- qaction = ac->action("nextVerse");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
- addAction(qaction);
+ qaction = ac->action("nextVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
+ addAction(qaction);
- qaction = ac->action("previousVerse");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
- addAction(qaction);
+ qaction = ac->action("previousVerse");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
+ addAction(qaction);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
-void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow )
-{
- CLexiconReadWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings()) {
- m_syncButton->setChecked(true);
- }
+void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_syncButton->setChecked(true);
+ }
}
-void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow )
-{
- CLexiconReadWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_syncButton->isChecked() );
+void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_syncButton->isChecked() );
}
-void CCommentaryReadWindow::initToolbars()
-{
- CLexiconReadWindow::initToolbars();
+void CCommentaryReadWindow::initToolbars() {
+ CLexiconReadWindow::initToolbars();
- m_syncButton = new QAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
- tr("Synchronize"),
- actionCollection()
- );
- m_syncButton->setCheckable(true);
- m_syncButton->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_syncButton->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_syncButton);
- buttonsToolBar()->addAction(m_syncButton);
+ m_syncButton = new QAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ tr("Synchronize"),
+ actionCollection()
+ );
+ m_syncButton->setCheckable(true);
+ m_syncButton->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ m_syncButton->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
+ actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_syncButton);
+ buttonsToolBar()->addAction(m_syncButton);
}
/** Reimplementation to handle the keychooser refresh. */
-void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason)
-{
- CLexiconReadWindow::reload(reason);
+void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CLexiconReadWindow::reload(reason);
- //refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
- keyChooser()->refreshContent();
+ //refresh the book lists
+ verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
/** rapper around key() to return the right type of key. */
-CSwordVerseKey* CCommentaryReadWindow::verseKey()
-{
- CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
- Q_ASSERT(k);
- return k;
+CSwordVerseKey* CCommentaryReadWindow::verseKey() {
+ CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
+ Q_ASSERT(k);
+ return k;
}
/** Moves to the next book. */
-void CCommentaryReadWindow::nextBook()
-{
- if (verseKey()->next(CSwordVerseKey::UseBook))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::nextBook() {
+ if (verseKey()->next(CSwordVerseKey::UseBook))
+ keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousBook()
-{
- if (verseKey()->previous(CSwordVerseKey::UseBook))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::previousBook() {
+ if (verseKey()->previous(CSwordVerseKey::UseBook))
+ keyChooser()->setKey(key());
}
/** Moves to the next book. */
-void CCommentaryReadWindow::nextChapter()
-{
- if (verseKey()->next(CSwordVerseKey::UseChapter))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::nextChapter() {
+ if (verseKey()->next(CSwordVerseKey::UseChapter))
+ keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousChapter()
-{
- if (verseKey()->previous(CSwordVerseKey::UseChapter))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::previousChapter() {
+ if (verseKey()->previous(CSwordVerseKey::UseChapter))
+ keyChooser()->setKey(key());
}
/** Moves to the next book. */
-void CCommentaryReadWindow::nextVerse()
-{
- if (verseKey()->next(CSwordVerseKey::UseVerse))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::nextVerse() {
+ if (verseKey()->next(CSwordVerseKey::UseVerse))
+ keyChooser()->setKey(key());
}
/** Moves one book behind. */
-void CCommentaryReadWindow::previousVerse()
-{
- if (verseKey()->previous(CSwordVerseKey::UseVerse))
- keyChooser()->setKey(key());
+void CCommentaryReadWindow::previousVerse() {
+ if (verseKey()->previous(CSwordVerseKey::UseVerse))
+ keyChooser()->setKey(key());
}
-bool CCommentaryReadWindow::syncAllowed() const
-{
- return m_syncButton->isChecked();
+bool CCommentaryReadWindow::syncAllowed() const {
+ return m_syncButton->isChecked();
}
/*!
\fn CCommentaryReadWindow::setupPopupMenu()
*/
-void CCommentaryReadWindow::setupPopupMenu()
-{
- CLexiconReadWindow::setupPopupMenu();
+void CCommentaryReadWindow::setupPopupMenu() {
+ CLexiconReadWindow::setupPopupMenu();
}
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index 333b48f..21f4630 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -23,45 +23,45 @@ class BtActionCollection;
*/
class CCommentaryReadWindow : public CLexiconReadWindow {
- Q_OBJECT
-public:
- /**
- * Reimplementation.
- */
- static void insertKeyboardActions( BtActionCollection* const a );
+ Q_OBJECT
+ public:
+ /**
+ * Reimplementation.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
- CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
- virtual bool syncAllowed() const;
+ CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ virtual bool syncAllowed() const;
-public slots: // Public slots
- void nextBook();
- void previousBook();
- void nextChapter();
- void previousChapter();
- void nextVerse();
- void previousVerse();
- /**
- * Reimplementation to handle the keychooser refresh.
- */
- virtual void reload(CSwordBackend::SetupChangedReason);
+ public slots: // Public slots
+ void nextBook();
+ void previousBook();
+ void nextChapter();
+ void previousChapter();
+ void nextVerse();
+ void previousVerse();
+ /**
+ * Reimplementation to handle the keychooser refresh.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason);
-protected:
- virtual void initActions();
- virtual void initToolbars();
+ protected:
+ virtual void initActions();
+ virtual void initToolbars();
-private:
- QAction* m_syncButton;
- CSwordVerseKey* verseKey();
-protected:
- virtual void setupPopupMenu();
+ private:
+ QAction* m_syncButton;
+ CSwordVerseKey* verseKey();
+ protected:
+ virtual void setupPopupMenu();
};
#endif
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 8b4a9cd..394e96b 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -32,520 +32,458 @@
using namespace Profile;
CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
- : QMainWindow(parent),
- m_mdi(parent),
- m_filterOptions(),
- m_displayOptions(),
- m_displaySettingsButton(0),
- m_keyChooser(0),
- m_swordKey(0),
- m_isReady(false),
- m_moduleChooserBar(0),
- m_mainToolBar(0),
- m_popupMenu(0),
- m_displayWidget(0)
-{
- 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);
- setModules(modules);
-
- // Connect this to the backend module list changes
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reload(CSwordBackend::SetupChangedReason)));
-}
-
-CDisplayWindow::~CDisplayWindow()
-{
- delete m_swordKey;
- m_swordKey = 0;
-}
-
-CMDIArea* CDisplayWindow::mdi() const
-{
- return m_mdi;
+ : QMainWindow(parent),
+ m_mdi(parent),
+ m_filterOptions(),
+ m_displayOptions(),
+ m_displaySettingsButton(0),
+ m_keyChooser(0),
+ m_swordKey(0),
+ m_isReady(false),
+ m_moduleChooserBar(0),
+ m_mainToolBar(0),
+ m_popupMenu(0),
+ m_displayWidget(0) {
+ 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);
+ setModules(modules);
+
+ // Connect this to the backend module list changes
+ connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reload(CSwordBackend::SetupChangedReason)));
+}
+
+CDisplayWindow::~CDisplayWindow() {
+ delete m_swordKey;
+ m_swordKey = 0;
+}
+
+CMDIArea* CDisplayWindow::mdi() const {
+ return m_mdi;
}
/** Returns the right window caption. */
-const QString CDisplayWindow::windowCaption()
-{
- if (!m_modules.count())
- {
- return QString::null;
- }
+const QString CDisplayWindow::windowCaption() {
+ if (!m_modules.count()) {
+ return QString::null;
+ }
- return QString(key()->key()).append(" (").append(m_modules.join(" | ")).append(")");
+ return QString(key()->key()).append(" (").append(m_modules.join(" | ")).append(")");
}
/** Returns the used modules as a QPtrList */
-QList<CSwordModuleInfo*> CDisplayWindow::modules()
-{
- QList<CSwordModuleInfo*> mods;
+QList<CSwordModuleInfo*> CDisplayWindow::modules() {
+ QList<CSwordModuleInfo*> mods;
- for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it)
- {
- Q_ASSERT(backend()->findModuleByName(*it));
- if (CSwordModuleInfo* m = backend()->findModuleByName(*it))
- {
- mods.append(m);
- }
- }
+ for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it) {
+ Q_ASSERT(backend()->findModuleByName(*it));
+ if (CSwordModuleInfo* m = backend()->findModuleByName(*it)) {
+ mods.append(m);
+ }
+ }
- return mods;
+ return mods;
}
/** Set the window caption. */
-void CDisplayWindow::setCaption( const QString& )
-{
- QWidget::setWindowTitle( windowCaption() );
- m_mdi->emitWindowCaptionChanged();
+void CDisplayWindow::setCaption( const QString& ) {
+ QWidget::setWindowTitle( windowCaption() );
+ m_mdi->emitWindowCaptionChanged();
}
-void CDisplayWindow::insertKeyboardActions( BtActionCollection* a )
-{
- qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
+void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
+ qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
- QAction* actn = new QAction(QIcon(), tr("Zoom in"), 0);
- actn->setShortcut(QKeySequence::ZoomIn);
- a->addAction("zoomIn", actn);
+ QAction* actn = new QAction(QIcon(), tr("Zoom in"), a);
+ actn->setShortcut(QKeySequence::ZoomIn);
+ a->addAction("zoomIn", actn);
- actn = new QAction(QIcon(), tr("Zoom out"), 0);
- actn->setShortcut(QKeySequence::ZoomOut);
- a->addAction("zoomOut", actn);
+ actn = new QAction(QIcon(), tr("Zoom out"), a);
+ actn->setShortcut(QKeySequence::ZoomOut);
+ a->addAction("zoomOut", actn);
- actn = new QAction(QIcon(), tr("Close"), 0);
- actn->setShortcut(QKeySequence::Close);
- a->addAction("closeWindow", actn);
+ actn = new QAction(QIcon(), tr("Close"), a);
+ actn->setShortcut(QKeySequence::Close);
+ a->addAction("closeWindow", actn);
- actn = new QAction(QIcon(), tr("Select all"), 0);
- actn->setShortcut(QKeySequence::SelectAll);
- a->addAction("selectAll", actn);
+ actn = new QAction(QIcon(), tr("Select all"), a);
+ actn->setShortcut(QKeySequence::SelectAll);
+ a->addAction("selectAll", actn);
- actn = new QAction(QIcon(), tr("Copy"), 0);
- actn->setShortcut(QKeySequence::Copy);
- a->addAction("copySelectedText", actn);
+ actn = new QAction(QIcon(), tr("Copy"), a);
+ actn->setShortcut(QKeySequence::Copy);
+ a->addAction("copySelectedText", actn);
- actn = new QAction(QIcon(), tr("Find..."), 0);
- actn->setShortcut(QKeySequence::Find);
- a->addAction("findText", actn);
+ actn = new QAction(QIcon(), tr("Find..."), a);
+ actn->setShortcut(QKeySequence::Find);
+ a->addAction("findText", actn);
- actn = new QAction(QIcon(), tr("Change location"), 0);
- actn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
- a->addAction("openLocation", actn);
+ actn = new QAction(QIcon(), tr("Change location"), 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)),
- tr("Search with works of this window"), 0);
- actn->setShortcut(CResMgr::displaywindows::general::search::accel);
- a->addAction(CResMgr::displaywindows::general::search::actionName, actn);
+ actn = new QAction(QIcon(util::filesystem::DirectoryUtil::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)),
- tr("Back in history"),
- a
- );
- action->setShortcut(CResMgr::displaywindows::general::backInHistory::accel);
- a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
+ BtToolBarPopupAction* action = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ tr("Back in history"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::general::backInHistory::accel);
+ a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
- action = new BtToolBarPopupAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
- tr("Forward in history"),
- a
- );
- action->setShortcut(CResMgr::displaywindows::general::forwardInHistory::accel);
- a->addAction(CResMgr::displaywindows::general::forwardInHistory::actionName, action);
+ action = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ tr("Forward in history"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::general::forwardInHistory::accel);
+ a->addAction(CResMgr::displaywindows::general::forwardInHistory::actionName, action);
}
-void CDisplayWindow::initActions()
-{
- qDebug("CDisplayWindow::initActions");
+void CDisplayWindow::initActions() {
+ qDebug("CDisplayWindow::initActions");
- BtActionCollection* ac = actionCollection();
+ BtActionCollection* ac = actionCollection();
- CDisplayWindow::insertKeyboardActions(ac);
+ CDisplayWindow::insertKeyboardActions(ac);
- QAction* actn = ac->action(CResMgr::displaywindows::general::search::actionName);
- QObject::connect(actn, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
+ QAction* actn = ac->action(CResMgr::displaywindows::general::search::actionName);
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
- CDisplayConnections* conn = displayWidget()->connectionsProxy();
+ CDisplayConnections* conn = displayWidget()->connectionsProxy();
- actn = ac->action("openLocation");
- QObject::connect(actn, SIGNAL(triggered()), this, SLOT(setFocusKeyChooser()));
- addAction(actn);
+ actn = ac->action("openLocation");
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(setFocusKeyChooser()));
+ addAction(actn);
- actn = ac->action("zoomIn");
- QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
- addAction(actn);
+ actn = ac->action("zoomIn");
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
+ addAction(actn);
- actn = ac->action("zoomOut");
- QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
- addAction(actn);
+ actn = ac->action("zoomOut");
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
+ addAction(actn);
- actn = ac->action("closeWindow");
- QObject::connect(actn, SIGNAL(triggered()), this, SLOT(close()));
- addAction(actn);
+ actn = ac->action("closeWindow");
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(close()));
+ addAction(actn);
- actn = ac->action("selectAll");
- QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
- addAction(actn);
+ actn = ac->action("selectAll");
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
+ addAction(actn);
- actn = ac->action("copySelectedText");
- QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(copySelection()));
- addAction(actn);
+ actn = ac->action("copySelectedText");
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(copySelection()));
+ addAction(actn);
- actn = ac->action("findText");
- QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(openFindTextDialog()));
- addAction(actn);
+ actn = ac->action("findText");
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(openFindTextDialog()));
+ addAction(actn);
- QAction* popupaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
- bool ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(back()));
- Q_ASSERT(ok);
- addAction(popupaction);
+ QAction* popupaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
+ bool ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(back()));
+ Q_ASSERT(ok);
+ addAction(popupaction);
- popupaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
- ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(fw()) );
- Q_ASSERT(ok);
- addAction(popupaction);
+ popupaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
+ ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(fw()) );
+ Q_ASSERT(ok);
+ addAction(popupaction);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows,ac);
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows, ac);
}
/** Refresh the settings of this window. */
-void CDisplayWindow::reload(CSwordBackend::SetupChangedReason)
-{
- //first make sure all used Sword modules are still present
- QMutableStringListIterator it(m_modules);
- while (it.hasNext()) {
- if (!backend()->findModuleByName(it.next()))
- {
- it.remove();
- }
- }
-
- if (m_modules.count() == 0)
- {
- close();
- return;
- }
-
- if (keyChooser()) keyChooser()->setModules( modules(), false );
-
- if (m_moduleChooserBar) { //necessary for edit windows which have now chooser bar
- m_moduleChooserBar->setModules(modules());
- }
- modulesChanged();
- lookup();
-
- CBTConfig::setupAccelSettings(CBTConfig::allWindows,actionCollection());
- CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
+void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
+ //first make sure all used Sword modules are still present
+ QMutableStringListIterator it(m_modules);
+ while (it.hasNext()) {
+ if (!backend()->findModuleByName(it.next())) {
+ it.remove();
+ }
+ }
+
+ if (m_modules.count() == 0) {
+ close();
+ return;
+ }
+
+ if (keyChooser()) keyChooser()->setModules( modules(), false );
+
+ if (m_moduleChooserBar) { //necessary for edit windows which have now chooser bar
+ m_moduleChooserBar->setModules(modules());
+ }
+ modulesChanged();
+ lookup();
+
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
}
/** Returns the filter options used by this window. */
-CSwordBackend::FilterOptions& CDisplayWindow::filterOptions()
-{
- return m_filterOptions;
+CSwordBackend::FilterOptions& CDisplayWindow::filterOptions() {
+ return m_filterOptions;
}
/** Returns the display options used by this display window. */
-CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions()
-{
- return m_displayOptions;
+CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions() {
+ return m_displayOptions;
}
/** Sets the new display options for this window. */
-void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions )
-{
- m_displayOptions = displayOptions;
+void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions ) {
+ m_displayOptions = displayOptions;
}
/** Sets the new filter options of this window. */
-void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions )
-{
- m_filterOptions = filterOptions;
+void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions ) {
+ m_filterOptions = filterOptions;
}
/** Returns true if the widget is ready for use. */
-bool CDisplayWindow::isReady() const
-{
- return m_isReady;
+bool CDisplayWindow::isReady() const {
+ return m_isReady;
}
/** Set the ready status */
-void CDisplayWindow::setReady( const bool& ready )
-{
- m_isReady = ready;
+void CDisplayWindow::setReady( const bool& ready ) {
+ m_isReady = ready;
}
/** Returns true if the window may be closed. */
-bool CDisplayWindow::queryClose()
-{
- return true;
+bool CDisplayWindow::queryClose() {
+ return true;
}
/** Returns the keychooser widget of this display window. */
-CKeyChooser* CDisplayWindow::keyChooser() const
-{
- return m_keyChooser;
+CKeyChooser* CDisplayWindow::keyChooser() const {
+ return m_keyChooser;
}
/** Sets the keychooser widget for this display window. */
-void CDisplayWindow::setKeyChooser( CKeyChooser* ck )
-{
- m_keyChooser = ck;
+void CDisplayWindow::setKeyChooser( CKeyChooser* ck ) {
+ m_keyChooser = ck;
}
/** Returns the key of this display window. */
-CSwordKey* CDisplayWindow::key() const
-{
- Q_ASSERT( m_swordKey );
- return m_swordKey;
+CSwordKey* CDisplayWindow::key() const {
+ Q_ASSERT( m_swordKey );
+ return m_swordKey;
}
/** Sets the new sword key. */
-void CDisplayWindow::setKey( CSwordKey* key )
-{
- Q_ASSERT( key );
- m_swordKey = key;
-}
-
-void CDisplayWindow::modulesChanged()
-{
- if (moduleChooserBar()) { //necessary for write windows
- setModules( m_moduleChooserBar->getModuleList() );
- }
-
- if (!modules().count())
- {
- close();
- }
- else
- {
- if (displaySettingsButton())
- {
- displaySettingsButton()->reset(modules());
- }
-
- key()->module(modules().first());
- keyChooser()->setModules(modules());
- }
+void CDisplayWindow::setKey( CSwordKey* key ) {
+ Q_ASSERT( key );
+ m_swordKey = key;
+}
+
+void CDisplayWindow::modulesChanged() {
+ if (moduleChooserBar()) { //necessary for write windows
+ setModules( m_moduleChooserBar->getModuleList() );
+ }
+
+ if (!modules().count()) {
+ close();
+ }
+ else {
+ if (displaySettingsButton()) {
+ displaySettingsButton()->reset(modules());
+ }
+
+ key()->module(modules().first());
+ keyChooser()->setModules(modules());
+ }
}
/** Returns the module chooser bar. */
-CModuleChooserBar* CDisplayWindow::moduleChooserBar() const
-{
- return m_moduleChooserBar;
+CModuleChooserBar* CDisplayWindow::moduleChooserBar() const {
+ return m_moduleChooserBar;
}
/** Sets the module chooser bar. */
-void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar )
-{
- if (m_moduleChooserBar)
- {
- disconnect(m_moduleChooserBar, SIGNAL(sigChanged()), this, SLOT(modulesChanged()));
- }
+void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar ) {
+ if (m_moduleChooserBar) {
+ disconnect(m_moduleChooserBar, SIGNAL(sigChanged()), this, SLOT(modulesChanged()));
+ }
- //if a new bar should be set!
- if (bar)
- {
- m_moduleChooserBar = bar;
- connect(bar, SIGNAL(sigChanged()), SLOT(modulesChanged()));
- }
+ //if a new bar should be set!
+ if (bar) {
+ m_moduleChooserBar = bar;
+ connect(bar, SIGNAL(sigChanged()), SLOT(modulesChanged()));
+ }
}
/** Sets the modules. */
-void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules )
-{
- qDebug("CDisplayWindow::setModules");
- m_modules.clear();
+void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
+ qDebug("CDisplayWindow::setModules");
+ m_modules.clear();
- foreach (CSwordModuleInfo* mod, newModules)
- {
- m_modules.append(mod->name());
- }
+ foreach (CSwordModuleInfo* mod, newModules) {
+ m_modules.append(mod->name());
+ }
}
/** Initialize the window. Call this method from the outside, because calling this in the constructor is not possible! */
-bool CDisplayWindow::init()
-{
- qDebug("CDisplayWindow::init");
- initView();
- setMinimumSize( 100,100 );
-
- setCaption(windowCaption());
- //setup focus stuff.
- setFocusPolicy(Qt::ClickFocus);
- parentWidget()->setFocusPolicy(Qt::ClickFocus);
- initActions();
- initToolbars();
- initConnections();
- setupPopupMenu();
-
- m_filterOptions = CBTConfig::getFilterOptionDefaults();
- m_displayOptions = CBTConfig::getDisplayOptionDefaults();
- if (displaySettingsButton()) {
- displaySettingsButton()->reset(modules());
- }
-
- setReady(true);
- return true;
+bool CDisplayWindow::init() {
+ qDebug("CDisplayWindow::init");
+ initView();
+ setMinimumSize( 100, 100 );
+
+ setCaption(windowCaption());
+ //setup focus stuff.
+ setFocusPolicy(Qt::ClickFocus);
+ parentWidget()->setFocusPolicy(Qt::ClickFocus);
+ initActions();
+ initToolbars();
+ initConnections();
+ setupPopupMenu();
+
+ m_filterOptions = CBTConfig::getFilterOptionDefaults();
+ m_displayOptions = CBTConfig::getDisplayOptionDefaults();
+ if (displaySettingsButton()) {
+ displaySettingsButton()->reset(modules());
+ }
+
+ setReady(true);
+ return true;
}
/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::mainToolBar() const
-{
- return m_mainToolBar;
+QToolBar* CDisplayWindow::mainToolBar() const {
+ return m_mainToolBar;
}
/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::buttonsToolBar() const
-{
- return m_buttonsToolBar;
+QToolBar* CDisplayWindow::buttonsToolBar() const {
+ return m_buttonsToolBar;
}
/** Sets the main toolbar. */
-void CDisplayWindow::setMainToolBar( QToolBar* bar )
-{
- m_mainToolBar = bar;
+void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
+ m_mainToolBar = bar;
}
/** Sets the main toolbar. */
-void CDisplayWindow::setButtonsToolBar( QToolBar* bar )
-{
- m_buttonsToolBar = bar;
+void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
+ m_buttonsToolBar = bar;
}
/** Returns the display settings button */
-CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const
-{
- return m_displaySettingsButton;
+CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const {
+ return m_displaySettingsButton;
}
/** Sets the display settings button. */
-void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button )
-{
- if (m_displaySettingsButton)
- disconnect(m_displaySettingsButton, SIGNAL( sigChanged() ),this, SLOT(lookup() ));
+void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button ) {
+ if (m_displaySettingsButton)
+ disconnect(m_displaySettingsButton, SIGNAL( sigChanged() ), this, SLOT(lookup() ));
- m_displaySettingsButton = button;
- connect(m_displaySettingsButton, SIGNAL(sigChanged()),this, SLOT(lookup()));
+ m_displaySettingsButton = button;
+ connect(m_displaySettingsButton, SIGNAL(sigChanged()), this, SLOT(lookup()));
}
/** Lookup the current key. Used to refresh the display. */
-void CDisplayWindow::lookup()
-{
- lookupSwordKey( key() );
-}
-
-void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& keyName )
-{
- if (!isReady())
- {
- return;
- }
-
- CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
- Q_ASSERT(m);
- if (!m)
- {
- return;
- }
-
- //ToDo: check for containsRef compat
- if (m && modules().contains(m))
- {
- key()->key(keyName);
- keyChooser()->setKey(key()); //the key chooser does send an update signal
- }
- else
- { //given module not displayed in this window
- //if the module is displayed in another display window we assume a wrong drop
- //create a new window for the given module
- QList<CSwordModuleInfo*> mList;
- mList.append(m);
- mdi()->emitCreateDisplayWindow(mList, keyName);
- }
-}
-
-void CDisplayWindow::lookupKey( const QString& keyName )
-{
- /* This function is called for example after a bookmark was dropped on this window
- */
- Q_ASSERT(modules().first());
-
- //qDebug("CDisplayWindow::lookup: %s", keyName.latin1());
- lookupModKey(modules().first()->name(), keyName);
+void CDisplayWindow::lookup() {
+ lookupSwordKey( key() );
+}
+
+void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& keyName ) {
+ if (!isReady()) {
+ return;
+ }
+
+ CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
+ Q_ASSERT(m);
+ if (!m) {
+ return;
+ }
+
+ //ToDo: check for containsRef compat
+ if (m && modules().contains(m)) {
+ key()->key(keyName);
+ keyChooser()->setKey(key()); //the key chooser does send an update signal
+ }
+ else { //given module not displayed in this window
+ //if the module is displayed in another display window we assume a wrong drop
+ //create a new window for the given module
+ QList<CSwordModuleInfo*> mList;
+ mList.append(m);
+ mdi()->emitCreateDisplayWindow(mList, keyName);
+ }
+}
+
+void CDisplayWindow::lookupKey( const QString& keyName ) {
+ /* This function is called for example after a bookmark was dropped on this window
+ */
+ Q_ASSERT(modules().first());
+
+ //qDebug("CDisplayWindow::lookup: %s", keyName.latin1());
+ lookupModKey(modules().first()->name(), keyName);
}
/** Update the status of the popup menu entries. */
-void CDisplayWindow::updatePopupMenu()
-{
+void CDisplayWindow::updatePopupMenu() {
}
///** Returns the installed popup menu. */
-QMenu* CDisplayWindow::popup()
-{
- // qWarning("CReadWindow::popup()");
- if (!m_popupMenu)
- {
- m_popupMenu = new QMenu(this);
- connect(m_popupMenu, SIGNAL(aboutToShow()), this, SLOT(updatePopupMenu()));
- if (displayWidget())
- {
- displayWidget()->installPopup(m_popupMenu);
- }
- /* else {
- qWarning("CDisplayWindow:: can't instal popup menu");
- }*/
- }
- return m_popupMenu;
+QMenu* CDisplayWindow::popup() {
+ // qWarning("CReadWindow::popup()");
+ if (!m_popupMenu) {
+ m_popupMenu = new QMenu(this);
+ connect(m_popupMenu, SIGNAL(aboutToShow()), this, SLOT(updatePopupMenu()));
+ if (displayWidget()) {
+ displayWidget()->installPopup(m_popupMenu);
+ }
+ /* else {
+ qWarning("CDisplayWindow:: can't instal popup menu");
+ }*/
+ }
+ return m_popupMenu;
}
/** Returns the display widget used by this implementation of CDisplayWindow. */
-CDisplay* CDisplayWindow::displayWidget() const
-{
- Q_ASSERT(m_displayWidget);
- return m_displayWidget;
+CDisplay* CDisplayWindow::displayWidget() const {
+ Q_ASSERT(m_displayWidget);
+ return m_displayWidget;
}
/** Sets the display widget used by this display window. */
-void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay )
-{
- m_displayWidget = newDisplay;
+void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay ) {
+ m_displayWidget = newDisplay;
}
-void CDisplayWindow::closeEvent(QCloseEvent* e)
-{
- if (!queryClose())
- {
- e->ignore();
- }
- else {
- e->accept();
- }
+void CDisplayWindow::closeEvent(QCloseEvent* e) {
+ if (!queryClose()) {
+ e->ignore();
+ }
+ else {
+ e->accept();
+ }
}
-void CDisplayWindow::slotSearchInModules()
-{
- Search::CSearchDialog::openDialog(modules());
+void CDisplayWindow::slotSearchInModules() {
+ Search::CSearchDialog::openDialog(modules());
}
-void CDisplayWindow::printAll()
-{
- m_displayWidget->connectionsProxy()->printAll( m_displayOptions, m_filterOptions);
+void CDisplayWindow::printAll() {
+ m_displayWidget->connectionsProxy()->printAll( m_displayOptions, m_filterOptions);
}
-void CDisplayWindow::printAnchorWithText()
-{
- m_displayWidget->connectionsProxy()->printAnchorWithText( m_displayOptions, m_filterOptions);
+void CDisplayWindow::printAnchorWithText() {
+ m_displayWidget->connectionsProxy()->printAnchorWithText( m_displayOptions, m_filterOptions);
}
-BtActionCollection* CDisplayWindow::actionCollection()
-{
- return m_actionCollection;
+BtActionCollection* CDisplayWindow::actionCollection() {
+ return m_actionCollection;
}
-void CDisplayWindow::setFocusKeyChooser()
-{
- keyChooser()->setFocus();
+void CDisplayWindow::setFocusKeyChooser() {
+ keyChooser()->setFocus();
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 733f06e..5a32f9f 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -39,190 +39,187 @@ class BtActionCollection;
* @author The BibleTime team
*/
-class CDisplayWindow : public QMainWindow, public CPointers
-{
- Q_OBJECT
-public:
- enum WriteWindowType
- {
- HTMLWindow = 1,
- PlainTextWindow = 2
- };
+class CDisplayWindow : public QMainWindow, public CPointers {
+ Q_OBJECT
+ public:
+ enum WriteWindowType {
+ HTMLWindow = 1,
+ PlainTextWindow = 2
+ };
- // Insert the keyboard accelerators of this window into the given KAccel object.
- static void insertKeyboardActions( BtActionCollection* const a );
+ // Insert the keyboard accelerators of this window into the given KAccel object.
+ static void insertKeyboardActions( BtActionCollection* const a );
- CMDIArea* mdi() const;
+ CMDIArea* mdi() const;
- // Returns the right window caption.
- const QString windowCaption();
+ // Returns the right window caption.
+ const QString windowCaption();
- // Returns the used modules as a QPtrList
- QList<CSwordModuleInfo*> modules();
+ // Returns the used modules as a QPtrList
+ QList<CSwordModuleInfo*> modules();
- // Store the settings of this window in the given CProfileWindow object.
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ // Store the settings of this window in the given CProfileWindow object.
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- // Store the settings of this window in the given profile window.
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ // 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& );
+ // Set the window caption.
+ virtual void setCaption( const QString& );
- // Sets the new filter options of this window.
- void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
+ // Sets the new filter options of this window.
+ void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
- // Sets the new display options for this window.
- void setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions );
+ // Sets the new display options for this window.
+ void setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions );
- // Returns the display options used by this display window.
- CSwordBackend::DisplayOptions& displayOptions();
+ // Returns the display options used by this display window.
+ CSwordBackend::DisplayOptions& displayOptions();
- // Returns the filter options used by this window.
- CSwordBackend::FilterOptions& filterOptions();
+ // Returns the filter options used by this window.
+ CSwordBackend::FilterOptions& filterOptions();
- // Set the ready status
- void setReady( const bool& ready );
+ // Set the ready status
+ void setReady( const bool& ready );
- // Returns true if the widget is ready for use.
- bool isReady() const;
+ // Returns true if the widget is ready for use.
+ bool isReady() const;
- // Returns true if the window may be closed.
- virtual bool queryClose();
+ // Returns true if the window may be closed.
+ virtual bool queryClose();
- // Returns the keychooser widget of this display window.
- CKeyChooser* keyChooser() const;
+ // Returns the keychooser widget of this display window.
+ CKeyChooser* keyChooser() const;
- // Sets the new sword key.
- void setKey( CSwordKey* key );
+ // Sets the new sword key.
+ void setKey( CSwordKey* key );
- // Returns the key of this display window.
- CSwordKey* key() const;
+ // Returns the key of this display window.
+ CSwordKey* key() const;
- // Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
- virtual bool init();
+ // Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
+ virtual bool init();
- // Sets the main toolbar.
- void setMainToolBar( QToolBar* bar );
+ // Sets the main toolbar.
+ void setMainToolBar( QToolBar* bar );
- // Sets the buttons toolbar.
- void setButtonsToolBar( QToolBar* bar );
+ // Sets the buttons toolbar.
+ void setButtonsToolBar( QToolBar* bar );
- // Returns the main toolbar.
- QToolBar* mainToolBar() const;
+ // Returns the main toolbar.
+ QToolBar* mainToolBar() const;
- // Returns the buttons toolbar.
- QToolBar* buttonsToolBar() const;
+ // Returns the buttons toolbar.
+ QToolBar* buttonsToolBar() const;
- // Initialize the toolbars
- virtual void initToolbars() = 0;
+ // Initialize the toolbars
+ virtual void initToolbars() = 0;
- // Returns the display settings button
- CDisplaySettingsButton* displaySettingsButton() const;
+ // Returns the display settings button
+ CDisplaySettingsButton* displaySettingsButton() const;
- // Sets the display settings button.
- void setDisplaySettingsButton( CDisplaySettingsButton* button );
+ // Sets the display settings button.
+ void setDisplaySettingsButton( CDisplaySettingsButton* button );
- virtual void setupPopupMenu() = 0;
+ virtual void setupPopupMenu() = 0;
- // Returns the display widget used by this implementation of CDisplayWindow.
- virtual CDisplay* displayWidget() const;
+ // Returns the display widget used by this implementation of CDisplayWindow.
+ virtual CDisplay* displayWidget() const;
- // Sets the display widget used by this display window.
- virtual void setDisplayWidget( CDisplay* newDisplay );
+ // Sets the display widget used by this display window.
+ virtual void setDisplayWidget( CDisplay* newDisplay );
- // Returns whether syncs to the active window are allowed at this time for this display window
- // @return boolean value whether sync is allowed
- virtual bool syncAllowed() const
- {
- return false;
- };
+ // Returns whether syncs to the active window are allowed at this time for this display window
+ // @return boolean value whether sync is allowed
+ virtual bool syncAllowed() const {
+ return false;
+ };
- BtActionCollection* actionCollection();
+ BtActionCollection* actionCollection();
-public slots:
+ public slots:
- // Lookup the specified key in the given module. If the module is not chosen withing
- // this display window create a new displaywindow with the right module in it.
- virtual void lookupModKey( const QString& module, const QString& key );
+ // Lookup the specified key in the given module. If the module is not chosen withing
+ // this display window create a new displaywindow with the right module in it.
+ virtual void lookupModKey( const QString& module, const QString& key );
- // Lookup the key in the chosen modules.
- virtual void lookupKey( const QString& key );
+ // Lookup the key in the chosen modules.
+ virtual void lookupKey( const QString& key );
- // Refresh the settings of this window.
- virtual void reload(CSwordBackend::SetupChangedReason reason);
+ // Refresh the settings of this window.
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
-protected:
- friend class CMDIArea;
- friend class CBibleReadWindow;
+ protected:
+ friend class CMDIArea;
+ friend class CBibleReadWindow;
- CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CDisplayWindow();
+ CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CDisplayWindow();
- // Initializes the intern keyboard actions.
- virtual void initActions();
+ // Initializes the intern keyboard actions.
+ virtual void initActions();
- // Sets the keychooser widget for this display window.
- void setKeyChooser( CKeyChooser* ck );
+ // Sets the keychooser widget for this display window.
+ void setKeyChooser( CKeyChooser* ck );
- // Returns the module chooser bar.
- CModuleChooserBar* moduleChooserBar() const;
+ // Returns the module chooser bar.
+ CModuleChooserBar* moduleChooserBar() const;
- // Lookup the given key.
- virtual void lookupSwordKey( CSwordKey* ) = 0;
+ // Lookup the given key.
+ virtual void lookupSwordKey( CSwordKey* ) = 0;
- // Sets the module chooser bar.
- void setModuleChooserBar( CModuleChooserBar* bar );
+ // Sets the module chooser bar.
+ void setModuleChooserBar( CModuleChooserBar* bar );
- // Sets the modules.
- void setModules( const QList<CSwordModuleInfo*>& modules );
+ // Sets the modules.
+ void setModules( const QList<CSwordModuleInfo*>& modules );
- // Initializes the signal / slot connections of this display window.
- virtual void initConnections() = 0;
+ // Initializes the signal / slot connections of this display window.
+ virtual void initConnections() = 0;
- // Initialize the view of this display window.
- virtual void initView() = 0;
+ // Initialize the view of this display window.
+ virtual void initView() = 0;
- // Returns the installed popup menu.
- QMenu* popup();
+ // Returns the installed popup menu.
+ QMenu* popup();
- virtual void closeEvent(QCloseEvent* e);
+ virtual void closeEvent(QCloseEvent* e);
-protected slots:
- virtual void modulesChanged();
+ protected slots:
+ virtual void modulesChanged();
- // Lookup the current key. Used to refresh the display.
- void lookup();
+ // Lookup the current key. Used to refresh the display.
+ void lookup();
- virtual void updatePopupMenu();
+ virtual void updatePopupMenu();
- void slotSearchInModules();
+ void slotSearchInModules();
- void printAll();
+ void printAll();
- void printAnchorWithText();
+ void printAnchorWithText();
- void setFocusKeyChooser();
+ void setFocusKeyChooser();
-private:
- BtActionCollection* m_actionCollection;
- CMDIArea* m_mdi;
+ private:
+ BtActionCollection* m_actionCollection;
+ CMDIArea* m_mdi;
- //we may only cache the module names bacause after a backend relaod the pointers are invalid!
- QStringList m_modules;
+ //we may only cache the module names bacause after a backend relaod the pointers are invalid!
+ QStringList m_modules;
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
+ CSwordBackend::FilterOptions m_filterOptions;
+ CSwordBackend::DisplayOptions m_displayOptions;
- CDisplaySettingsButton* m_displaySettingsButton;
- CKeyChooser* m_keyChooser;
- CSwordKey* m_swordKey;
- bool m_isReady;
- CModuleChooserBar* m_moduleChooserBar;
- QToolBar* m_mainToolBar;
- QToolBar* m_buttonsToolBar;
- QMenu* m_popupMenu;
- CDisplay* m_displayWidget;
+ CDisplaySettingsButton* m_displaySettingsButton;
+ CKeyChooser* m_keyChooser;
+ CSwordKey* m_swordKey;
+ bool m_isReady;
+ CModuleChooserBar* m_moduleChooserBar;
+ QToolBar* m_mainToolBar;
+ QToolBar* m_buttonsToolBar;
+ QMenu* m_popupMenu;
+ CDisplay* m_displayWidget;
};
#endif
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index d386ecf..6581ffd 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.cpp
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -1,7 +1,7 @@
//
// C++ Implementation: cdisplaywindowfactory
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2007
@@ -25,33 +25,31 @@
#include "frontend/cmdiarea.h"
-CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
-{
- qDebug("CDisplayWindowFactory::createReadInstance");
- switch (modules.first()->type()) {
- case CSwordModuleInfo::Bible:
- return new CBibleReadWindow(modules, parent);
- case CSwordModuleInfo::Commentary:
- return new CCommentaryReadWindow(modules, parent);
- case CSwordModuleInfo::Lexicon:
- return new CLexiconReadWindow(modules, parent);
- case CSwordModuleInfo::GenericBook:
- return new CBookReadWindow(modules, parent);
- default:
- qWarning("unknown module type");
- break;
- }
- return 0;
+CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent) {
+ qDebug("CDisplayWindowFactory::createReadInstance");
+ switch (modules.first()->type()) {
+ case CSwordModuleInfo::Bible:
+ return new CBibleReadWindow(modules, parent);
+ case CSwordModuleInfo::Commentary:
+ return new CCommentaryReadWindow(modules, parent);
+ case CSwordModuleInfo::Lexicon:
+ return new CLexiconReadWindow(modules, parent);
+ case CSwordModuleInfo::GenericBook:
+ return new CBookReadWindow(modules, parent);
+ default:
+ qWarning("unknown module type");
+ break;
+ }
+ return 0;
}
-CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type)
-{
- if (type == CDisplayWindow::HTMLWindow) {
- return new CHTMLWriteWindow(modules, parent);
- }
- else {
- return new CPlainWriteWindow(modules, parent);
- }
- return 0;
+CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type) {
+ if (type == CDisplayWindow::HTMLWindow) {
+ return new CHTMLWriteWindow(modules, parent);
+ }
+ else {
+ return new CPlainWriteWindow(modules, parent);
+ }
+ return 0;
}
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index 4bc4372..d8bf2a9 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -1,7 +1,7 @@
//
// C++ Interface: cdisplaywindowfactory
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2007
@@ -21,14 +21,13 @@ class CReadWindow;
class CWriteWindow;
class CMDIArea;
-class CDisplayWindowFactory
-{
-public:
- static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type = CDisplayWindow::HTMLWindow);
+class CDisplayWindowFactory {
+ public:
+ static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type = CDisplayWindow::HTMLWindow);
-private:
- CDisplayWindowFactory();
+ private:
+ CDisplayWindowFactory();
};
#endif
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index cee16e0..df4018e 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -31,137 +31,137 @@
using namespace Profile;
CHTMLWriteWindow::CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
-: CPlainWriteWindow(modules, parent) {}
+ : CPlainWriteWindow(modules, parent) {}
CHTMLWriteWindow::~CHTMLWriteWindow() {}
void CHTMLWriteWindow::initView() {
- CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
- Q_ASSERT(writeDisplay);
- setDisplayWidget( writeDisplay );
- setCentralWidget( displayWidget()->view() );
-
- setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
- addToolBar(mainToolBar());
-
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
+ Q_ASSERT(writeDisplay);
+ setDisplayWidget( writeDisplay );
+ setCentralWidget( displayWidget()->view() );
+
+ setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
+ addToolBar(mainToolBar());
+
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
}
void CHTMLWriteWindow::initConnections() {
- CWriteWindow::initConnections();
+ CWriteWindow::initConnections();
- connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+ connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
void CHTMLWriteWindow::initToolbars() {
- //setup the main toolbar
- m_actions.syncWindow = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
- mainToolBar()->addAction(m_actions.syncWindow);
-
- m_actions.saveText = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- m_actions.saveText->setToolTip( tr("Save text") );
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT( saveCurrentText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT( deleteEntry() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
-
- m_actions.restoreText = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT( restoreText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
-
- //html formatting toolbar
- QToolBar* bar = new QToolBar(this);
- bar->setAllowedAreas(Qt::TopToolBarArea);
- bar->setFloatable(false);
- ((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
- addToolBar(bar);
+ //setup the main toolbar
+ m_actions.syncWindow = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ tr("Sync with active Bible"),
+ actionCollection()
+ );
+ m_actions.syncWindow->setCheckable(true);
+ m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
+ actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
+ mainToolBar()->addAction(m_actions.syncWindow);
+
+ m_actions.saveText = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ tr("Save text"),
+ actionCollection()
+ );
+ m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
+ m_actions.saveText->setToolTip( tr("Save text") );
+ QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT( saveCurrentText() ) );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
+ mainToolBar()->addAction(m_actions.saveText);
+
+
+ m_actions.deleteEntry = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ tr("Delete current entry"),
+ actionCollection()
+ );
+ m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
+ m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
+ QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT( deleteEntry() ) );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
+ mainToolBar()->addAction(m_actions.deleteEntry);
+
+ m_actions.restoreText = new QAction(
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ tr("Restore original text"),
+ actionCollection()
+ );
+ m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
+ m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
+ QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT( restoreText() ) );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
+ mainToolBar()->addAction(m_actions.restoreText);
+
+ //html formatting toolbar
+ QToolBar* bar = new QToolBar(this);
+ bar->setAllowedAreas(Qt::TopToolBarArea);
+ bar->setFloatable(false);
+ ((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
+ addToolBar(bar);
}
void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ CWriteWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
}
void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
- }
+ CWriteWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_actions.syncWindow->setChecked(true);
+ }
}
/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Loads the original text from the module. */
void CHTMLWriteWindow::restoreText() {
- lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
- textChanged();
+ lookupSwordKey(key());
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
}
bool CHTMLWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ return m_actions.syncWindow->isChecked();
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CHTMLWriteDisplay*)displayWidget())->toHtml();
- //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
- QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
- re.setMinimal(true);
- t.replace(re, "");
- t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
-
- const QString& oldKey = this->key()->key();
- if( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
-
- ((CWriteDisplay*)displayWidget())->setModified(false);
- 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.") ) );
- }
+ QString t = ((CHTMLWriteDisplay*)displayWidget())->toHtml();
+ //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
+ QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
+ re.setMinimal(true);
+ t.replace(re, "");
+ t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
+
+ const QString& oldKey = this->key()->key();
+ if ( modules().first()->isWritable() ) {
+ modules().first()->write(this->key(), t );
+ this->key()->key( oldKey );
+
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ 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.") ) );
+ }
}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 9c50957..452a362 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -22,54 +22,54 @@ class QAction;
* @author The BibleTime team
*/
class CHTMLWriteWindow : public CPlainWriteWindow {
- Q_OBJECT
-public:
- CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CHTMLWriteWindow();
+ Q_OBJECT
+ public:
+ CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CHTMLWriteWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* );
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* );
- virtual bool syncAllowed() const;
+ virtual bool syncAllowed() const;
-protected: // Protected methods
- /**
- * Initialize the state of this widget.
- */
- virtual void initView();
- virtual void initConnections();
- virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::HTMLWindow;
- };
+ protected: // Protected methods
+ /**
+ * Initialize the state of this widget.
+ */
+ virtual void initView();
+ virtual void initConnections();
+ virtual void initToolbars();
+ virtual CDisplayWindow::WriteWindowType writeWindowType() {
+ return CDisplayWindow::HTMLWindow;
+ };
-protected slots:
- /**
- * Is called when the current text was changed.
- */
- virtual void textChanged();
- /**
- * Loads the original text from the module.
- */
- virtual void restoreText();
- /**
- * Saves the text for the current key. Directly writes the changed text into the module.
- */
- virtual void saveCurrentText( const QString& );
-private:
- struct {
- QAction* saveText;
- QAction* restoreText;
- QAction* deleteEntry;
- QAction* syncWindow;
- }
- m_actions;
+ protected slots:
+ /**
+ * Is called when the current text was changed.
+ */
+ virtual void textChanged();
+ /**
+ * Loads the original text from the module.
+ */
+ virtual void restoreText();
+ /**
+ * Saves the text for the current key. Directly writes the changed text into the module.
+ */
+ virtual void saveCurrentText( const QString& );
+ private:
+ struct {
+ QAction* saveText;
+ QAction* restoreText;
+ QAction* deleteEntry;
+ QAction* syncWindow;
+ }
+ m_actions;
};
#endif
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index df22de9..d06578e 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -33,350 +33,330 @@
#include <QAction>
CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
- : CReadWindow(moduleList, parent)
-{
- qDebug("CLexiconReadWindow::CLexiconReadWindow");
- moduleList.first();
- setKey( CSwordKey::createInstance(moduleList.first()) );
+ : CReadWindow(moduleList, parent) {
+ qDebug("CLexiconReadWindow::CLexiconReadWindow");
+ moduleList.first();
+ setKey( CSwordKey::createInstance(moduleList.first()) );
}
-CLexiconReadWindow::~CLexiconReadWindow()
-{
+CLexiconReadWindow::~CLexiconReadWindow() {
}
-void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a )
-{
- qDebug("CLexiconReadWindow::insertKeyboardActions");
- QAction* qaction;
- qaction = new QAction( tr("Next entry"), a);
- qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
- a->addAction("nextEntry", qaction);
+void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+ qDebug("CLexiconReadWindow::insertKeyboardActions");
+ QAction* qaction;
+ qaction = new QAction( tr("Next entry"), a);
+ qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
+ a->addAction("nextEntry", qaction);
- qaction = new QAction( tr("Previous entry"), a);
- qaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
- a->addAction("previousEntry", qaction);
-
- qaction = new QAction(tr("Copy reference only"), a);
- a->addAction("copyReferenceOnly", qaction);
+ qaction = new QAction( tr("Previous entry"), a);
+ qaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
+ a->addAction("previousEntry", qaction);
- qaction = new QAction(tr("Save entry as HTML"), a);
- a->addAction("saveHtml", qaction);
+ qaction = new QAction(tr("Copy reference only"), a);
+ a->addAction("copyReferenceOnly", qaction);
- qaction = new QAction(tr("Print reference only"), a);
- a->addAction("printReferenceOnly", qaction);
+ qaction = new QAction(tr("Save entry as HTML"), a);
+ a->addAction("saveHtml", qaction);
- qaction = new QAction(tr("Entry with text"), a);
- a->addAction("copyEntryWithText", qaction);
+ qaction = new QAction(tr("Print reference only"), a);
+ a->addAction("printReferenceOnly", qaction);
- qaction = new QAction(tr("Entry as plain text"), a);
- a->addAction("saveEntryAsPlain", qaction);
+ qaction = new QAction(tr("Entry with text"), a);
+ a->addAction("copyEntryWithText", qaction);
- qaction = new QAction(tr("Entry with text"), a);
- a->addAction("printEntryWithText", qaction);
+ qaction = new QAction(tr("Entry as plain text"), a);
+ a->addAction("saveEntryAsPlain", qaction);
- qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's Search"), a);
- qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
- a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
+ qaction = new QAction(tr("Entry with text"), a);
+ a->addAction("printEntryWithText", qaction);
+
+ qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's Search"), a);
+ qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+ a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
}
-void CLexiconReadWindow::initActions()
-{
- qDebug("CLexiconReadWindow::initActions");
+void CLexiconReadWindow::initActions() {
+ qDebug("CLexiconReadWindow::initActions");
+
+ BtActionCollection* ac = actionCollection();
+ CReadWindow::initActions();
+ CLexiconReadWindow::insertKeyboardActions(ac);
- BtActionCollection* ac = actionCollection();
- CReadWindow::initActions();
- CLexiconReadWindow::insertKeyboardActions(ac);
+ m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
+ ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
+ Q_ASSERT(m_actions.backInHistory);
+ addAction(m_actions.backInHistory);
- m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
- ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
- Q_ASSERT(m_actions.backInHistory);
- addAction(m_actions.backInHistory);
+ m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
+ ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
+ Q_ASSERT(m_actions.forwardInHistory);
+ addAction(m_actions.forwardInHistory);
- m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
- ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
- Q_ASSERT(m_actions.forwardInHistory);
- addAction(m_actions.forwardInHistory);
+ QAction* qaction;
- QAction* qaction;
+ qaction = ac->action("nextEntry");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
+ addAction(qaction);
- qaction = ac->action("nextEntry");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
- addAction(qaction);
+ qaction = ac->action("previousEntry");
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
+ addAction(qaction);
- qaction = ac->action("previousEntry");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
- addAction(qaction);
+ m_actions.selectAll = ac->action("selectAll");
+ Q_ASSERT(m_actions.selectAll);
- m_actions.selectAll = ac->action("selectAll");
- Q_ASSERT(m_actions.selectAll);
+ m_actions.findText = ac->action("findText");
+ Q_ASSERT(m_actions.findText);
- m_actions.findText = ac->action("findText");
- Q_ASSERT(m_actions.findText);
+ m_actions.findStrongs = ac->action(CResMgr::displaywindows::general::findStrongs::actionName);
+ QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
+ addAction(m_actions.findStrongs);
- m_actions.findStrongs = ac->action(CResMgr::displaywindows::general::findStrongs::actionName);
- QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
- addAction(m_actions.findStrongs);
+ m_actions.copy.reference = ac->action("copyReferenceOnly");
+ QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
+ addAction(m_actions.copy.reference);
- m_actions.copy.reference = ac->action("copyReferenceOnly");
- QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
- addAction(m_actions.copy.reference);
+ m_actions.copy.entry = ac->action("copyEntryWithText");
+ QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
+ addAction(m_actions.copy.entry);
- m_actions.copy.entry = ac->action("copyEntryWithText");
- QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
- addAction(m_actions.copy.entry);
+ Q_ASSERT(ac->action("copySelectedText"));
+ m_actions.copy.selectedText = ac->action("copySelectedText");
- Q_ASSERT(ac->action("copySelectedText"));
- m_actions.copy.selectedText = ac->action("copySelectedText");
-
- m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
- QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
- addAction(m_actions.save.entryAsPlain);
+ m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
+ QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
+ addAction(m_actions.save.entryAsPlain);
- m_actions.save.entryAsHTML = ac->action("saveHtml");
- QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
- addAction(m_actions.save.entryAsHTML);
+ m_actions.save.entryAsHTML = ac->action("saveHtml");
+ QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
+ addAction(m_actions.save.entryAsHTML);
- m_actions.print.reference = ac->action("printReferenceOnly");
- QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
- addAction(m_actions.print.reference);
+ m_actions.print.reference = ac->action("printReferenceOnly");
+ QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
+ addAction(m_actions.print.reference);
- m_actions.print.entry = ac->action("printEntryWithText");
- QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
- addAction(m_actions.print.entry);
+ m_actions.print.entry = ac->action("printEntryWithText");
+ QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
+ addAction(m_actions.print.entry);
- // init with the user defined settings
- qDebug("call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions");
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
+ // init with the user defined settings
+ qDebug("call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions");
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
}
/** No descriptions */
-void CLexiconReadWindow::initConnections()
-{
- qDebug("CLexiconReadWindow::initConnections");
- Q_ASSERT(keyChooser());
-
- connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(keyChooser()->history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
-
- //connect the history actions to the right slots
- bool ok = connect(
- m_actions.backInHistory->popupMenu(), SIGNAL(aboutToShow()),
- this, SLOT(slotFillBackHistory())
- );
- Q_ASSERT(ok);
- ok = connect(
- m_actions.backInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
- keyChooser()->history(), SLOT(move(QAction*))
- );
- Q_ASSERT(ok);
- ok = connect(
- m_actions.forwardInHistory->popupMenu(), SIGNAL(aboutToShow()),
- this, SLOT(slotFillForwardHistory())
- );
- Q_ASSERT(ok);
- ok = connect(
- m_actions.forwardInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
- keyChooser()->history(), SLOT(move(QAction*))
- );
- Q_ASSERT(ok);
+void CLexiconReadWindow::initConnections() {
+ qDebug("CLexiconReadWindow::initConnections");
+ Q_ASSERT(keyChooser());
+
+ connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ connect(keyChooser()->history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
+
+ //connect the history actions to the right slots
+ bool ok = connect(
+ m_actions.backInHistory->popupMenu(), SIGNAL(aboutToShow()),
+ this, SLOT(slotFillBackHistory())
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.backInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
+ keyChooser()->history(), SLOT(move(QAction*))
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.forwardInHistory->popupMenu(), SIGNAL(aboutToShow()),
+ this, SLOT(slotFillForwardHistory())
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.forwardInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
+ keyChooser()->history(), SLOT(move(QAction*))
+ );
+ Q_ASSERT(ok);
}
-void CLexiconReadWindow::initView()
-{
- qDebug("CLexiconReadWindow::initView");
- setDisplayWidget( CDisplay::createReadInstance(this) );
- setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
- addToolBar(mainToolBar());
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
- setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
- moduleChooserBar()->adjustSize();
- addToolBar(moduleChooserBar());
- setButtonsToolBar( new QToolBar(this) );
- buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- buttonsToolBar()->setFloatable(false);
- addToolBar(buttonsToolBar());
- setWindowIcon(CToolClass::getIconForModule(modules().first()));
- setCentralWidget( displayWidget()->view() );
+void CLexiconReadWindow::initView() {
+ qDebug("CLexiconReadWindow::initView");
+ setDisplayWidget( CDisplay::createReadInstance(this) );
+ setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
+ addToolBar(mainToolBar());
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+ setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
+ moduleChooserBar()->adjustSize();
+ addToolBar(moduleChooserBar());
+ setButtonsToolBar( new QToolBar(this) );
+ buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ buttonsToolBar()->setFloatable(false);
+ addToolBar(buttonsToolBar());
+ setWindowIcon(CToolClass::getIconForModule(modules().first()));
+ setCentralWidget( displayWidget()->view() );
}
-void CLexiconReadWindow::initToolbars()
-{
- //main toolbar
- Q_ASSERT(m_actions.backInHistory);
- mainToolBar()->addAction(m_actions.backInHistory); //1st button
- mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
-
- //buttons toolbar
- QAction* action = qobject_cast<QAction*>(actionCollection()->action(
- CResMgr::displaywindows::general::search::actionName));
- Q_ASSERT( action );
- if (action) {
- buttonsToolBar()->addAction(action);
- }
- setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
-
- //TODO: find the right place for the button
- buttonsToolBar()->addWidget(displaySettingsButton());
+void CLexiconReadWindow::initToolbars() {
+ //main toolbar
+ Q_ASSERT(m_actions.backInHistory);
+ mainToolBar()->addAction(m_actions.backInHistory); //1st button
+ mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+
+ //buttons toolbar
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName));
+ Q_ASSERT( action );
+ if (action) {
+ buttonsToolBar()->addAction(action);
+ }
+ setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+
+ //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()->addAction(m_actions.findText);
- popup()->addAction(m_actions.findStrongs);
- popup()->addAction(m_actions.selectAll);
- popup()->addSeparator();
-
- m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
-
- m_actions.copyMenu->addAction(m_actions.copy.reference);
- m_actions.copyMenu->addAction(m_actions.copy.entry);
- m_actions.copyMenu->addSeparator();
- m_actions.copyMenu->addAction(m_actions.copy.selectedText);
- popup()->addMenu(m_actions.copyMenu);
-
- m_actions.saveMenu = new QMenu(
- tr("Save..."),
- popup()
- );
- m_actions.saveMenu->addAction(m_actions.save.entryAsPlain);
- m_actions.saveMenu->addAction(m_actions.save.entryAsHTML);
-
- // Save raw HTML action for debugging purposes
- if (qApp->property("--debug").toBool()) {
- QAction* debugAction = new QAction("Raw HTML", this);
- QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
- m_actions.saveMenu->addAction(debugAction);
- } // end of Save Raw HTML
-
- popup()->addMenu(m_actions.saveMenu);
-
- m_actions.printMenu = new QMenu(
- tr("Print..."),
- popup()
- );
- m_actions.printMenu->addAction(m_actions.print.reference);
- m_actions.printMenu->addAction(m_actions.print.entry);
- popup()->addMenu(m_actions.printMenu);
+void CLexiconReadWindow::setupPopupMenu() {
+ popup()->setTitle(tr("Lexicon window"));
+ popup()->setIcon(CToolClass::getIconForModule(modules().first()));
+ popup()->addAction(m_actions.findText);
+ popup()->addAction(m_actions.findStrongs);
+ popup()->addAction(m_actions.selectAll);
+ popup()->addSeparator();
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
+
+ m_actions.copyMenu->addAction(m_actions.copy.reference);
+ m_actions.copyMenu->addAction(m_actions.copy.entry);
+ m_actions.copyMenu->addSeparator();
+ m_actions.copyMenu->addAction(m_actions.copy.selectedText);
+ popup()->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(
+ tr("Save..."),
+ popup()
+ );
+ m_actions.saveMenu->addAction(m_actions.save.entryAsPlain);
+ m_actions.saveMenu->addAction(m_actions.save.entryAsHTML);
+
+ // Save raw HTML action for debugging purposes
+ if (qApp->property("--debug").toBool()) {
+ QAction* debugAction = new QAction("Raw HTML", this);
+ QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
+ m_actions.saveMenu->addAction(debugAction);
+ } // end of Save Raw HTML
+
+ popup()->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(
+ tr("Print..."),
+ popup()
+ );
+ m_actions.printMenu->addAction(m_actions.print.reference);
+ m_actions.printMenu->addAction(m_actions.print.entry);
+ popup()->addMenu(m_actions.printMenu);
}
/** Reimplemented. */
-void CLexiconReadWindow::updatePopupMenu()
-{
- //enable the action depending on the supported module features
+void CLexiconReadWindow::updatePopupMenu() {
+ //enable the action depending on the supported module features
+
+ m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
- m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
-
- m_actions.copy.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
- m_actions.copy.selectedText->setEnabled( displayWidget()->hasSelection() );
+ m_actions.copy.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.selectedText->setEnabled( displayWidget()->hasSelection() );
- m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
}
-void CLexiconReadWindow::reload(CSwordBackend::SetupChangedReason reason)
-{
- CReadWindow::reload(reason);
+void CLexiconReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CReadWindow::reload(reason);
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, actionCollection());
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, actionCollection());
}
/** No descriptions */
-void CLexiconReadWindow::nextEntry()
-{
- keyChooser()->setKey(ldKey()->NextEntry());
+void CLexiconReadWindow::nextEntry() {
+ keyChooser()->setKey(ldKey()->NextEntry());
}
/** No descriptions */
-void CLexiconReadWindow::previousEntry()
-{
- keyChooser()->setKey(ldKey()->PreviousEntry());
+void CLexiconReadWindow::previousEntry() {
+ keyChooser()->setKey(ldKey()->PreviousEntry());
}
/** Reimplementation to return the right key. */
-CSwordLDKey* CLexiconReadWindow::ldKey()
-{
- return dynamic_cast<CSwordLDKey*>(CDisplayWindow::key());
+CSwordLDKey* CLexiconReadWindow::ldKey() {
+ return dynamic_cast<CSwordLDKey*>(CDisplayWindow::key());
}
/** This function saves the entry as html using the CExportMgr class. */
void CLexiconReadWindow::saveAsHTML() {
- CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
- mgr.saveKey(key(), CExportManager::HTML, true);
+ CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(key(), CExportManager::HTML, true);
}
/** Saving the raw HTML for debugging purposes */
-void 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");
- return;
- }
- QString source = disp->text();
- file.write(source.toUtf8());
- //qDebug() << "wrote" << bytes << "bytes";
- file.close();
- file.flush();
- } else {
- qDebug("No htmlreaddisplay widget!");
- }
-
+void 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");
+ return;
+ }
+ QString source = disp->text();
+ file.write(source.toUtf8());
+ //qDebug() << "wrote" << bytes << "bytes";
+ file.close();
+ file.flush();
+ }
+ else {
+ qDebug("No htmlreaddisplay widget!");
+ }
+
}
/** This function saves the entry as html using the CExportMgr class. */
-void CLexiconReadWindow::saveAsPlain()
-{
- CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
- mgr.saveKey(key(), CExportManager::Text, true);
+void CLexiconReadWindow::saveAsPlain() {
+ CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(key(), CExportManager::Text, true);
}
-void CLexiconReadWindow::slotFillBackHistory()
-{
- qDebug("CLexiconReadWindow::slotFillBackHistory");
+void CLexiconReadWindow::slotFillBackHistory() {
+ qDebug("CLexiconReadWindow::slotFillBackHistory");
- QMenu* menu = m_actions.backInHistory->popupMenu();
- menu->clear();
+ QMenu* menu = m_actions.backInHistory->popupMenu();
+ menu->clear();
- //TODO: take the history list and fill the menu
- QListIterator<QAction*> it(keyChooser()->history()->getBackList());
- while (it.hasNext())
- {
- menu->addAction(it.next());
- }
+ //TODO: take the history list and fill the menu
+ QListIterator<QAction*> it(keyChooser()->history()->getBackList());
+ while (it.hasNext()) {
+ menu->addAction(it.next());
+ }
}
-void CLexiconReadWindow::slotFillForwardHistory()
-{
- qDebug("CLexiconReadWindow::slotFillForwardHistory");
-
- QMenu* menu = m_actions.forwardInHistory->popupMenu();
- menu->clear();
- //TODO: take the history list and fill the menu using addAction
- QListIterator<QAction*> it(keyChooser()->history()->getFwList());
- while (it.hasNext())
- {
- menu->addAction(it.next());
- }
+void CLexiconReadWindow::slotFillForwardHistory() {
+ qDebug("CLexiconReadWindow::slotFillForwardHistory");
+
+ QMenu* menu = m_actions.forwardInHistory->popupMenu();
+ menu->clear();
+ //TODO: take the history list and fill the menu using addAction
+ QListIterator<QAction*> it(keyChooser()->history()->getFwList());
+ while (it.hasNext()) {
+ menu->addAction(it.next());
+ }
}
-void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled)
-{
- qDebug("CLexiconReadWindow::slotUpdateHistoryButtons");
- Q_ASSERT(m_actions.backInHistory);
- Q_ASSERT(keyChooser());
+void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled) {
+ qDebug("CLexiconReadWindow::slotUpdateHistoryButtons");
+ Q_ASSERT(m_actions.backInHistory);
+ Q_ASSERT(keyChooser());
- m_actions.backInHistory->setEnabled( backEnabled );
- m_actions.forwardInHistory->setEnabled( fwEnabled );
+ m_actions.backInHistory->setEnabled( backEnabled );
+ m_actions.forwardInHistory->setEnabled( fwEnabled );
}
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index 45e9ceb..ee28c25 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -26,95 +26,95 @@ class QMenu;
*/
class CLexiconReadWindow : public CReadWindow {
- Q_OBJECT
-public:
- CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CLexiconReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- // virtual void storeProfileSettings( CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- // virtual void applyProfileSettings( CProfileWindow* profileWindow );
- /**
- * Reimplementation.
- */
- // static void insertKeyboardActions( KAccel* a );
- static void insertKeyboardActions( BtActionCollection* const a );
-
-public slots:
- /**
- * Refreshes the content of this display window and the content of the keychooser.
- */
- virtual void reload(CSwordBackend::SetupChangedReason reason);
-
-protected:
- virtual void initActions();
- virtual void initToolbars();
- virtual void initConnections();
- virtual void initView();
- virtual void updatePopupMenu();
- virtual void setupPopupMenu();
-
-
- struct ActionsStruct {
- BtToolBarPopupAction* backInHistory;
- BtToolBarPopupAction* forwardInHistory;
-
- QAction* selectAll;
- QAction* findText;
- QAction* findStrongs;
-
- QMenu* copyMenu;
- struct {
- QAction* reference;
- QAction* entry;
- QAction* selectedText;
- }
- copy;
-
- QMenu* saveMenu;
- struct {
- QAction* reference;
- QAction* entryAsPlain;
- QAction* entryAsHTML;
- }
- save;
-
- QMenu* printMenu;
- struct {
- QAction* reference;
- QAction* entry;
- }
- print;
- }
- m_actions;
-
-private:
- /**
- * Reimplementation to return the right key.
- */
- CSwordLDKey* ldKey();
-
-protected slots: // Protected slots
- void previousEntry();
- void nextEntry();
- /**
- * This function saves the entry as html using the CExportMgr class.
- */
- void saveAsHTML();
- /**
- * This function saves the entry as plain text using the CExportMgr class.
- */
- void saveAsPlain();
- void saveRawHTML();
-
- void slotFillBackHistory();
- void slotFillForwardHistory();
-
- void slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled);
+ Q_OBJECT
+ public:
+ CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CLexiconReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ // virtual void storeProfileSettings( CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ // virtual void applyProfileSettings( CProfileWindow* profileWindow );
+ /**
+ * Reimplementation.
+ */
+ // static void insertKeyboardActions( KAccel* a );
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ public slots:
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
+ protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+ virtual void updatePopupMenu();
+ virtual void setupPopupMenu();
+
+
+ struct ActionsStruct {
+ BtToolBarPopupAction* backInHistory;
+ BtToolBarPopupAction* forwardInHistory;
+
+ QAction* selectAll;
+ QAction* findText;
+ QAction* findStrongs;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* reference;
+ QAction* entry;
+ QAction* selectedText;
+ }
+ copy;
+
+ QMenu* saveMenu;
+ struct {
+ QAction* reference;
+ QAction* entryAsPlain;
+ QAction* entryAsHTML;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* reference;
+ QAction* entry;
+ }
+ print;
+ }
+ m_actions;
+
+ private:
+ /**
+ * Reimplementation to return the right key.
+ */
+ CSwordLDKey* ldKey();
+
+ protected slots: // Protected slots
+ void previousEntry();
+ void nextEntry();
+ /**
+ * This function saves the entry as html using the CExportMgr class.
+ */
+ void saveAsHTML();
+ /**
+ * This function saves the entry as plain text using the CExportMgr class.
+ */
+ void saveAsPlain();
+ void saveRawHTML();
+
+ void slotFillBackHistory();
+ void slotFillForwardHistory();
+
+ void slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled);
};
#endif
diff --git a/src/frontend/displaywindow/cmodulechooserbar.cpp b/src/frontend/displaywindow/cmodulechooserbar.cpp
index a282c4b..2e47851 100644
--- a/src/frontend/displaywindow/cmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/cmodulechooserbar.cpp
@@ -17,113 +17,110 @@
#include <QToolBar>
CModuleChooserBar::CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent)
- : QToolBar(parent),
- m_moduleType(type),
- m_idCounter(0),
- m_buttonLimit(-1) //-1 means no limit
-{
- setAllowedAreas(Qt::TopToolBarArea);
- setFloatable(false);
- //insert buttons if useModules != 0
- QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
- if ((m_buttonLimit != -1) && ( m_buttonLimit <= (int)m_buttonList.count()) ) { //we reached the button limit
- break;
- }
- addButton( *it );
- }
-
- // We can add a button to choose an additional module
- if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
- addButton(0); //add a button without module set
- }
+ : QToolBar(parent),
+ m_moduleType(type),
+ m_idCounter(0),
+ m_buttonLimit(-1) { //-1 means no limit
+ setAllowedAreas(Qt::TopToolBarArea);
+ setFloatable(false);
+ //insert buttons if useModules != 0
+ QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
+ if ((m_buttonLimit != -1) && ( m_buttonLimit <= (int)m_buttonList.count()) ) { //we reached the button limit
+ break;
+ }
+ addButton( *it );
+ }
+
+ // We can add a button to choose an additional module
+ if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
+ addButton(0); //add a button without module set
+ }
}
-CModuleChooserButton* CModuleChooserBar::addButton( CSwordModuleInfo* const module )
-{
- CModuleChooserButton* b = new CModuleChooserButton(module, m_moduleType, ++m_idCounter, this);
- QAction* a = addWidget(b);
- m_buttonList.append(b);
- connect( b, SIGNAL(sigAddButton()), this, SLOT(addButton()) );
- connect( b, SIGNAL(sigRemoveButton(const int)), this, SLOT(removeButton(const int)) );
- connect( b, SIGNAL(sigChanged()), SIGNAL(sigChanged()) );
- connect( b, SIGNAL(sigChanged()), SLOT(updateMenuItems()) );
- a->setVisible(true);
- updateMenuItems(); //make sure the items are up to date with the newest module list
- return b;
+CModuleChooserButton* CModuleChooserBar::addButton( CSwordModuleInfo* const module ) {
+ CModuleChooserButton* b = new CModuleChooserButton(module, m_moduleType, ++m_idCounter, this);
+ QAction* a = addWidget(b);
+ m_buttonList.append(b);
+ connect( b, SIGNAL(sigAddButton()), this, SLOT(addButton()) );
+ connect( b, SIGNAL(sigRemoveButton(const int)), this, SLOT(removeButton(const int)) );
+ connect( b, SIGNAL(sigChanged()), SIGNAL(sigChanged()) );
+ connect( b, SIGNAL(sigChanged()), SLOT(updateMenuItems()) );
+ a->setVisible(true);
+ updateMenuItems(); //make sure the items are up to date with the newest module list
+ return b;
}
void CModuleChooserBar::addButton( ) {
- addButton(0);
+ addButton(0);
}
//change current with next and remove
/** Removes a button from the toolbar */
void CModuleChooserBar::removeButton( const int ID ) {
- QMutableListIterator<CModuleChooserButton*> it(m_buttonList);
- while (it.hasNext()) {
- CModuleChooserButton* b = it.next();
- if (b->getId() == ID) { //found the right button to remove
- it.remove();
- b->deleteLater();
- break;
- }
- }
- emit sigChanged();
- updateMenuItems(); //make sure the items are up to date with the newest module list
+ QMutableListIterator<CModuleChooserButton*> it(m_buttonList);
+ while (it.hasNext()) {
+ CModuleChooserButton* b = it.next();
+ if (b->getId() == ID) { //found the right button to remove
+ it.remove();
+ b->deleteLater();
+ break;
+ }
+ }
+ emit sigChanged();
+ updateMenuItems(); //make sure the items are up to date with the newest module list
}
/** Returns a list of selected modules. */
QList<CSwordModuleInfo*> CModuleChooserBar::getModuleList() {
- QList<CSwordModuleInfo*> list;
- foreach (CModuleChooserButton* b, m_buttonList)
- {
- if (b->module()) list.append( b->module() );
- }
- return list;
+ QList<CSwordModuleInfo*> list;
+ foreach (CModuleChooserButton* b, m_buttonList) {
+ if (b->module()) list.append( b->module() );
+ }
+ return list;
}
//change current with remove
/** Sets the number of the maximum count of buttons. */
void CModuleChooserBar::setButtonLimit(const int limit) {
- m_buttonLimit = limit;
- if (limit == -1) //no need to delete buttons
- return;
+ m_buttonLimit = limit;
+ if (limit == -1) //no need to delete buttons
+ return;
- const int tooMuch = m_buttonList.size() - limit;
- for (int i = 0; i < tooMuch; ++i) {
- CModuleChooserButton* b = m_buttonList.takeLast();
- b->deleteLater();
- }
+ const int tooMuch = m_buttonList.size() - limit;
+ for (int i = 0; i < tooMuch; ++i) {
+ CModuleChooserButton* b = m_buttonList.takeLast();
+ b->deleteLater();
+ }
- updateMenuItems();
+ updateMenuItems();
}
/** Sets the modules which are chosen in this module chooser bar. */
void CModuleChooserBar::setModules( QList<CSwordModuleInfo*> useModules ) {
- setButtonLimit(0);
- setButtonLimit(-1); //these two lines clear the bar
+ setButtonLimit(0);
+ setButtonLimit(-1); //these two lines clear the bar
- if (!useModules.count()) return;
+ if (!useModules.count()) return;
- QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
- if ( (m_buttonLimit != -1) && (m_buttonLimit <= (int)m_buttonList.count()) ) {
- break;
- }
- addButton( *it );
- }
+ QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
+ if ( (m_buttonLimit != -1) && (m_buttonLimit <= (int)m_buttonList.count()) ) {
+ break;
+ }
+ addButton( *it );
+ }
- if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
- addButton(0);//add button without module set
- }
+ if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
+ addButton(0);//add button without module set
+ }
- updateMenuItems();
+ updateMenuItems();
}
void CModuleChooserBar::updateMenuItems() {
- resize(sizeHint());
- update(); //seems to be neccessary to enforce display of the layout changes when a button was removed or added
- foreach (CModuleChooserButton* b, m_buttonList)
- b->updateMenuItems();
+ resize(sizeHint());
+ update(); //seems to be neccessary to enforce display of the layout changes when a button was removed or added
+ foreach (CModuleChooserButton* b, m_buttonList)
+ b->updateMenuItems();
}
diff --git a/src/frontend/displaywindow/cmodulechooserbar.h b/src/frontend/displaywindow/cmodulechooserbar.h
index d21fcb9..1a9ce95 100644
--- a/src/frontend/displaywindow/cmodulechooserbar.h
+++ b/src/frontend/displaywindow/cmodulechooserbar.h
@@ -26,51 +26,51 @@ class QWidget;
* @author The BibleTime team
*/
class CModuleChooserBar : public QToolBar {
- Q_OBJECT
-public:
- /**
- * Default constructor
- */
- CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent=0);
- /**
- * Returns a list of selected modules.
- */
- QList<CSwordModuleInfo*> getModuleList();
- /**
- * Sets the number of the maximum count of buttons.
- */
- void setButtonLimit( const int limit);
- /**
- * Sets the modules which are chosen in this module chooser bar.
- */
- void setModules( QList<CSwordModuleInfo*> modules );
+ Q_OBJECT
+ public:
+ /**
+ * Default constructor
+ */
+ CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent = 0);
+ /**
+ * Returns a list of selected modules.
+ */
+ QList<CSwordModuleInfo*> getModuleList();
+ /**
+ * Sets the number of the maximum count of buttons.
+ */
+ void setButtonLimit( const int limit);
+ /**
+ * Sets the modules which are chosen in this module chooser bar.
+ */
+ void setModules( QList<CSwordModuleInfo*> modules );
-signals:
- void sigChanged();
+ signals:
+ void sigChanged();
-protected:
- /**
- * Adds a button to the toolbar
- */
- CModuleChooserButton* addButton( CSwordModuleInfo* const module );
+ protected:
+ /**
+ * Adds a button to the toolbar
+ */
+ CModuleChooserButton* addButton( CSwordModuleInfo* const module );
-protected slots: // Protected slots
- /*
- * This slot calls the addButton function above to add a button.
- */
- void addButton();
- /**
- * Removes a button from the toolbar
- */
- void removeButton( const int ID );
- /** */
- void updateMenuItems();
+ protected slots: // Protected slots
+ /*
+ * This slot calls the addButton function above to add a button.
+ */
+ void addButton();
+ /**
+ * Removes a button from the toolbar
+ */
+ void removeButton( const int ID );
+ /** */
+ void updateMenuItems();
-private:
- CSwordModuleInfo::ModuleType m_moduleType;
- int m_idCounter;
- int m_buttonLimit;
- QList<CModuleChooserButton*> m_buttonList;
+ private:
+ CSwordModuleInfo::ModuleType m_moduleType;
+ int m_idCounter;
+ int m_buttonLimit;
+ QList<CModuleChooserButton*> m_buttonList;
};
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.cpp b/src/frontend/displaywindow/cmodulechooserbutton.cpp
index dd5a9ee..14760e0 100644
--- a/src/frontend/displaywindow/cmodulechooserbutton.cpp
+++ b/src/frontend/displaywindow/cmodulechooserbutton.cpp
@@ -26,186 +26,184 @@
#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)
-{
- m_moduleType = type;
- m_module = useModule;
- m_hasModule = (m_module) ? true : false;
-
- setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
- setPopupMode(QToolButton::InstantPopup);
-
- populateMenu();
+CModuleChooserButton::CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent)
+ : QToolButton(parent),
+ m_id(id), m_popup(0), m_moduleChooserBar(parent) {
+ m_moduleType = type;
+ m_module = useModule;
+ m_hasModule = (m_module) ? true : false;
+
+ setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ setPopupMode(QToolButton::InstantPopup);
+
+ populateMenu();
}
CModuleChooserButton::~CModuleChooserButton() {
- qDeleteAll(m_submenus);
- m_submenus.clear();
- delete m_popup; //not necessary, because has "this" as parent?
+ qDeleteAll(m_submenus);
+ m_submenus.clear();
+ delete m_popup; //not necessary, because has "this" as parent?
}
/** Returns the icon used for the current status. */
const QString CModuleChooserButton::iconName() {
- switch (m_moduleType) {
- case CSwordModuleInfo::Bible:
- return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
- case CSwordModuleInfo::Commentary:
- return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
- case CSwordModuleInfo::Lexicon:
- return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
- case CSwordModuleInfo::GenericBook:
- return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
- default: //return as default the bible icon
- return CResMgr::modules::bible::icon_unlocked;
- }
+ switch (m_moduleType) {
+ case CSwordModuleInfo::Bible:
+ return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
+ case CSwordModuleInfo::Commentary:
+ return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
+ case CSwordModuleInfo::Lexicon:
+ return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
+ case CSwordModuleInfo::GenericBook:
+ return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
+ default: //return as default the bible icon
+ return CResMgr::modules::bible::icon_unlocked;
+ }
}
CSwordModuleInfo* CModuleChooserButton::module() {
- foreach (QMenu* popup, m_submenus) {
- foreach (QAction* action, popup->actions()) {
- if ( action->isChecked() ) { //idAt -> , isItemChecked -> QAction::isChecked
- QString mod = action->text(); //popup->text(popup->idAt(i)); //text ->
- mod.remove(QChar('&')); //remove hotkey indicators
- return backend()->findModuleByName( mod.left(mod.indexOf(" ")) );
- }
- }
- }
- return 0; //"none" selected
+ foreach (QMenu* popup, m_submenus) {
+ foreach (QAction* action, popup->actions()) {
+ if ( action->isChecked() ) { //idAt -> , isItemChecked -> QAction::isChecked
+ QString mod = action->text(); //popup->text(popup->idAt(i)); //text ->
+ mod.remove(QChar('&')); //remove hotkey indicators
+ return backend()->findModuleByName( mod.left(mod.indexOf(" ")) );
+ }
+ }
+ }
+ return 0; //"none" selected
}
/** Returns the id used for this button. */
int CModuleChooserButton::getId() const {
- return m_id;
+ return m_id;
}
/** Is called after a module was selected in the popup */
void CModuleChooserButton::moduleChosen( QAction* action ) {
-
- QListIterator<QMenu*> it(m_submenus);
- while (it.hasNext()) {
- QMenu* popup = it.next();
- foreach (QAction* a, popup->actions()) {
- a->setChecked(false);
- }
- action->setChecked(true);
- }
-
- m_noneAction->setChecked(false); //uncheck the "none" item
- if (action->text().remove(QChar('&')) == tr("NONE")) { // note: this is for m_popup, the toplevel!
- if (m_hasModule) {
- emit sigRemoveButton(m_id);
- return;
- }
- }
- else {
- if (!m_hasModule) {
- emit sigAddButton();
- }
-
- m_hasModule = true;
- m_module = module();
-
- setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
- emit sigChanged();
-
- if (m_module) {
- setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
- }
- else {
- setToolTip( tr("Select an additional work") );
- }
- }
+
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* a, popup->actions()) {
+ a->setChecked(false);
+ }
+ action->setChecked(true);
+ }
+
+ m_noneAction->setChecked(false); //uncheck the "none" item
+ if (action->text().remove(QChar('&')) == tr("NONE")) { // note: this is for m_popup, the toplevel!
+ if (m_hasModule) {
+ emit sigRemoveButton(m_id);
+ return;
+ }
+ }
+ else {
+ if (!m_hasModule) {
+ emit sigAddButton();
+ }
+
+ m_hasModule = true;
+ m_module = module();
+
+ setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ emit sigChanged();
+
+ if (m_module) {
+ setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
+ }
+ else {
+ setToolTip( tr("Select an additional work") );
+ }
+ }
}
/** No descriptions */
void CModuleChooserButton::populateMenu() {
- qDeleteAll(m_submenus);
- m_submenus.clear();
- delete m_popup;
- m_popup = new QMenu(this);
-
- if (m_module) {
- this->setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
- }
- else {
- this->setToolTip( tr("Select an additional work") );
- }
-
- m_noneAction = m_popup->addAction(tr("NONE"));
- m_noneAction->setCheckable(true);
- if (!m_module) m_noneAction->setChecked(true);
-
- m_popup->addSeparator();
- connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
- setMenu(m_popup);
-
-
- // ******* Add languages and modules ********
-
- // Filters: add only non-hidden and right type
- BTModuleTreeItem::HiddenOff hiddenFilter;
- TypeFilter typeFilter(m_moduleType);
- QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
- filters.append(&hiddenFilter);
- }
- filters.append(&typeFilter);
- BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
- // add all items recursively
- addItemToMenu(&root, m_popup);
+ qDeleteAll(m_submenus);
+ m_submenus.clear();
+ delete m_popup;
+ m_popup = new QMenu(this);
+
+ if (m_module) {
+ this->setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
+ }
+ else {
+ this->setToolTip( tr("Select an additional work") );
+ }
+
+ m_noneAction = m_popup->addAction(tr("NONE"));
+ m_noneAction->setCheckable(true);
+ if (!m_module) m_noneAction->setChecked(true);
+
+ m_popup->addSeparator();
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ setMenu(m_popup);
+
+
+ // ******* Add languages and modules ********
+
+ // Filters: add only non-hidden and right type
+ BTModuleTreeItem::HiddenOff hiddenFilter;
+ TypeFilter typeFilter(m_moduleType);
+ QList<BTModuleTreeItem::Filter*> filters;
+ if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ filters.append(&hiddenFilter);
+ }
+ filters.append(&typeFilter);
+ BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
+ // add all items recursively
+ addItemToMenu(&root, m_popup);
}
-void CModuleChooserButton::addItemToMenu(BTModuleTreeItem* item, QMenu* menu)
-{
- foreach (BTModuleTreeItem* i, item->children()) {
-
- if (i->type() == BTModuleTreeItem::Language) {
- // argument menu was m_popup, create and add a new lang menu to it
- QMenu* langMenu = new QMenu(i->text(), this);
- menu->addMenu(langMenu);
- m_submenus.append(langMenu);
- connect(langMenu, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
- // add the module items to the lang menu
- addItemToMenu(i, langMenu);
- }
- else {
- // item must be module, create and add it to the lang menu
- QString name(i->text());
- name.append(" ").append(i->moduleInfo()->isLocked() ? tr("[locked]") : QString::null);
- QAction* modItem = new QAction(name, menu);
- modItem->setCheckable(true);
- if ( m_module && i->text() == m_module->name()) modItem->setChecked(true);
- menu->addAction(modItem);
- }
- }
+void CModuleChooserButton::addItemToMenu(BTModuleTreeItem* item, QMenu* menu) {
+ foreach (BTModuleTreeItem* i, item->children()) {
+
+ if (i->type() == BTModuleTreeItem::Language) {
+ // argument menu was m_popup, create and add a new lang menu to it
+ QMenu* langMenu = new QMenu(i->text(), this);
+ menu->addMenu(langMenu);
+ m_submenus.append(langMenu);
+ connect(langMenu, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ // add the module items to the lang menu
+ addItemToMenu(i, langMenu);
+ }
+ else {
+ // item must be module, create and add it to the lang menu
+ QString name(i->text());
+ name.append(" ").append(i->moduleInfo()->isLocked() ? tr("[locked]") : QString::null);
+ QAction* modItem = new QAction(name, menu);
+ modItem->setCheckable(true);
+ if ( m_module && i->text() == m_module->name()) modItem->setChecked(true);
+ menu->addAction(modItem);
+ }
+ }
}
void CModuleChooserButton::updateMenuItems() {
- QString moduleName;
- CSwordModuleInfo* module = 0;
- QList<CSwordModuleInfo*> chosenModules = m_moduleChooserBar->getModuleList();
-
- //for ( QMenu* popup = m_submenus.first(); popup; popup = m_submenus.next() ) {
- QListIterator<QMenu*> it(m_submenus);
- while (it.hasNext()) {
- QMenu* popup = it.next();
- foreach (QAction* action, popup->actions()) {
- moduleName = action->text();
- moduleName.remove(QChar('&')); //remove Hotkey indicator
- module = backend()->findModuleByName( moduleName.left(moduleName.lastIndexOf(" ")) );
-
- //Q_ASSERT(module);
- if (!module) qWarning("Can't find module with name %s", moduleName.toLatin1().data());
-
- bool alreadyChosen = chosenModules.contains( module );
- if (m_module) {
- alreadyChosen = alreadyChosen && (m_module->name() != moduleName);
- }
- //grey it out, it was chosen already
- action->setEnabled(!alreadyChosen);
- }
- }
+ QString moduleName;
+ CSwordModuleInfo* module = 0;
+ QList<CSwordModuleInfo*> chosenModules = m_moduleChooserBar->getModuleList();
+
+ //for ( QMenu* popup = m_submenus.first(); popup; popup = m_submenus.next() ) {
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* action, popup->actions()) {
+ moduleName = action->text();
+ moduleName.remove(QChar('&')); //remove Hotkey indicator
+ module = backend()->findModuleByName( moduleName.left(moduleName.lastIndexOf(" ")) );
+
+ //Q_ASSERT(module);
+ if (!module) qWarning("Can't find module with name %s", moduleName.toLatin1().data());
+
+ bool alreadyChosen = chosenModules.contains( module );
+ if (m_module) {
+ alreadyChosen = alreadyChosen && (m_module->name() != moduleName);
+ }
+ //grey it out, it was chosen already
+ action->setEnabled(!alreadyChosen);
+ }
+ }
}
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.h b/src/frontend/displaywindow/cmodulechooserbutton.h
index 7715bf3..23646c9 100644
--- a/src/frontend/displaywindow/cmodulechooserbutton.h
+++ b/src/frontend/displaywindow/cmodulechooserbutton.h
@@ -27,56 +27,60 @@ class CModuleChooserBar;
* @author The BibleTime team
*/
class CModuleChooserButton : public QToolButton, public CPointers {
- Q_OBJECT
-public:
-
- /** Filter out modules of wrong type. See populateMenu() and BTModuleTreeItem. */
- struct TypeFilter : public BTModuleTreeItem::Filter {
- TypeFilter(CSwordModuleInfo::ModuleType t) {m_mType = t;}
- bool filter(CSwordModuleInfo* mi) { return (mi->type() == m_mType); }
- CSwordModuleInfo::ModuleType m_mType;
- };
-
- CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent);
- ~CModuleChooserButton();
-
- CSwordModuleInfo* module();
- /**
- * Returns the id used for this button.
- */
- int getId() const;
- void updateMenuItems();
-
-protected:
- /** Populates the menu with language submenus and module items. */
- void populateMenu();
- /** Adds items to the menu recursively. */
- void addItemToMenu(BTModuleTreeItem* item, QMenu* menu);
-
-private:
- /**
- * Returns the icon used for the current status.
- */
- const QString iconName();
-
- bool m_hasModule;
- int m_id;
- QAction* m_noneAction;
- CSwordModuleInfo::ModuleType m_moduleType;
- CSwordModuleInfo* m_module;
-
- QMenu* m_popup;
- QList<QMenu*> m_submenus;
-
- CModuleChooserBar* m_moduleChooserBar;
-
-
-private slots:
- void moduleChosen(QAction* action );
-
-signals:
- void sigRemoveButton(const int ID);
- void sigAddButton();
- void sigChanged();
+ Q_OBJECT
+ public:
+
+ /** Filter out modules of wrong type. See populateMenu() and BTModuleTreeItem. */
+ struct TypeFilter : public BTModuleTreeItem::Filter {
+ TypeFilter(CSwordModuleInfo::ModuleType t) {
+ m_mType = t;
+ }
+ bool filter(CSwordModuleInfo* mi) {
+ return (mi->type() == m_mType);
+ }
+ CSwordModuleInfo::ModuleType m_mType;
+ };
+
+ CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent);
+ ~CModuleChooserButton();
+
+ CSwordModuleInfo* module();
+ /**
+ * Returns the id used for this button.
+ */
+ int getId() const;
+ void updateMenuItems();
+
+ protected:
+ /** Populates the menu with language submenus and module items. */
+ void populateMenu();
+ /** Adds items to the menu recursively. */
+ void addItemToMenu(BTModuleTreeItem* item, QMenu* menu);
+
+ private:
+ /**
+ * Returns the icon used for the current status.
+ */
+ const QString iconName();
+
+ bool m_hasModule;
+ int m_id;
+ QAction* m_noneAction;
+ CSwordModuleInfo::ModuleType m_moduleType;
+ CSwordModuleInfo* m_module;
+
+ QMenu* m_popup;
+ QList<QMenu*> m_submenus;
+
+ CModuleChooserBar* m_moduleChooserBar;
+
+
+ private slots:
+ void moduleChosen(QAction* action );
+
+ signals:
+ void sigRemoveButton(const int ID);
+ void sigAddButton();
+ void sigChanged();
};
#endif
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index 71dc603..dc97aec 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -30,9 +30,8 @@
using namespace Profile;
CPlainWriteWindow::CPlainWriteWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent) :
- CWriteWindow(moduleList, parent)
-{
- setKey( CSwordKey::createInstance(moduleList.first()) );
+ CWriteWindow(moduleList, parent) {
+ setKey( CSwordKey::createInstance(moduleList.first()) );
}
@@ -40,142 +39,142 @@ CPlainWriteWindow::~CPlainWriteWindow() {}
/** Initialize the state of this widget. */
void CPlainWriteWindow::initView() {
- // qWarning("CPlainWriteWindow::initView()");
- setDisplayWidget( CDisplay::createWriteInstance(this) );
- setCentralWidget( displayWidget()->view() );
-
- setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
- addToolBar(mainToolBar());
- addToolBarBreak();
-
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ // qWarning("CPlainWriteWindow::initView()");
+ setDisplayWidget( CDisplay::createWriteInstance(this) );
+ setCentralWidget( displayWidget()->view() );
+
+ setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
+ addToolBar(mainToolBar());
+ addToolBarBreak();
+
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
}
void CPlainWriteWindow::initToolbars() {
- m_actions.syncWindow = new QAction(
- //KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- mainToolBar()->addAction(m_actions.syncWindow);
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
-
-
- m_actions.saveText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
- m_actions.saveText->setToolTip( tr("Save text") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
-
-
- m_actions.restoreText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT(restoreText()) );
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
+ m_actions.syncWindow = new QAction(
+ //KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ tr("Sync with active Bible"),
+ actionCollection()
+ );
+ m_actions.syncWindow->setCheckable(true);
+ m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
+ mainToolBar()->addAction(m_actions.syncWindow);
+ actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
+
+
+ m_actions.saveText = new QAction(
+ //KIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ tr("Save text"),
+ actionCollection()
+ );
+ m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
+ QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
+ m_actions.saveText->setToolTip( tr("Save text") );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
+ mainToolBar()->addAction(m_actions.saveText);
+
+
+ m_actions.deleteEntry = new QAction(
+ //KIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ tr("Delete current entry"),
+ actionCollection()
+ );
+ m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
+ QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
+ m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
+ mainToolBar()->addAction(m_actions.deleteEntry);
+
+
+ m_actions.restoreText = new QAction(
+ //KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ tr("Restore original text"),
+ actionCollection()
+ );
+ m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
+ QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT(restoreText()) );
+ m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
+ actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
+ mainToolBar()->addAction(m_actions.restoreText);
}
void CPlainWriteWindow::initConnections() {
- CWriteWindow::initConnections();
- QObject::connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- QObject::connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+ CWriteWindow::initConnections();
+ QObject::connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ QObject::connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ CWriteWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
}
void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
- }
+ CWriteWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_actions.syncWindow->setChecked(true);
+ }
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CWriteDisplay*)displayWidget())->plainText();
- //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
- QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
- re.setMinimal(true);
- t.replace(re, "");
- t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
-
- const QString& oldKey = this->key()->key();
- if( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
-
- ((CWriteDisplay*)displayWidget())->setModified(false);
- 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.") ) );
- }
+ QString t = ((CWriteDisplay*)displayWidget())->plainText();
+ //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
+ QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
+ re.setMinimal(true);
+ t.replace(re, "");
+ t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
+
+ const QString& oldKey = this->key()->key();
+ if ( modules().first()->isWritable() ) {
+ modules().first()->write(this->key(), t );
+ this->key()->key( oldKey );
+
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ 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.") ) );
+ }
}
/** Loads the original text from the module. */
void CPlainWriteWindow::restoreText() {
- lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
- textChanged();
+ lookupSwordKey(key());
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
}
/** Is called when the current text was changed. */
void CPlainWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Deletes the module entry and clears the edit widget, */
void CPlainWriteWindow::deleteEntry() {
- modules().first()->deleteEntry( key() );
- lookupSwordKey( key() );
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ modules().first()->deleteEntry( key() );
+ lookupSwordKey( key() );
+ ((CWriteDisplay*)displayWidget())->setModified(false);
}
/** Setups the popup menu of this display widget. */
void CPlainWriteWindow::setupPopupMenu() {}
bool CPlainWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ return m_actions.syncWindow->isChecked();
}
void CPlainWriteWindow::initActions() {
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index 1ed4215..a190f47 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -25,72 +25,72 @@ class QString;
* @author The BibleTime team
*/
class CPlainWriteWindow : public CWriteWindow {
- Q_OBJECT
-public:
- CPlainWriteWindow( QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CPlainWriteWindow();
+ Q_OBJECT
+ public:
+ CPlainWriteWindow( QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CPlainWriteWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Setups the popup menu of this display widget.
- */
- virtual void setupPopupMenu();
- virtual bool syncAllowed() const;
+ /**
+ * Setups the popup menu of this display widget.
+ */
+ virtual void setupPopupMenu();
+ virtual bool syncAllowed() const;
-protected: // Protected methods
- /**
- * Initialize the state of this widget.
- */
- virtual void initView();
- virtual void initConnections();
- virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::PlainTextWindow;
- };
+ protected: // Protected methods
+ /**
+ * Initialize the state of this widget.
+ */
+ virtual void initView();
+ virtual void initConnections();
+ virtual void initToolbars();
+ virtual CDisplayWindow::WriteWindowType writeWindowType() {
+ return CDisplayWindow::PlainTextWindow;
+ };
- /**
- * Initializes the intern keyboard actions.
- */
- virtual void initActions();
- /**
- * Insert the keyboard accelerators of this window into the given KAccel object.
- */
- static void insertKeyboardActions( BtActionCollection* const a );
+ /**
+ * Initializes the intern keyboard actions.
+ */
+ virtual void initActions();
+ /**
+ * Insert the keyboard accelerators of this window into the given KAccel object.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
-private:
- struct {
- QAction* saveText;
- QAction* deleteEntry;
- QAction* restoreText;
- QAction* syncWindow;
- }
- m_actions;
+ private:
+ struct {
+ QAction* saveText;
+ QAction* deleteEntry;
+ QAction* restoreText;
+ QAction* syncWindow;
+ }
+ m_actions;
-protected slots: // Protected slots
- /**
- * Saves the text for the current key. Directly writes the changed text into the module.
- */
- virtual void saveCurrentText( const QString& );
- /**
- * Is called when the current text was changed.
- */
- virtual void textChanged();
- /**
- * Loads the original text from the module.
- */
- virtual void restoreText();
- /**
- * Deletes the module entry and clears the edit widget.
- */
- virtual void deleteEntry();
+ protected slots: // Protected slots
+ /**
+ * Saves the text for the current key. Directly writes the changed text into the module.
+ */
+ virtual void saveCurrentText( const QString& );
+ /**
+ * Is called when the current text was changed.
+ */
+ virtual void textChanged();
+ /**
+ * Loads the original text from the module.
+ */
+ virtual void restoreText();
+ /**
+ * Deletes the module entry and clears the edit widget.
+ */
+ virtual void deleteEntry();
};
#endif
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index a7d53ac..860fa72 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -31,156 +31,153 @@ typedef BtHtmlReadDisplay HTMLREADDISPLAY;
using namespace Profile;
CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CDisplayWindow(modules,parent),
- m_displayWidget(0)
-{
- qDebug("CReadWindow::CReadWindow");
- // installEventFilter(this);
+ : CDisplayWindow(modules, parent),
+ m_displayWidget(0) {
+ qDebug("CReadWindow::CReadWindow");
+ // installEventFilter(this);
}
CReadWindow::~CReadWindow() {
- // qWarning("destructor of CReadWindow");
+ // qWarning("destructor of CReadWindow");
}
/** Sets the display widget of this display window. */
void CReadWindow::setDisplayWidget( CDisplay* newDisplay ) {
- Q_ASSERT(dynamic_cast<CReadDisplay*>(newDisplay));
- CDisplayWindow::setDisplayWidget(newDisplay);
- if (m_displayWidget) {
- disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceClicked(const QString&, const QString&)), this, SLOT(lookupModKey(const QString&, const QString&)));
- disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceDropped(const QString&)), this, SLOT(lookupKey(const QString&)));
-
- HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
- if (v) {
- QObject::disconnect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
- }
-
- }
-
- m_displayWidget = (CReadDisplay*)newDisplay;
- connect(
- m_displayWidget->connectionsProxy(),
- SIGNAL(referenceClicked(const QString&, const QString&)),
- this,
- SLOT(lookupModKey(const QString&, const QString&))
- );
-
- connect(
- m_displayWidget->connectionsProxy(),
- SIGNAL(referenceDropped(const QString&)),
- this,
- SLOT(lookupKey(const QString&))
- );
- HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
- if (v)
- {
- QObject::connect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
- }
+ Q_ASSERT(dynamic_cast<CReadDisplay*>(newDisplay));
+ CDisplayWindow::setDisplayWidget(newDisplay);
+ if (m_displayWidget) {
+ disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceClicked(const QString&, const QString&)), this, SLOT(lookupModKey(const QString&, const QString&)));
+ disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceDropped(const QString&)), this, SLOT(lookupKey(const QString&)));
+
+ HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ if (v) {
+ QObject::disconnect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
+ }
+
+ }
+
+ m_displayWidget = (CReadDisplay*)newDisplay;
+ connect(
+ m_displayWidget->connectionsProxy(),
+ SIGNAL(referenceClicked(const QString&, const QString&)),
+ this,
+ SLOT(lookupModKey(const QString&, const QString&))
+ );
+
+ connect(
+ m_displayWidget->connectionsProxy(),
+ SIGNAL(referenceDropped(const QString&)),
+ this,
+ SLOT(lookupKey(const QString&))
+ );
+ HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ if (v) {
+ QObject::connect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
+ }
}
/** Lookup the given entry. */
void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
- qDebug() << "CReadWindow::lookup newKey" << newKey->key();
- Q_ASSERT(newKey);
+ qDebug() << "CReadWindow::lookup newKey" << newKey->key();
+ Q_ASSERT(newKey);
- using namespace Rendering;
+ using namespace Rendering;
// Q_ASSERT(isReady() && newKey && modules().first());
- if (!isReady() || !newKey || modules().empty() || !modules().first()) {
- return;
- }
-
- if (key() != newKey) {
- key()->key(newKey->key());
- }
-
- //next-TODO: how about options?
- Q_ASSERT(modules().first()->getDisplay());
- CEntryDisplay* display = modules().first()->getDisplay();
- if (display) { //do we have a display object?
- displayWidget()->setText(
- display->text(
- modules(),
- newKey->key(),
- displayOptions(),
- filterOptions()
- )
- );
- }
-
- setCaption( windowCaption() );
-
- // moving to anchor happens in slotMoveToAnchor which catches the completed() signal from KHTMLPart
-
- qDebug() << "CReadWindow::lookup end, key is :" << newKey->key();
+ if (!isReady() || !newKey || modules().empty() || !modules().first()) {
+ return;
+ }
+
+ if (key() != newKey) {
+ key()->key(newKey->key());
+ }
+
+ //next-TODO: how about options?
+ Q_ASSERT(modules().first()->getDisplay());
+ CEntryDisplay* display = modules().first()->getDisplay();
+ if (display) { //do we have a display object?
+ displayWidget()->setText(
+ display->text(
+ modules(),
+ newKey->key(),
+ displayOptions(),
+ filterOptions()
+ )
+ );
+ }
+
+ setCaption( windowCaption() );
+
+ // moving to anchor happens in slotMoveToAnchor which catches the completed() signal from KHTMLPart
+
+ qDebug() << "CReadWindow::lookup end, key is :" << newKey->key();
}
-void CReadWindow::slotMoveToAnchor()
-{
- qDebug("CReadWindow::slotMoveToAnchor");
- ((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
+void CReadWindow::slotMoveToAnchor() {
+ qDebug("CReadWindow::slotMoveToAnchor");
+ ((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
}
/** Store the settings of this window in the given CProfileWindow object. */
void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
- QRect rect;
- rect.setX(parentWidget()->x());
- rect.setY(parentWidget()->y());
- rect.setWidth(parentWidget()->width());
- rect.setHeight(parentWidget()->height());
- settings->setGeometry(rect);
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->setType(modules().first()->type());
- settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
- settings->setFocus( (this == dynamic_cast<CReadWindow*>(mdi()->activeSubWindow()) ) ); //set property to true if this window is the active one.
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->setKey( key()->key() );
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
-
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
- }
- settings->setModules(mods);
+ QRect rect;
+ rect.setX(parentWidget()->x());
+ rect.setY(parentWidget()->y());
+ rect.setWidth(parentWidget()->width());
+ rect.setHeight(parentWidget()->height());
+ settings->setGeometry(rect);
+
+ // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
+ settings->setType(modules().first()->type());
+ settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
+ settings->setFocus( (this == dynamic_cast<CReadWindow*>(mdi()->activeSubWindow()) ) ); //set property to true if this window is the active one.
+
+ if (key()) {
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
+ QString oldLang;
+ if (vk) {
+ oldLang = QString(vk->getLocale());
+ vk->setLocale("en"); //save english locale names as default!
+ }
+ settings->setKey( key()->key() );
+ if (vk) {
+ vk->setLocale(oldLang.toLatin1());
+ }
+ }
+
+ QStringList mods;
+
+ QList<CSwordModuleInfo*> allMods = modules();
+ QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
+ for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
+ mods.append((*it)->name());
+ }
+ settings->setModules(mods);
}
void CReadWindow::applyProfileSettings(CProfileWindow * const settings) {
- // parentWidget()->setUpdatesEnabled(false);
- setUpdatesEnabled(false);
-
- if (settings->maximized()) { //maximize this window
- // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
- parentWidget()->showMaximized();
- }
- else {
- const QRect rect = settings->geometry();
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- }
-
- setUpdatesEnabled(true);
+ // parentWidget()->setUpdatesEnabled(false);
+ setUpdatesEnabled(false);
+
+ if (settings->maximized()) { //maximize this window
+ // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
+ parentWidget()->showMaximized();
+ }
+ else {
+ const QRect rect = settings->geometry();
+ parentWidget()->resize(rect.width(), rect.height());
+ parentWidget()->move(rect.x(), rect.y());
+ }
+
+ setUpdatesEnabled(true);
}
void CReadWindow::insertKeyboardActions( BtActionCollection* const ) {}
/** No descriptions */
void CReadWindow::copyDisplayedText() {
- CExportManager mgr(QString::null);
- mgr.copyKey(key(), CExportManager::Text, true);
+ CExportManager mgr(QString::null);
+ mgr.copyKey(key(), CExportManager::Text, true);
}
@@ -188,18 +185,18 @@ void CReadWindow::copyDisplayedText() {
\fn CReadWindow::resizeEvent(QResizeEvent* e)
*/
void CReadWindow::resizeEvent(QResizeEvent* /*e*/) {
- if (displayWidget()) {
- ((CReadDisplay*)displayWidget())->moveToAnchor(Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()));
- }
+ if (displayWidget()) {
+ ((CReadDisplay*)displayWidget())->moveToAnchor(Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()));
+ }
}
void CReadWindow::openSearchStrongsDialog() {
// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
- QString searchText = QString::null;
-
- if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
- searchText.append("strong:").append(displayWidget()->getCurrentNodeInfo() [CDisplay::Lemma]);
- }
-
- Search::CSearchDialog::openDialog( modules(), searchText, 0 );
+ QString searchText = QString::null;
+
+ if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
+ searchText.append("strong:").append(displayWidget()->getCurrentNodeInfo() [CDisplay::Lemma]);
+ }
+
+ Search::CSearchDialog::openDialog( modules(), searchText, 0 );
}
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index 3630b58..6144b2d 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -28,52 +28,52 @@ class QResizeEvent;
*/
class CReadWindow : public CDisplayWindow {
- Q_OBJECT
-public:
- // static void insertKeyboardActions( KAccel* const a );
- static void insertKeyboardActions( BtActionCollection* const a );
-
- CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
-
-protected: // Protected methods
- /**
- * Sets the display widget of this display window.
- */
- virtual void setDisplayWidget( CDisplay* newDisplay );
- /**
- */
- virtual void resizeEvent(QResizeEvent* e);
-
-protected slots:
- /**
- * Load the text using the key
- */
- virtual void lookupSwordKey( CSwordKey* );
- /**
- * Catch the signal when the KHTMLPart has finished the layout (anchors are not ready before that).
- */
- virtual void slotMoveToAnchor();
-
- /**
- * Update the status of the popup menu entries.
- */
- virtual void copyDisplayedText();
- /** Open the search dialog with the strong info of the last clicked word.
- *
- */
- void openSearchStrongsDialog();
-
-private:
- CReadDisplay* m_displayWidget;
+ Q_OBJECT
+ public:
+ // static void insertKeyboardActions( KAccel* const a );
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
+
+ protected: // Protected methods
+ /**
+ * Sets the display widget of this display window.
+ */
+ virtual void setDisplayWidget( CDisplay* newDisplay );
+ /**
+ */
+ virtual void resizeEvent(QResizeEvent* e);
+
+ protected slots:
+ /**
+ * Load the text using the key
+ */
+ virtual void lookupSwordKey( CSwordKey* );
+ /**
+ * Catch the signal when the KHTMLPart has finished the layout (anchors are not ready before that).
+ */
+ virtual void slotMoveToAnchor();
+
+ /**
+ * Update the status of the popup menu entries.
+ */
+ virtual void copyDisplayedText();
+ /** Open the search dialog with the strong info of the last clicked word.
+ *
+ */
+ void openSearchStrongsDialog();
+
+ private:
+ CReadDisplay* m_displayWidget;
};
#endif
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
index 62009c0..c60d9cd 100644
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ b/src/frontend/displaywindow/cwritewindow.cpp
@@ -24,7 +24,7 @@
using namespace Profile;
CWriteWindow::CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
-: CDisplayWindow(modules, parent), m_writeDisplay(0) {}
+ : CDisplayWindow(modules, parent), m_writeDisplay(0) {}
CWriteWindow::~CWriteWindow() {}
@@ -32,8 +32,8 @@ CWriteWindow::~CWriteWindow() {}
void CWriteWindow::insertKeyboardActions( BtActionCollection* const ) {}
void CWriteWindow::initConnections() {
- Q_ASSERT(keyChooser());
- QObject::connect(keyChooser(), SIGNAL(beforeKeyChange(const QString&)), this, SLOT(beforeKeyChange(const QString&)));
+ Q_ASSERT(keyChooser());
+ QObject::connect(keyChooser(), SIGNAL(beforeKeyChange(const QString&)), this, SLOT(beforeKeyChange(const QString&)));
}
void CWriteWindow::initActions() {}
@@ -41,121 +41,121 @@ void CWriteWindow::initActions() {}
void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
- settings->setWriteWindowType( writeWindowType() );
-
- QRect rect;
- rect.setX(parentWidget()->x());
- rect.setY(parentWidget()->y());
- rect.setWidth(parentWidget()->width());
- rect.setHeight(parentWidget()->height());
- settings->setGeometry(rect);
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->setType(modules().first()->type());
- settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString::fromLatin1(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->setKey( key()->key() );
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
- }
- settings->setModules(mods);
+ settings->setWriteWindowType( writeWindowType() );
+
+ QRect rect;
+ rect.setX(parentWidget()->x());
+ rect.setY(parentWidget()->y());
+ rect.setWidth(parentWidget()->width());
+ rect.setHeight(parentWidget()->height());
+ settings->setGeometry(rect);
+
+ // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
+ settings->setType(modules().first()->type());
+ settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
+
+ if (key()) {
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
+ QString oldLang;
+ if (vk) {
+ oldLang = QString::fromLatin1(vk->getLocale());
+ vk->setLocale("en"); //save english locale names as default!
+ }
+ settings->setKey( key()->key() );
+ if (vk) {
+ vk->setLocale(oldLang.toLatin1());
+ }
+ }
+
+ QStringList mods;
+ QList<CSwordModuleInfo*> allMods = modules();
+ QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
+ for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
+ mods.append((*it)->name());
+ }
+ settings->setModules(mods);
}
void CWriteWindow::applyProfileSettings(CProfileWindow * const settings) {
- setUpdatesEnabled(false);
-
- if (settings->maximized()) {
- parentWidget()->showMaximized();
- }
- else {
- const QRect rect = settings->geometry();
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- //setGeometry( settings->geometry() );
- }
- // displayWidget()->view()->horizontalScrollBar()->setValue( settings->scrollbarPositions().horizontal );
- // m_htmlWidget->view()->verticalScrollBar()->setValue( settings->scrollbarPositions().vertical );
-
- setUpdatesEnabled(true);
+ setUpdatesEnabled(false);
+
+ if (settings->maximized()) {
+ parentWidget()->showMaximized();
+ }
+ else {
+ const QRect rect = settings->geometry();
+ parentWidget()->resize(rect.width(), rect.height());
+ parentWidget()->move(rect.x(), rect.y());
+ //setGeometry( settings->geometry() );
+ }
+ // displayWidget()->view()->horizontalScrollBar()->setValue( settings->scrollbarPositions().horizontal );
+ // m_htmlWidget->view()->verticalScrollBar()->setValue( settings->scrollbarPositions().vertical );
+
+ setUpdatesEnabled(true);
}
void CWriteWindow::setDisplayWidget( CDisplay* display ) {
- Q_ASSERT(dynamic_cast<CWriteDisplay*>(display));
- CDisplayWindow::setDisplayWidget((CWriteDisplay*)display);
- m_writeDisplay = (CWriteDisplay*)display;
+ Q_ASSERT(dynamic_cast<CWriteDisplay*>(display));
+ CDisplayWindow::setDisplayWidget((CWriteDisplay*)display);
+ m_writeDisplay = (CWriteDisplay*)display;
}
void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
- //set the raw text to the display widget
- if (!newKey)
- return;
-
- if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
- key()->key(newKey->key());
- }
-
- if ( modules().count() ) {
- displayWidget()->setText( key()->rawText() );
- }
- setCaption( windowCaption() );
+ //set the raw text to the display widget
+ if (!newKey)
+ return;
+
+ if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
+ key()->key(newKey->key());
+ }
+
+ if ( modules().count() ) {
+ displayWidget()->setText( key()->rawText() );
+ }
+ setCaption( 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) ) {
- case QMessageBox::Yes: //save and close
- saveCurrentText();
- m_writeDisplay->setModified( false );
- return true;
- case QMessageBox::No: //don't save and close
- return true;
- default: // cancel, don't close
- return false;
- }
- }
- return true;
+ //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) ) {
+ case QMessageBox::Yes: //save and close
+ saveCurrentText();
+ m_writeDisplay->setModified( false );
+ return true;
+ case QMessageBox::No: //don't save and close
+ return true;
+ default: // cancel, don't close
+ return false;
+ }
+ }
+ return true;
}
void CWriteWindow::beforeKeyChange(const QString& key) {
- Q_ASSERT(displayWidget());
- Q_ASSERT(keyChooser());
- if (!isReady()) return;
-
- //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) ) {
- case QMessageBox::Yes: { //save the changes
- saveCurrentText( key );
- break;
- }
- default: {// set modified to false so it won't ask again
- ((CWriteDisplay*)displayWidget())->setModified(false);
- break;
- }
- }
- }
+ Q_ASSERT(displayWidget());
+ Q_ASSERT(keyChooser());
+ if (!isReady()) return;
+
+ //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) ) {
+ case QMessageBox::Yes: { //save the changes
+ saveCurrentText( key );
+ break;
+ }
+ default: {// set modified to false so it won't ask again
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ break;
+ }
+ }
+ }
}
void CWriteWindow::saveCurrentText() {
- if(key()) {
- saveCurrentText(key()->key());
- }
+ if (key()) {
+ saveCurrentText(key()->key());
+ }
}
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
index c3b47c2..e2ffc54 100644
--- a/src/frontend/displaywindow/cwritewindow.h
+++ b/src/frontend/displaywindow/cwritewindow.h
@@ -23,50 +23,50 @@ class BtActionCollection;
*/
class CWriteWindow : public CDisplayWindow {
- Q_OBJECT
-public:
- static void insertKeyboardActions( BtActionCollection* const a );
+ Q_OBJECT
+ public:
+ static void insertKeyboardActions( BtActionCollection* const a );
- CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CWriteWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
- virtual void initConnections();
- virtual void initActions();
+ CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CWriteWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
+ virtual void initConnections();
+ virtual void initActions();
-public slots:
- /**
- * Look up the given key and display the text. In our case we offer to edit the text.
- */
- virtual void lookupSwordKey( CSwordKey* key );
+ public slots:
+ /**
+ * Look up the given key and display the text. In our case we offer to edit the text.
+ */
+ virtual void lookupSwordKey( CSwordKey* key );
-protected: // Protected methods
- /**
- * Saves the given text as text of the given key. Use this function
- * as backend in each write window implementation.
- */
- void setDisplayWidget( CDisplay* display );
- virtual CDisplayWindow::WriteWindowType writeWindowType() = 0;
- virtual bool queryClose();
- virtual void saveCurrentText( const QString& key ) = 0;
+ protected: // Protected methods
+ /**
+ * Saves the given text as text of the given key. Use this function
+ * as backend in each write window implementation.
+ */
+ void setDisplayWidget( CDisplay* display );
+ virtual CDisplayWindow::WriteWindowType writeWindowType() = 0;
+ virtual bool queryClose();
+ virtual void saveCurrentText( const QString& key ) = 0;
-protected slots:
- /** Save text to the module
- */
- void saveCurrentText();
- /**
- */
- virtual void beforeKeyChange(const QString&);
+ protected slots:
+ /** Save text to the module
+ */
+ void saveCurrentText();
+ /**
+ */
+ virtual void beforeKeyChange(const QString&);
-private:
- CWriteDisplay* m_writeDisplay;
+ private:
+ CWriteDisplay* m_writeDisplay;
};
#endif
diff --git a/src/frontend/htmldialogs/btaboutdialog.cpp b/src/frontend/htmldialogs/btaboutdialog.cpp
index 0f783e9..2c6f553 100644
--- a/src/frontend/htmldialogs/btaboutdialog.cpp
+++ b/src/frontend/htmldialogs/btaboutdialog.cpp
@@ -28,226 +28,208 @@ static QString make_version();
// Implements the Help > About dialog box
BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags )
- : BtTabHtmlDialog (tr("About BibleTime"), 5, parent, wflags)
-{
- resize(550,340);
- init_lic_tab();
- init_sword_tab();
- init_qt_tab();
- init_contributors_tab();
- init_bt_tab();
-}
-
-BtAboutDialog::~BtAboutDialog()
-{
-}
-
-void BtAboutDialog::init_bt_tab()
-{
- selectTab(0);
- setTabText("BibleTime" );
- QString content;
- content = make_file_icon("bibletime");
- content += "&nbsp;&nbsp;";
- content += make_bold("BibleTime " + make_version());
- content = make_center(content) + make_br();
- content += tr("BibleTime is an easy to use but powerful Bible study tool.");
- content += make_br() + make_br();
- content += tr("We are looking for developers and translators.");
- content += " ";
- content += tr("If you would like to join our team, please send an email to info@bibletime.info.");
- content += make_br() + make_br();
- content += tr("(c)1999-2009, The BibleTime Team");
- content += make_br();
- content += make_link("http://www.bibletime.info","http://www.bibletime.info");
- QString bibletime = make_html(make_head("") + make_body(content));
- setHtml(bibletime);
-}
-
-void BtAboutDialog::init_contributors_tab()
-{
- selectTab(1);
- setTabText(tr("Contributors"));
- QString content;
- content += make_bold(tr("The following people contributed to BibleTime:")) + make_br();
- // sorted alphabetically (last name)
- content += "<ul>";
- content += "<li>Thomas Abthorpe (" + tr("documentation and translation manager") + ")</li>";
- content += "<li>Joachim Ansorg (" + tr("project founder, developer") + ")</li>";
- content += "<li>David Blue (" + tr("designer") + ")</li>";
- content += "<li>Tim Brodie (" + tr("developer") + ")</li>";
- content += "<li>Timothy R. Butler (" + tr("designer") + ")</li>";
- content += "<li>Jim Campbell (" + tr("developer") + ")</li>";
- content += "<li>Lee Carpenter (" + tr("developer") + ")</li>";
- content += "<li>Jeremy Erickson (" + tr("packager") + ")</li>";
- content += "<li>Troy A. Griffitts (" + tr("creator of The Sword Project") + ")</li>";
- content += "<li>Martin Gruner (" + tr("project manager, developer") + ")</li>";
- content += "<li>Thomas Hagedorn (" + tr("domain sponsor") + ")</li>";
- content += "<li>Bob Harman (" + tr("howto") + ")</li>";
- content += "<li>Gary Holmlund (" + tr("developer") + ")</li>";
- content += "<li>Nikolay Igotti (" + tr("developer") + ")</li>";
- content += "<li>Eeli Kaikkonnen (" + tr("developer") + ")</li>";
- content += "<li>Chris Kujawa (" + tr("developer") + ")</li>";
- content += "<li>Mark Lybarger (" + tr("developer") + ")</li>";
- content += "<li>Luke Mauldin (" + tr("developer") + ")</li>";
- content += "<li>James Ots (" + tr("designer") + ")</li>";
- content += "<li>Fred Saalbach (" + tr("documentation") + ")</li>";
- content += "<li>Gary Sims (" + tr("developer") + ")</li>";
- content += "<li>Wolfgang Stradner (" + tr("tester, usability expert") + ")</li>";
- content += "<li>Thorsten Uhlmann (" + tr("developer") + ")</li>";
- content += "<li>David White (" + tr("developer") + ")</li>";
- content += "<li>Mark Zealey (" + tr("developer") + ")</li>";
- content += "</ul>";
-
- content += make_bold(tr("The following people translated BibleTime into their language:")) + make_br();
- // sorted alphabetically (last name)
- content += "<ul>";
- content += "<li>Horatiu Alexe</li>";
- content += "<li>Jan B&ecarron;lohoubek</li>";
- content += "<li>Chun-shek Chan</li>";
- content += "<li>Ilpo Kantonen</li>";
- content += "<li>Pavel Laukko</li>";
- content += "<li>Piotr Markiewicz</li>";
- content += "<li>G&eacute;za Nov&aacute;k</li>";
- content += "<li>Gabriel P&eacute;rez</li>";
- content += "<li>Igor Plisco</li>";
- content += "<li>Zdenko Podobn&yacute;</li>";
- content += "<li>Jaak Ristioja</li>";
- content += "<li>Igor Rykhlin</li>";
- content += "<li>Vlad Savitsky</li>";
- content += "<li>Johan van der Lingen</li>";
- content += "<li>Jean Van Schaftingen</li>";
- content += "<li>Dmitry Yurevich</li>";
- content += "<li>Esteban Zeller</li>";
- content += "</ul>";
- content += make_br();
- content += tr("Some names may be missing, please email bibletime-translations@lists.sourceforge.net if you notice errors or omissions.");
-
- QString contributors = make_html(make_head("") + make_body(content));
- setHtml(contributors);
-}
-
-
-void BtAboutDialog::init_sword_tab()
-{
- selectTab(2);
- setTabText("Sword" );
-
- QString version( sword::SWVersion::currentVersion.getText());
- QString content = make_br() + make_br();
- content += make_center(make_bold(tr("SWORD library version %1").arg(version)));
- content += make_br();
-
- content += tr("BibleTime makes use of the SWORD Project. The SWORD Project is the CrossWire Bible Society's free Bible software project. Its purpose is to create cross-platform open-source tools-- covered by the GNU General Public License-- that allow programmers and Bible societies to write new Bible software more quickly and easily.");
- content += make_br() + make_br();
- content += tr("The SWORD Project") + make_br();
- content += make_link("http://www.crosswire.org/sword/index.jsp","www.crosswire.org/sword/index.jsp");
-
- setHtml(content);
-
-}
-
-void BtAboutDialog::init_qt_tab()
-{
- selectTab(3);
- setTabText("Qt");
- QString content;
- 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 += 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 += 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.");
- QString qt = make_html(make_head("") + make_body(content));
- setHtml(qt);
-}
-
-void BtAboutDialog::init_lic_tab()
-{
- selectTab(4);
- setTabText(tr("License"));
-
- QByteArray text;
- text += tr("BibleTime is released under the GPL license.");
- text += " ";
- 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 += 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 += tr("The complete legally binding license is below.");
-
- QFile licFile(util::filesystem::DirectoryUtil::getLicenseDir().path() + "/license.html");
- if (licFile.open(QFile::ReadOnly))
- {
- QByteArray html;
- while (!licFile.atEnd())
- {
- QByteArray line = licFile.readLine();
- html = html + line;
- }
- licFile.close();
- html.replace("TRANSLATED TEXT", text);
- setHtml(QString(html));
- }
+ : BtTabHtmlDialog (tr("About BibleTime"), 5, parent, wflags) {
+ resize(550, 340);
+ init_lic_tab();
+ init_sword_tab();
+ init_qt_tab();
+ init_contributors_tab();
+ init_bt_tab();
+}
+
+BtAboutDialog::~BtAboutDialog() {
+}
+
+void BtAboutDialog::init_bt_tab() {
+ selectTab(0);
+ setTabText("BibleTime" );
+ QString content;
+ content = make_file_icon("bibletime");
+ content += "&nbsp;&nbsp;";
+ content += make_bold("BibleTime " + make_version());
+ content = make_center(content) + make_br();
+ content += tr("BibleTime is an easy to use but powerful Bible study tool.");
+ content += make_br() + make_br();
+ content += tr("We are looking for developers and translators.");
+ content += " ";
+ content += tr("If you would like to join our team, please send an email to info@bibletime.info.");
+ content += make_br() + make_br();
+ content += tr("(c)1999-2009, The BibleTime Team");
+ content += make_br();
+ content += make_link("http://www.bibletime.info", "http://www.bibletime.info");
+ QString bibletime = make_html(make_head("") + make_body(content));
+ setHtml(bibletime);
+}
+
+void BtAboutDialog::init_contributors_tab() {
+ selectTab(1);
+ setTabText(tr("Contributors"));
+ QString content;
+ content += make_bold(tr("The following people contributed to BibleTime:")) + make_br();
+ // sorted alphabetically (last name)
+ content += "<ul>";
+ content += "<li>Thomas Abthorpe (" + tr("documentation and translation manager") + ")</li>";
+ content += "<li>Joachim Ansorg (" + tr("project founder, developer") + ")</li>";
+ content += "<li>David Blue (" + tr("designer") + ")</li>";
+ content += "<li>Tim Brodie (" + tr("developer") + ")</li>";
+ content += "<li>Timothy R. Butler (" + tr("designer") + ")</li>";
+ content += "<li>Jim Campbell (" + tr("developer") + ")</li>";
+ content += "<li>Lee Carpenter (" + tr("developer") + ")</li>";
+ content += "<li>Jeremy Erickson (" + tr("packager") + ")</li>";
+ content += "<li>Troy A. Griffitts (" + tr("creator of The Sword Project") + ")</li>";
+ content += "<li>Martin Gruner (" + tr("project manager, developer") + ")</li>";
+ content += "<li>Thomas Hagedorn (" + tr("domain sponsor") + ")</li>";
+ content += "<li>Bob Harman (" + tr("howto") + ")</li>";
+ content += "<li>Gary Holmlund (" + tr("developer") + ")</li>";
+ content += "<li>Nikolay Igotti (" + tr("developer") + ")</li>";
+ content += "<li>Eeli Kaikkonnen (" + tr("developer") + ")</li>";
+ content += "<li>Chris Kujawa (" + tr("developer") + ")</li>";
+ content += "<li>Mark Lybarger (" + tr("developer") + ")</li>";
+ content += "<li>Luke Mauldin (" + tr("developer") + ")</li>";
+ content += "<li>James Ots (" + tr("designer") + ")</li>";
+ content += "<li>Fred Saalbach (" + tr("documentation") + ")</li>";
+ content += "<li>Gary Sims (" + tr("developer") + ")</li>";
+ content += "<li>Wolfgang Stradner (" + tr("tester, usability expert") + ")</li>";
+ content += "<li>Thorsten Uhlmann (" + tr("developer") + ")</li>";
+ content += "<li>David White (" + tr("developer") + ")</li>";
+ content += "<li>Mark Zealey (" + tr("developer") + ")</li>";
+ content += "</ul>";
+
+ content += make_bold(tr("The following people translated BibleTime into their language:")) + make_br();
+ // sorted alphabetically (last name)
+ content += "<ul>";
+ content += "<li>Horatiu Alexe</li>";
+ content += "<li>Jan B&ecarron;lohoubek</li>";
+ content += "<li>Chun-shek Chan</li>";
+ content += "<li>Ilpo Kantonen</li>";
+ content += "<li>Pavel Laukko</li>";
+ content += "<li>Piotr Markiewicz</li>";
+ content += "<li>G&eacute;za Nov&aacute;k</li>";
+ content += "<li>Gabriel P&eacute;rez</li>";
+ content += "<li>Igor Plisco</li>";
+ content += "<li>Zdenko Podobn&yacute;</li>";
+ content += "<li>Jaak Ristioja</li>";
+ content += "<li>Igor Rykhlin</li>";
+ content += "<li>Vlad Savitsky</li>";
+ content += "<li>Johan van der Lingen</li>";
+ content += "<li>Jean Van Schaftingen</li>";
+ content += "<li>Dmitry Yurevich</li>";
+ content += "<li>Esteban Zeller</li>";
+ content += "</ul>";
+ content += make_br();
+ content += tr("Some names may be missing, please email bibletime-translations@lists.sourceforge.net if you notice errors or omissions.");
+
+ QString contributors = make_html(make_head("") + make_body(content));
+ setHtml(contributors);
+}
+
+
+void BtAboutDialog::init_sword_tab() {
+ selectTab(2);
+ setTabText("Sword" );
+
+ QString version( sword::SWVersion::currentVersion.getText());
+ QString content = make_br() + make_br();
+ content += make_center(make_bold(tr("SWORD library version %1").arg(version)));
+ content += make_br();
+
+ content += tr("BibleTime makes use of the SWORD Project. The SWORD Project is the CrossWire Bible Society's free Bible software project. Its purpose is to create cross-platform open-source tools-- covered by the GNU General Public License-- that allow programmers and Bible societies to write new Bible software more quickly and easily.");
+ content += make_br() + make_br();
+ content += tr("The SWORD Project") + make_br();
+ content += make_link("http://www.crosswire.org/sword/index.jsp", "www.crosswire.org/sword/index.jsp");
+
+ setHtml(content);
+
+}
+
+void BtAboutDialog::init_qt_tab() {
+ selectTab(3);
+ setTabText("Qt");
+ QString content;
+ 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 += 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 += 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.");
+ QString qt = make_html(make_head("") + make_body(content));
+ setHtml(qt);
+}
+
+void BtAboutDialog::init_lic_tab() {
+ selectTab(4);
+ setTabText(tr("License"));
+
+ QByteArray text;
+ text += tr("BibleTime is released under the GPL license.");
+ text += " ";
+ 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 += 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 += tr("The complete legally binding license is below.");
+
+ QFile licFile(util::filesystem::DirectoryUtil::getLicenseDir().path() + "/license.html");
+ if (licFile.open(QFile::ReadOnly)) {
+ QByteArray html;
+ while (!licFile.atEnd()) {
+ QByteArray line = licFile.readLine();
+ html = html + line;
+ }
+ licFile.close();
+ html.replace("TRANSLATED TEXT", text);
+ setHtml(QString(html));
+ }
}
// Helper functions
-static QString make_center(const QString& content)
-{
- return "<center>" + content + "</center>";
+static QString make_center(const QString& content) {
+ return "<center>" + content + "</center>";
}
-static QString make_br()
-{
- return "<br>";
+static QString make_br() {
+ return "<br>";
}
-static QString make_bold(const QString& content)
-{
- return "<b>" + content + "</b>";
+static QString make_bold(const QString& content) {
+ return "<b>" + content + "</b>";
}
-static QString make_html(const QString& content)
-{
- return "<html>" + content + "</html>";
+static QString make_html(const QString& content) {
+ return "<html>" + content + "</html>";
}
-static QString make_head(const QString& content)
-{
- return "<head>" + content + "</head>";
+static QString make_head(const QString& content) {
+ return "<head>" + content + "</head>";
}
-static QString make_body(const QString& content)
-{
- return "<body>" + content + "</body>";
+static QString make_body(const QString& content) {
+ return "<body>" + content + "</body>";
}
-static QString make_link(const QString& link, const QString& text)
-{
- return "<a href=\"" + link + "\">" + text +"</a>";
+static QString make_link(const QString& link, const QString& text) {
+ return "<a href=\"" + link + "\">" + text + "</a>";
}
-static QString make_version()
-{
+static QString make_version() {
// return "";
- return BT_VERSION;
+ return BT_VERSION;
}
-static QString make_file_icon(const QString& icon)
-{
- QString dir = "<img src=file://" + util::filesystem::DirectoryUtil::getIconDir().path();
- return dir + "/" + icon +".png >";
+static QString make_file_icon(const QString& icon) {
+ QString dir = "<img src=file://" + util::filesystem::DirectoryUtil::getIconDir().path();
+ return dir + "/" + icon + ".png >";
}
diff --git a/src/frontend/htmldialogs/btaboutdialog.h b/src/frontend/htmldialogs/btaboutdialog.h
index 067cad7..6521f7f 100644
--- a/src/frontend/htmldialogs/btaboutdialog.h
+++ b/src/frontend/htmldialogs/btaboutdialog.h
@@ -12,18 +12,17 @@
#include "bttabhtmldialog.h"
-class BtAboutDialog : public BtTabHtmlDialog
-{
- Q_OBJECT
+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();
- void init_qt_tab();
- void init_lic_tab();
+ public:
+ BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ ~BtAboutDialog();
+ void init_bt_tab();
+ void init_contributors_tab();
+ void init_sword_tab();
+ void init_qt_tab();
+ void init_lic_tab();
};
#endif
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.cpp b/src/frontend/htmldialogs/bttabhtmldialog.cpp
index f8a83f7..4d2b57c 100644
--- a/src/frontend/htmldialogs/bttabhtmldialog.cpp
+++ b/src/frontend/htmldialogs/bttabhtmldialog.cpp
@@ -21,120 +21,104 @@
#include <QContextMenuEvent>
BtTabHtmlDialog::BtTabHtmlDialog
- (const QString& title, int tabs, QWidget *parent, Qt::WindowFlags wflags )
- : QDialog(parent, wflags), m_webView(0), m_tabWidget(0), m_tabs(tabs)
-{
- //Set the flag to destroy when closed
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(title);
- resize(400, 300);
-
- QVBoxLayout *vboxLayout = new QVBoxLayout(this);
- if (tabs == 0)
- {
- m_webView = new BtWebView(this);
- init_connections(m_webView);
- vboxLayout->addWidget(m_webView);
- m_webView->setHtml("Hi");
- }
- else
- {
- m_tabWidget = new QTabWidget(this);
- vboxLayout->addWidget(m_tabWidget);
- for (int i=0; i<tabs; i++)
- {
- QWebView* webView = new BtWebView(this);
- init_connections(webView);
- webView->setObjectName("View" + QString::number(i));
- webView->setHtml(" ");
- m_tabWidget->addTab(webView,"Tab" + QString::number(i));
- m_tabWidget->show();
- }
- }
-
- QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
- vboxLayout->addWidget(buttonBox);
-
- bool ok;
- ok = connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- Q_ASSERT(ok);
- ok = connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- Q_ASSERT(ok);
+(const QString& title, int tabs, QWidget *parent, Qt::WindowFlags wflags )
+ : QDialog(parent, wflags), m_webView(0), m_tabWidget(0), m_tabs(tabs) {
+ //Set the flag to destroy when closed
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(title);
+ resize(400, 300);
+
+ QVBoxLayout *vboxLayout = new QVBoxLayout(this);
+ if (tabs == 0) {
+ m_webView = new BtWebView(this);
+ init_connections(m_webView);
+ vboxLayout->addWidget(m_webView);
+ m_webView->setHtml("Hi");
+ }
+ else {
+ m_tabWidget = new QTabWidget(this);
+ vboxLayout->addWidget(m_tabWidget);
+ for (int i = 0; i < tabs; i++) {
+ QWebView* webView = new BtWebView(this);
+ init_connections(webView);
+ webView->setObjectName("View" + QString::number(i));
+ webView->setHtml(" ");
+ m_tabWidget->addTab(webView, "Tab" + QString::number(i));
+ m_tabWidget->show();
+ }
+ }
+
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ util::prepareDialogBox(buttonBox);
+ vboxLayout->addWidget(buttonBox);
+
+ bool ok;
+ ok = connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ Q_ASSERT(ok);
+ ok = connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ Q_ASSERT(ok);
}
-BtTabHtmlDialog::~BtTabHtmlDialog()
-{
+BtTabHtmlDialog::~BtTabHtmlDialog() {
}
-
-void BtTabHtmlDialog::init_connections(QWebView* webView)
-{
- webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
- bool ok = connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
- Q_ASSERT(ok);
+
+void BtTabHtmlDialog::init_connections(QWebView* webView) {
+ webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ bool ok = connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
+ Q_ASSERT(ok);
}
-void BtTabHtmlDialog::linkClicked(const QUrl url)
-{
- QDesktopServices::openUrl(url);
+void BtTabHtmlDialog::linkClicked(const QUrl url) {
+ QDesktopServices::openUrl(url);
}
-void BtTabHtmlDialog::selectTab(int tab)
-{
- Q_ASSERT(tab >= 0 && tab < m_tabWidget->count());
- m_tabWidget->setCurrentIndex(tab);
+void BtTabHtmlDialog::selectTab(int tab) {
+ Q_ASSERT(tab >= 0 && tab < m_tabWidget->count());
+ m_tabWidget->setCurrentIndex(tab);
}
-QWebView* BtTabHtmlDialog::webView()
-{
- QWebView* webview = 0;
- if (m_tabs == 0)
- webview = m_webView;
- else
- {
- QWidget* widget = m_tabWidget->currentWidget();
- QString name = widget->objectName();
- webview = qobject_cast<QWebView*>(widget);
- }
- Q_ASSERT(webview != 0);
- return webview;
+QWebView* BtTabHtmlDialog::webView() {
+ QWebView* webview = 0;
+ if (m_tabs == 0)
+ webview = m_webView;
+ else {
+ QWidget* widget = m_tabWidget->currentWidget();
+ QString name = widget->objectName();
+ webview = qobject_cast<QWebView*>(widget);
+ }
+ Q_ASSERT(webview != 0);
+ return webview;
}
-void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl)
-{
- QUrl url = baseUrl;
- if (url == QUrl())
- {
- QString dir = "file://" + util::filesystem::DirectoryUtil::getIconDir().path();
- url.setUrl(dir);
- }
- webView()->setHtml(html,url);
+void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl) {
+ QUrl url = baseUrl;
+ if (url == QUrl()) {
+ QString dir = "file://" + util::filesystem::DirectoryUtil::getIconDir().path();
+ url.setUrl(dir);
+ }
+ webView()->setHtml(html, url);
}
-void BtTabHtmlDialog::setUrl(const QUrl& url)
-{
- webView()->setUrl(url);
+void BtTabHtmlDialog::setUrl(const QUrl& url) {
+ webView()->setUrl(url);
}
-void BtTabHtmlDialog::setTabText(const QString& tabName)
-{
- Q_ASSERT(m_tabs != 0); // There are no tabs to name
- int index = m_tabWidget->currentIndex();
- m_tabWidget->setTabText(index,tabName);
+void BtTabHtmlDialog::setTabText(const QString& tabName) {
+ Q_ASSERT(m_tabs != 0); // There are no tabs to name
+ int index = m_tabWidget->currentIndex();
+ m_tabWidget->setTabText(index, tabName);
}
// ******************* BtWebView *******************
BtWebView::BtWebView(QWidget* parent)
- : QWebView(parent), m_popup(0)
-{
- m_popup = new QMenu(this);
- QAction* copyAction = pageAction(QWebPage::Copy);
- m_popup->addAction(copyAction);
+ : QWebView(parent), m_popup(0) {
+ m_popup = new QMenu(this);
+ QAction* copyAction = pageAction(QWebPage::Copy);
+ m_popup->addAction(copyAction);
}
-void BtWebView::contextMenuEvent(QContextMenuEvent* event)
-{
- m_popup->exec(event->globalPos());
+void BtWebView::contextMenuEvent(QContextMenuEvent* event) {
+ m_popup->exec(event->globalPos());
}
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.h b/src/frontend/htmldialogs/bttabhtmldialog.h
index 2b40f12..3ccdc0f 100644
--- a/src/frontend/htmldialogs/bttabhtmldialog.h
+++ b/src/frontend/htmldialogs/bttabhtmldialog.h
@@ -18,10 +18,10 @@
class QTabWidget;
class QMenu;
-// This class creates a dialog with zero or more tabs. For zero tabs it is
+// This class creates a dialog with zero or more tabs. For zero tabs it is
// just a single QWebView inside the dialog. For 1 or more tabs, each tab
// contains a separate QWebView. Each QWebView can have either plain text or
-// html text. The class will automatically delete itself when closed.
+// html text. The class will automatically delete itself when closed.
// The class can either be directly called or subclassed. The dialog is not modal.
// Typical direct usage:
@@ -44,44 +44,42 @@ class QMenu;
// dlg->show();
-class BtTabHtmlDialog : public QDialog
-{
- Q_OBJECT
-public:
- BtTabHtmlDialog(const QString& title, int numberTabs, QWidget *parent=0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtTabHtmlDialog();
- void selectTab(int tab);
- void setTabText(const QString& tabName);
+class BtTabHtmlDialog : public QDialog {
+ Q_OBJECT
+ public:
+ BtTabHtmlDialog(const QString& title, int numberTabs, QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ ~BtTabHtmlDialog();
+ void selectTab(int tab);
+ void setTabText(const QString& tabName);
// See QWebView::setHtml()
- void setHtml(const QString& html, const QUrl& baseUrl=QUrl());
+ void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
// See QWebView::setUrl()
- void setUrl(const QUrl& url);
-
-private slots:
- void linkClicked(const QUrl url);
-
-private:
- void init_connections(QWebView* webView);
- QWebView* webView();
-
- QWebView* m_webView;
- QTabWidget* m_tabWidget;
- int m_tabs;
+ void setUrl(const QUrl& url);
+
+ private slots:
+ void linkClicked(const QUrl url);
+
+ private:
+ void init_connections(QWebView* webView);
+ QWebView* webView();
+
+ QWebView* m_webView;
+ QTabWidget* m_tabWidget;
+ int m_tabs;
};
-class BtWebView : public QWebView
-{
-public:
- BtWebView(QWidget* parent=0);
+class BtWebView : public QWebView {
+ public:
+ BtWebView(QWidget* parent = 0);
-protected:
- void contextMenuEvent(QContextMenuEvent* event);
+ protected:
+ void contextMenuEvent(QContextMenuEvent* event);
-private:
- QMenu* m_popup;
+ private:
+ QMenu* m_popup;
};
#endif
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 7eae47f..8b14ded 100644
--- a/src/frontend/keychooser/bthistory.cpp
+++ b/src/frontend/keychooser/bthistory.cpp
@@ -1,7 +1,7 @@
//
// C++ Implementation: BTHistory
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2007
@@ -22,109 +22,100 @@
BTHistory::BTHistory(QWidget* parent)
- : m_historyList(),
- m_index(-1),
- m_inHistoryFunction(false)
-{
- setParent(parent);
- Q_ASSERT(class_invariant());
+ : m_historyList(),
+ m_index(-1),
+ m_inHistoryFunction(false) {
+ setParent(parent);
+ Q_ASSERT(class_invariant());
}
void BTHistory::add(CSwordKey* newKey) {
- 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.
- if (!m_inHistoryFunction && ((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->text()) ))
- {
- if (!newKey->key().isEmpty()) {
- m_historyList.insert(++m_index, new QAction(newKey->key(), this));
- }
- // TODO: history limit?
- sendChangedSignal();
- }
- Q_ASSERT(class_invariant());
+ 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.
+ if (!m_inHistoryFunction && ((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->text()) )) {
+ if (!newKey->key().isEmpty()) {
+ m_historyList.insert(++m_index, new QAction(newKey->key(), this));
+ }
+ // TODO: history limit?
+ sendChangedSignal();
+ }
+ Q_ASSERT(class_invariant());
}
-void BTHistory::move(QAction* historyItem)
-{
- qDebug("BTHistory::move");
- //Q_ASSERT(historyItem);
- Q_ASSERT(m_historyList.count());
-
- m_inHistoryFunction = true;
- //find the action in the list
- m_index = m_historyList.indexOf(historyItem);
- //move to the selected item in the list, it will be the current item
- QString newKey = m_historyList.at(m_index)->text();
- emit historyMoved(newKey); // signal to "outsiders"; key has been changed
- sendChangedSignal();
-
- m_inHistoryFunction = false;
- Q_ASSERT(class_invariant());
+void BTHistory::move(QAction* historyItem) {
+ qDebug("BTHistory::move");
+ //Q_ASSERT(historyItem);
+ Q_ASSERT(m_historyList.count());
+
+ m_inHistoryFunction = true;
+ //find the action in the list
+ m_index = m_historyList.indexOf(historyItem);
+ //move to the selected item in the list, it will be the current item
+ QString newKey = m_historyList.at(m_index)->text();
+ emit historyMoved(newKey); // signal to "outsiders"; key has been changed
+ sendChangedSignal();
+
+ m_inHistoryFunction = false;
+ Q_ASSERT(class_invariant());
}
-void BTHistory::back()
-{
- qDebug("BTHistory::back");
- if ( m_index >= 1) {
- move(m_historyList.at(m_index-1));
- }
- Q_ASSERT(class_invariant());
+void BTHistory::back() {
+ qDebug("BTHistory::back");
+ if ( m_index >= 1) {
+ move(m_historyList.at(m_index - 1));
+ }
+ Q_ASSERT(class_invariant());
}
-void BTHistory::fw()
-{
- qDebug("BTHistory::fw");
- if (m_index < (m_historyList.size()-1)) {
- move(m_historyList.at(m_index+1));
- }
- Q_ASSERT(class_invariant());
+void BTHistory::fw() {
+ qDebug("BTHistory::fw");
+ if (m_index < (m_historyList.size() - 1)) {
+ move(m_historyList.at(m_index + 1));
+ }
+ Q_ASSERT(class_invariant());
}
-QList<QAction*> BTHistory::getBackList()
-{
- qDebug("BTHistory::getBackList");
+QList<QAction*> BTHistory::getBackList() {
+ qDebug("BTHistory::getBackList");
- QList<QAction*> list;
- for (int i = m_index-1; i >= 0; --i) {
- list.append(m_historyList.at(i));
- }
+ QList<QAction*> list;
+ for (int i = m_index - 1; i >= 0; --i) {
+ list.append(m_historyList.at(i));
+ }
- qDebug() << "return:" << list;
- Q_ASSERT(class_invariant());
- return list;
+ qDebug() << "return:" << list;
+ Q_ASSERT(class_invariant());
+ return list;
}
-QList<QAction*> BTHistory::getFwList()
-{
- qDebug("BTHistory::getFwList");
-
- QList<QAction*> list;
- //qDebug() << "historyList.size:" << m_historyList.size();
- for (int i = m_index+1; i < m_historyList.size(); ++i) {
- //qDebug() << "i:" << i;
- list.append(m_historyList.at(i));
- }
- qDebug() << "return:" << list;
-
- Q_ASSERT(class_invariant());
- return list;
+QList<QAction*> BTHistory::getFwList() {
+ qDebug("BTHistory::getFwList");
+
+ QList<QAction*> list;
+ //qDebug() << "historyList.size:" << m_historyList.size();
+ for (int i = m_index + 1; i < m_historyList.size(); ++i) {
+ //qDebug() << "i:" << i;
+ list.append(m_historyList.at(i));
+ }
+ qDebug() << "return:" << list;
+
+ Q_ASSERT(class_invariant());
+ return list;
}
-void BTHistory::sendChangedSignal()
-{
- bool backEnabled = m_index > 0; //there are items in the back list
- bool fwEnabled = m_historyList.size() > m_index+1; //there are items in the fw list
- emit historyChanged(backEnabled, fwEnabled);
- Q_ASSERT(class_invariant());
+void BTHistory::sendChangedSignal() {
+ bool backEnabled = m_index > 0; //there are items in the back list
+ bool fwEnabled = m_historyList.size() > m_index + 1; //there are items in the fw list
+ emit historyChanged(backEnabled, fwEnabled);
+ Q_ASSERT(class_invariant());
}
-bool BTHistory::class_invariant()
-{
- for (int i = 0; i < m_historyList.size(); ++i) {
- if (!m_historyList.at(i) || m_historyList.at(i)->text().isEmpty()) return false;
- }
- if (!(m_index >= -1 && m_index < m_historyList.size())) return false;
- return true;
+bool BTHistory::class_invariant() {
+ for (int i = 0; i < m_historyList.size(); ++i) {
+ if (!m_historyList.at(i) || m_historyList.at(i)->text().isEmpty()) return false;
+ }
+ if (!(m_index >= -1 && m_index < m_historyList.size())) return false;
+ return true;
}
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index 34e5fdb..9c09e10 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -1,7 +1,7 @@
//
// C++ Interface: BTHistory
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2007
@@ -21,60 +21,59 @@ class CSwordKey;
class QAction;
class QWidget;
-class BTHistory: public QObject
-{
- Q_OBJECT
+class BTHistory: public QObject {
+ Q_OBJECT
-public:
- BTHistory(QWidget* parent);
- ~BTHistory() {};
+ public:
+ BTHistory(QWidget* parent);
+ ~BTHistory() {};
- /**
- * Return a list of Actions behind the current point, the first of the history list will be the
- * last in the returned list and vice versa.
- */
- QList<QAction*> getBackList();
- /**
- * Return a list of Actions after the current point.
- */
- QList<QAction*> getFwList();
+ /**
+ * Return a list of Actions behind the current point, the first of the history list will be the
+ * last in the returned list and vice versa.
+ */
+ QList<QAction*> getBackList();
+ /**
+ * Return a list of Actions after the current point.
+ */
+ QList<QAction*> getFwList();
-public slots:
- /**
- * Add a new key to the history.
- */
- void add(CSwordKey* newKey);
- /**
- * Move the current point in history list.
- */
- void move(QAction*);
- /**
- * Go back one step in history.
- */
- void back();
- /**
- * Go forward one step in history.
- */
- void fw();
-
-signals:
- /**
- * Signal will be sent when the history has been changed (added, moved)
- */
- void historyChanged(bool backEnabled, bool fwEnabled);
- /**
- * Signal will be sent when the current point in history has moved
- */
- void historyMoved(QString& newKey);
+ public slots:
+ /**
+ * Add a new key to the history.
+ */
+ void add(CSwordKey* newKey);
+ /**
+ * Move the current point in history list.
+ */
+ void move(QAction*);
+ /**
+ * Go back one step in history.
+ */
+ void back();
+ /**
+ * Go forward one step in history.
+ */
+ void fw();
-private:
+ signals:
+ /**
+ * Signal will be sent when the history has been changed (added, moved)
+ */
+ void historyChanged(bool backEnabled, bool fwEnabled);
+ /**
+ * Signal will be sent when the current point in history has moved
+ */
+ void historyMoved(QString& newKey);
- void sendChangedSignal();
- bool class_invariant();
+ private:
- QList<QAction*> m_historyList;
- int m_index; //pointer to the current item; -1==empty, 0==first etc.
- bool m_inHistoryFunction; //to prevent recursive behaviour
+ void sendChangedSignal();
+ bool class_invariant();
+
+ QList<QAction*> m_historyList;
+ int m_index; //pointer to the current item; -1==empty, 0==first etc.
+ bool m_inHistoryFunction; //to prevent recursive behaviour
};
#endif
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index 411bf26..ca13baa 100644
--- a/src/frontend/keychooser/cbookkeychooser.cpp
+++ b/src/frontend/keychooser/cbookkeychooser.cpp
@@ -23,256 +23,244 @@
QMap<QObject*, int> boxes;
CBookKeyChooser::CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, key, parent), m_layout(0)
-{
+ : CKeyChooser(modules, key, parent), m_layout(0) {
- setModules(modules, false);
- m_key = dynamic_cast<CSwordTreeKey*>(key);
- if (!m_modules.count()) {
- m_key = 0;
- }
+ setModules(modules, false);
+ m_key = dynamic_cast<CSwordTreeKey*>(key);
+ if (!m_modules.count()) {
+ m_key = 0;
+ }
- setModules(modules, true);
- setKey(key);
+ setModules(modules, true);
+ setKey(key);
- adjustFont();
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ adjustFont();
+ connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
CBookKeyChooser::~CBookKeyChooser() {}
-void CBookKeyChooser::setKey(CSwordKey* newKey)
-{
- setKey(newKey, true);
+void CBookKeyChooser::setKey(CSwordKey* newKey) {
+ setKey(newKey, true);
}
/** Sets a new key to this keychooser */
-void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal)
-{
- if (m_key != newKey) { //set the internal key to the new one
- m_key = dynamic_cast<CSwordTreeKey*>(newKey);
- }
-
- QString oldKey = m_key->key(); //string backup of key
-
- if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
- m_key->firstChild();
- oldKey = m_key->key();
- }
-
- const int oldOffset = m_key->getOffset(); //backup key position
-
- QStringList siblings; //split up key
- if (m_key && !oldKey.isEmpty()) {
- siblings = oldKey.split('/', QString::SkipEmptyParts);
- }
-
- int depth = 0;
- int index = 0;
-
- m_key->root(); //start iteration at root node
-
- while( m_key->firstChild() && (depth < siblings.count()) ) {
- QString key = m_key->key();
- index = (depth == 0) ? -1 : 0;
-
- bool found = false;
-
- do { //look for matching sibling
- ++index;
- found = (m_key->getLocalNameUnicode() == siblings[depth]);
- }
- while (!found && m_key->nextSibling());
-
- if (found)
- key = m_key->key(); //found: change key to this level
- else
- m_key->key(key); //not found: restore old key
-
- setupCombo(key, depth, index);
-
- //last iteration: check to see if another box can be filled with child entries
- if (depth == siblings.count()-1 && m_key->hasChildren())
- {
- m_key->firstChild();
- setupCombo(m_key->key(), ++depth, 0);
- }
-
- depth++;
- }
-
- //clear the combos which were not filled
- for (; depth < m_modules.first()->depth(); ++depth) {
- CKeyChooserWidget* chooser = m_chooserWidgets.at(depth);
- if (chooser) chooser->reset(0,0,false);
- }
-
- if (oldKey.isEmpty()) {
- m_key->root();
- }
- else {
- //m_key->key(oldKey);
- m_key->setOffset(oldOffset);
- }
-
- if (emitSignal) emit keyChanged(m_key);
+void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
+ if (m_key != newKey) { //set the internal key to the new one
+ m_key = dynamic_cast<CSwordTreeKey*>(newKey);
+ }
+
+ QString oldKey = m_key->key(); //string backup of key
+
+ if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ m_key->firstChild();
+ oldKey = m_key->key();
+ }
+
+ const int oldOffset = m_key->getOffset(); //backup key position
+
+ QStringList siblings; //split up key
+ if (m_key && !oldKey.isEmpty()) {
+ siblings = oldKey.split('/', QString::SkipEmptyParts);
+ }
+
+ int depth = 0;
+ int index = 0;
+
+ m_key->root(); //start iteration at root node
+
+ while ( m_key->firstChild() && (depth < siblings.count()) ) {
+ QString key = m_key->key();
+ index = (depth == 0) ? -1 : 0;
+
+ bool found = false;
+
+ do { //look for matching sibling
+ ++index;
+ found = (m_key->getLocalNameUnicode() == siblings[depth]);
+ }
+ while (!found && m_key->nextSibling());
+
+ if (found)
+ key = m_key->key(); //found: change key to this level
+ else
+ m_key->key(key); //not found: restore old key
+
+ setupCombo(key, depth, index);
+
+ //last iteration: check to see if another box can be filled with child entries
+ if (depth == siblings.count() - 1 && m_key->hasChildren()) {
+ m_key->firstChild();
+ setupCombo(m_key->key(), ++depth, 0);
+ }
+
+ depth++;
+ }
+
+ //clear the combos which were not filled
+ for (; depth < m_modules.first()->depth(); ++depth) {
+ CKeyChooserWidget* chooser = m_chooserWidgets.at(depth);
+ if (chooser) chooser->reset(0, 0, false);
+ }
+
+ if (oldKey.isEmpty()) {
+ m_key->root();
+ }
+ else {
+ //m_key->key(oldKey);
+ m_key->setOffset(oldOffset);
+ }
+
+ if (emitSignal) emit keyChanged(m_key);
}
/** Returns the key of this kechooser. */
-CSwordKey* CBookKeyChooser::key()
-{
- return m_key;
+CSwordKey* CBookKeyChooser::key() {
+ return m_key;
}
/** Sets another module to this keychooser */
-void CBookKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh)
-{
- m_modules.clear();
-
- // for (modules.first(); modules.current(); modules.next()) {
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- if ( (*it)->type() == CSwordModuleInfo::GenericBook ) {
- if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
- m_modules.append(book);
- }
- }
- }
-
- //refresh the number of combos
- if (refresh && m_modules.count() && m_key) {
- if (!m_layout) {
- m_layout = new QHBoxLayout(this);
- m_layout->setSpacing(0);
- m_layout->setContentsMargins(0,0,0,0);
- }
-
- qDeleteAll(m_chooserWidgets);
- m_chooserWidgets.clear();
-
- for (int i = 0; i < m_modules.first()->depth(); ++i) {
- // Create an empty keychooser, don't handle next/prev signals
- CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this);
- m_chooserWidgets.append( w );
-
- //don't allow a too high width, try to keep as narrow as possible
- //to aid users with smaller screen resolutions
- int totalWidth = 200; //only 1 level
- if (m_modules.first()->depth() > 1) {
- if (m_modules.first()->depth() > 3)
- totalWidth = 400; //4+ levels
- else
- totalWidth = 300; //2-3 levels
- }
-
- int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth());
-
- w->comboBox()->setMaximumWidth(maxWidth);
- w->comboBox()->setCurrentIndex(0);
-
- connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
- connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int)));
-
- m_layout->addWidget(w);
- boxes[w] = i;
-
- w->show();
- }
-
- //set the tab order of the key chooser widgets
-
- CKeyChooserWidget* chooser = 0;
- CKeyChooserWidget* chooser_prev = 0;
- const int count = m_chooserWidgets.count();
- for (int i = 0; i < count; ++i) {
- chooser = m_chooserWidgets.at(i);
- Q_ASSERT(chooser);
-
- if (chooser && chooser_prev) {
- QWidget::setTabOrder(chooser_prev, chooser);
- }
-
- chooser_prev = chooser;
- }
- QWidget::setTabOrder(chooser, 0);
-
- updateKey(m_key);
- adjustFont(); // only when refresh is set.
- }
+void CBookKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
+ m_modules.clear();
+
+ // for (modules.first(); modules.current(); modules.next()) {
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
+ if ( (*it)->type() == CSwordModuleInfo::GenericBook ) {
+ if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
+ m_modules.append(book);
+ }
+ }
+ }
+
+ //refresh the number of combos
+ if (refresh && m_modules.count() && m_key) {
+ if (!m_layout) {
+ m_layout = new QHBoxLayout(this);
+ m_layout->setSpacing(0);
+ m_layout->setContentsMargins(0, 0, 0, 0);
+ }
+
+ qDeleteAll(m_chooserWidgets);
+ m_chooserWidgets.clear();
+
+ for (int i = 0; i < m_modules.first()->depth(); ++i) {
+ // Create an empty keychooser, don't handle next/prev signals
+ CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this);
+ m_chooserWidgets.append( w );
+
+ //don't allow a too high width, try to keep as narrow as possible
+ //to aid users with smaller screen resolutions
+ int totalWidth = 200; //only 1 level
+ if (m_modules.first()->depth() > 1) {
+ if (m_modules.first()->depth() > 3)
+ totalWidth = 400; //4+ levels
+ else
+ totalWidth = 300; //2-3 levels
+ }
+
+ int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth());
+
+ w->comboBox()->setMaximumWidth(maxWidth);
+ w->comboBox()->setCurrentIndex(0);
+
+ connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
+ connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int)));
+
+ m_layout->addWidget(w);
+ boxes[w] = i;
+
+ w->show();
+ }
+
+ //set the tab order of the key chooser widgets
+
+ CKeyChooserWidget* chooser = 0;
+ CKeyChooserWidget* chooser_prev = 0;
+ const int count = m_chooserWidgets.count();
+ for (int i = 0; i < count; ++i) {
+ chooser = m_chooserWidgets.at(i);
+ Q_ASSERT(chooser);
+
+ if (chooser && chooser_prev) {
+ QWidget::setTabOrder(chooser_prev, chooser);
+ }
+
+ chooser_prev = chooser;
+ }
+ QWidget::setTabOrder(chooser, 0);
+
+ updateKey(m_key);
+ adjustFont(); // only when refresh is set.
+ }
}
/** No descriptions */
-void CBookKeyChooser::adjustFont()
-{
- //Make sure the entries are displayed correctly.
- QListIterator<CKeyChooserWidget*> it(m_chooserWidgets);
- while (it.hasNext()) {
- it.next()->comboBox()->setFont( CBTConfig::get( m_modules.first()->language() ).second );
- }
+void CBookKeyChooser::adjustFont() {
+ //Make sure the entries are displayed correctly.
+ QListIterator<CKeyChooserWidget*> it(m_chooserWidgets);
+ while (it.hasNext()) {
+ it.next()->comboBox()->setFont( CBTConfig::get( m_modules.first()->language() ).second );
+ }
}
/** Refreshes the content. */
-void CBookKeyChooser::refreshContent()
-{
- if (m_key) {
- updateKey( m_key ); //refresh with current key
- }
+void CBookKeyChooser::refreshContent() {
+ if (m_key) {
+ updateKey( m_key ); //refresh with current key
+ }
}
-void CBookKeyChooser::setupCombo(const QString key, const int depth, const int currentItem)
-{
- CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
+void CBookKeyChooser::setupCombo(const QString key, const int depth, const int currentItem) {
+ CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
- CSwordTreeKey tmpKey(*m_key);
- tmpKey.key(key);
- tmpKey.parent();
- tmpKey.firstChild();
+ CSwordTreeKey tmpKey(*m_key);
+ tmpKey.key(key);
+ tmpKey.parent();
+ tmpKey.firstChild();
- QStringList items;
- if (depth > 0) items << QString::null; //insert an empty item at the top
+ QStringList items;
+ if (depth > 0) items << QString::null; //insert an empty item at the top
- do {
- items << tmpKey.getLocalNameUnicode();
- }
- while (tmpKey.nextSibling());
+ do {
+ items << tmpKey.getLocalNameUnicode();
+ }
+ while (tmpKey.nextSibling());
- if (chooserWidget) chooserWidget->reset(items,currentItem,false);
+ if (chooserWidget) chooserWidget->reset(items, currentItem, false);
}
/** A keychooser changed. Update and emit a signal if necessary. */
-void CBookKeyChooser::keyChooserChanged(int /*newIndex*/)
-{
- const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code!
+void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
+ const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code!
- QStringList items;
- CKeyChooserWidget* chooser;
+ QStringList items;
+ CKeyChooserWidget* chooser;
- for (int i = 0; i < m_chooserWidgets.count(); ++i) {
- chooser = m_chooserWidgets.at(i);
- const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null;
+ for (int i = 0; i < m_chooserWidgets.count(); ++i) {
+ chooser = m_chooserWidgets.at(i);
+ const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null;
- if (currentText.isEmpty() || i > activeID) {
- break;
- }
+ if (currentText.isEmpty() || i > activeID) {
+ break;
+ }
- items << currentText;
- }
+ items << currentText;
+ }
- QString newKey("/");
- newKey.append(items.join("/"));
+ QString newKey("/");
+ newKey.append(items.join("/"));
- m_key->key(newKey);
- setKey(m_key);
+ m_key->key(newKey);
+ setKey(m_key);
}
/** Updates the keychoosers for the given key but emit no signal. */
-void CBookKeyChooser::updateKey(CSwordKey* key)
-{
- setKey(key, false);
+void CBookKeyChooser::updateKey(CSwordKey* key) {
+ setKey(key, false);
}
-void CBookKeyChooser::setKey(QString& newKey)
-{
- m_key->key(newKey);
- setKey(m_key);
+void CBookKeyChooser::setKey(QString& newKey) {
+ m_key->key(newKey);
+ setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index 80dd03f..d32d6e9 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -14,73 +14,73 @@
#include "ckeychooser.h"
#include "ckeychooserwidget.h"
-#include <QList>
+#include <QList>
class CSwordKey;
class CSwordBookModuleInfo;
class CSwordTreeKey;
namespace sword {
- class TreeKeyIdx;
+class TreeKeyIdx;
}
/** The keychooser implementation for books.
* @author The BibleTime team
*/
class CBookKeyChooser : public CKeyChooser {
- Q_OBJECT
-public:
- CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key=0, QWidget *parent=0);
- ~CBookKeyChooser();
- /**
- * Refreshes the content.
- */
- virtual void refreshContent();
- /**
- * Sets another module to this keychooser
- */
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = false);
- /**
- * Returns the key of this keychooser
- */
- virtual CSwordKey* key();
- /**
- * Sets a new key to this keychooser
- */
- virtual void setKey(CSwordKey*);
- /**
- * Sets a new key to this keychooser
- */
- void setKey(CSwordKey*, const bool emitSignal);
+ Q_OBJECT
+ public:
+ CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+ ~CBookKeyChooser();
+ /**
+ * Refreshes the content.
+ */
+ virtual void refreshContent();
+ /**
+ * Sets another module to this keychooser
+ */
+ virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = false);
+ /**
+ * Returns the key of this keychooser
+ */
+ virtual CSwordKey* key();
+ /**
+ * Sets a new key to this keychooser
+ */
+ virtual void setKey(CSwordKey*);
+ /**
+ * Sets a new key to this keychooser
+ */
+ void setKey(CSwordKey*, const bool emitSignal);
-public slots: // Public slots
- /**
- * Updates the keychoosers for the given key but emit no signal.
- */
- void updateKey(CSwordKey*);
+ public slots: // Public slots
+ /**
+ * Updates the keychoosers for the given key but emit no signal.
+ */
+ void updateKey(CSwordKey*);
-protected: // Protected methods
- /**
- * Fills the combo given by depth with the items from the key having depth "depth".
- * The parent sibling is given by key.
- */
- void setupCombo(const QString key, const int depth, const int currentItem);
- /** No descriptions */
- virtual void adjustFont();
+ protected: // Protected methods
+ /**
+ * Fills the combo given by depth with the items from the key having depth "depth".
+ * The parent sibling is given by key.
+ */
+ void setupCombo(const QString key, const int depth, const int currentItem);
+ /** No descriptions */
+ virtual void adjustFont();
-protected slots:
- /**
- * A keychooser changed. Update and emit a signal if necessary.
- */
- void keyChooserChanged(int);
- virtual void setKey(QString& newKey);
+ protected slots:
+ /**
+ * A keychooser changed. Update and emit a signal if necessary.
+ */
+ void keyChooserChanged(int);
+ virtual void setKey(QString& newKey);
-private:
- QList<CKeyChooserWidget*> m_chooserWidgets;
- QList<CSwordBookModuleInfo*> m_modules;
- CSwordTreeKey *m_key;
- QHBoxLayout* m_layout;
+ private:
+ QList<CKeyChooserWidget*> m_chooserWidgets;
+ QList<CSwordBookModuleInfo*> m_modules;
+ CSwordTreeKey *m_key;
+ QHBoxLayout* m_layout;
};
#endif
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index 7297d76..e348005 100644
--- a/src/frontend/keychooser/cbooktreechooser.cpp
+++ b/src/frontend/keychooser/cbooktreechooser.cpp
@@ -23,112 +23,111 @@
#include <QDebug>
CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
-: CKeyChooser(modules, key, parent),
-m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
-
- setModules(modules, false);
-
- //if there is no module there is no key either
- if (!modules.count()) {
- m_modules.clear();
- m_key = 0;
- }
-
- //now setup the keychooser widgets
- m_treeView = new QTreeWidget(this);
-
- QHBoxLayout* layout = new QHBoxLayout(this);
- layout->setSpacing(0);
- layout->setContentsMargins(0,0,0,0);
- layout->addWidget(m_treeView);
- m_treeView->header()->hide();
-
- //when user selects the item whe must react
- connect(m_treeView, SIGNAL(currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(itemActivated(QTreeWidgetItem*)));
-
- setKey(key);
- adjustFont();
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ : CKeyChooser(modules, key, parent),
+ m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
+
+ setModules(modules, false);
+
+ //if there is no module there is no key either
+ if (!modules.count()) {
+ m_modules.clear();
+ m_key = 0;
+ }
+
+ //now setup the keychooser widgets
+ m_treeView = new QTreeWidget(this);
+
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(m_treeView);
+ m_treeView->header()->hide();
+
+ //when user selects the item whe must react
+ connect(m_treeView, SIGNAL(currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(itemActivated(QTreeWidgetItem*)));
+
+ setKey(key);
+ adjustFont();
+ connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
CBookTreeChooser::~CBookTreeChooser() {}
/** Sets a new key to this keychooser. Inherited from ckeychooser. */
void CBookTreeChooser::setKey(CSwordKey* key) {
- setKey(key, false);
+ setKey(key, false);
}
/** Sets a new key to this keychooser. Inherited from ckeychooser. */
void CBookTreeChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
- qDebug("CBookTreeChooser::setKey");
-
- if (m_key != newKey ) {
- m_key = dynamic_cast<CSwordTreeKey*>(newKey);
- }
-
- const QString key = m_key->key(); //key as text, path
-
- QTreeWidgetItem* matching_item = m_treeView->topLevelItem(0);
-
- QTreeWidgetItemIterator it(m_treeView);
- while (*it) {
- if ((*it)->text(1) == key)
- {
- matching_item = (*it);
- break;
- }
- ++it;
- }
-
- m_treeView->setCurrentItem( matching_item );
- m_treeView->scrollToItem(matching_item);
-
- if (emitSignal) {
- emit keyChanged(m_key);
- }
+ qDebug("CBookTreeChooser::setKey");
+
+ if (m_key != newKey ) {
+ m_key = dynamic_cast<CSwordTreeKey*>(newKey);
+ }
+
+ const QString key = m_key->key(); //key as text, path
+
+ QTreeWidgetItem* matching_item = m_treeView->topLevelItem(0);
+
+ QTreeWidgetItemIterator it(m_treeView);
+ while (*it) {
+ if ((*it)->text(1) == key) {
+ matching_item = (*it);
+ break;
+ }
+ ++it;
+ }
+
+ m_treeView->setCurrentItem( matching_item );
+ m_treeView->scrollToItem(matching_item);
+
+ if (emitSignal) {
+ emit keyChanged(m_key);
+ }
}
/** Returns the key of this keychooser. Inherited from ckeychooser.*/
CSwordKey* CBookTreeChooser::key() {
- return m_key;
+ return m_key;
}
/** Sets another module to this keychooser. Inherited from ckeychooser (therefore
the list of modules instead of one). */
void CBookTreeChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
-
- //Add given modules into private list
- m_modules.clear();
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
- m_modules.append(book);
- }
- }
-
- //if there exists a module and a key, setup the visible tree
- if (refresh && m_modules.count() && m_key) {
- const uint offset = m_key->getOffset(); //actually unnecessary, taken care of in setupTree
- setupTree();
- m_key->setOffset( offset );
-
- adjustFont(); //only when refresh is set.
- }
+
+ //Add given modules into private list
+ m_modules.clear();
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
+ if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
+ m_modules.append(book);
+ }
+ }
+
+ //if there exists a module and a key, setup the visible tree
+ if (refresh && m_modules.count() && m_key) {
+ const uint offset = m_key->getOffset(); //actually unnecessary, taken care of in setupTree
+ setupTree();
+ m_key->setOffset( offset );
+
+ adjustFont(); //only when refresh is set.
+ }
}
/** From ckeychooser. */
void CBookTreeChooser::adjustFont() {
- //Make sure the entries are displayed correctly.
- m_treeView->setFont( CBTConfig::get(m_modules.first()->language()).second );
-
+ //Make sure the entries are displayed correctly.
+ m_treeView->setFont( CBTConfig::get(m_modules.first()->language()).second );
+
}
/** Refreshes the content. Inherited from ckeychooser. */
void CBookTreeChooser::refreshContent() {
- if (m_key) {
- updateKey(m_key); //refresh with current key
- }
+ if (m_key) {
+ updateKey(m_key); //refresh with current key
+ }
}
@@ -138,63 +137,63 @@ void CBookTreeChooser::refreshContent() {
/** Slot for signal when item is selected by user. */
void CBookTreeChooser::itemActivated( QTreeWidgetItem* item ) {
- qDebug("CBookTreeChooser::itemActivated");
- //Sometimes Qt calls this function with a null pointer.
- if (item){
- m_key->key(item->text(1));
- //tell possible listeners about the change
- emit keyChanged(m_key);
- }
+ qDebug("CBookTreeChooser::itemActivated");
+ //Sometimes Qt calls this function with a null pointer.
+ if (item) {
+ m_key->key(item->text(1));
+ //tell possible listeners about the change
+ emit keyChanged(m_key);
+ }
}
/** Inherited from ckeychooser */
void CBookTreeChooser::updateKey( CSwordKey* key ) {
- setKey(key, false);
+ setKey(key, false);
}
/** Reimplementation to handle tree creation on show. */
void CBookTreeChooser::show() {
- CKeyChooser::show();
-
- if (!m_treeView->topLevelItemCount()) {
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- setupTree(); //create the tree structure
- m_treeView->resize(m_treeView->sizeHint());
- QApplication::restoreOverrideCursor();
- }
+ CKeyChooser::show();
+
+ if (!m_treeView->topLevelItemCount()) {
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ setupTree(); //create the tree structure
+ m_treeView->resize(m_treeView->sizeHint());
+ QApplication::restoreOverrideCursor();
+ }
}
/** Creates the tree structure in the view. */
void CBookTreeChooser::setupTree() {
- m_treeView->clear();
+ m_treeView->clear();
+
+ const unsigned long offset = m_key->getOffset();
- const unsigned long offset = m_key->getOffset();
-
- m_key->root();
- addKeyChildren(m_key, m_treeView->invisibleRootItem());
+ m_key->root();
+ addKeyChildren(m_key, m_treeView->invisibleRootItem());
- m_key->setOffset( offset );
- setKey(m_key, false); //the module may have changed
+ m_key->setOffset( offset );
+ setKey(m_key, false); //the module may have changed
}
/** Populates tree widget with items. */
void CBookTreeChooser::addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item) {
- if (key->hasChildren()) {
- key->firstChild();
- do {
- QStringList columns;
- columns << key->getLocalNameUnicode() << key->key();
- QTreeWidgetItem *i = new QTreeWidgetItem(item, columns, QTreeWidgetItem::Type);
- i->setData(0, Qt::ToolTipRole, key->getLocalNameUnicode());
- int offset = key->getOffset();
- addKeyChildren(key, i);
- key->setOffset(offset);
- } while (key->nextSibling());
- }
+ if (key->hasChildren()) {
+ key->firstChild();
+ do {
+ QStringList columns;
+ columns << key->getLocalNameUnicode() << key->key();
+ QTreeWidgetItem *i = new QTreeWidgetItem(item, columns, QTreeWidgetItem::Type);
+ i->setData(0, Qt::ToolTipRole, key->getLocalNameUnicode());
+ int offset = key->getOffset();
+ addKeyChildren(key, i);
+ key->setOffset(offset);
+ }
+ while (key->nextSibling());
+ }
}
-void CBookTreeChooser::setKey(QString& newKey)
-{
- m_key->key(newKey);
- setKey(m_key);
+void CBookTreeChooser::setKey(QString& newKey) {
+ m_key->key(newKey);
+ setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 455ba01..943127b 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -26,7 +26,7 @@ class CSwordBookModuleInfo;
class CSwordTreeKey;
namespace sword {
- class TreeKeyIdx;
+class TreeKeyIdx;
}
class QTreeWidget;
@@ -36,52 +36,52 @@ class QTreeWidgetItem;
* @author The BibleTime team
*/
class CBookTreeChooser : public CKeyChooser {
- Q_OBJECT
-public:
- CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key=0, QWidget *parent=0);
- ~CBookTreeChooser();
- /**
- * Refreshes the content.
- */
- virtual void refreshContent();
- /**
- * Sets another module to this keychooser
- */
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
- /**
- * Returns the key of this keychooser.
- */
- virtual CSwordKey* key();
- /**
- * Sets a new key to this keychooser
- */
- virtual void setKey(CSwordKey*);
- void setKey(CSwordKey*, const bool emitSinal);
-
-public slots: // Public slots
- virtual void updateKey( CSwordKey* );
- /**
- * Reimplementation to handle tree creation on show.
- */
- virtual void show();
-
-
-protected: // Protected methods
- /**
- * Creates the first level of the tree structure.
- */
- void setupTree();
- virtual void adjustFont();
- void addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item);
-
-protected slots: // Protected slots
- void itemActivated( QTreeWidgetItem* item );
- void setKey(QString& newKey);
-
-private:
- QList<CSwordBookModuleInfo*> m_modules;
- CSwordTreeKey* m_key;
- QTreeWidget* m_treeView;
+ Q_OBJECT
+ public:
+ CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+ ~CBookTreeChooser();
+ /**
+ * Refreshes the content.
+ */
+ virtual void refreshContent();
+ /**
+ * Sets another module to this keychooser
+ */
+ virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
+ /**
+ * Returns the key of this keychooser.
+ */
+ virtual CSwordKey* key();
+ /**
+ * Sets a new key to this keychooser
+ */
+ virtual void setKey(CSwordKey*);
+ void setKey(CSwordKey*, const bool emitSinal);
+
+ public slots: // Public slots
+ virtual void updateKey( CSwordKey* );
+ /**
+ * Reimplementation to handle tree creation on show.
+ */
+ virtual void show();
+
+
+ protected: // Protected methods
+ /**
+ * Creates the first level of the tree structure.
+ */
+ void setupTree();
+ virtual void adjustFont();
+ void addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item);
+
+ protected slots: // Protected slots
+ void itemActivated( QTreeWidgetItem* item );
+ void setKey(QString& newKey);
+
+ private:
+ QList<CSwordBookModuleInfo*> m_modules;
+ CSwordTreeKey* m_key;
+ QTreeWidget* m_treeView;
};
#endif
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index f0650d6..11b4db3 100644
--- a/src/frontend/keychooser/ckeychooser.cpp
+++ b/src/frontend/keychooser/ckeychooser.cpp
@@ -27,38 +27,36 @@
#include <QDebug>
CKeyChooser::CKeyChooser(QList<CSwordModuleInfo*>, CSwordKey *, QWidget *parent)
- : QWidget(parent),
- m_history(0)
-{
- //qDebug("CKeyChooser::CKeyChooser");
- m_history = new BTHistory(this);
- QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+ : QWidget(parent),
+ m_history(0) {
+ //qDebug("CKeyChooser::CKeyChooser");
+ m_history = new BTHistory(this);
+ QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
}
CKeyChooser::~CKeyChooser() {}
CKeyChooser* CKeyChooser::createInstance(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) {
- if (!modules.count()) {
- return 0;
- }
-
- switch ( modules.first()->type() ) {
- case CSwordModuleInfo::Commentary: //Bibles and commentaries use the same key chooser
- case CSwordModuleInfo::Bible:
- return new CBibleKeyChooser(modules,key,parent);
- break;
- case CSwordModuleInfo::Lexicon:
- return new CLexiconKeyChooser(modules,key,parent);
- case CSwordModuleInfo::GenericBook:
- return new CBookKeyChooser(modules,key,parent);
- default:
- return 0;
- }
+ if (!modules.count()) {
+ return 0;
+ }
+
+ switch ( modules.first()->type() ) {
+ case CSwordModuleInfo::Commentary: //Bibles and commentaries use the same key chooser
+ case CSwordModuleInfo::Bible:
+ return new CBibleKeyChooser(modules, key, parent);
+ break;
+ case CSwordModuleInfo::Lexicon:
+ return new CLexiconKeyChooser(modules, key, parent);
+ case CSwordModuleInfo::GenericBook:
+ return new CBookKeyChooser(modules, key, parent);
+ default:
+ return 0;
+ }
}
-BTHistory* CKeyChooser::history()
-{
- return m_history;
+BTHistory* CKeyChooser::history() {
+ return m_history;
}
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index d10a74a..455da20 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -34,82 +34,82 @@ class BTHistory;
*/
class CKeyChooser : public QWidget {
- Q_OBJECT
-
-public:
-
- /**
- * Creates a proper Instance, either
- *
- @ref CLexiconKeyChooser or
- * @ref CBibleKeyChooser
- * @param info the @ref CModuleInfo to be represented by the KeyChooser
- * @param key if not NULL, the @ref CKey the KeyChooser should be set to
- * @param parent the parent of the widget to create
- */
- static CKeyChooser* createInstance(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent);
-
-
-public slots:
- /**
- * sets the @ref CKey
- * @param key the key which the widget should be set to
- */
- virtual void setKey(CSwordKey* key) = 0;
- /**
- * sets the @ref CKey
- * @param key the key which the widget should be set to
- */
- virtual void updateKey(CSwordKey* key) = 0;
- /**
- * gets the current @ref CKey
- *
- * @return the current @ref CKey
- */
- virtual CSwordKey* key() = 0;
- /**
- * Sets the module of this keychooser and refreshes the comboboxes
- */
- virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true ) = 0;
- /**
- * Freshes the content of the different key chooser parts.
- */
- virtual void refreshContent() = 0;
-
- /**
- * Returns the history object of this keychooser.
- */
- BTHistory* history();
-
-signals:
-
- /**
- * is emitted if the @ref CKey was changed by the user
- */
- void keyChanged(CSwordKey* newKey);
- /**
- * Is emitted before the key is changed!
- */
- void beforeKeyChange(const QString& key);
-
-protected:
-
- /**
- * the constructor - DO NOT USE! -- use @ref #createInstance instead!
- */
- CKeyChooser(QList<CSwordModuleInfo*> info, CSwordKey *key=0, QWidget *parent=0);
- virtual ~CKeyChooser();
- /**
- * Set the appropriate font do display the modules
- */
- virtual void adjustFont() = 0;
-
-protected slots:
- virtual void setKey(QString& newKey) = 0;
-
-private:
- BTHistory* m_history;
-
+ Q_OBJECT
+
+ public:
+
+ /**
+ * Creates a proper Instance, either
+ *
+ @ref CLexiconKeyChooser or
+ * @ref CBibleKeyChooser
+ * @param info the @ref CModuleInfo to be represented by the KeyChooser
+ * @param key if not NULL, the @ref CKey the KeyChooser should be set to
+ * @param parent the parent of the widget to create
+ */
+ static CKeyChooser* createInstance(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent);
+
+
+ public slots:
+ /**
+ * sets the @ref CKey
+ * @param key the key which the widget should be set to
+ */
+ virtual void setKey(CSwordKey* key) = 0;
+ /**
+ * sets the @ref CKey
+ * @param key the key which the widget should be set to
+ */
+ virtual void updateKey(CSwordKey* key) = 0;
+ /**
+ * gets the current @ref CKey
+ *
+ * @return the current @ref CKey
+ */
+ virtual CSwordKey* key() = 0;
+ /**
+ * Sets the module of this keychooser and refreshes the comboboxes
+ */
+ virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true ) = 0;
+ /**
+ * Freshes the content of the different key chooser parts.
+ */
+ virtual void refreshContent() = 0;
+
+ /**
+ * Returns the history object of this keychooser.
+ */
+ BTHistory* history();
+
+ signals:
+
+ /**
+ * is emitted if the @ref CKey was changed by the user
+ */
+ void keyChanged(CSwordKey* newKey);
+ /**
+ * Is emitted before the key is changed!
+ */
+ void beforeKeyChange(const QString& key);
+
+ protected:
+
+ /**
+ * the constructor - DO NOT USE! -- use @ref #createInstance instead!
+ */
+ CKeyChooser(QList<CSwordModuleInfo*> info, CSwordKey *key = 0, QWidget *parent = 0);
+ virtual ~CKeyChooser();
+ /**
+ * Set the appropriate font do display the modules
+ */
+ virtual void adjustFont() = 0;
+
+ protected slots:
+ virtual void setKey(QString& newKey) = 0;
+
+ private:
+ BTHistory* m_history;
+
};
#endif
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index d3e1a55..88b7ed7 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -22,345 +22,303 @@
#include <QLineEdit>
#include <QDebug>
-class BtKeyLineEdit : public QLineEdit
-{
-public:
- BtKeyLineEdit(QWidget* parent)
- : QLineEdit(parent)
- {
- }
-protected:
- void focusInEvent(QFocusEvent* event)
- {
- Qt::FocusReason reason = event->reason();
- if (reason == Qt::OtherFocusReason)
- {
- selectAll();
- }
- QWidget::focusInEvent(event);
- }
+class BtKeyLineEdit : public QLineEdit {
+ public:
+ BtKeyLineEdit(QWidget* parent)
+ : QLineEdit(parent) {
+ }
+ protected:
+ void focusInEvent(QFocusEvent* event) {
+ Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason) {
+ selectAll();
+ }
+ QWidget::focusInEvent(event);
+ }
};
CKCComboBox::CKCComboBox()
-: QComboBox()
-{
- setFocusPolicy(Qt::WheelFocus);
- setLineEdit(new BtKeyLineEdit(this));
- if (lineEdit()) {
- installEventFilter( lineEdit() );
- }
+ : QComboBox() {
+ setFocusPolicy(Qt::WheelFocus);
+ setLineEdit(new BtKeyLineEdit(this));
+ if (lineEdit()) {
+ installEventFilter( lineEdit() );
+ }
}
/** Reimplementation. */
-bool CKCComboBox::eventFilter( QObject *o, QEvent *e )
-{
- if (e->type() == QEvent::FocusOut)
- {
- QFocusEvent* f = static_cast<QFocusEvent*>(e);
-
- if (o == lineEdit() && f->reason() == Qt::TabFocusReason)
- {
- int index = findText(currentText());
- if (index == -1) {
- index = 0;// return 0 if not found
- }
- setCurrentIndex( index );
- emit focusOut( index );
-
- return false;
- }
- else if (f->reason() == Qt::PopupFocusReason)
- {
- return false;
- }
- else if (f->reason() == Qt::ActiveWindowFocusReason)
- {
- emit activated(currentText());
- return false;
- }
- else if (f->reason() == Qt::MouseFocusReason)
- {
- emit activated(currentText());
- return false;
- }
- else if (o == this)
- {
- emit activated(currentText());
- return false;
- }
- }
-
- return QComboBox::eventFilter(o,e);
+bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
+ if (e->type() == QEvent::FocusOut) {
+ QFocusEvent* f = static_cast<QFocusEvent*>(e);
+
+ if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
+ int index = findText(currentText());
+ if (index == -1) {
+ index = 0;// return 0 if not found
+ }
+ setCurrentIndex( index );
+ emit focusOut( index );
+
+ return false;
+ }
+ else if (f->reason() == Qt::PopupFocusReason) {
+ return false;
+ }
+ else if (f->reason() == Qt::ActiveWindowFocusReason) {
+ emit activated(currentText());
+ return false;
+ }
+ else if (f->reason() == Qt::MouseFocusReason) {
+ emit activated(currentText());
+ return false;
+ }
+ else if (o == this) {
+ emit activated(currentText());
+ return false;
+ }
+ }
+
+ return QComboBox::eventFilter(o, e);
}
/** Scrolls in the list if the wheel of the mouse was used. */
-void CKCComboBox::wheelEvent( QWheelEvent* e )
-{
- return QComboBox::wheelEvent(e);
-
- const signed int change = (int)((float)e->delta()/(float)120);
- int current = currentIndex();
-
- if ((current+change >= 0) && (current+change<count()) )
- {
- setCurrentIndex(current+change);
- e->accept();
- emit activated( currentIndex() );
- }
- else {
- e->ignore();
- }
+void CKCComboBox::wheelEvent( QWheelEvent* e ) {
+ return QComboBox::wheelEvent(e);
+
+ const signed int change = (int)((float)e->delta() / (float)120);
+ int current = currentIndex();
+
+ if ((current + change >= 0) && (current + change < count()) ) {
+ setCurrentIndex(current + change);
+ e->accept();
+ emit activated( currentIndex() );
+ }
+ else {
+ e->ignore();
+ }
}
//**********************************************************************************/
-CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent)
-{
- m_useNextPrevSignals = useNextPrevSignals;
+CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
+ m_useNextPrevSignals = useNextPrevSignals;
- for (int index=1; index <= count; index++)
- {
- m_list.append( QString::number(index) );
- }
- init();
- reset(m_list,0,false);
+ for (int index = 1; index <= count; index++) {
+ m_list.append( QString::number(index) );
+ }
+ init();
+ reset(m_list, 0, false);
}
-CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent)
-{
- m_useNextPrevSignals = useNextPrevSignals;
-
- if (list)
- {
- m_list = *list; //deep copy the items of list
- }
- else
- {
- m_list.clear();
- }
-
- init();
- reset(m_list,0,false);
+CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
+ m_useNextPrevSignals = useNextPrevSignals;
+
+ if (list) {
+ m_list = *list; //deep copy the items of list
+ }
+ else {
+ m_list.clear();
+ }
+
+ init();
+ reset(m_list, 0, false);
}
-void CKeyChooserWidget::reset(const int count, int index, bool do_emit)
-{
- //This prevents the widget from resetting during application load, which
- //produces undesirable behavior.
- //if (!updatesEnabled())
- // return;
+void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
+ //This prevents the widget from resetting during application load, which
+ //produces undesirable behavior.
+ //if (!updatesEnabled())
+ // return;
- m_list.clear();
- for (int i=1; i <= count; i++)
- { //TODO: CHECK
- m_list.append( QString::number(i) );
- }
+ m_list.clear();
+ for (int i = 1; i <= count; i++) { //TODO: CHECK
+ m_list.append( QString::number(i) );
+ }
- reset(&m_list,index,do_emit);
+ reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(QStringList& list, int index, bool do_emit)
-{
- //This prevents the widget from resetting during application load, which
- //produces undesirable behavior.
- //if (!updatesEnabled())
- // return;
+void CKeyChooserWidget::reset(QStringList& list, int index, bool do_emit) {
+ //This prevents the widget from resetting during application load, which
+ //produces undesirable behavior.
+ //if (!updatesEnabled())
+ // return;
- m_list = list;
- reset(&m_list,index,do_emit);
+ m_list = list;
+ reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit)
-{
- //if (isResetting || !updatesEnabled())
- if (isResetting)
- return;
-
- // qWarning("starting insert");
- isResetting = true;
-
- oldKey = QString::null;
-
- // m_comboBox->setUpdatesEnabled(false);
- //DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
- m_comboBox->hide();
- m_comboBox->clear();
- if (list)
- {
- m_comboBox->insertItems(-1, *list);
- }
-
- if (!list || (list && !list->count())) { //nothing in the combobox
- setEnabled(false);
- }
- else if (!isEnabled())
- { //was disabled
- setEnabled(true);
- }
-
- if (list->count())
- {
- m_comboBox->setCurrentIndex(index);
- }
- if (do_emit) {
- emit changed(m_comboBox->currentIndex());
- }
-
- const QSize dummySize = m_comboBox->sizeHint(); //without this function call the combo box won't be properly sized!
- //DON'T REMOVE OR MOVE THE show()! Otherwise QComboBox's sizeHint() function won't work properly!
- m_comboBox->show();
-
- // m_comboBox->setFont( m_comboBox->font() );
- // m_comboBox->setUpdatesEnabled(true);
-
- isResetting = false;
- // qWarning("inserted");
+void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
+ //if (isResetting || !updatesEnabled())
+ if (isResetting)
+ return;
+
+ // qWarning("starting insert");
+ isResetting = true;
+
+ oldKey = QString::null;
+
+ // m_comboBox->setUpdatesEnabled(false);
+ //DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
+ m_comboBox->hide();
+ m_comboBox->clear();
+ if (list) {
+ m_comboBox->insertItems(-1, *list);
+ }
+
+ if (!list || (list && !list->count())) { //nothing in the combobox
+ setEnabled(false);
+ }
+ else if (!isEnabled()) { //was disabled
+ setEnabled(true);
+ }
+
+ if (list->count()) {
+ m_comboBox->setCurrentIndex(index);
+ }
+ if (do_emit) {
+ emit changed(m_comboBox->currentIndex());
+ }
+
+ const QSize dummySize = m_comboBox->sizeHint(); //without this function call the combo box won't be properly sized!
+ //DON'T REMOVE OR MOVE THE show()! Otherwise QComboBox's sizeHint() function won't work properly!
+ m_comboBox->show();
+
+ // m_comboBox->setFont( m_comboBox->font() );
+ // m_comboBox->setUpdatesEnabled(true);
+
+ isResetting = false;
+ // qWarning("inserted");
}
/** Initializes this widget. We need this function because we have more than one constructor. */
-void CKeyChooserWidget::init()
-{
- qDebug("CKeyChooserWidget::init");
- oldKey = QString::null;
+void CKeyChooserWidget::init() {
+ qDebug("CKeyChooserWidget::init");
+ oldKey = QString::null;
- setFocusPolicy(Qt::WheelFocus);
+ setFocusPolicy(Qt::WheelFocus);
- m_comboBox = new CKCComboBox();
- setFocusProxy(m_comboBox);
- m_comboBox->setAutoCompletion( true );
- m_comboBox->setEditable(true);
- m_comboBox->setInsertPolicy(QComboBox::NoInsert);
- m_comboBox->setFocusPolicy(Qt::WheelFocus);
+ m_comboBox = new CKCComboBox();
+ setFocusProxy(m_comboBox);
+ m_comboBox->setAutoCompletion( true );
+ m_comboBox->setEditable(true);
+ m_comboBox->setInsertPolicy(QComboBox::NoInsert);
+ m_comboBox->setFocusPolicy(Qt::WheelFocus);
- m_mainLayout = new QHBoxLayout( this );
- m_mainLayout->setSpacing(0);
- m_mainLayout->setContentsMargins(0,0,0,0);
- m_mainLayout->addWidget(m_comboBox);
+ m_mainLayout = new QHBoxLayout( this );
+ m_mainLayout->setSpacing(0);
+ m_mainLayout->setContentsMargins(0, 0, 0, 0);
+ m_mainLayout->addWidget(m_comboBox);
- m_scroller = new CScrollerWidgetSet(this);
+ m_scroller = new CScrollerWidgetSet(this);
- m_mainLayout->addWidget( m_scroller );
- m_mainLayout->addSpacing(0);
+ m_mainLayout->addWidget( m_scroller );
+ m_mainLayout->addSpacing(0);
- setTabOrder(m_comboBox, 0);
- setFocusProxy(m_comboBox);
+ setTabOrder(m_comboBox, 0);
+ setFocusProxy(m_comboBox);
- connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
- connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
- connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)) );
+ connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
+ connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
+ connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)) );
- connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
- // connect(m_comboBox, SIGNAL(activated(const QString&)), SLOT(slotReturnPressed(const QString&)));
- connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
- connect(m_comboBox, SIGNAL(focusOut(int)), SIGNAL(focusOut(int)));
+ connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
+ // connect(m_comboBox, SIGNAL(activated(const QString&)), SLOT(slotReturnPressed(const QString&)));
+ connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
+ connect(m_comboBox, SIGNAL(focusOut(int)), SIGNAL(focusOut(int)));
- updatelock = false;
- isResetting = false;
+ updatelock = false;
+ isResetting = false;
}
/** Is called when the return key was presed in the combobox. */
-void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/)
-{
- Q_ASSERT(comboBox()->lineEdit());
- qDebug("return pressed");
-
- QString text = comboBox()->lineEdit()->text();
- for (int index = 0; index < comboBox()->count(); ++index)
- {
- if (comboBox()->itemText(index) == text)
- {
+void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
+ Q_ASSERT(comboBox()->lineEdit());
+ qDebug("return pressed");
+
+ QString text = comboBox()->lineEdit()->text();
+ for (int index = 0; index < comboBox()->count(); ++index) {
+ if (comboBox()->itemText(index) == text) {
// emit changed(index);
- emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
- break;
- }
- }
+ emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
+ break;
+ }
+ }
}
/** Is called when the current item of the combo box was changed. */
-void CKeyChooserWidget::slotComboChanged(int index)
-{
- qDebug("CKeyChooserWidget::slotComboChanged(int index)");
- if (!updatesEnabled())
- {
- return;
- }
+void CKeyChooserWidget::slotComboChanged(int index) {
+ qDebug("CKeyChooserWidget::slotComboChanged(int index)");
+ if (!updatesEnabled()) {
+ return;
+ }
- setUpdatesEnabled(false);
+ setUpdatesEnabled(false);
- const QString key = comboBox()->itemText( index );
- if (oldKey.isNull() || (oldKey != key))
- {
- emit changed(index);
- }
+ const QString key = comboBox()->itemText( index );
+ if (oldKey.isNull() || (oldKey != key)) {
+ emit changed(index);
+ }
- oldKey = key;
+ oldKey = key;
- setUpdatesEnabled(true);
+ setUpdatesEnabled(true);
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip)
-{
- comboBox()->setToolTip(comboTip);
- m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
+void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
+ comboBox()->setToolTip(comboTip);
+ m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
}
/** Sets the current item to the one with the given text */
-bool CKeyChooserWidget::setItem( const QString item )
-{
- bool ret = false;
- const int count = comboBox()->count();
- for (int i = 0; i < count; ++i)
- {
- if (comboBox()->itemText(i) == item)
- {
- comboBox()->setCurrentIndex(i);
- ret = true;
- break;
- }
- }
- if (!ret)
- comboBox()->setCurrentIndex(-1);
- return ret;
+bool CKeyChooserWidget::setItem( const QString item ) {
+ bool ret = false;
+ const int count = comboBox()->count();
+ for (int i = 0; i < count; ++i) {
+ if (comboBox()->itemText(i) == item) {
+ comboBox()->setCurrentIndex(i);
+ ret = true;
+ break;
+ }
+ }
+ if (!ret)
+ comboBox()->setCurrentIndex(-1);
+ return ret;
}
/* Handlers for the various scroller widgetset. */
-void CKeyChooserWidget::lock()
-{
- updatelock = true;
- comboBox()->setEditable(false);
- oldKey = comboBox()->currentText();
+void CKeyChooserWidget::lock() {
+ updatelock = true;
+ comboBox()->setEditable(false);
+ oldKey = comboBox()->currentText();
}
-void CKeyChooserWidget::unlock()
-{
- updatelock = false;
- comboBox()->setEditable(true);
- comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
- if (comboBox()->currentText() != oldKey)
- {
- emit changed(comboBox()->currentIndex());
- }
+void CKeyChooserWidget::unlock() {
+ updatelock = false;
+ comboBox()->setEditable(true);
+ comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
+ if (comboBox()->currentText() != oldKey) {
+ emit changed(comboBox()->currentIndex());
+ }
}
-void CKeyChooserWidget::changeCombo(int n)
-{
- const int old_index = comboBox()->currentIndex();
- int new_index = old_index + n;
-
- //index of highest Item
- const int max = comboBox()->count()-1;
- if(new_index > max) new_index = max;
- if(new_index < 0) new_index = 0;
-
- if(new_index != old_index)
- {
- comboBox()->setCurrentIndex(new_index);
- if(!updatelock)
- emit changed(new_index);
- }
+void CKeyChooserWidget::changeCombo(int n) {
+ const int old_index = comboBox()->currentIndex();
+ int new_index = old_index + n;
+
+ //index of highest Item
+ const int max = comboBox()->count() - 1;
+ if (new_index > max) new_index = max;
+ if (new_index < 0) new_index = 0;
+
+ if (new_index != old_index) {
+ comboBox()->setCurrentIndex(new_index);
+ if (!updatelock)
+ emit changed(new_index);
+ }
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 05b0236..4a141c1 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -28,30 +28,30 @@ class CScrollerWidgetSet;
* This class is used in the key chooser widgets
*/
class CKCComboBox : public QComboBox {
- Q_OBJECT
-
-public:
- CKCComboBox();
- /**
- * Returns the size this widget would like to have.
- */
- // virtual QSize sizeHint() const;
-
-protected:
- /**
- * Reimplementation.
- */
- virtual bool eventFilter( QObject *o, QEvent *e );
- /**
- * Scrolls in the list if the wheel of the mouse was used.
- */
- virtual void wheelEvent( QWheelEvent* e);
-
-signals:
- /**
- * Emitted when the user moves the focus away from the combo by pressing tab
- */
- void focusOut(int itemIndex);
+ Q_OBJECT
+
+ public:
+ CKCComboBox();
+ /**
+ * Returns the size this widget would like to have.
+ */
+ // virtual QSize sizeHint() const;
+
+ protected:
+ /**
+ * Reimplementation.
+ */
+ virtual bool eventFilter( QObject *o, QEvent *e );
+ /**
+ * Scrolls in the list if the wheel of the mouse was used.
+ */
+ virtual void wheelEvent( QWheelEvent* e);
+
+ signals:
+ /**
+ * Emitted when the user moves the focus away from the combo by pressing tab
+ */
+ void focusOut(int itemIndex);
};
/**
@@ -62,110 +62,112 @@ signals:
* @author The BibleTime team
*/
class CKeyChooserWidget : public QWidget {
- Q_OBJECT
-public:
- /**
- * the constructor
- */
- CKeyChooserWidget(QStringList *list=0, const bool useNextPrevSignals = false, QWidget *parent=0 );
- /**
- * the constructor
- */
- CKeyChooserWidget(int count=0, const bool useNextPrevSignals = false, QWidget *parent=0 );
- /**
- * This function does clear the combobox, then fill in
- * the StringList, set the ComboBox' current item to index
- * and if do_emit is true, it will emit @ref #changed
- *
- * @param list the stringlist to be inserted
- * @param index the index that the combobox is to jump to
- * @param do_emit should we emit @ref #changed(int)
- */
- void reset(const int count, int index, bool do_emit);
- void reset(QStringList& list, int index, bool do_emit);
- void reset(QStringList *list, int index, bool do_emit);
- /**
- * Initializes this widget. We need this function because
- * we have more than one constructor.
- */
- virtual void init();
- /**
- *
- */
- // virtual void adjustSize();
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString comboTip, const QString nextEntry, const QString scrollButton, const QString previousEntry);
- /**
- * Sets the current item to the one with the given text
- */
- bool setItem( const QString item);
- /**
- * Return the combobox of this key chooser widget.
- */
- QComboBox* comboBox() {return m_comboBox;};
-
-public slots:
- /**
- * is called to lock the combobox
- */
- void lock()
- ;
- /**
- * is called to unlock the combobox
- */
- void unlock();
- /**
- * is called to move the combobox to a certain index
- * @param index the index to jump to
- */
- void changeCombo(int index);
- void slotComboChanged(int index);
-
-signals:
- /**
- * Is emitted if the widget changed, but
- * only if it is not locked or being reset
- *
- * @param the current ComboBox index
- */
- void changed(int index);
- /**
- * Is emitted if the widget was left with a focus out event.
- * @param index The new index of the ComboBox
- */
- void focusOut(int index);
-
-protected:
- /**
- * indicates wheter we are resetting at the moment
- */
- bool isResetting;
- /**
- *
- */
- QString oldKey;
-
-protected slots: // Protected slots
- /**
- * Is called when the return key was presed in the combobox.
- */
- void slotReturnPressed( /*const QString&*/ );
-
-
-private:
- friend class CLexiconKeyChooser;
- QStringList m_list;
- bool m_useNextPrevSignals;
- bool updatelock;
-
- /**
- * Members should never be public!!
- */
- CKCComboBox* m_comboBox;
- QHBoxLayout *m_mainLayout;
- CScrollerWidgetSet * m_scroller;
+ Q_OBJECT
+ public:
+ /**
+ * the constructor
+ */
+ CKeyChooserWidget(QStringList *list = 0, const bool useNextPrevSignals = false, QWidget *parent = 0 );
+ /**
+ * the constructor
+ */
+ CKeyChooserWidget(int count = 0, const bool useNextPrevSignals = false, QWidget *parent = 0 );
+ /**
+ * This function does clear the combobox, then fill in
+ * the StringList, set the ComboBox' current item to index
+ * and if do_emit is true, it will emit @ref #changed
+ *
+ * @param list the stringlist to be inserted
+ * @param index the index that the combobox is to jump to
+ * @param do_emit should we emit @ref #changed(int)
+ */
+ void reset(const int count, int index, bool do_emit);
+ void reset(QStringList& list, int index, bool do_emit);
+ void reset(QStringList *list, int index, bool do_emit);
+ /**
+ * Initializes this widget. We need this function because
+ * we have more than one constructor.
+ */
+ virtual void init();
+ /**
+ *
+ */
+ // virtual void adjustSize();
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips( const QString comboTip, const QString nextEntry, const QString scrollButton, const QString previousEntry);
+ /**
+ * Sets the current item to the one with the given text
+ */
+ bool setItem( const QString item);
+ /**
+ * Return the combobox of this key chooser widget.
+ */
+ QComboBox* comboBox() {
+ return m_comboBox;
+ };
+
+ public slots:
+ /**
+ * is called to lock the combobox
+ */
+ void lock()
+ ;
+ /**
+ * is called to unlock the combobox
+ */
+ void unlock();
+ /**
+ * is called to move the combobox to a certain index
+ * @param index the index to jump to
+ */
+ void changeCombo(int index);
+ void slotComboChanged(int index);
+
+ signals:
+ /**
+ * Is emitted if the widget changed, but
+ * only if it is not locked or being reset
+ *
+ * @param the current ComboBox index
+ */
+ void changed(int index);
+ /**
+ * Is emitted if the widget was left with a focus out event.
+ * @param index The new index of the ComboBox
+ */
+ void focusOut(int index);
+
+ protected:
+ /**
+ * indicates wheter we are resetting at the moment
+ */
+ bool isResetting;
+ /**
+ *
+ */
+ QString oldKey;
+
+ protected slots: // Protected slots
+ /**
+ * Is called when the return key was presed in the combobox.
+ */
+ void slotReturnPressed( /*const QString&*/ );
+
+
+ private:
+ friend class CLexiconKeyChooser;
+ QStringList m_list;
+ bool m_useNextPrevSignals;
+ bool updatelock;
+
+ /**
+ * Members should never be public!!
+ */
+ CKCComboBox* m_comboBox;
+ QHBoxLayout *m_mainLayout;
+ CScrollerWidgetSet * m_scroller;
};
#endif
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 53d8ac0..c1f3cb1 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -29,120 +29,118 @@
CLexiconKeyChooser::CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, key, parent),
- m_key(dynamic_cast<CSwordLDKey*>(key))
-{
- setModules(modules, false);
-
- //we use a layout because the key chooser should be resized to full size
- m_layout = new QHBoxLayout(this);
- m_layout->setSpacing(0);
- m_layout->setContentsMargins(0,0,0,0);
- m_layout->setDirection(QBoxLayout::LeftToRight);
- m_layout->setSizeConstraint(QLayout::SetNoConstraint);
-
- m_widget = new CKeyChooserWidget(0, false, this);
- setFocusProxy(m_widget);
-
- //don't allow a too high width, try to keep as narrow as possible
- //to aid users with smaller screen resolutions
- m_widget->comboBox()->setMaximumWidth(200);
-
- m_widget->setToolTips(
- tr("Entries of the current work"),
- tr("Next entry"),
- tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."),
- tr("Previous entry")
- );
-
- m_layout->addWidget(m_widget,0,Qt::AlignLeft);
-
- connect(m_widget,SIGNAL(changed(int)),SLOT(activated(int)));
- connect(m_widget,SIGNAL(focusOut(int)),SLOT(activated(int)));
-
- setModules(modules, true);
- setKey(key);
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ : CKeyChooser(modules, key, parent),
+ m_key(dynamic_cast<CSwordLDKey*>(key)) {
+ setModules(modules, false);
+
+ //we use a layout because the key chooser should be resized to full size
+ m_layout = new QHBoxLayout(this);
+ m_layout->setSpacing(0);
+ m_layout->setContentsMargins(0, 0, 0, 0);
+ m_layout->setDirection(QBoxLayout::LeftToRight);
+ m_layout->setSizeConstraint(QLayout::SetNoConstraint);
+
+ m_widget = new CKeyChooserWidget(0, false, this);
+ setFocusProxy(m_widget);
+
+ //don't allow a too high width, try to keep as narrow as possible
+ //to aid users with smaller screen resolutions
+ m_widget->comboBox()->setMaximumWidth(200);
+
+ m_widget->setToolTips(
+ tr("Entries of the current work"),
+ tr("Next entry"),
+ tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."),
+ tr("Previous entry")
+ );
+
+ m_layout->addWidget(m_widget, 0, Qt::AlignLeft);
+
+ connect(m_widget, SIGNAL(changed(int)), SLOT(activated(int)));
+ connect(m_widget, SIGNAL(focusOut(int)), SLOT(activated(int)));
+
+ setModules(modules, true);
+ setKey(key);
+ connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
CSwordKey* CLexiconKeyChooser::key() {
- // qWarning("key");
- return m_key;
+ // qWarning("key");
+ return m_key;
}
-void CLexiconKeyChooser::setKey(CSwordKey* key)
-{
- qDebug("CLexiconKeyChooser::setKey");
+void CLexiconKeyChooser::setKey(CSwordKey* key) {
+ qDebug("CLexiconKeyChooser::setKey");
- if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) {
- return;
- }
+ if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) {
+ return;
+ }
- QString newKey = m_key->key();
- const int index = m_widget->comboBox()->findText(newKey);
- m_widget->comboBox()->setCurrentIndex(index);
+ QString newKey = m_key->key();
+ const int index = m_widget->comboBox()->findText(newKey);
+ m_widget->comboBox()->setCurrentIndex(index);
- // qWarning("setKey end");
- emit keyChanged( m_key);
+ // qWarning("setKey end");
+ emit keyChanged( m_key);
}
void CLexiconKeyChooser::activated(int index) {
- // qWarning("activated");
- const QString text = m_widget->comboBox()->itemText(index);
-
- // To prevent from eternal loop, because activated() is emitted again
- if (m_key && m_key->key() != text) {
- m_key->key(text);
- setKey(m_key);
- }
- // qWarning("activated end");
+ // qWarning("activated");
+ const QString text = m_widget->comboBox()->itemText(index);
+
+ // To prevent from eternal loop, because activated() is emitted again
+ if (m_key && m_key->key() != text) {
+ m_key->key(text);
+ setKey(m_key);
+ }
+ // qWarning("activated end");
}
inline bool my_cmpEntries(const QString& a, const QString& b) {
- return a < b;
+ return a < b;
}
/** Reimplementation. */
void CLexiconKeyChooser::refreshContent() {
- if (m_modules.count() == 1) {
- m_widget->reset(m_modules.first()->entries(), 0, true);
- // qWarning("resetted");
- }
- else {
- typedef std::multimap<unsigned int, QStringList*> EntryMap;
- EntryMap entryMap;
- QStringList* entries = 0;
- QListIterator<CSwordLexiconModuleInfo*> mit(m_modules);
- while (mit.hasNext()) {
- entries = mit.next()->entries();
- entryMap.insert( std::make_pair(entries->count(), entries) );
- }
-
- QStringList goodEntries; //The string list which contains the entries which are available in all modules
-
- EntryMap::iterator it = entryMap.begin(); //iterator to go thoigh all selected modules
- QStringList refEntries = *(it->second); //copy the items for the first time
- QStringList* cmpEntries = ( ++it )->second; //list for comparision, starts with the second module in the map
-
- while(it != entryMap.end()) {
- std::set_intersection(
- refEntries.begin(), --(refEntries.end()), //--end() is the last valid entry
- cmpEntries->begin(), --(cmpEntries->end()),
- std::back_inserter(goodEntries), //append valid entries to the end of goodEntries
- my_cmpEntries //ci_cmpEntries is the comparision function
- );
-
- cmpEntries = ( ++it )->second; //this is a pointer to the string list of a new module
-
- /*
- * use the good entries for next comparision,
- * because the final list can only have the entries of goodEntries as maxiumum
- */
- refEntries = goodEntries;
- };
-
- m_widget->reset(goodEntries, 0, true); //write down the entries
- } //end of ELSE
+ if (m_modules.count() == 1) {
+ m_widget->reset(m_modules.first()->entries(), 0, true);
+ // qWarning("resetted");
+ }
+ else {
+ typedef std::multimap<unsigned int, QStringList*> EntryMap;
+ EntryMap entryMap;
+ QStringList* entries = 0;
+ QListIterator<CSwordLexiconModuleInfo*> mit(m_modules);
+ while (mit.hasNext()) {
+ entries = mit.next()->entries();
+ entryMap.insert( std::make_pair(entries->count(), entries) );
+ }
+
+ QStringList goodEntries; //The string list which contains the entries which are available in all modules
+
+ EntryMap::iterator it = entryMap.begin(); //iterator to go thoigh all selected modules
+ QStringList refEntries = *(it->second); //copy the items for the first time
+ QStringList* cmpEntries = ( ++it )->second; //list for comparision, starts with the second module in the map
+
+ while (it != entryMap.end()) {
+ std::set_intersection(
+ refEntries.begin(), --(refEntries.end()), //--end() is the last valid entry
+ cmpEntries->begin(), --(cmpEntries->end()),
+ std::back_inserter(goodEntries), //append valid entries to the end of goodEntries
+ my_cmpEntries //ci_cmpEntries is the comparision function
+ );
+
+ cmpEntries = ( ++it )->second; //this is a pointer to the string list of a new module
+
+ /*
+ * use the good entries for next comparision,
+ * because the final list can only have the entries of goodEntries as maxiumum
+ */
+ refEntries = goodEntries;
+ };
+
+ m_widget->reset(goodEntries, 0, true); //write down the entries
+ } //end of ELSE
}
@@ -154,28 +152,27 @@ void CLexiconKeyChooser::adjustFont() {
/** Sets the module and refreshes the combo boxes */
void CLexiconKeyChooser::setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh ) {
- while (!m_modules.isEmpty())
- m_modules.takeFirst(); // not deleting the pointer
-
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- CSwordLexiconModuleInfo* lexicon = dynamic_cast<CSwordLexiconModuleInfo*>(*it);
- if (lexicon) {
- m_modules.append(lexicon);
- }
- }
-
- if (refresh) {
- refreshContent();
- // adjustFont();
- }
+ while (!m_modules.isEmpty())
+ m_modules.takeFirst(); // not deleting the pointer
+
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
+ CSwordLexiconModuleInfo* lexicon = dynamic_cast<CSwordLexiconModuleInfo*>(*it);
+ if (lexicon) {
+ m_modules.append(lexicon);
+ }
+ }
+
+ if (refresh) {
+ refreshContent();
+ // adjustFont();
+ }
}
/** No descriptions */
void CLexiconKeyChooser::updateKey(CSwordKey*) {}
-void CLexiconKeyChooser::setKey(QString& newKey)
-{
- m_key->key(newKey);
- setKey(m_key);
+void CLexiconKeyChooser::setKey(QString& newKey) {
+ m_key->key(newKey);
+ setKey(m_key);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index a75ce37..ea1137b 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -33,53 +33,53 @@ class QHBoxLayout;
* @author The BibleTime team
*/
class CLexiconKeyChooser : public CKeyChooser {
- Q_OBJECT
-public:
- /**
- * The constructor
- *
- * you should not need to use this, use @ref CKeyChooser::createInstance instead
- */
- CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key=0, QWidget *parent=0);
-
-public slots:
- /**
- * see @ref CKeyChooser::getKey
- * @return Return the key object we use.
- */
- virtual CSwordKey* key();
- /**
- * see @ref CKeyChooser::setKey
- */
- virtual void setKey(CSwordKey* key);
- /**
- * used to react to changes in the @ref CKeyChooserWidget
- *
- * @param index not used
- **/
- virtual void activated(int index);
- /**
- * Reimplementation.
- */
- virtual void refreshContent();
- /**
- * Sets the module and refreshes the combo boxes of this keychooser.
- */
- virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true );
-
-protected:
- CKeyChooserWidget *m_widget;
- CSwordLDKey* m_key;
- QList<CSwordLexiconModuleInfo*> m_modules;
- QHBoxLayout *m_layout;
-
- virtual void adjustFont();
-
-public slots: // Public slots
- virtual void updateKey(CSwordKey* key);
-
-protected slots:
- virtual void setKey(QString& newKey);
+ Q_OBJECT
+ public:
+ /**
+ * The constructor
+ *
+ * you should not need to use this, use @ref CKeyChooser::createInstance instead
+ */
+ CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+
+ public slots:
+ /**
+ * see @ref CKeyChooser::getKey
+ * @return Return the key object we use.
+ */
+ virtual CSwordKey* key();
+ /**
+ * see @ref CKeyChooser::setKey
+ */
+ virtual void setKey(CSwordKey* key);
+ /**
+ * used to react to changes in the @ref CKeyChooserWidget
+ *
+ * @param index not used
+ **/
+ virtual void activated(int index);
+ /**
+ * Reimplementation.
+ */
+ virtual void refreshContent();
+ /**
+ * Sets the module and refreshes the combo boxes of this keychooser.
+ */
+ virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true );
+
+ protected:
+ CKeyChooserWidget *m_widget;
+ CSwordLDKey* m_key;
+ QList<CSwordLexiconModuleInfo*> m_modules;
+ QHBoxLayout *m_layout;
+
+ virtual void adjustFont();
+
+ public slots: // Public slots
+ virtual void updateKey(CSwordKey* key);
+
+ protected slots:
+ virtual void setKey(QString& newKey);
};
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 3287eef..4303fb1 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -18,8 +18,7 @@
#include <QWheelEvent>
CScrollButton::CScrollButton(QWidget *parent)
- : QToolButton(parent), m_isLocked(false)
-{
+ : QToolButton(parent), m_isLocked(false) {
setFocusPolicy(Qt::WheelFocus);
setCursor(Qt::SplitVCursor);
}
@@ -57,11 +56,14 @@ void CScrollButton::mouseMoveEvent(QMouseEvent *e) {
int avchange(vchange >= 0 ? vchange : -vchange);
if (avchange < 10) {
avchange = (int) pow(avchange, 0.3);
- } else if (avchange < 30) {
+ }
+ else if (avchange < 30) {
avchange = (int) pow(avchange, 0.6);
- } else if (avchange < 40) {
+ }
+ else if (avchange < 40) {
avchange = (int) pow(avchange, 1.2);
- } else {
+ }
+ else {
avchange = (int) pow(avchange, 2.0);
}
@@ -69,7 +71,8 @@ void CScrollButton::mouseMoveEvent(QMouseEvent *e) {
if (avchange != 0) {
if (vchange > 0) {
emit change_requested(avchange);
- } else if (vchange < 0) {
+ }
+ else if (vchange < 0) {
emit change_requested(-avchange);
}
}
@@ -77,7 +80,8 @@ void CScrollButton::mouseMoveEvent(QMouseEvent *e) {
// Move the mouse cursor to the center of this widget:
QCursor::setPos(center);
- } else {
+ }
+ else {
QToolButton::mouseMoveEvent(e);
}
}
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 3af4ca8..54b82e6 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -22,7 +22,7 @@ class QWheelEvent;
* \author The BibleTime team.
*/
class CScrollButton: public QToolButton {
- Q_OBJECT
+ Q_OBJECT
public:
CScrollButton(QWidget *parent = 0);
virtual ~CScrollButton();
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 3577803..5f417a1 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.cpp
+++ b/src/frontend/keychooser/cscrollerwidgetset.cpp
@@ -23,65 +23,75 @@ const unsigned int ARROW_HEIGHT = 12;
const unsigned int MOVER_HEIGHT = 6;
CScrollerWidgetSet::CScrollerWidgetSet(QWidget *parent) : QWidget(parent) {
- m_layout = new QVBoxLayout(this);
- m_layout->setSpacing(0);
- m_layout->setContentsMargins(0,0,0,0);
- m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);
-
- btn_up = new QToolButton(this);
- btn_up->setArrowType(Qt::UpArrow);
-
- btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_up->setFocusPolicy(Qt::NoFocus);
- btn_up->setAutoRaise(true);
-
- btn_fx = new CScrollButton(this);
- btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
- btn_fx->setFocusPolicy(Qt::NoFocus);
-
- btn_down = new QToolButton(this);
- btn_down->setArrowType(Qt::DownArrow);
- btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_down->setFocusPolicy(Qt::NoFocus);
- btn_down->setAutoRaise(true);
-
- m_layout->addWidget( btn_up,0 );
- m_layout->addWidget( btn_fx,0 );
- m_layout->addWidget( btn_down,0 );
- setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.
-
- connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
- connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
- connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
- connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
- connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
+ m_layout = new QVBoxLayout(this);
+ m_layout->setSpacing(0);
+ m_layout->setContentsMargins(0, 0, 0, 0);
+ m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);
+
+ btn_up = new QToolButton(this);
+ btn_up->setArrowType(Qt::UpArrow);
+
+ btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
+ btn_up->setFocusPolicy(Qt::NoFocus);
+ btn_up->setAutoRaise(true);
+
+ btn_fx = new CScrollButton(this);
+ btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
+ btn_fx->setFocusPolicy(Qt::NoFocus);
+
+ btn_down = new QToolButton(this);
+ btn_down->setArrowType(Qt::DownArrow);
+ btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
+ btn_down->setFocusPolicy(Qt::NoFocus);
+ btn_down->setAutoRaise(true);
+
+ m_layout->addWidget( btn_up, 0 );
+ m_layout->addWidget( btn_fx, 0 );
+ m_layout->addWidget( btn_down, 0 );
+ setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.
+
+ connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
+ connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
+ connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
+ connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
+ connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
}
/** Sets the tooltips for the given entries using the parameters as text. */
void CScrollerWidgetSet::setToolTips( const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- btn_fx->setToolTip(scrollButtonTip);
- btn_down->setToolTip(nextEntryTip);
- btn_up->setToolTip(previousEntryTip);
+ btn_fx->setToolTip(scrollButtonTip);
+ btn_down->setToolTip(nextEntryTip);
+ btn_up->setToolTip(previousEntryTip);
}
void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
- /**
- * The problem is, that wheel events do everytime have the delta value 120
- */
- const int vchange = ((e->delta() > 0) ? (-1) : (1));
-
- if (vchange!=0) {//do not emit a change with value 0
- emit change(vchange);
- e->accept();
- }
- else {
- e->ignore();
- }
+ /**
+ * The problem is, that wheel events do everytime have the delta value 120
+ */
+ const int vchange = ((e->delta() > 0) ? (-1) : (1));
+
+ if (vchange != 0) {//do not emit a change with value 0
+ emit change(vchange);
+ e->accept();
+ }
+ else {
+ e->ignore();
+ }
}
-void CScrollerWidgetSet::slotLock() { emit scroller_pressed(); }
-void CScrollerWidgetSet::slotUnlock() { emit scroller_released(); }
-void CScrollerWidgetSet::slotScroller(int n) { emit change(n); }
-void CScrollerWidgetSet::slotUpClick() { slotScroller(-1); }
-void CScrollerWidgetSet::slotDownClick() { slotScroller(1); }
+void CScrollerWidgetSet::slotLock() {
+ emit scroller_pressed();
+}
+void CScrollerWidgetSet::slotUnlock() {
+ emit scroller_released();
+}
+void CScrollerWidgetSet::slotScroller(int n) {
+ emit change(n);
+}
+void CScrollerWidgetSet::slotUpClick() {
+ slotScroller(-1);
+}
+void CScrollerWidgetSet::slotDownClick() {
+ slotScroller(1);
+}
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index bd482df..90d87b6 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -29,47 +29,47 @@ class CScrollButton;
* @author The BibleTime team
*/
class CScrollerWidgetSet : public QWidget {
- Q_OBJECT
-public:
- /**
- * the constructor
- */
- CScrollerWidgetSet(QWidget *parent=0);
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString nextEntry, const QString scrollButton, const QString previousEntry);
-
-signals:
- /**
- * is emitted to proceed to some other entry relative to the
- * current, indicated by the int value
- */
- void change(int count);
-
- /**
- * These emit when the scroll button is pressed or released
- */
- void scroller_pressed();
- void scroller_released();
-
-protected:
-
- virtual void wheelEvent( QWheelEvent* e );
-
- QToolButton* btn_up;
- QToolButton* btn_down;
- CScrollButton* btn_fx;
-
-protected slots:
- void slotLock();
- void slotUnlock();
- void slotUpClick();
- void slotDownClick();
- void slotScroller(int);
-
-private:
- QVBoxLayout *m_layout;
+ Q_OBJECT
+ public:
+ /**
+ * the constructor
+ */
+ CScrollerWidgetSet(QWidget *parent = 0);
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips( const QString nextEntry, const QString scrollButton, const QString previousEntry);
+
+ signals:
+ /**
+ * is emitted to proceed to some other entry relative to the
+ * current, indicated by the int value
+ */
+ void change(int count);
+
+ /**
+ * These emit when the scroll button is pressed or released
+ */
+ void scroller_pressed();
+ void scroller_released();
+
+ protected:
+
+ virtual void wheelEvent( QWheelEvent* e );
+
+ QToolButton* btn_up;
+ QToolButton* btn_down;
+ CScrollButton* btn_fx;
+
+ protected slots:
+ void slotLock();
+ void slotUnlock();
+ void slotUpClick();
+ void slotDownClick();
+ void slotScroller(int);
+
+ private:
+ QVBoxLayout *m_layout;
};
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index c738353..2d59bed 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -17,118 +17,106 @@
const unsigned int ARROW_HEIGHT = 15;
BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref)
- : QToolButton(),
- m_ref(ref)
-{
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
- setAutoRaise(false);
- setArrowType(Qt::NoArrow);
- setFixedHeight(ARROW_HEIGHT);
- setFocusPolicy(Qt::NoFocus);
- setPopupMode(QToolButton::InstantPopup);
- setStyleSheet("QToolButton{margin:0px;}QToolButton::menu-indicator{subcontrol-position: center center;}");
-
- BtVerseKeyMenu* m = new BtVerseKeyMenu(this);
+ : QToolButton(),
+ m_ref(ref) {
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ setAutoRaise(false);
+ setArrowType(Qt::NoArrow);
+ setFixedHeight(ARROW_HEIGHT);
+ setFocusPolicy(Qt::NoFocus);
+ setPopupMode(QToolButton::InstantPopup);
+ setStyleSheet("QToolButton{margin:0px;}QToolButton::menu-indicator{subcontrol-position: center center;}");
+
+ BtVerseKeyMenu* m = new BtVerseKeyMenu(this);
// KAcceleratorManager::setNoAccel(m);
- setMenu(m);
- QObject::connect(m, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuTriggered(QAction*)));
+ setMenu(m);
+ QObject::connect(m, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuTriggered(QAction*)));
}
-void BtDropdownChooserButton::mousePressEvent(QMouseEvent* e)
-{
- //qDebug("BtDropdownChooserButton::mousePressEvent");
- //recreate the menu
- menu()->clear();
- this->newList();
+void BtDropdownChooserButton::mousePressEvent(QMouseEvent* e) {
+ //qDebug("BtDropdownChooserButton::mousePressEvent");
+ //recreate the menu
+ menu()->clear();
+ this->newList();
- QToolButton::mousePressEvent(e);
+ QToolButton::mousePressEvent(e);
}
-void BtDropdownChooserButton::wheelEvent(QWheelEvent* e)
-{
- // The problem is, that wheel events do everytime have the delta value 120
- const int vchange = ((e->delta() > 0) ? (-1) : (1));
-
- if (vchange!=0) {//do not emit a change with value 0
- emit stepItem(vchange);
- e->accept();
- }
- else {
- e->ignore();
- }
+void BtDropdownChooserButton::wheelEvent(QWheelEvent* e) {
+ // The problem is, that wheel events do everytime have the delta value 120
+ const int vchange = ((e->delta() > 0) ? (-1) : (1));
+
+ if (vchange != 0) {//do not emit a change with value 0
+ emit stepItem(vchange);
+ e->accept();
+ }
+ else {
+ e->ignore();
+ }
}
//******************Book dropdown button*************************************/
BtBookDropdownChooserButton::BtBookDropdownChooserButton(CKeyReferenceWidget* ref)
- : BtDropdownChooserButton(ref)
-{
- setToolTip(tr("Select book"));
- QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepBook(int)));
+ : BtDropdownChooserButton(ref) {
+ setToolTip(tr("Select book"));
+ QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepBook(int)));
}
-void BtBookDropdownChooserButton::newList()
-{
- QMenu* m = menu();
- QStringList* booklist = ref()->m_module->books();
- foreach (QString bookname, *booklist) {
- m->addAction(bookname);
- }
+void BtBookDropdownChooserButton::newList() {
+ QMenu* m = menu();
+ QStringList* booklist = ref()->m_module->books();
+ foreach (QString bookname, *booklist) {
+ m->addAction(bookname);
+ }
}
-void BtBookDropdownChooserButton::slotMenuTriggered(QAction* action)
-{
- qDebug() << "BtBookDropdownChooserButton::slotMenuTriggered" << action->text();
- m_ref->slotChangeBook(action->text());
+void BtBookDropdownChooserButton::slotMenuTriggered(QAction* action) {
+ qDebug() << "BtBookDropdownChooserButton::slotMenuTriggered" << action->text();
+ m_ref->slotChangeBook(action->text());
}
//****************** Chapter dropdown button *************************************/
BtChapterDropdownChooserButton::BtChapterDropdownChooserButton(CKeyReferenceWidget* ref)
- : BtDropdownChooserButton(ref)
-{
- setToolTip(tr("Select chapter"));
- QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepChapter(int)));
+ : BtDropdownChooserButton(ref) {
+ setToolTip(tr("Select chapter"));
+ QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepChapter(int)));
}
-void BtChapterDropdownChooserButton::newList()
-{
- QMenu* m = menu();
- int count = ref()->m_module->chapterCount(ref()->m_key->book());
- for (int i = 1; i <= count; i++) {
- m->addAction(QString::number(i));
- }
+void BtChapterDropdownChooserButton::newList() {
+ QMenu* m = menu();
+ int count = ref()->m_module->chapterCount(ref()->m_key->book());
+ for (int i = 1; i <= count; i++) {
+ m->addAction(QString::number(i));
+ }
}
-void BtChapterDropdownChooserButton::slotMenuTriggered(QAction* action)
-{
- m_ref->slotChangeChapter(action->text().toInt());
+void BtChapterDropdownChooserButton::slotMenuTriggered(QAction* action) {
+ m_ref->slotChangeChapter(action->text().toInt());
}
//****************** Verse dropdown button *************************************/
BtVerseDropdownChooserButton::BtVerseDropdownChooserButton(CKeyReferenceWidget* ref)
- : BtDropdownChooserButton(ref)
-{
- setToolTip(tr("Select verse"));
- QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepVerse(int)));
+ : BtDropdownChooserButton(ref) {
+ setToolTip(tr("Select verse"));
+ QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepVerse(int)));
}
-void BtVerseDropdownChooserButton::newList()
-{
- QMenu* m = menu();
- int count = ref()->m_module->verseCount(ref()->m_key->book(), ref()->m_key->Chapter());
- for (int i = 1; i <= count; i++) {
- m->addAction(QString::number(i));
- }
+void BtVerseDropdownChooserButton::newList() {
+ QMenu* m = menu();
+ int count = ref()->m_module->verseCount(ref()->m_key->book(), ref()->m_key->Chapter());
+ for (int i = 1; i <= count; i++) {
+ m->addAction(QString::number(i));
+ }
}
-void BtVerseDropdownChooserButton::slotMenuTriggered(QAction* action)
-{
- m_ref->slotChangeVerse(action->text().toInt());
+void BtVerseDropdownChooserButton::slotMenuTriggered(QAction* action) {
+ m_ref->slotChangeVerse(action->text().toInt());
}
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index 969f5c2..12f2f65 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -18,62 +18,60 @@ class CKeyReferenceWidget;
/**
* Base class for book/ch/v dropdown list chooser buttons.
*/
-class BtDropdownChooserButton : public QToolButton
-{
- Q_OBJECT
-public:
- BtDropdownChooserButton(CKeyReferenceWidget* ref);
+class BtDropdownChooserButton : public QToolButton {
+ Q_OBJECT
+ public:
+ BtDropdownChooserButton(CKeyReferenceWidget* ref);
- virtual ~BtDropdownChooserButton() {}
- /** The item list is constructed here just before the menu is shown.*/
- virtual void mousePressEvent(QMouseEvent* event);
- /** Recreates the menu list.*/
- virtual void newList() = 0;
- /** Returns the verse reference widget which this button belongs to.*/
- CKeyReferenceWidget* ref() {return m_ref;}
-public slots:
- /** When a menu item is selected the key will be changed.*/
- virtual void slotMenuTriggered(QAction* action) = 0;
-protected:
- CKeyReferenceWidget* m_ref;
- void wheelEvent(QWheelEvent* event);
-signals:
- void stepItem(int step);
+ virtual ~BtDropdownChooserButton() {}
+ /** The item list is constructed here just before the menu is shown.*/
+ virtual void mousePressEvent(QMouseEvent* event);
+ /** Recreates the menu list.*/
+ virtual void newList() = 0;
+ /** Returns the verse reference widget which this button belongs to.*/
+ CKeyReferenceWidget* ref() {
+ return m_ref;
+ }
+ public slots:
+ /** When a menu item is selected the key will be changed.*/
+ virtual void slotMenuTriggered(QAction* action) = 0;
+ protected:
+ CKeyReferenceWidget* m_ref;
+ void wheelEvent(QWheelEvent* event);
+ signals:
+ void stepItem(int step);
};
/** See BtDropdownChooserButton.*/
-class BtBookDropdownChooserButton : public BtDropdownChooserButton
-{
- Q_OBJECT
-public:
- BtBookDropdownChooserButton(CKeyReferenceWidget* ref);
- ~BtBookDropdownChooserButton() {}
- virtual void newList();
-public slots:
- virtual void slotMenuTriggered(QAction* action);
+class BtBookDropdownChooserButton : public BtDropdownChooserButton {
+ Q_OBJECT
+ public:
+ BtBookDropdownChooserButton(CKeyReferenceWidget* ref);
+ ~BtBookDropdownChooserButton() {}
+ virtual void newList();
+ public slots:
+ virtual void slotMenuTriggered(QAction* action);
};
/** See BtDropdownChooserButton.*/
-class BtChapterDropdownChooserButton : public BtDropdownChooserButton
-{
- Q_OBJECT
-public:
- BtChapterDropdownChooserButton(CKeyReferenceWidget* ref);
- ~BtChapterDropdownChooserButton() {}
- virtual void newList();
-public slots:
- virtual void slotMenuTriggered(QAction* action);
+class BtChapterDropdownChooserButton : public BtDropdownChooserButton {
+ Q_OBJECT
+ public:
+ BtChapterDropdownChooserButton(CKeyReferenceWidget* ref);
+ ~BtChapterDropdownChooserButton() {}
+ virtual void newList();
+ public slots:
+ virtual void slotMenuTriggered(QAction* action);
};
/** See BtDropdownChooserButton.*/
-class BtVerseDropdownChooserButton : public BtDropdownChooserButton
-{
- Q_OBJECT
-public:
- BtVerseDropdownChooserButton(CKeyReferenceWidget* ref);
- ~BtVerseDropdownChooserButton() {}
- virtual void newList();
-public slots:
- virtual void slotMenuTriggered(QAction* action);
+class BtVerseDropdownChooserButton : public BtDropdownChooserButton {
+ Q_OBJECT
+ public:
+ BtVerseDropdownChooserButton(CKeyReferenceWidget* ref);
+ ~BtVerseDropdownChooserButton() {}
+ virtual void newList();
+ public slots:
+ virtual void slotMenuTriggered(QAction* action);
};
#endif
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index f8607e4..82a07b7 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
@@ -16,37 +16,34 @@
#include <QDebug>
BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent)
- : QMenu(parent),
- m_timerId(0),
- m_firstClickLock(true)
-{
- qDebug("BtVerseKeyMenu::BtVerseKeyMenu");
- QObject::connect(this, SIGNAL(aboutToShow()), this, SLOT(startFirstClickDelayTimer()));
+ : QMenu(parent),
+ m_timerId(0),
+ m_firstClickLock(true) {
+ qDebug("BtVerseKeyMenu::BtVerseKeyMenu");
+ QObject::connect(this, SIGNAL(aboutToShow()), this, SLOT(startFirstClickDelayTimer()));
}
-void BtVerseKeyMenu::startFirstClickDelayTimer()
-{
- //qDebug() << "BtVerseKeyMenu::startFirstClickDelayTimer";
- m_firstClickLock = true;
- killTimer(m_timerId);
- m_timerId = startTimer(300);
+void BtVerseKeyMenu::startFirstClickDelayTimer() {
+ //qDebug() << "BtVerseKeyMenu::startFirstClickDelayTimer";
+ m_firstClickLock = true;
+ killTimer(m_timerId);
+ m_timerId = startTimer(300);
}
-void BtVerseKeyMenu::timerEvent(QTimerEvent* e)
-{
- if (e->timerId() == m_timerId) {
- //qDebug() << "BtVerseKeyMenu::timerEvent";
- killTimer(m_timerId);
- m_firstClickLock = false;
- } else {
- QMenu::timerEvent(e);
- }
+void BtVerseKeyMenu::timerEvent(QTimerEvent* e) {
+ if (e->timerId() == m_timerId) {
+ //qDebug() << "BtVerseKeyMenu::timerEvent";
+ killTimer(m_timerId);
+ m_firstClickLock = false;
+ }
+ else {
+ QMenu::timerEvent(e);
+ }
}
-void BtVerseKeyMenu::mouseReleaseEvent(QMouseEvent* e)
-{
- //qDebug() << "BtVerseKeyMenu::mouseReleaseEvent";
- if (m_firstClickLock) return;
- //qDebug() << "BtVerseKeyMenu::mouseReleaseEvent 2";
- QMenu::mouseReleaseEvent(e);
+void BtVerseKeyMenu::mouseReleaseEvent(QMouseEvent* e) {
+ //qDebug() << "BtVerseKeyMenu::mouseReleaseEvent";
+ if (m_firstClickLock) return;
+ //qDebug() << "BtVerseKeyMenu::mouseReleaseEvent 2";
+ QMenu::mouseReleaseEvent(e);
}
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index 45d9385..29c0736 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -21,23 +21,22 @@ class QTimerEvent;
* This is implemented mostly because it needs a delay which prevents unwanted actions after
* the menu has been shown and mouse button is released over some item.
*/
-class BtVerseKeyMenu : public QMenu
-{
- Q_OBJECT
-public:
- BtVerseKeyMenu(QWidget* parent);
- ~BtVerseKeyMenu(){}
-protected:
- virtual void mouseReleaseEvent(QMouseEvent* event);
- /** Frees the mouse button release after the delay has elapsed.*/
- virtual void timerEvent(QTimerEvent* event);
-private slots:
- /** Starts the delay timer for the first mouse button release.*/
- void startFirstClickDelayTimer();
+class BtVerseKeyMenu : public QMenu {
+ Q_OBJECT
+ public:
+ BtVerseKeyMenu(QWidget* parent);
+ ~BtVerseKeyMenu() {}
+ protected:
+ virtual void mouseReleaseEvent(QMouseEvent* event);
+ /** Frees the mouse button release after the delay has elapsed.*/
+ virtual void timerEvent(QTimerEvent* event);
+ private slots:
+ /** Starts the delay timer for the first mouse button release.*/
+ void startFirstClickDelayTimer();
-private:
- int m_timerId;
- bool m_firstClickLock;
+ private:
+ int m_timerId;
+ bool m_firstClickLock;
};
#endif
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index afe3482..493d9c4 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -23,87 +23,83 @@
#include <QDebug>
-CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) :
- CKeyChooser(modules, key, parent),
- m_key(dynamic_cast<CSwordVerseKey*>(key))
-{
- w_ref = 0;
- setModules(modules, false);
- if (!m_modules.count()) {
- qWarning() << "CBibleKeyChooser: module is not a Bible or commentary!";
- m_key = 0;
- return;
- }
- QHBoxLayout* layout = new QHBoxLayout(this);
- layout->setSpacing(0);
- layout->setContentsMargins(0,0,0,0);
- layout->setDirection( QBoxLayout::LeftToRight );
-
- w_ref = new CKeyReferenceWidget(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()), m_key, this);
- setFocusProxy(w_ref);
- layout->addWidget(w_ref);
-
- connect(w_ref,SIGNAL(changed(CSwordVerseKey *)),SLOT(refChanged(CSwordVerseKey *)));
-
- setKey(m_key); //set the key without changing it, setKey(key()) would change it
-
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) :
+ CKeyChooser(modules, key, parent),
+ m_key(dynamic_cast<CSwordVerseKey*>(key)) {
+ w_ref = 0;
+ setModules(modules, false);
+ if (!m_modules.count()) {
+ qWarning() << "CBibleKeyChooser: module is not a Bible or commentary!";
+ m_key = 0;
+ return;
+ }
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setDirection( QBoxLayout::LeftToRight );
+
+ w_ref = new CKeyReferenceWidget(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()), m_key, this);
+ setFocusProxy(w_ref);
+ layout->addWidget(w_ref);
+
+ connect(w_ref, SIGNAL(changed(CSwordVerseKey *)), SLOT(refChanged(CSwordVerseKey *)));
+
+ setKey(m_key); //set the key without changing it, setKey(key()) would change it
+
+ connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
CSwordKey* CBibleKeyChooser::key() {
- return m_key;
+ return m_key;
}
-void CBibleKeyChooser::setKey(CSwordKey* key)
-{
- Q_ASSERT(dynamic_cast<CSwordVerseKey*>(key));
- if (dynamic_cast<CSwordVerseKey*>(key) == 0) return;
+void CBibleKeyChooser::setKey(CSwordKey* key) {
+ Q_ASSERT(dynamic_cast<CSwordVerseKey*>(key));
+ if (dynamic_cast<CSwordVerseKey*>(key) == 0) return;
- emit (beforeKeyChange(m_key->key())); //required to make direct setKey calls work from the outside
- m_key = dynamic_cast<CSwordVerseKey*>(key);
- w_ref->setKey(m_key);
- emit keyChanged(m_key);
+ emit (beforeKeyChange(m_key->key())); //required to make direct setKey calls work from the outside
+ m_key = dynamic_cast<CSwordVerseKey*>(key);
+ w_ref->setKey(m_key);
+ emit keyChanged(m_key);
}
-void CBibleKeyChooser::refChanged(CSwordVerseKey* key)
-{
- Q_ASSERT(m_key);
- Q_ASSERT(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);
+ setUpdatesEnabled(false);
+ if (m_key) emit beforeKeyChange(m_key->key());
+ m_key = key;
+ emit keyChanged(m_key);
- setUpdatesEnabled(true);
+ setUpdatesEnabled(true);
}
void CBibleKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
- m_modules.clear();
+ m_modules.clear();
- foreach (CSwordModuleInfo* mod, modules) {
- if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
- if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(mod)) m_modules.append(bible);
- }
- }
+ foreach (CSwordModuleInfo* mod, modules) {
+ if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
+ if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(mod)) m_modules.append(bible);
+ }
+ }
- // First time this is called we havnt set up w_ref.
- if (w_ref) w_ref->setModule(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()));
- if (refresh) refreshContent();
+ // First time this is called we havnt set up w_ref.
+ if (w_ref) w_ref->setModule(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()));
+ if (refresh) refreshContent();
}
void CBibleKeyChooser::refreshContent() {
- setKey(m_key);
+ setKey(m_key);
}
void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {}
void CBibleKeyChooser::adjustFont() {}
-void CBibleKeyChooser::setKey(QString& newKey)
-{
- m_key->key(newKey);
- setKey(m_key);
+void CBibleKeyChooser::setKey(QString& newKey) {
+ m_key->key(newKey);
+ setKey(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
index a410354..e412e60 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -34,45 +34,45 @@ class CSwordBibleModuleInfo;
*/
class CBibleKeyChooser : public CKeyChooser {
- Q_OBJECT
-
-public:
- /**
- * the constructor
- * you should not need to use this, use @ref CKeyChooser::createInstance instead
- */
- CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key=0, QWidget *parent=0);
-
-public slots:
- /**
- * see @ref CKeyChooser::getKey
- */
- CSwordKey* key();
- /**
- * see @ref CKeyChooser::setKey
- */
- virtual void setKey(CSwordKey *key);
- /**
- * Sets the module
- */
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
- /**
- * used to react to changes
- * @param index not used
- */
- void refChanged(CSwordVerseKey *key);
-
- void updateKey(CSwordKey* key);
- void adjustFont();
- void refreshContent();
-
-protected slots:
- virtual void setKey(QString& newKey);
-
-private:
- CKeyReferenceWidget* w_ref;
- QList<CSwordBibleModuleInfo*> m_modules;
- CSwordVerseKey *m_key;
+ Q_OBJECT
+
+ public:
+ /**
+ * the constructor
+ * you should not need to use this, use @ref CKeyChooser::createInstance instead
+ */
+ CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+
+ public slots:
+ /**
+ * see @ref CKeyChooser::getKey
+ */
+ CSwordKey* key();
+ /**
+ * see @ref CKeyChooser::setKey
+ */
+ virtual void setKey(CSwordKey *key);
+ /**
+ * Sets the module
+ */
+ virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
+ /**
+ * used to react to changes
+ * @param index not used
+ */
+ void refChanged(CSwordVerseKey *key);
+
+ void updateKey(CSwordKey* key);
+ void adjustFont();
+ void refreshContent();
+
+ protected slots:
+ virtual void setKey(QString& newKey);
+
+ private:
+ CKeyReferenceWidget* w_ref;
+ QList<CSwordBibleModuleInfo*> m_modules;
+ CSwordVerseKey *m_key;
};
#endif
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
index cedb4b3..7cedfc0 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
@@ -33,95 +33,90 @@
#include <QToolButton>
#include <QFocusEvent>
-class BtLineEdit : public QLineEdit
-{
-public:
- BtLineEdit(QWidget* parent)
- : QLineEdit(parent)
- {
- }
-protected:
- void focusInEvent(QFocusEvent* event)
- {
- Qt::FocusReason reason = event->reason();
- if (reason == Qt::OtherFocusReason)
- {
- selectAll();
- }
-
- QWidget::focusInEvent(event);
- }
+class BtLineEdit : public QLineEdit {
+ public:
+ BtLineEdit(QWidget* parent)
+ : QLineEdit(parent) {
+ }
+ protected:
+ void focusInEvent(QFocusEvent* event) {
+ Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason) {
+ selectAll();
+ }
+
+ QWidget::focusInEvent(event);
+ }
};
CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
- QWidget(parent),
- m_key(key),
- m_dropDownHoverTimer(this)
-{
-
- updatelock = false;
- m_module = mod;
-
- setFocusPolicy(Qt::WheelFocus);
-
- QToolButton* clearRef = new QToolButton(this);
- clearRef->setIcon(util::filesystem::DirectoryUtil::getIcon("edit_clear_locationbar"));
- clearRef->setAutoRaise(true);
- clearRef->setStyleSheet("QToolButton{margin:0px;}");
- connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
-
- m_bookScroller = new CScrollerWidgetSet(this);
-
- m_textbox = new BtLineEdit( this );
- setFocusProxy(m_textbox);
- m_textbox->setContentsMargins(0, 0, 0, 0);
-
- setKey(key); // The order of these two functions is important.
- setModule();
-
- m_chapterScroller = new CScrollerWidgetSet(this);
- m_verseScroller = new CScrollerWidgetSet(this);
-
- QHBoxLayout* m_mainLayout = new QHBoxLayout( this );
- m_mainLayout->setContentsMargins(0,0,0,0);
- m_mainLayout->setSpacing(0);
- m_mainLayout->addWidget(clearRef);
- m_mainLayout->addWidget(m_bookScroller);
- m_mainLayout->addWidget(m_textbox);
- m_mainLayout->addWidget(m_chapterScroller);
- m_mainLayout->addWidget(m_verseScroller);
-
-
- setTabOrder(m_textbox, 0);
- m_dropDownButtons = new QWidget(0);
- m_dropDownButtons->setWindowFlags(Qt::Popup);
- m_dropDownButtons->setAttribute(Qt::WA_WindowPropagation);
- m_dropDownButtons->setCursor(Qt::ArrowCursor);
- QHBoxLayout *dropDownButtonsLayout(new QHBoxLayout(m_dropDownButtons));
- m_bookDropdownButton = new BtBookDropdownChooserButton(this);
- dropDownButtonsLayout->addWidget(m_bookDropdownButton, 2);
- m_chapterDropdownButton = new BtChapterDropdownChooserButton(this);
- dropDownButtonsLayout->addWidget(m_chapterDropdownButton, 1);
- m_verseDropdownButton = new BtVerseDropdownChooserButton(this);
- dropDownButtonsLayout->addWidget(m_verseDropdownButton, 1);
- dropDownButtonsLayout->setContentsMargins(0, 0, 0, 0);
- dropDownButtonsLayout->setSpacing(0);
- m_dropDownButtons->setLayout(dropDownButtonsLayout);
- m_dropDownButtons->hide();
-
- m_dropDownButtons->installEventFilter(this);
-
- m_dropDownHoverTimer.setInterval(500);
- m_dropDownHoverTimer.setSingleShot(true);
- connect(&m_dropDownHoverTimer, SIGNAL(timeout()),
- m_dropDownButtons, SLOT(hide()));
-
- QString scrollButtonToolTip(tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."));
+ QWidget(parent),
+ m_key(key),
+ m_dropDownHoverTimer(this) {
+
+ updatelock = false;
+ m_module = mod;
+
+ setFocusPolicy(Qt::WheelFocus);
+
+ QToolButton* clearRef = new QToolButton(this);
+ clearRef->setIcon(util::filesystem::DirectoryUtil::getIcon("edit_clear_locationbar"));
+ clearRef->setAutoRaise(true);
+ clearRef->setStyleSheet("QToolButton{margin:0px;}");
+ connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
+
+ m_bookScroller = new CScrollerWidgetSet(this);
+
+ m_textbox = new BtLineEdit( this );
+ setFocusProxy(m_textbox);
+ m_textbox->setContentsMargins(0, 0, 0, 0);
+
+ setKey(key); // The order of these two functions is important.
+ setModule();
+
+ m_chapterScroller = new CScrollerWidgetSet(this);
+ m_verseScroller = new CScrollerWidgetSet(this);
+
+ QHBoxLayout* m_mainLayout = new QHBoxLayout( this );
+ m_mainLayout->setContentsMargins(0, 0, 0, 0);
+ m_mainLayout->setSpacing(0);
+ m_mainLayout->addWidget(clearRef);
+ m_mainLayout->addWidget(m_bookScroller);
+ m_mainLayout->addWidget(m_textbox);
+ m_mainLayout->addWidget(m_chapterScroller);
+ m_mainLayout->addWidget(m_verseScroller);
+
+
+ setTabOrder(m_textbox, 0);
+ m_dropDownButtons = new QWidget(0);
+ m_dropDownButtons->setWindowFlags(Qt::Popup);
+ m_dropDownButtons->setAttribute(Qt::WA_WindowPropagation);
+ m_dropDownButtons->setCursor(Qt::ArrowCursor);
+ QHBoxLayout *dropDownButtonsLayout(new QHBoxLayout(m_dropDownButtons));
+ m_bookDropdownButton = new BtBookDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_bookDropdownButton, 2);
+ m_chapterDropdownButton = new BtChapterDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_chapterDropdownButton, 1);
+ m_verseDropdownButton = new BtVerseDropdownChooserButton(this);
+ dropDownButtonsLayout->addWidget(m_verseDropdownButton, 1);
+ dropDownButtonsLayout->setContentsMargins(0, 0, 0, 0);
+ dropDownButtonsLayout->setSpacing(0);
+ m_dropDownButtons->setLayout(dropDownButtonsLayout);
+ m_dropDownButtons->hide();
+
+ m_dropDownButtons->installEventFilter(this);
+
+ m_dropDownHoverTimer.setInterval(500);
+ m_dropDownHoverTimer.setSingleShot(true);
+ connect(&m_dropDownHoverTimer, SIGNAL(timeout()),
+ m_dropDownButtons, SLOT(hide()));
+
+ QString scrollButtonToolTip(tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."));
m_bookScroller->setToolTips(
- tr("Next book"),
- scrollButtonToolTip,
- tr("Previous book")
+ tr("Next book"),
+ scrollButtonToolTip,
+ tr("Previous book")
);
m_chapterScroller->setToolTips(
tr("Next chapter"),
@@ -134,36 +129,32 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
tr("Previous verse")
);
- // signals and slots connections
-
- connect(m_bookScroller, SIGNAL(change(int)), SLOT(slotStepBook(int)));
- connect(m_bookScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
- connect(m_bookScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
- connect(m_textbox, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
- connect(m_chapterScroller, SIGNAL(change(int)), SLOT(slotStepChapter(int)));
- connect(m_chapterScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
- connect(m_chapterScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
- connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
- connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
- connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
+ // signals and slots connections
+
+ connect(m_bookScroller, SIGNAL(change(int)), SLOT(slotStepBook(int)));
+ connect(m_bookScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
+ connect(m_bookScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
+ connect(m_textbox, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
+ connect(m_chapterScroller, SIGNAL(change(int)), SLOT(slotStepChapter(int)));
+ connect(m_chapterScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
+ connect(m_chapterScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
+ connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
+ connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
+ connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
-CKeyReferenceWidget::~CKeyReferenceWidget()
-{
+CKeyReferenceWidget::~CKeyReferenceWidget() {
delete m_dropDownButtons;
}
-void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m)
-{
- if (m) //can be null
- {
- m_module = m;
- m_key->module(m);
- }
+void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m) {
+ if (m) { //can be null
+ m_module = m;
+ m_key->module(m);
+ }
}
-bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e)
-{
+bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
if (o != m_dropDownButtons) return false;
switch (e->type()) {
case QEvent::Enter:
@@ -177,8 +168,7 @@ bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e)
}
}
-void CKeyReferenceWidget::enterEvent(QEvent *)
-{
+void CKeyReferenceWidget::enterEvent(QEvent *) {
m_dropDownHoverTimer.stop();
resetDropDownButtons();
@@ -187,22 +177,18 @@ void CKeyReferenceWidget::enterEvent(QEvent *)
m_dropDownButtons->show();
}
-void CKeyReferenceWidget::leaveEvent(QEvent *)
-{
+void CKeyReferenceWidget::leaveEvent(QEvent *) {
m_dropDownHoverTimer.start();
}
-void CKeyReferenceWidget::resizeEvent(QResizeEvent *event)
-{
- if (m_dropDownButtons->isVisible())
- {
+void CKeyReferenceWidget::resizeEvent(QResizeEvent *event) {
+ if (m_dropDownButtons->isVisible()) {
resetDropDownButtons();
}
QWidget::resizeEvent(event);
}
-void CKeyReferenceWidget::resetDropDownButtons()
-{
+void CKeyReferenceWidget::resetDropDownButtons() {
m_dropDownButtons->setParent(window());
int h(m_dropDownButtons->layout()->minimumSize().height());
QPoint topLeft(mapTo(window(), QPoint(m_textbox->x(), height())));
@@ -210,14 +196,12 @@ void CKeyReferenceWidget::resetDropDownButtons()
m_textbox->width(), h);
}
-void CKeyReferenceWidget::slotClearRef( )
-{
- m_textbox->setText("");
- m_textbox->setFocus();
+void CKeyReferenceWidget::slotClearRef( ) {
+ m_textbox->setText("");
+ m_textbox->setFocus();
}
-void CKeyReferenceWidget::updateText()
-{
+void CKeyReferenceWidget::updateText() {
QString text(m_key->key());
m_textbox->setText(text);
QFontMetrics fm(m_textbox->font());
@@ -228,101 +212,87 @@ void CKeyReferenceWidget::updateText()
}
}
-bool CKeyReferenceWidget::setKey(CSwordVerseKey *key)
-{
- if (!key) return false;
+bool CKeyReferenceWidget::setKey(CSwordVerseKey *key) {
+ if (!key) return false;
- m_key->key(key->key());
- updateText();
- return true;
+ m_key->key(key->key());
+ updateText();
+ return true;
}
-QLineEdit* CKeyReferenceWidget::textbox()
-{
- return m_textbox;
+QLineEdit* CKeyReferenceWidget::textbox() {
+ return m_textbox;
}
-void CKeyReferenceWidget::slotReturnPressed()
-{
- m_key->key(m_textbox->text());
- updateText();
- emit changed(m_key);
+void CKeyReferenceWidget::slotReturnPressed() {
+ m_key->key(m_textbox->text());
+ updateText();
+ emit changed(m_key);
}
/* Handlers for the various scroller widgetsets. Do we really want a verse scroller? */
-void CKeyReferenceWidget::slotUpdateLock()
-{
- updatelock = true;
- oldKey = m_key->key();
+void CKeyReferenceWidget::slotUpdateLock() {
+ updatelock = true;
+ oldKey = m_key->key();
}
-void CKeyReferenceWidget::slotUpdateUnlock()
-{
- updatelock = false;
- if (oldKey != m_key->key())
- emit changed(m_key);
+void CKeyReferenceWidget::slotUpdateUnlock() {
+ updatelock = false;
+ if (oldKey != m_key->key())
+ emit changed(m_key);
}
-void CKeyReferenceWidget::slotStepBook(int n)
-{
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseBook ) : key.previous( CSwordVerseKey::UseBook );
- if (!updatelock)
- emit changed(&key); // does *m_key = key
- updateText();
+void CKeyReferenceWidget::slotStepBook(int n) {
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseBook ) : key.previous( CSwordVerseKey::UseBook );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
+ updateText();
}
-void CKeyReferenceWidget::slotStepChapter(int n)
-{
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseChapter ) : key.previous( CSwordVerseKey::UseChapter );
- if (!updatelock)
- emit changed(&key); // does *m_key = key
- updateText();
+void CKeyReferenceWidget::slotStepChapter(int n) {
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseChapter ) : key.previous( CSwordVerseKey::UseChapter );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
+ updateText();
}
-void CKeyReferenceWidget::slotStepVerse(int n)
-{
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseVerse ) : key.previous( CSwordVerseKey::UseVerse );
- if (!updatelock)
- emit changed(&key); // does *m_key = key
- updateText();
+void CKeyReferenceWidget::slotStepVerse(int n) {
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseVerse ) : key.previous( CSwordVerseKey::UseVerse );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
+ updateText();
}
-void CKeyReferenceWidget::slotChangeVerse(int n)
-{
- if (m_key->Verse() != n)
- {
- m_key->Verse( n );
- setKey( m_key );
- }
- updateText();
- if (!updatelock) emit changed(m_key);
+void CKeyReferenceWidget::slotChangeVerse(int n) {
+ if (m_key->Verse() != n) {
+ m_key->Verse( n );
+ setKey( m_key );
+ }
+ updateText();
+ if (!updatelock) emit changed(m_key);
}
-void CKeyReferenceWidget::slotChangeChapter(int n)
-{
- if (m_key->Chapter() != n)
- {
- m_key->Chapter( n );
- setKey( m_key );
- }
- updateText();
- if (!updatelock)
- emit changed(m_key);
+void CKeyReferenceWidget::slotChangeChapter(int n) {
+ if (m_key->Chapter() != n) {
+ m_key->Chapter( n );
+ setKey( m_key );
+ }
+ updateText();
+ if (!updatelock)
+ emit changed(m_key);
}
-void CKeyReferenceWidget::slotChangeBook(QString bookname)
-{
- if (m_key->book() != bookname)
- {
- m_key->book( bookname );
- setKey( m_key );
- }
- updateText();
- if (!updatelock)
- emit changed(m_key);
+void CKeyReferenceWidget::slotChangeBook(QString bookname) {
+ if (m_key->book() != bookname) {
+ m_key->book( bookname );
+ setKey( m_key );
+ }
+ updateText();
+ if (!updatelock)
+ emit changed(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
index 0324dbe..95a188e 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
@@ -25,69 +25,69 @@ class QLineEdit;
class CKeyReferenceWidget : public QWidget {
- Q_OBJECT
-public:
- /**
- * the constructor
- */
- CKeyReferenceWidget(CSwordBibleModuleInfo *, CSwordVerseKey*, QWidget *parent=0, const char *name=0);
- ~CKeyReferenceWidget();
- bool setKey(CSwordVerseKey* key);
- QLineEdit* textbox();
- void setModule(CSwordBibleModuleInfo *m = 0);
- bool eventFilter(QObject *o, QEvent *e);
-
-signals:
- void changed(CSwordVerseKey* key);
-
-protected:
- void enterEvent(QEvent *event);
- void leaveEvent(QEvent *event);
- void resizeEvent(QResizeEvent *event);
- void resetDropDownButtons();
- void updateText();
-
-protected slots: // Protected slots
- /**
- * Is called when the return key was presed in the textbox.
- */
- void slotReturnPressed();
-
- void slotClearRef();
-
- void slotUpdateLock();
- void slotUpdateUnlock();
- void slotStepBook(int);
- void slotStepChapter(int);
- void slotStepVerse(int);
- void slotChangeBook(QString bookname);
- void slotChangeChapter(int chapter);
- void slotChangeVerse(int verse);
-
-private:
- friend class CLexiconKeyChooser;
- friend class BtDropdownChooserButton;
- friend class BtBookDropdownChooserButton;
- friend class BtChapterDropdownChooserButton;
- friend class BtVerseDropdownChooserButton;
-
- CSwordVerseKey *m_key;
-
- QLineEdit* m_textbox;
-
- CScrollerWidgetSet *m_bookScroller;
- CScrollerWidgetSet *m_chapterScroller;
- CScrollerWidgetSet *m_verseScroller;
-
- QWidget *m_dropDownButtons;
- QTimer m_dropDownHoverTimer;
- BtDropdownChooserButton* m_bookDropdownButton;
- BtDropdownChooserButton* m_chapterDropdownButton;
- BtDropdownChooserButton* m_verseDropdownButton;
-
- bool updatelock;
- QString oldKey;
- CSwordBibleModuleInfo *m_module;
+ Q_OBJECT
+ public:
+ /**
+ * the constructor
+ */
+ CKeyReferenceWidget(CSwordBibleModuleInfo *, CSwordVerseKey*, QWidget *parent = 0, const char *name = 0);
+ ~CKeyReferenceWidget();
+ bool setKey(CSwordVerseKey* key);
+ QLineEdit* textbox();
+ void setModule(CSwordBibleModuleInfo *m = 0);
+ bool eventFilter(QObject *o, QEvent *e);
+
+ signals:
+ void changed(CSwordVerseKey* key);
+
+ protected:
+ void enterEvent(QEvent *event);
+ void leaveEvent(QEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void resetDropDownButtons();
+ void updateText();
+
+ protected slots: // Protected slots
+ /**
+ * Is called when the return key was presed in the textbox.
+ */
+ void slotReturnPressed();
+
+ void slotClearRef();
+
+ void slotUpdateLock();
+ void slotUpdateUnlock();
+ void slotStepBook(int);
+ void slotStepChapter(int);
+ void slotStepVerse(int);
+ void slotChangeBook(QString bookname);
+ void slotChangeChapter(int chapter);
+ void slotChangeVerse(int verse);
+
+ private:
+ friend class CLexiconKeyChooser;
+ friend class BtDropdownChooserButton;
+ friend class BtBookDropdownChooserButton;
+ friend class BtChapterDropdownChooserButton;
+ friend class BtVerseDropdownChooserButton;
+
+ CSwordVerseKey *m_key;
+
+ QLineEdit* m_textbox;
+
+ CScrollerWidgetSet *m_bookScroller;
+ CScrollerWidgetSet *m_chapterScroller;
+ CScrollerWidgetSet *m_verseScroller;
+
+ QWidget *m_dropDownButtons;
+ QTimer m_dropDownHoverTimer;
+ BtDropdownChooserButton* m_bookDropdownButton;
+ BtDropdownChooserButton* m_chapterDropdownButton;
+ BtDropdownChooserButton* m_verseDropdownButton;
+
+ bool updatelock;
+ QString oldKey;
+ CSwordBibleModuleInfo *m_module;
};
#endif
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp b/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
index ac86b0e..cdfa870 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
@@ -21,130 +21,120 @@
#include <QDebug>
BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
- : BtBookmarkItemBase(parent)
-{
- setText(0, name);
- setFlags(Qt::ItemIsEditable|Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled);
+ : BtBookmarkItemBase(parent) {
+ setText(0, name);
+ setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
}
-bool BtBookmarkFolder::enableAction(MenuAction action)
-{
- if (action == ChangeFolder || action == NewFolder || action == DeleteEntries || action == ImportBookmarks )
- return true;
- if (action == ExportBookmarks || action == ImportBookmarks )
- return true;
- if ((action == PrintBookmarks) && childCount())
- return true;
- return false;
+bool BtBookmarkFolder::enableAction(MenuAction action) {
+ if (action == ChangeFolder || action == NewFolder || action == DeleteEntries || action == ImportBookmarks )
+ return true;
+ if (action == ExportBookmarks || action == ImportBookmarks )
+ return true;
+ if ((action == PrintBookmarks) && childCount())
+ return true;
+ return false;
}
-void BtBookmarkFolder::exportBookmarks()
-{
- QString filter = QObject::tr("BibleTime bookmark files") + QString(" (*.btb);;") + QObject::tr("All files") + QString(" (*.*)");
- QString fileName = QFileDialog::getSaveFileName(0, QObject::tr("Export Bookmarks"), "", filter);
+void BtBookmarkFolder::exportBookmarks() {
+ QString filter = QObject::tr("BibleTime bookmark files") + QString(" (*.btb);;") + QObject::tr("All files") + QString(" (*.*)");
+ QString fileName = QFileDialog::getSaveFileName(0, QObject::tr("Export Bookmarks"), "", filter);
- if (!fileName.isEmpty()) {
- qDebug() << "exportBookmarks()";
- BtBookmarkLoader loader;
- loader.saveTreeFromRootItem(this, fileName, false ); //false: don't overwrite without asking
- };
+ if (!fileName.isEmpty()) {
+ qDebug() << "exportBookmarks()";
+ BtBookmarkLoader loader;
+ loader.saveTreeFromRootItem(this, fileName, false ); //false: don't overwrite without asking
+ };
}
-void BtBookmarkFolder::importBookmarks()
-{
- QString filter = QObject::tr("BibleTime bookmark files") + QString(" (*.btb);;") + QObject::tr("All files") + QString(" (*.*)");
- QString fileName = QFileDialog::getOpenFileName(0, QObject::tr("Import bookmarks"), "", filter);
- if (!fileName.isEmpty()) {
- qDebug() << "import bookmarks";
- BtBookmarkLoader loader;
- QList<QTreeWidgetItem*> itemList = loader.loadTree(fileName);
- this->insertChildren(0, itemList);
- };
+void BtBookmarkFolder::importBookmarks() {
+ QString filter = QObject::tr("BibleTime bookmark files") + QString(" (*.btb);;") + QObject::tr("All files") + QString(" (*.*)");
+ QString fileName = QFileDialog::getOpenFileName(0, QObject::tr("Import bookmarks"), "", filter);
+ if (!fileName.isEmpty()) {
+ qDebug() << "import bookmarks";
+ BtBookmarkLoader loader;
+ QList<QTreeWidgetItem*> itemList = loader.loadTree(fileName);
+ this->insertChildren(0, itemList);
+ };
}
-QString BtBookmarkFolder::toolTip()
-{
- return QString();
+QString BtBookmarkFolder::toolTip() {
+ return QString();
}
-void BtBookmarkFolder::newSubFolder()
-{
- if (dynamic_cast<BtBookmarkFolder*>(this)) {
- BtBookmarkFolder* f = new BtBookmarkFolder(this, QObject::tr("New folder"));
+void BtBookmarkFolder::newSubFolder() {
+ if (dynamic_cast<BtBookmarkFolder*>(this)) {
+ BtBookmarkFolder* f = new BtBookmarkFolder(this, QObject::tr("New folder"));
- treeWidget()->setCurrentItem(f);
- f->update();
- f->rename();
- }
+ treeWidget()->setCurrentItem(f);
+ f->update();
+ f->rename();
+ }
}
-QList<QTreeWidgetItem*> BtBookmarkFolder::getChildList() const
-{
- QList<QTreeWidgetItem*> list;
- for (int i = 0; i < childCount(); i++) {
- list.append(child(i));
- }
- return list;
+QList<QTreeWidgetItem*> BtBookmarkFolder::getChildList() const {
+ QList<QTreeWidgetItem*> list;
+ for (int i = 0; i < childCount(); i++) {
+ list.append(child(i));
+ }
+ return list;
}
-void BtBookmarkFolder::rename()
-{
- treeWidget()->editItem(this);
+void BtBookmarkFolder::rename() {
+ treeWidget()->editItem(this);
}
-void BtBookmarkFolder::update()
-{
- qDebug() << "BtBookmarkFolder::update()";
- BtBookmarkItemBase::update();
- if (isExpanded() && childCount())
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::openedFolder::icon));
- else
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::closedFolder::icon));
+void BtBookmarkFolder::update() {
+ qDebug() << "BtBookmarkFolder::update()";
+ BtBookmarkItemBase::update();
+ if (isExpanded() && childCount())
+ setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::openedFolder::icon));
+ else
+ setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::closedFolder::icon));
}
-bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const
-{
- qDebug() << "BtBookmarkFolder::hasDescendant, this:" << this << "possible descendant:" << item;
-
- if (this == item) {
- qDebug() << "it's this, return true";
- return true;
- }
- if (getChildList().indexOf(item) > -1) {
- qDebug() << "direct child, return true";
- return true;
- }
- foreach(QTreeWidgetItem* childItem, getChildList()) {
- bool subresult = false;
- BtBookmarkFolder* folder = 0;
- if ( (folder = dynamic_cast<BtBookmarkFolder*>(childItem)) ) {
- subresult = folder->hasDescendant(childItem);
- }
-
- if (subresult == true) {
- qDebug() << "descendand child, return true";
- return true;
- }
- }
- qDebug() << "no child, return false";
- return false;
+bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
+ qDebug() << "BtBookmarkFolder::hasDescendant, this:" << this << "possible descendant:" << item;
+
+ if (this == item) {
+ qDebug() << "it's this, return true";
+ return true;
+ }
+ if (getChildList().indexOf(item) > -1) {
+ qDebug() << "direct child, return true";
+ return true;
+ }
+ foreach(QTreeWidgetItem* childItem, getChildList()) {
+ bool subresult = false;
+ BtBookmarkFolder* folder = 0;
+ if ( (folder = dynamic_cast<BtBookmarkFolder*>(childItem)) ) {
+ subresult = folder->hasDescendant(childItem);
+ }
+
+ if (subresult == true) {
+ qDebug() << "descendand child, return true";
+ return true;
+ }
+ }
+ qDebug() << "no child, return false";
+ return false;
}
-BtBookmarkFolder* BtBookmarkFolder::deepCopy()
-{
- qDebug() << "BtBookmarkFolder::deepCopy";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, this->text(0));
- foreach(QTreeWidgetItem* subitem, getChildList()) {
- if (BtBookmarkItem* bmItem = dynamic_cast<BtBookmarkItem*>(subitem)) {
- newFolder->addChild(new BtBookmarkItem(*bmItem));
- } else {
- if (BtBookmarkFolder* bmFolder = dynamic_cast<BtBookmarkFolder*>(subitem)) {
- newFolder->addChild(bmFolder->deepCopy());
- }
- }
- }
- newFolder->update();
- return newFolder;
+BtBookmarkFolder* BtBookmarkFolder::deepCopy() {
+ qDebug() << "BtBookmarkFolder::deepCopy";
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, this->text(0));
+ foreach(QTreeWidgetItem* subitem, getChildList()) {
+ if (BtBookmarkItem* bmItem = dynamic_cast<BtBookmarkItem*>(subitem)) {
+ newFolder->addChild(new BtBookmarkItem(*bmItem));
+ }
+ else {
+ if (BtBookmarkFolder* bmFolder = dynamic_cast<BtBookmarkFolder*>(subitem)) {
+ newFolder->addChild(bmFolder->deepCopy());
+ }
+ }
+ }
+ newFolder->update();
+ return newFolder;
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h b/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
index a659917..d00222b 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
@@ -15,37 +15,36 @@
#define CURRENT_SYNTAX_VERSION 1
-class BtBookmarkFolder : public BtBookmarkItemBase
-{
-public:
- friend class BtBookmarkLoader;
- BtBookmarkFolder(QTreeWidgetItem* parent, QString name);
- ~BtBookmarkFolder() {}
+class BtBookmarkFolder : public BtBookmarkItemBase {
+ public:
+ friend class BtBookmarkLoader;
+ BtBookmarkFolder(QTreeWidgetItem* parent, QString name);
+ ~BtBookmarkFolder() {}
- /** See the base class. */
- virtual bool enableAction(const MenuAction action);
+ /** See the base class. */
+ virtual bool enableAction(const MenuAction action);
- /** User gives a file from which to load items into this folder. */
- virtual void exportBookmarks();
- /** User gives a file to which items from this folder are saved. */
- virtual void importBookmarks();
+ /** User gives a file from which to load items into this folder. */
+ virtual void exportBookmarks();
+ /** User gives a file to which items from this folder are saved. */
+ virtual void importBookmarks();
- /** Creates a new folder under this. */
- void newSubFolder();
+ /** Creates a new folder under this. */
+ void newSubFolder();
- /** Returns a list of direct childs of this item. */
- QList<QTreeWidgetItem*> getChildList() const;
+ /** Returns a list of direct childs of this item. */
+ QList<QTreeWidgetItem*> getChildList() const;
- /** Returns true if the given item is this or a direct or indirect subitem of this. */
- bool hasDescendant(QTreeWidgetItem* item) const;
+ /** Returns true if the given item is this or a direct or indirect subitem of this. */
+ bool hasDescendant(QTreeWidgetItem* item) const;
- /** Creates a deep copy of this item. */
- BtBookmarkFolder* deepCopy();
+ /** Creates a deep copy of this item. */
+ BtBookmarkFolder* deepCopy();
- void rename();
- void update();
+ void rename();
+ void update();
- QString toolTip();
+ QString toolTip();
};
#endif
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
index 84473f7..ba9632e 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
@@ -25,139 +25,127 @@
BtBookmarkItem::BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description)
- :m_description(description),
- m_moduleName(module ? module->name() : QString::null)
-{
- if (((module && (module->type() == CSwordModuleInfo::Bible)) || (module->type() == CSwordModuleInfo::Commentary)) ) {
- CSwordVerseKey vk(0);
- vk.key(key);
- vk.setLocale("en");
- m_key = vk.key(); //the m_key member is always the english key!
- }
- else {
- m_key = key;
- };
-
- update();
+ : m_description(description),
+ m_moduleName(module ? module->name() : QString::null) {
+ if (((module && (module->type() == CSwordModuleInfo::Bible)) || (module->type() == CSwordModuleInfo::Commentary)) ) {
+ CSwordVerseKey vk(0);
+ vk.key(key);
+ vk.setLocale("en");
+ m_key = vk.key(); //the m_key member is always the english key!
+ }
+ else {
+ m_key = key;
+ };
+
+ update();
}
BtBookmarkItem::BtBookmarkItem(QTreeWidgetItem* parent)
- : BtBookmarkItemBase(parent)
-{}
+ : BtBookmarkItemBase(parent) {}
BtBookmarkItem::BtBookmarkItem(const BtBookmarkItem& other)
- : BtBookmarkItemBase(0),
- m_key(other.m_key),
- m_description(other.m_description),
- m_moduleName(other.m_moduleName)
-{
- update();
+ : BtBookmarkItemBase(0),
+ m_key(other.m_key),
+ m_description(other.m_description),
+ m_moduleName(other.m_moduleName) {
+ update();
}
-CSwordModuleInfo* BtBookmarkItem::module()
-{
- CSwordModuleInfo* const m = CPointers::backend()->findModuleByName(m_moduleName);
- return m;
+CSwordModuleInfo* BtBookmarkItem::module() {
+ CSwordModuleInfo* const m = CPointers::backend()->findModuleByName(m_moduleName);
+ return m;
}
-QString BtBookmarkItem::key()
-{
- const QString englishKeyName = englishKey();
- if (!module()) {
- return englishKeyName;
- }
+QString BtBookmarkItem::key() {
+ const QString englishKeyName = englishKey();
+ if (!module()) {
+ return englishKeyName;
+ }
- QString returnKeyName = englishKeyName;
- if ((module()->type() == CSwordModuleInfo::Bible) || (module()->type() == CSwordModuleInfo::Commentary)) {
- CSwordVerseKey vk(0);
- vk.key(englishKeyName);
- vk.setLocale(CPointers::backend()->booknameLanguage().toLatin1() );
+ QString returnKeyName = englishKeyName;
+ if ((module()->type() == CSwordModuleInfo::Bible) || (module()->type() == CSwordModuleInfo::Commentary)) {
+ CSwordVerseKey vk(0);
+ vk.key(englishKeyName);
+ vk.setLocale(CPointers::backend()->booknameLanguage().toLatin1() );
- returnKeyName = vk.key(); //the returned key is always in the currently set bookname language
- }
+ returnKeyName = vk.key(); //the returned key is always in the currently set bookname language
+ }
- return returnKeyName;
+ return returnKeyName;
}
-const QString& BtBookmarkItem::description()
-{
- return m_description;
+const QString& BtBookmarkItem::description() {
+ return m_description;
}
-void BtBookmarkItem::setDescription(QString text)
-{
- m_description = text;
+void BtBookmarkItem::setDescription(QString text) {
+ m_description = text;
}
-QString BtBookmarkItem::toolTip()
-{
- if (!module()) {
- return QString::null;
- }
-
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
- filterOptions.footnotes = false;
- filterOptions.scriptureReferences = false;
- CPointers::backend()->setFilterOptions(filterOptions);
-
- QString ret;
- boost::scoped_ptr<CSwordKey> k( CSwordKey::createInstance(module()) );
- k->key(this->key());
-
- const CLanguageMgr::Language* lang = module()->language();
- CBTConfig::FontSettingsPair fontPair = CBTConfig::get
- (lang);
-
- Q_ASSERT(k.get());
- if (fontPair.first) { //use a special font
- ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
- .arg(key())
- .arg(module()->name())
- .arg(description())
- ;
- }
- else {
- ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
- .arg(key())
- .arg(module()->name())
- .arg(description())
- ;
- }
-
- return ret;
+QString BtBookmarkItem::toolTip() {
+ if (!module()) {
+ return QString::null;
+ }
+
+ CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
+ filterOptions.footnotes = false;
+ filterOptions.scriptureReferences = false;
+ CPointers::backend()->setFilterOptions(filterOptions);
+
+ QString ret;
+ boost::scoped_ptr<CSwordKey> k( CSwordKey::createInstance(module()) );
+ k->key(this->key());
+
+ const CLanguageMgr::Language* lang = module()->language();
+ CBTConfig::FontSettingsPair fontPair = CBTConfig::get
+ (lang);
+
+ Q_ASSERT(k.get());
+ if (fontPair.first) { //use a special font
+ ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
+ .arg(key())
+ .arg(module()->name())
+ .arg(description())
+ ;
+ }
+ else {
+ ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
+ .arg(key())
+ .arg(module()->name())
+ .arg(description())
+ ;
+ }
+
+ return ret;
}
-bool BtBookmarkItem::enableAction(MenuAction action)
-{
- if (action == ChangeBookmark || (module() && (action == PrintBookmarks)) || action == DeleteEntries)
- return true;
+bool BtBookmarkItem::enableAction(MenuAction action) {
+ if (action == ChangeBookmark || (module() && (action == PrintBookmarks)) || action == DeleteEntries)
+ return true;
- return false;
+ return false;
}
-void BtBookmarkItem::rename()
-{
- bool ok = false;
- const QString newDescription = CInputDialog::getText(QObject::tr("Change description ..."), QObject::tr("Enter a new description for the chosen bookmark."), description(), &ok, treeWidget());
+void BtBookmarkItem::rename() {
+ bool ok = false;
+ const QString newDescription = CInputDialog::getText(QObject::tr("Change description ..."), QObject::tr("Enter a new description for the chosen bookmark."), description(), &ok, treeWidget());
- if (ok) {
- m_description = newDescription;
- update();
- }
+ if (ok) {
+ m_description = newDescription;
+ update();
+ }
}
-QString BtBookmarkItem::englishKey() const
-{
- return m_key;
+QString BtBookmarkItem::englishKey() const {
+ return m_key;
}
-void BtBookmarkItem::update()
-{
- qDebug() << "BtBookmarkItem::update";
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::bookmark::icon));
+void BtBookmarkItem::update() {
+ qDebug() << "BtBookmarkItem::update";
+ setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::bookmark::icon));
- const QString title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
- setText(0, title);
- setToolTip(0, toolTip());
+ const QString title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
+ setText(0, title);
+ setToolTip(0, toolTip());
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.h b/src/frontend/mainindex/bookmarks/btbookmarkitem.h
index 8529e23..1708627 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitem.h
@@ -18,50 +18,49 @@
class BtBookmarkFolder;
class CSwordModuleInfo;
-class BtBookmarkItem : public BtBookmarkItemBase
-{
-public:
- friend class BtBookmarkLoader;
+class BtBookmarkItem : public BtBookmarkItemBase {
+ public:
+ friend class BtBookmarkLoader;
- BtBookmarkItem(QTreeWidgetItem* parent);
+ BtBookmarkItem(QTreeWidgetItem* parent);
- /** Creates a bookmark with module, key and description. */
- BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description);
+ /** Creates a bookmark with module, key and description. */
+ BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description);
- /** Creates a copy. */
- BtBookmarkItem(const BtBookmarkItem& other);
+ /** Creates a copy. */
+ BtBookmarkItem(const BtBookmarkItem& other);
- ~BtBookmarkItem() {}
+ ~BtBookmarkItem() {}
- /** Returns the used module, 0 if there is no such module. */
- CSwordModuleInfo* module();
+ /** Returns the used module, 0 if there is no such module. */
+ CSwordModuleInfo* module();
- /** Returns the used key. */
- QString key();
+ /** Returns the used key. */
+ QString key();
- /** Returns the used description. */
- const QString& description();
- /** Sets the description text for this bookmark. */
- virtual void setDescription(QString text);
+ /** Returns the used description. */
+ const QString& description();
+ /** Sets the description text for this bookmark. */
+ virtual void setDescription(QString text);
- /** Returns a tooltip for this bookmark. */
- virtual QString toolTip();
+ /** Returns a tooltip for this bookmark. */
+ virtual QString toolTip();
- /** Returns whether the action is supported by this item. */
- virtual bool enableAction(MenuAction action);
+ /** Returns whether the action is supported by this item. */
+ virtual bool enableAction(MenuAction action);
- /** Changes this bookmark. */
- virtual void rename();
+ /** Changes this bookmark. */
+ virtual void rename();
- void update();
+ void update();
-private:
- /** Returns the english key.*/
- QString englishKey() const;
+ private:
+ /** Returns the english key.*/
+ QString englishKey() const;
- QString m_key;
- QString m_description;
- QString m_moduleName;
+ QString m_key;
+ QString m_description;
+ QString m_moduleName;
};
#endif
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
index bd5ae13..a4270a8 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
@@ -13,29 +13,26 @@
#include <QTreeWidgetItem>
#include <QDropEvent>
-BtBookmarkItemBase::BtBookmarkItemBase()
-{}
+BtBookmarkItemBase::BtBookmarkItemBase() {}
BtBookmarkItemBase::BtBookmarkItemBase(QTreeWidgetItem* parent)
- : QTreeWidgetItem(parent)
-{}
+ : QTreeWidgetItem(parent) {}
-CBookmarkIndex* BtBookmarkItemBase::bookmarkWidget() const
-{
- return dynamic_cast<CBookmarkIndex*>(treeWidget());
+CBookmarkIndex* BtBookmarkItemBase::bookmarkWidget() const {
+ return dynamic_cast<CBookmarkIndex*>(treeWidget());
}
// void BtBookmarkItemBase::dropped(QDropEvent* e)
// {
-//
+//
// }
-//
+//
// void BtBookmarkItemBase::addPreviousSibling(BtBookmarkItemBase* item)
// {
-//
+//
// }
-//
+//
// void BtBookmarkItemBase::addNextSibling(BtBookmarkItemBase* item)
// {
-//
+//
// }
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h b/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
index 1e486e6..326f760 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
@@ -19,43 +19,42 @@
class CBookmarkIndex;
-class BtBookmarkItemBase : public QTreeWidgetItem
-{
-public:
+class BtBookmarkItemBase : public QTreeWidgetItem {
+ public:
- enum MenuAction {
- NewFolder = 0,
- ChangeFolder,
+ enum MenuAction {
+ NewFolder = 0,
+ ChangeFolder,
- ChangeBookmark,
- ImportBookmarks,
- ExportBookmarks,
- PrintBookmarks,
+ ChangeBookmark,
+ ImportBookmarks,
+ ExportBookmarks,
+ PrintBookmarks,
- DeleteEntries,
+ DeleteEntries,
- ActionBegin = NewFolder,
- ActionEnd = DeleteEntries
- };
+ ActionBegin = NewFolder,
+ ActionEnd = DeleteEntries
+ };
- /** Where to drop/create item(s): above, below or inside an item.*/
- enum Location {Above, Below, Inside};
+ /** Where to drop/create item(s): above, below or inside an item.*/
+ enum Location {Above, Below, Inside};
- BtBookmarkItemBase();
- BtBookmarkItemBase(QTreeWidgetItem* parent);
- virtual ~BtBookmarkItemBase() {}
+ BtBookmarkItemBase();
+ BtBookmarkItemBase(QTreeWidgetItem* parent);
+ virtual ~BtBookmarkItemBase() {}
- virtual QString toolTip() = 0;
- virtual CBookmarkIndex* bookmarkWidget() const;
+ virtual QString toolTip() = 0;
+ virtual CBookmarkIndex* bookmarkWidget() const;
- /** Returns true if the given action should be enabled in the popup menu. */
- virtual bool enableAction( MenuAction action ) = 0;
+ /** Returns true if the given action should be enabled in the popup menu. */
+ virtual bool enableAction( MenuAction action ) = 0;
- /** Rename the item. */
- virtual void rename() = 0;
+ /** Rename the item. */
+ virtual void rename() = 0;
- /** Update the item (icon etc.) after creating or changing it. */
- virtual void update() {}
+ /** Update the item (icon etc.) after creating or changing it. */
+ virtual void update() {}
};
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp b/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
index 3e70dbe..f6f3913 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
@@ -28,147 +28,143 @@
#define CURRENT_SYNTAX_VERSION 1
-QList<QTreeWidgetItem*> BtBookmarkLoader::loadTree(QString fileName)
-{
- qDebug() << "BtBookmarkLoader::loadTree";
- QList<QTreeWidgetItem*> itemList;
-
- QDomDocument doc;
- doc.setContent(loadXmlFromFile(fileName));
-
- //bookmarkfolder::loadBookmarksFromXML()
-
- QDomElement document = doc.documentElement();
- if( document.tagName() != "SwordBookmarks" ) {
- qWarning("Not a BibleTime Bookmark XML file");
- return QList<QTreeWidgetItem*>();
- }
-
- QDomElement child = document.firstChild().toElement();
-
- while ( !child.isNull() && child.parentNode() == document) {
- qDebug() << "BtBookmarkLoader::loadTree while start";
- QTreeWidgetItem* i = handleXmlElement(child, 0);
- itemList.append(i);
- if (!child.nextSibling().isNull()) {
- child = child.nextSibling().toElement();
- } else {
- child = QDomElement(); //null
- }
-
- }
-
- return itemList;
+QList<QTreeWidgetItem*> BtBookmarkLoader::loadTree(QString fileName) {
+ qDebug() << "BtBookmarkLoader::loadTree";
+ QList<QTreeWidgetItem*> itemList;
+
+ QDomDocument doc;
+ doc.setContent(loadXmlFromFile(fileName));
+
+ //bookmarkfolder::loadBookmarksFromXML()
+
+ QDomElement document = doc.documentElement();
+ if ( document.tagName() != "SwordBookmarks" ) {
+ qWarning("Not a BibleTime Bookmark XML file");
+ return QList<QTreeWidgetItem*>();
+ }
+
+ QDomElement child = document.firstChild().toElement();
+
+ while ( !child.isNull() && child.parentNode() == document) {
+ qDebug() << "BtBookmarkLoader::loadTree while start";
+ QTreeWidgetItem* i = handleXmlElement(child, 0);
+ itemList.append(i);
+ if (!child.nextSibling().isNull()) {
+ child = child.nextSibling().toElement();
+ }
+ else {
+ child = QDomElement(); //null
+ }
+
+ }
+
+ return itemList;
}
-QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeWidgetItem* parent)
-{
- qDebug() << "BtBookmarkLoader::handleXmlElement";
- QTreeWidgetItem* newItem = 0;
- if (element.tagName() == "Folder") {
- qDebug() << "BtBookmarkLoader::handleXmlElement: found folder";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(parent, QString());
- if (element.hasAttribute("caption")) {
- newFolder->setText(0, element.attribute("caption"));
- }
- QDomNodeList childList = element.childNodes();
- for (unsigned int i = 0; i < childList.length(); i++) {
- qDebug() << "BtBookmarkLoader::handleXmlElement: go through child list of folder";
- QDomElement newElement = childList.at(i).toElement();
- QTreeWidgetItem* newChildItem = handleXmlElement(newElement, newFolder);
- newFolder->addChild(newChildItem);
- }
- newFolder->update();
- newItem = newFolder;
- }
- else if (element.tagName() == "Bookmark") {
- qDebug() << "BtBookmarkLoader::handleXmlElement: found bookmark";
- BtBookmarkItem* newBookmarkItem = new BtBookmarkItem(parent);
- if (element.hasAttribute("modulename")) {
- //we use the name in all cases, even if the module isn't installed anymore
- newBookmarkItem->m_moduleName = element.attribute("modulename");
- }
- if (element.hasAttribute("key")) {
- newBookmarkItem->m_key = element.attribute("key");
- }
- if (element.hasAttribute("description")) {
- newBookmarkItem->m_description = element.attribute("description");
- }
- newBookmarkItem->update();
- newItem = newBookmarkItem;
- }
- qDebug() << "BtBookmarkLoader::handleXmlElement: return new item";
- return newItem;
+QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeWidgetItem* parent) {
+ qDebug() << "BtBookmarkLoader::handleXmlElement";
+ QTreeWidgetItem* newItem = 0;
+ if (element.tagName() == "Folder") {
+ qDebug() << "BtBookmarkLoader::handleXmlElement: found folder";
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(parent, QString());
+ if (element.hasAttribute("caption")) {
+ newFolder->setText(0, element.attribute("caption"));
+ }
+ QDomNodeList childList = element.childNodes();
+ for (unsigned int i = 0; i < childList.length(); i++) {
+ qDebug() << "BtBookmarkLoader::handleXmlElement: go through child list of folder";
+ QDomElement newElement = childList.at(i).toElement();
+ QTreeWidgetItem* newChildItem = handleXmlElement(newElement, newFolder);
+ newFolder->addChild(newChildItem);
+ }
+ newFolder->update();
+ newItem = newFolder;
+ }
+ else if (element.tagName() == "Bookmark") {
+ qDebug() << "BtBookmarkLoader::handleXmlElement: found bookmark";
+ BtBookmarkItem* newBookmarkItem = new BtBookmarkItem(parent);
+ if (element.hasAttribute("modulename")) {
+ //we use the name in all cases, even if the module isn't installed anymore
+ newBookmarkItem->m_moduleName = element.attribute("modulename");
+ }
+ if (element.hasAttribute("key")) {
+ newBookmarkItem->m_key = element.attribute("key");
+ }
+ if (element.hasAttribute("description")) {
+ newBookmarkItem->m_description = element.attribute("description");
+ }
+ newBookmarkItem->update();
+ newItem = newBookmarkItem;
+ }
+ qDebug() << "BtBookmarkLoader::handleXmlElement: return new item";
+ return newItem;
}
-QString BtBookmarkLoader::loadXmlFromFile(QString fileName)
-{
- if (fileName.isNull()) {
- fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
- }
- QFile file(fileName);
- if (!file.exists())
- return QString();
-
- QString xml;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t;
- t.setAutoDetectUnicode(false);
- t.setCodec(QTextCodec::codecForName("UTF-8"));
- t.setDevice(&file);
- xml = t.readAll();
- file.close();
- }
- return xml;
+QString BtBookmarkLoader::loadXmlFromFile(QString fileName) {
+ if (fileName.isNull()) {
+ fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
+ }
+ QFile file(fileName);
+ if (!file.exists())
+ return QString();
+
+ QString xml;
+ if (file.open(QIODevice::ReadOnly)) {
+ QTextStream t;
+ t.setAutoDetectUnicode(false);
+ t.setCodec(QTextCodec::codecForName("UTF-8"));
+ t.setDevice(&file);
+ xml = t.readAll();
+ file.close();
+ }
+ return xml;
}
-void BtBookmarkLoader::saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString fileName, bool forceOverwrite)
-{
- Q_ASSERT(rootItem);
- if (fileName.isNull()) {
- fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
- }
+void BtBookmarkLoader::saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString fileName, bool forceOverwrite) {
+ Q_ASSERT(rootItem);
+ if (fileName.isNull()) {
+ fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
+ }
- QDomDocument doc("DOC");
- doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
+ QDomDocument doc("DOC");
+ doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
- QDomElement content = doc.createElement("SwordBookmarks");
- content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
- doc.appendChild(content);
+ QDomElement content = doc.createElement("SwordBookmarks");
+ content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
+ doc.appendChild(content);
- //append the XML nodes of all child items
+ //append the XML nodes of all child items
- for (int i = 0; i < rootItem->childCount(); i++) {
- saveItem(rootItem->child(i), content);
- }
- CToolClass::savePlainFile(fileName, doc.toString(), forceOverwrite, QTextCodec::codecForName("UTF-8"));
+ for (int i = 0; i < rootItem->childCount(); i++) {
+ saveItem(rootItem->child(i), content);
+ }
+ CToolClass::savePlainFile(fileName, doc.toString(), forceOverwrite, QTextCodec::codecForName("UTF-8"));
}
-void BtBookmarkLoader::saveItem(QTreeWidgetItem* item, QDomElement& parentElement)
-{
- BtBookmarkFolder* folderItem = 0;
- BtBookmarkItem* bookmarkItem = 0;
+void BtBookmarkLoader::saveItem(QTreeWidgetItem* item, QDomElement& parentElement) {
+ BtBookmarkFolder* folderItem = 0;
+ BtBookmarkItem* bookmarkItem = 0;
- if ((folderItem = dynamic_cast<BtBookmarkFolder*>(item))) {
- QDomElement elem = parentElement.ownerDocument().createElement("Folder");
- elem.setAttribute("caption", folderItem->text(0));
+ if ((folderItem = dynamic_cast<BtBookmarkFolder*>(item))) {
+ QDomElement elem = parentElement.ownerDocument().createElement("Folder");
+ elem.setAttribute("caption", folderItem->text(0));
- parentElement.appendChild(elem);
+ parentElement.appendChild(elem);
- for (int i = 0; i < folderItem->childCount(); i++) {
- saveItem(folderItem->child(i), elem);
- }
- }
- else if ((bookmarkItem = dynamic_cast<BtBookmarkItem*>(item))) {
- QDomElement elem = parentElement.ownerDocument().createElement("Bookmark");
+ for (int i = 0; i < folderItem->childCount(); i++) {
+ saveItem(folderItem->child(i), elem);
+ }
+ }
+ else if ((bookmarkItem = dynamic_cast<BtBookmarkItem*>(item))) {
+ QDomElement elem = parentElement.ownerDocument().createElement("Bookmark");
- elem.setAttribute("key", bookmarkItem->englishKey());
- elem.setAttribute("description", bookmarkItem->description());
- elem.setAttribute("modulename", bookmarkItem->m_moduleName);
- elem.setAttribute("moduledescription", bookmarkItem->module() ? bookmarkItem->module()->config(CSwordModuleInfo::Description) : QString::null);
+ elem.setAttribute("key", bookmarkItem->englishKey());
+ elem.setAttribute("description", bookmarkItem->description());
+ elem.setAttribute("modulename", bookmarkItem->m_moduleName);
+ elem.setAttribute("moduledescription", bookmarkItem->module() ? bookmarkItem->module()->config(CSwordModuleInfo::Description) : QString::null);
- parentElement.appendChild(elem);
- }
+ parentElement.appendChild(elem);
+ }
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.h b/src/frontend/mainindex/bookmarks/btbookmarkloader.h
index 3ae0bb6..7a981d9 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkloader.h
@@ -22,26 +22,25 @@ class QTreeWidgetItem;
/**
* Class for loading and saving bookmarks.
*/
-class BtBookmarkLoader
-{
-public:
- /** Loads a list of items (with subitem trees) from a named file
- * or from the default bookmarks file. */
- QList<QTreeWidgetItem*> loadTree(QString fileName=QString::null);
-
- /** Takes one item and saves the tree which is under it to a named file
- * or to the default bookmarks file, asking the user about overwriting if necessary. */
- void saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString fileName=QString::null, bool forceOverwrite=true);
-
-private:
- /** Create a new item from a document element. */
- QTreeWidgetItem* handleXmlElement(QDomElement& element, QTreeWidgetItem* parent);
-
- /** Writes one item to a document element. */
- void saveItem(QTreeWidgetItem* item, QDomElement& parentElement);
-
- /** Loads a bookmark XML document from a named file or from the default bookmarks file. */
- QString loadXmlFromFile(QString fileName=QString::null);
+class BtBookmarkLoader {
+ public:
+ /** Loads a list of items (with subitem trees) from a named file
+ * or from the default bookmarks file. */
+ QList<QTreeWidgetItem*> loadTree(QString fileName = QString::null);
+
+ /** Takes one item and saves the tree which is under it to a named file
+ * or to the default bookmarks file, asking the user about overwriting if necessary. */
+ void saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString fileName = QString::null, bool forceOverwrite = true);
+
+ private:
+ /** Create a new item from a document element. */
+ QTreeWidgetItem* handleXmlElement(QDomElement& element, QTreeWidgetItem* parent);
+
+ /** Writes one item to a document element. */
+ void saveItem(QTreeWidgetItem* item, QDomElement& parentElement);
+
+ /** Loads a bookmark XML document from a named file or from the default bookmarks file. */
+ QString loadXmlFromFile(QString fileName = QString::null);
};
#endif
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
index 7405fd3..6d35793 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
@@ -55,638 +55,636 @@
#include <QDebug>
CBookmarkIndex::CBookmarkIndex(QWidget *parent)
- : QTreeWidget(parent),
- m_magTimer(this),
- m_previousEventItem(0)
-{
- setMouseTracking(true);
- m_magTimer.setSingleShot(true);
- m_magTimer.setInterval(CBTConfig::get(CBTConfig::magDelay));
- setContextMenuPolicy(Qt::CustomContextMenu);
- initView();
- initConnections();
- initTree();
+ : QTreeWidget(parent),
+ m_magTimer(this),
+ m_previousEventItem(0) {
+ setMouseTracking(true);
+ m_magTimer.setSingleShot(true);
+ m_magTimer.setInterval(CBTConfig::get(CBTConfig::magDelay));
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ initView();
+ initConnections();
+ initTree();
}
-CBookmarkIndex::~CBookmarkIndex()
-{
- saveBookmarks();
+CBookmarkIndex::~CBookmarkIndex() {
+ saveBookmarks();
}
/** Initializes the view. */
-void CBookmarkIndex::initView()
-{
- //qDebug("CBookmarkIndex::initView");
-
- header()->hide();
-
- setFocusPolicy(Qt::WheelFocus);
-
- //d'n'd related settings
- setDragEnabled( true );
- setAcceptDrops( true );
- setDragDropMode(QAbstractItemView::DragDrop);
- viewport()->setAcceptDrops(true);
- setAutoScroll(true);
- setAutoExpandDelay(800);
-
- setItemsExpandable(true);
- setRootIsDecorated(true);
- setAllColumnsShowFocus(true);
- setSelectionMode(QAbstractItemView::ExtendedSelection);
-
- //setup the popup menu
- m_popup = new QMenu(viewport());
- m_popup->setTitle(tr("Bookmarks"));
-
- m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
- m_actions.changeFolder = newQAction(tr("Rename folder"),CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);
-
- m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
- m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
- m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
- m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);
-
- m_actions.deleteEntries = newQAction(tr("Remove selected items..."), CResMgr::mainIndex::deleteItems::icon, 0, this, SLOT(deleteEntries()), this);
-
-
- //fill the popup menu itself
- m_popup->addAction(m_actions.newFolder);
- m_popup->addAction(m_actions.changeFolder);
- QAction* separator = new QAction(this);
- separator->setSeparator(true);
- m_popup->addAction(separator);
- m_popup->addAction(m_actions.changeBookmark);
- m_popup->addAction(m_actions.importBookmarks);
- m_popup->addAction(m_actions.exportBookmarks);
- m_popup->addAction(m_actions.printBookmarks);
- separator = new QAction(this);
- separator->setSeparator(true);
- m_popup->addAction(separator);
- m_popup->addAction(m_actions.deleteEntries);
-
- //qDebug("CBookmarkIndex::initView end");
+void CBookmarkIndex::initView() {
+ //qDebug("CBookmarkIndex::initView");
+
+ header()->hide();
+
+ setFocusPolicy(Qt::WheelFocus);
+
+ //d'n'd related settings
+ setDragEnabled( true );
+ setAcceptDrops( true );
+ setDragDropMode(QAbstractItemView::DragDrop);
+ viewport()->setAcceptDrops(true);
+ setAutoScroll(true);
+ setAutoExpandDelay(800);
+
+ setItemsExpandable(true);
+ setRootIsDecorated(true);
+ setAllColumnsShowFocus(true);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ //setup the popup menu
+ m_popup = new QMenu(viewport());
+ m_popup->setTitle(tr("Bookmarks"));
+
+ m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
+ m_actions.changeFolder = newQAction(tr("Rename folder"), CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);
+
+ m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
+ m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
+ m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
+ m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);
+
+ m_actions.deleteEntries = newQAction(tr("Remove selected items..."), CResMgr::mainIndex::deleteItems::icon, 0, this, SLOT(deleteEntries()), this);
+
+
+ //fill the popup menu itself
+ m_popup->addAction(m_actions.newFolder);
+ m_popup->addAction(m_actions.changeFolder);
+ QAction* separator = new QAction(this);
+ separator->setSeparator(true);
+ m_popup->addAction(separator);
+ m_popup->addAction(m_actions.changeBookmark);
+ m_popup->addAction(m_actions.importBookmarks);
+ m_popup->addAction(m_actions.exportBookmarks);
+ m_popup->addAction(m_actions.printBookmarks);
+ separator = new QAction(this);
+ separator->setSeparator(true);
+ m_popup->addAction(separator);
+ m_popup->addAction(m_actions.deleteEntries);
+
+ //qDebug("CBookmarkIndex::initView end");
}
/** Convenience function for creating a new QAction.
* Should be replaced with something better; it was easier to make a new function
* 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);
- QObject::connect(action, SIGNAL(triggered()), receiver, slot);
- return action;
+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);
+ QObject::connect(action, SIGNAL(triggered()), receiver, slot);
+ return action;
}
/** Initialize the SIGNAL<->SLOT connections */
-void CBookmarkIndex::initConnections()
-{
- //qDebug("CBookmarkIndex::initConnections");
- bool ok;
- ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
- Q_ASSERT(ok);
- ok = connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
- SLOT(contextMenu(const QPoint&)));
- Q_ASSERT(ok);
- ok = connect(&m_magTimer, SIGNAL(timeout()), this, SLOT(magTimeout()));
- Q_ASSERT(ok);
- ok = connect(this, SIGNAL(itemEntered(QTreeWidgetItem*, int)), this, SLOT(slotItemEntered(QTreeWidgetItem*, int)) );
- Q_ASSERT(ok);
+void CBookmarkIndex::initConnections() {
+ //qDebug("CBookmarkIndex::initConnections");
+ bool ok;
+ ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
+ SLOT(contextMenu(const QPoint&)));
+ Q_ASSERT(ok);
+ ok = connect(&m_magTimer, SIGNAL(timeout()), this, SLOT(magTimeout()));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(itemEntered(QTreeWidgetItem*, int)), this, SLOT(slotItemEntered(QTreeWidgetItem*, int)) );
+ Q_ASSERT(ok);
}
/**
* Hack to get single click and selection working. See slotExecuted.
*/
-void CBookmarkIndex::mouseReleaseEvent(QMouseEvent* event)
-{
- //qDebug("CBookmarkIndex::mouseReleaseEvent");
- m_mouseReleaseEventModifiers = event->modifiers();
- QTreeWidget::mouseReleaseEvent(event);
+void CBookmarkIndex::mouseReleaseEvent(QMouseEvent* event) {
+ //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");
-
- //HACK: checking the modifier keys from the last mouseReleaseEvent
- //depends on executing order: mouseReleaseEvent first, then itemClicked signal
- int modifiers = m_mouseReleaseEventModifiers;
- m_mouseReleaseEventModifiers = Qt::NoModifier;
- if (modifiers != Qt::NoModifier) {
- return;
- }
-
- BtBookmarkItemBase* btItem = dynamic_cast<BtBookmarkItemBase*>(i);
- if (!btItem) {
- return;
- }
-
- BtBookmarkFolder* folderItem = 0;
- BtBookmarkItem* bookmarkItem = 0;
- if ((folderItem = dynamic_cast<BtBookmarkFolder*>(btItem))) {
- i->setExpanded( !i->isExpanded() );
- }
- else if (( bookmarkItem = dynamic_cast<BtBookmarkItem*>(btItem) )) { //clicked on a bookmark
- if (CSwordModuleInfo* mod = bookmarkItem->module()) {
- QList<CSwordModuleInfo*> modules;
- modules.append(mod);
- emit createReadDisplayWindow(modules, bookmarkItem->key());
- }
- }
+void CBookmarkIndex::slotExecuted( QTreeWidgetItem* i ) {
+ qDebug("CBookmarkIndex::slotExecuted");
+
+ //HACK: checking the modifier keys from the last mouseReleaseEvent
+ //depends on executing order: mouseReleaseEvent first, then itemClicked signal
+ int modifiers = m_mouseReleaseEventModifiers;
+ m_mouseReleaseEventModifiers = Qt::NoModifier;
+ if (modifiers != Qt::NoModifier) {
+ return;
+ }
+
+ BtBookmarkItemBase* btItem = dynamic_cast<BtBookmarkItemBase*>(i);
+ if (!btItem) {
+ return;
+ }
+
+ BtBookmarkFolder* folderItem = 0;
+ BtBookmarkItem* bookmarkItem = 0;
+ if ((folderItem = dynamic_cast<BtBookmarkFolder*>(btItem))) {
+ i->setExpanded( !i->isExpanded() );
+ }
+ else if (( bookmarkItem = dynamic_cast<BtBookmarkItem*>(btItem) )) { //clicked on a bookmark
+ if (CSwordModuleInfo* mod = bookmarkItem->module()) {
+ QList<CSwordModuleInfo*> modules;
+ modules.append(mod);
+ emit createReadDisplayWindow(modules, bookmarkItem->key());
+ }
+ }
}
/** Creates a drag mime data object for the current selection. */
-QMimeData* CBookmarkIndex::dragObject()
-{
- BTMimeData::ItemList dndItems;
- BTMimeData* mimeData = new BTMimeData;
-
- foreach( QTreeWidgetItem* widgetItem, selectedItems() ) {
- if (!widgetItem)
- break;
- if (dynamic_cast<BtBookmarkItemBase*>(widgetItem)) {
- if (BtBookmarkItem* bookmark = dynamic_cast<BtBookmarkItem*>( widgetItem )) {
- //take care of bookmarks which have no valid module any more, e.g. if it was uninstalled
- const QString moduleName = bookmark->module() ? bookmark->module()->name() : QString::null;
- mimeData->appendBookmark(moduleName, bookmark->key(), bookmark->description());
- }
- }
- }
- return mimeData;
+QMimeData* CBookmarkIndex::dragObject() {
+ BTMimeData::ItemList dndItems;
+ BTMimeData* mimeData = new BTMimeData;
+
+ foreach( QTreeWidgetItem* widgetItem, selectedItems() ) {
+ if (!widgetItem)
+ break;
+ if (dynamic_cast<BtBookmarkItemBase*>(widgetItem)) {
+ if (BtBookmarkItem* bookmark = dynamic_cast<BtBookmarkItem*>( widgetItem )) {
+ //take care of bookmarks which have no valid module any more, e.g. if it was uninstalled
+ const QString moduleName = bookmark->module() ? bookmark->module()->name() : QString::null;
+ mimeData->appendBookmark(moduleName, bookmark->key(), bookmark->description());
+ }
+ }
+ }
+ return mimeData;
}
-void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event )
-{
- //qDebug("CBookmarkIndex::dragEnterEvent");
- setState(QAbstractItemView::DraggingState);
- QTreeWidget::dragEnterEvent(event);
- if (event->source() == this || event->mimeData()->hasFormat("BibleTime/Bookmark")) {
- event->acceptProposedAction();
- }
+void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event ) {
+ //qDebug("CBookmarkIndex::dragEnterEvent");
+ setState(QAbstractItemView::DraggingState);
+ QTreeWidget::dragEnterEvent(event);
+ if (event->source() == this || event->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ event->acceptProposedAction();
+ }
}
-void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event )
-{
- //qDebug("CBookmarkIndex::dragMoveEvent");
+void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event ) {
+ //qDebug("CBookmarkIndex::dragMoveEvent");
- // do this first, otherwise the event may be ignored
- QTreeWidget::dragMoveEvent(event);
+ // do this first, otherwise the event may be ignored
+ QTreeWidget::dragMoveEvent(event);
- event->acceptProposedAction();
- event->accept();
+ event->acceptProposedAction();
+ event->accept();
+
+ // do this to paint the arrow
+ m_dragMovementPosition = event->pos();
+ viewport()->update();
- // do this to paint the arrow
- m_dragMovementPosition = event->pos();
- viewport()->update();
-
}
-void CBookmarkIndex::dragLeaveEvent( QDragLeaveEvent* )
-{
- qDebug("CBookmarkIndex::dragLeaveEvent");
- setState(QAbstractItemView::NoState); // not dragging anymore
- viewport()->update(); // clear the arrow
+void CBookmarkIndex::dragLeaveEvent( QDragLeaveEvent* ) {
+ qDebug("CBookmarkIndex::dragLeaveEvent");
+ setState(QAbstractItemView::NoState); // not dragging anymore
+ viewport()->update(); // clear the arrow
}
-void CBookmarkIndex::paintEvent(QPaintEvent* event)
-{
- static QPixmap pix;
- static int halfPixHeight;
- static bool arrowInitialized = false;
-
- // Initialize the static variables, including the arrow pixmap
- if (!arrowInitialized) {
- arrowInitialized = true;
- int arrowSize = CToolClass::mWidth(this, 1);
- QString fileName;
- if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.svg")) {
- fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.svg");
- } else {
- if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.png")) {
- fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.png");
- } else {
- qWarning() << "Picture file pointing_arrow.svg or .png not found!";
- }
- }
-
- pix = QPixmap(fileName);
- pix = pix.scaled(arrowSize, arrowSize, Qt::KeepAspectRatioByExpanding);
- halfPixHeight = pix.height()/2;
- }
-
- // Do the normal painting first
- QTreeWidget::paintEvent(event);
-
- // Paint the arrow if the drag is going on
- if (QAbstractItemView::DraggingState == state()) {
- bool rtol = QApplication::isRightToLeft();
-
- QPainter painter(this->viewport());
- QTreeWidgetItem* item = itemAt(m_dragMovementPosition);
- bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
- bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);
-
- // Find the place for the arrow
- QRect rect = visualItemRect(item);
- int xCoord = rtol ? rect.right() : rect.left();
- int yCoord;
- if (isFolder) {
- if (m_dragMovementPosition.y() > rect.bottom() - (2* rect.height()/3) ) {
- yCoord = rect.bottom() - halfPixHeight; // bottom
- xCoord = rtol ? (xCoord - indentation()) : (xCoord + indentation());
- } else {
- yCoord = rect.top() - halfPixHeight - 1; // top
- }
-
- } else {
- if (isBookmark) {
- if (m_dragMovementPosition.y() > rect.bottom() - rect.height()/2) {
- yCoord = rect.bottom() - halfPixHeight; // bottom
- } else {
- yCoord = rect.top() - halfPixHeight - 1; // top
- }
- } else {
- if (item) { // the extra item
- yCoord = rect.top() - halfPixHeight - 1;
- } else { // empty area
- rect = visualItemRect(m_extraItem);
- yCoord = rect.top() - halfPixHeight - 1;
- xCoord = rtol ? rect.right() : rect.left();
- }
- }
- }
-
- painter.drawPixmap(xCoord, yCoord, pix);
- }
+void CBookmarkIndex::paintEvent(QPaintEvent* event) {
+ static QPixmap pix;
+ static int halfPixHeight;
+ static bool arrowInitialized = false;
+
+ // Initialize the static variables, including the arrow pixmap
+ if (!arrowInitialized) {
+ arrowInitialized = true;
+ int arrowSize = CToolClass::mWidth(this, 1);
+ QString fileName;
+ if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.svg")) {
+ fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.svg");
+ }
+ else {
+ if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.png")) {
+ fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.png");
+ }
+ else {
+ qWarning() << "Picture file pointing_arrow.svg or .png not found!";
+ }
+ }
+
+ pix = QPixmap(fileName);
+ pix = pix.scaled(arrowSize, arrowSize, Qt::KeepAspectRatioByExpanding);
+ halfPixHeight = pix.height() / 2;
+ }
+
+ // Do the normal painting first
+ QTreeWidget::paintEvent(event);
+
+ // Paint the arrow if the drag is going on
+ if (QAbstractItemView::DraggingState == state()) {
+ bool rtol = QApplication::isRightToLeft();
+
+ QPainter painter(this->viewport());
+ QTreeWidgetItem* item = itemAt(m_dragMovementPosition);
+ bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
+ bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);
+
+ // Find the place for the arrow
+ QRect rect = visualItemRect(item);
+ int xCoord = rtol ? rect.right() : rect.left();
+ int yCoord;
+ if (isFolder) {
+ if (m_dragMovementPosition.y() > rect.bottom() - (2* rect.height() / 3) ) {
+ yCoord = rect.bottom() - halfPixHeight; // bottom
+ xCoord = rtol ? (xCoord - indentation()) : (xCoord + indentation());
+ }
+ else {
+ yCoord = rect.top() - halfPixHeight - 1; // top
+ }
+
+ }
+ else {
+ if (isBookmark) {
+ if (m_dragMovementPosition.y() > rect.bottom() - rect.height() / 2) {
+ yCoord = rect.bottom() - halfPixHeight; // bottom
+ }
+ else {
+ yCoord = rect.top() - halfPixHeight - 1; // top
+ }
+ }
+ else {
+ if (item) { // the extra item
+ yCoord = rect.top() - halfPixHeight - 1;
+ }
+ else { // empty area
+ rect = visualItemRect(m_extraItem);
+ yCoord = rect.top() - halfPixHeight - 1;
+ xCoord = rtol ? rect.right() : rect.left();
+ }
+ }
+ }
+
+ painter.drawPixmap(xCoord, yCoord, pix);
+ }
}
-void CBookmarkIndex::dropEvent( QDropEvent* event )
-{
- qDebug("CBookmarkIndex::dropEvent");
-
- //setState(QAbstractItemView::NoState);
- // Try to prevent annoying timed autocollapsing. Remember to disconnect before return.
- QObject::connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
- QTreeWidgetItem* item = itemAt(event->pos());
- QTreeWidgetItem* parentItem = 0;
- int indexUnderParent = 0;
-
- // Find the place where the drag is dropped
- if (item) {
- qDebug()<<"there was item";
-
- QRect rect = visualItemRect(item);
- bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
- bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);
-
- if (isFolder) { // item is a folder
- qDebug()<<"item was folder";
- if (event->pos().y() > rect.bottom() - (2* rect.height()/3) ) {
- parentItem = item;
- } else {
- parentItem = item->parent();
- if (!parentItem) {
- parentItem = invisibleRootItem();
- }
- qDebug()<<"item:" << item << "parent:" << parentItem;
- indexUnderParent = parentItem->indexOfChild(item); // before the current folder
- }
- } else {
- if (isBookmark) { // item is a bookmark
- qDebug()<<"item was bookmark";
- parentItem = item->parent();
- if (!parentItem) {
- parentItem = invisibleRootItem();
- }
- indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
- if (event->pos().y() > rect.bottom() - rect.height()/2) {
- indexUnderParent++; // after the current bookmark
- }
- } else { // item is the extra item
- parentItem = item->parent();
- if (!parentItem) {
- parentItem = invisibleRootItem();
- }
- indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
- }
- }
-
- } else { // no item under event point: drop to the end
- qDebug()<<"there was no item";
- parentItem = invisibleRootItem();
- indexUnderParent = parentItem->childCount()-1;
- }
-
-
- if ( event->source() == this ) {
- qDebug("dropping internal drag");
- event->accept();
-
- bool bookmarksOnly = true;
- bool targetIncluded = false;
- bool moreThanOneFolder = false;
-
- QList<QTreeWidgetItem*> newItems = addItemsToDropTree(parentItem, bookmarksOnly, targetIncluded, moreThanOneFolder);
-
- if (moreThanOneFolder) {
- QToolTip::showText(QCursor::pos(), tr("Can drop only bookmarks or one folder"));
- QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
- return;
- }
- if (targetIncluded) {
- QToolTip::showText(QCursor::pos(), tr("Can't drop folder into the folder itself or into its subfolder"));
- QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
- return;
- }
- // Ask whether to copy or move with a popup menu
-
- QMenu* dropPopupMenu = new QMenu(this);
- QAction* copy = dropPopupMenu->addAction(tr("Copy"));
- QAction* move = dropPopupMenu->addAction(tr("Move"));
- QAction* dropAction = dropPopupMenu->exec(QCursor::pos());
- if (dropAction == copy) {
- qDebug() << "copy";
- parentItem->insertChildren(indexUnderParent, newItems);
- } else {
- if (dropAction == move) {
- qDebug() << "move";
- parentItem->insertChildren(indexUnderParent, newItems);
- deleteEntries(false);
- } else {
- QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
- return; // user canceled
- }
- }
-
- } else {
- qDebug()<<"the source was outside this";
- createBookmarkFromDrop(event, parentItem, indexUnderParent);
- }
- QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
- setState(QAbstractItemView::NoState);
+void CBookmarkIndex::dropEvent( QDropEvent* event ) {
+ qDebug("CBookmarkIndex::dropEvent");
+
+ //setState(QAbstractItemView::NoState);
+ // Try to prevent annoying timed autocollapsing. Remember to disconnect before return.
+ QObject::connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ QTreeWidgetItem* item = itemAt(event->pos());
+ QTreeWidgetItem* parentItem = 0;
+ int indexUnderParent = 0;
+
+ // Find the place where the drag is dropped
+ if (item) {
+ qDebug() << "there was item";
+
+ QRect rect = visualItemRect(item);
+ bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
+ bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);
+
+ if (isFolder) { // item is a folder
+ qDebug() << "item was folder";
+ if (event->pos().y() > rect.bottom() - (2* rect.height() / 3) ) {
+ parentItem = item;
+ }
+ else {
+ parentItem = item->parent();
+ if (!parentItem) {
+ parentItem = invisibleRootItem();
+ }
+ qDebug() << "item:" << item << "parent:" << parentItem;
+ indexUnderParent = parentItem->indexOfChild(item); // before the current folder
+ }
+ }
+ else {
+ if (isBookmark) { // item is a bookmark
+ qDebug() << "item was bookmark";
+ parentItem = item->parent();
+ if (!parentItem) {
+ parentItem = invisibleRootItem();
+ }
+ indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
+ if (event->pos().y() > rect.bottom() - rect.height() / 2) {
+ indexUnderParent++; // after the current bookmark
+ }
+ }
+ else { // item is the extra item
+ parentItem = item->parent();
+ if (!parentItem) {
+ parentItem = invisibleRootItem();
+ }
+ indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
+ }
+ }
+
+ }
+ else { // no item under event point: drop to the end
+ qDebug() << "there was no item";
+ parentItem = invisibleRootItem();
+ indexUnderParent = parentItem->childCount() - 1;
+ }
+
+
+ if ( event->source() == this ) {
+ qDebug("dropping internal drag");
+ event->accept();
+
+ bool bookmarksOnly = true;
+ bool targetIncluded = false;
+ bool moreThanOneFolder = false;
+
+ QList<QTreeWidgetItem*> newItems = addItemsToDropTree(parentItem, bookmarksOnly, targetIncluded, moreThanOneFolder);
+
+ if (moreThanOneFolder) {
+ QToolTip::showText(QCursor::pos(), tr("Can drop only bookmarks or one folder"));
+ QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ return;
+ }
+ if (targetIncluded) {
+ QToolTip::showText(QCursor::pos(), tr("Can't drop folder into the folder itself or into its subfolder"));
+ QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ return;
+ }
+ // Ask whether to copy or move with a popup menu
+
+ QMenu* dropPopupMenu = new QMenu(this);
+ QAction* copy = dropPopupMenu->addAction(tr("Copy"));
+ QAction* move = dropPopupMenu->addAction(tr("Move"));
+ QAction* dropAction = dropPopupMenu->exec(QCursor::pos());
+ if (dropAction == copy) {
+ qDebug() << "copy";
+ parentItem->insertChildren(indexUnderParent, newItems);
+ }
+ else {
+ if (dropAction == move) {
+ qDebug() << "move";
+ parentItem->insertChildren(indexUnderParent, newItems);
+ deleteEntries(false);
+ }
+ else {
+ QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ return; // user canceled
+ }
+ }
+
+ }
+ else {
+ qDebug() << "the source was outside this";
+ createBookmarkFromDrop(event, parentItem, indexUnderParent);
+ }
+ QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ setState(QAbstractItemView::NoState);
}
-void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent)
-{
- //qDebug("CBookmarkIndex::createBookmarkFromDrop");
- //take the bookmark data from the mime source
- const BTMimeData* mdata = dynamic_cast<const BTMimeData*>(event->mimeData());
- if (mdata) {
- //create the new bookmark
- QString moduleName = mdata->bookmark().module();
- QString keyText = mdata->bookmark().key();
- QString description = mdata->bookmark().description();
- CSwordModuleInfo* minfo = CPointers::backend()->findModuleByName(moduleName);
-
- QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description);
- parentItem->insertChild(indexInParent, newItem);
- }
+void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent) {
+ //qDebug("CBookmarkIndex::createBookmarkFromDrop");
+ //take the bookmark data from the mime source
+ const BTMimeData* mdata = dynamic_cast<const BTMimeData*>(event->mimeData());
+ if (mdata) {
+ //create the new bookmark
+ QString moduleName = mdata->bookmark().module();
+ QString keyText = mdata->bookmark().key();
+ QString description = mdata->bookmark().description();
+ CSwordModuleInfo* minfo = CPointers::backend()->findModuleByName(moduleName);
+
+ QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description);
+ parentItem->insertChild(indexInParent, newItem);
+ }
}
/** Load the tree from file */
void CBookmarkIndex::initTree() {
- qDebug("CBookmarkIndex::initTree");
- BtBookmarkLoader loader;
- addTopLevelItems(loader.loadTree());
-
- // add the invisible extra item at the end
- m_extraItem = new QTreeWidgetItem();
- m_extraItem->setFlags(Qt::ItemIsDropEnabled);
- addTopLevelItem(m_extraItem);
+ qDebug("CBookmarkIndex::initTree");
+ BtBookmarkLoader loader;
+ addTopLevelItems(loader.loadTree());
+
+ // add the invisible extra item at the end
+ m_extraItem = new QTreeWidgetItem();
+ m_extraItem->setFlags(Qt::ItemIsDropEnabled);
+ addTopLevelItem(m_extraItem);
}
-void CBookmarkIndex::slotItemEntered(QTreeWidgetItem* item, int)
-{
- qDebug() << "CBookmarkIndex::slotItemEntered";
- if (item == m_extraItem) {
- m_extraItem->setText(0, tr("Drag references from text views to this view"));
- }
- else {
- m_extraItem->setText(0, QString::null);
- }
+void CBookmarkIndex::slotItemEntered(QTreeWidgetItem* item, int) {
+ qDebug() << "CBookmarkIndex::slotItemEntered";
+ if (item == m_extraItem) {
+ m_extraItem->setText(0, tr("Drag references from text views to this view"));
+ }
+ else {
+ m_extraItem->setText(0, QString::null);
+ }
}
/** Returns the correct QAction object for the given type of action. */
QAction* CBookmarkIndex::action( BtBookmarkItemBase::MenuAction type ) const {
- switch (type) {
- case BtBookmarkItemBase::NewFolder:
- return m_actions.newFolder;
- case BtBookmarkItemBase::ChangeFolder:
- return m_actions.changeFolder;
-
- case BtBookmarkItemBase::ChangeBookmark:
- return m_actions.changeBookmark;
- case BtBookmarkItemBase::ImportBookmarks:
- return m_actions.importBookmarks;
- case BtBookmarkItemBase::ExportBookmarks:
- return m_actions.exportBookmarks;
- case BtBookmarkItemBase::PrintBookmarks:
- return m_actions.printBookmarks;
-
- case BtBookmarkItemBase::DeleteEntries:
- return m_actions.deleteEntries;
-
- default:
- return 0;
- }
+ switch (type) {
+ case BtBookmarkItemBase::NewFolder:
+ return m_actions.newFolder;
+ case BtBookmarkItemBase::ChangeFolder:
+ return m_actions.changeFolder;
+
+ case BtBookmarkItemBase::ChangeBookmark:
+ return m_actions.changeBookmark;
+ case BtBookmarkItemBase::ImportBookmarks:
+ return m_actions.importBookmarks;
+ case BtBookmarkItemBase::ExportBookmarks:
+ return m_actions.exportBookmarks;
+ case BtBookmarkItemBase::PrintBookmarks:
+ return m_actions.printBookmarks;
+
+ case BtBookmarkItemBase::DeleteEntries:
+ return m_actions.deleteEntries;
+
+ default:
+ return 0;
+ }
}
/** Shows the context menu at the given position. */
-void CBookmarkIndex::contextMenu(const QPoint& p)
-{
- //qDebug("CBookmarkIndex::contextMenu");
- //setup menu entries depending on current selection
- QTreeWidgetItem* i = itemAt(p);
- QList<QTreeWidgetItem *> items = selectedItems();
- //The item which was clicked may not be selected
- if (i && !items.contains(i) && i != m_extraItem)
- items.append(i);
-
- if (items.count() == 0) {
- //special handling for no selection
- BtBookmarkItemBase::MenuAction actionType;
- for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
- actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
- if (QAction* a = action(actionType)) {
- switch (index) {
- //case BtBookmarkItemBase::ExportBookmarks:
- //case BtBookmarkItemBase::ImportBookmarks:
- case BtBookmarkItemBase::NewFolder:
- //case BtBookmarkItemBase::PrintBookmarks:
- a->setEnabled(true);
- break;
- default:
- a->setEnabled(false);
- }
- }
- }
- }
- else if (items.count() == 1) {
- //special handling for one selected item
-
- BtBookmarkItemBase* item = dynamic_cast<BtBookmarkItemBase*>(items.at(0));
- BtBookmarkItemBase::MenuAction actionType;
- for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
- actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
- if (QAction* a = action(actionType))
- a->setEnabled( item->enableAction(actionType) );
- }
- }
- else {
- //first disable all actions
- BtBookmarkItemBase::MenuAction actionType;
- for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
- actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
- if (QAction* a = action(actionType))
- a->setEnabled(false);
- }
- //enable the menu items depending on the types of the selected items.
- for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
- actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
- bool enableAction = isMultiAction(actionType);
- QListIterator<QTreeWidgetItem *> it(items);
- while(it.hasNext()) {
- BtBookmarkItemBase* i = dynamic_cast<BtBookmarkItemBase*>(it.next());
- enableAction = enableAction && i->enableAction(actionType);
- }
- if (enableAction) {
- QAction* a = action(actionType) ;
- if (i && a)
- a->setEnabled(enableAction);
- }
- }
- }
- //finally, open the popup
- m_popup->exec(mapToGlobal(p));
- //qDebug("CBookmarkIndex::contextMenu end");
+void CBookmarkIndex::contextMenu(const QPoint& p) {
+ //qDebug("CBookmarkIndex::contextMenu");
+ //setup menu entries depending on current selection
+ QTreeWidgetItem* i = itemAt(p);
+ QList<QTreeWidgetItem *> items = selectedItems();
+ //The item which was clicked may not be selected
+ if (i && !items.contains(i) && i != m_extraItem)
+ items.append(i);
+
+ if (items.count() == 0) {
+ //special handling for no selection
+ BtBookmarkItemBase::MenuAction actionType;
+ for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
+ actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
+ if (QAction* a = action(actionType)) {
+ switch (index) {
+ //case BtBookmarkItemBase::ExportBookmarks:
+ //case BtBookmarkItemBase::ImportBookmarks:
+ case BtBookmarkItemBase::NewFolder:
+ //case BtBookmarkItemBase::PrintBookmarks:
+ a->setEnabled(true);
+ break;
+ default:
+ a->setEnabled(false);
+ }
+ }
+ }
+ }
+ else if (items.count() == 1) {
+ //special handling for one selected item
+
+ BtBookmarkItemBase* item = dynamic_cast<BtBookmarkItemBase*>(items.at(0));
+ BtBookmarkItemBase::MenuAction actionType;
+ for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
+ actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
+ if (QAction* a = action(actionType))
+ a->setEnabled( item->enableAction(actionType) );
+ }
+ }
+ else {
+ //first disable all actions
+ BtBookmarkItemBase::MenuAction actionType;
+ for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
+ actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
+ if (QAction* a = action(actionType))
+ a->setEnabled(false);
+ }
+ //enable the menu items depending on the types of the selected items.
+ for (int index = BtBookmarkItemBase::ActionBegin; index <= BtBookmarkItemBase::ActionEnd; ++index) {
+ actionType = static_cast<BtBookmarkItemBase::MenuAction>(index);
+ bool enableAction = isMultiAction(actionType);
+ QListIterator<QTreeWidgetItem *> it(items);
+ while (it.hasNext()) {
+ BtBookmarkItemBase* i = dynamic_cast<BtBookmarkItemBase*>(it.next());
+ enableAction = enableAction && i->enableAction(actionType);
+ }
+ if (enableAction) {
+ QAction* a = action(actionType) ;
+ if (i && a)
+ a->setEnabled(enableAction);
+ }
+ }
+ }
+ //finally, open the popup
+ m_popup->exec(mapToGlobal(p));
+ //qDebug("CBookmarkIndex::contextMenu end");
}
/** Adds a new subfolder to the current item. */
void CBookmarkIndex::createNewFolder() {
- //qDebug("CBookmarkIndex::createNewFolder");
- QList<QTreeWidgetItem*> selected = selectedItems();
- if (selected.count() > 0) {
- BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
- if (i) {
- i->newSubFolder();
- }
- }
- else {
- // create a top level folder
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, QObject::tr("New folder"));
- //parentFolder->addChild(newFolder);
- insertTopLevelItem(topLevelItemCount()-1, newFolder);
- newFolder->update();
- newFolder->rename();
- }
+ //qDebug("CBookmarkIndex::createNewFolder");
+ QList<QTreeWidgetItem*> selected = selectedItems();
+ if (selected.count() > 0) {
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ if (i) {
+ i->newSubFolder();
+ }
+ }
+ else {
+ // create a top level folder
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, QObject::tr("New folder"));
+ //parentFolder->addChild(newFolder);
+ insertTopLevelItem(topLevelItemCount() - 1, newFolder);
+ newFolder->update();
+ newFolder->rename();
+ }
}
/** Opens a dialog to change the current folder. */
void CBookmarkIndex::changeFolder() {
- BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
- Q_ASSERT(i);
- if (i) {
- i->rename();
- }
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ Q_ASSERT(i);
+ if (i) {
+ i->rename();
+ }
}
/** Changes the current bookmark. */
void CBookmarkIndex::changeBookmark() {
- BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(currentItem());
- Q_ASSERT(i);
+ BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(currentItem());
+ Q_ASSERT(i);
- if (i) {
- i->rename();
- }
+ if (i) {
+ i->rename();
+ }
}
/** Exports the bookmarks being in the selected folder. */
void CBookmarkIndex::exportBookmarks() {
- BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
- Q_ASSERT(i);
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ Q_ASSERT(i);
- if (i) {
- i->exportBookmarks();
- }
+ if (i) {
+ i->exportBookmarks();
+ }
}
/** Import bookmarks from a file and add them to the selected folder. */
void CBookmarkIndex::importBookmarks() {
- BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
- Q_ASSERT(i);
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ Q_ASSERT(i);
- if (i) {
- i->importBookmarks();
- }
+ if (i) {
+ i->importBookmarks();
+ }
}
/** Prints the selected bookmarks. */
void CBookmarkIndex::printBookmarks() {
- Printing::CPrinter::KeyTree tree;
- Printing::CPrinter::KeyTreeItem::Settings settings;
- settings.keyRenderingFace = Printing::CPrinter::KeyTreeItem::Settings::CompleteShort;
-
- QList<QTreeWidgetItem*> items;
- BtBookmarkFolder* bf = dynamic_cast<BtBookmarkFolder*>(currentItem());
-
- if (bf) {
- items = bf->getChildList();
- }
- else {
- items = selectedItems();
- }
-
- //create a tree of keytreeitems using the bookmark hierarchy.
- QListIterator<QTreeWidgetItem*> it(items);
- while(it.hasNext()) {
- BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(it.next());
- if (i) {
- qDebug() << "printBookmarks: add to list" << i->key();
- tree.append( new Printing::CPrinter::KeyTreeItem( i->key(), i->module(), settings ) );
- }
- }
-
- if (items.count() == 0) {
- qWarning("Tried to print empty bookmark list.");
- return;
- }
- boost::scoped_ptr<Printing::CPrinter> printer(
- new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
- );
- printer->printKeyTree(tree);
+ Printing::CPrinter::KeyTree tree;
+ Printing::CPrinter::KeyTreeItem::Settings settings;
+ settings.keyRenderingFace = Printing::CPrinter::KeyTreeItem::Settings::CompleteShort;
+
+ QList<QTreeWidgetItem*> items;
+ BtBookmarkFolder* bf = dynamic_cast<BtBookmarkFolder*>(currentItem());
+
+ if (bf) {
+ items = bf->getChildList();
+ }
+ else {
+ items = selectedItems();
+ }
+
+ //create a tree of keytreeitems using the bookmark hierarchy.
+ QListIterator<QTreeWidgetItem*> it(items);
+ while (it.hasNext()) {
+ BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(it.next());
+ if (i) {
+ qDebug() << "printBookmarks: add to list" << i->key();
+ tree.append( new Printing::CPrinter::KeyTreeItem( i->key(), i->module(), settings ) );
+ }
+ }
+
+ if (items.count() == 0) {
+ qWarning("Tried to print empty bookmark list.");
+ return;
+ }
+ boost::scoped_ptr<Printing::CPrinter> printer(
+ new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
+ );
+ printer->printKeyTree(tree);
}
/** Deletes the selected entries. */
-void CBookmarkIndex::deleteEntries(bool confirm)
-{
- if (confirm) {
- if (!selectedItems().count()) {
- BtBookmarkItemBase* f = dynamic_cast<BtBookmarkItemBase*>(currentItem());
- if (f) {
- currentItem()->setSelected(true);
- } else {
- return;
- }
- }
-
- 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) {
- return;
- }
- }
-
- while (selectedItems().size() > 0) {
- delete selectedItems().at(0); // deleting all does not work because it may cause double deletion
- }
+void CBookmarkIndex::deleteEntries(bool confirm) {
+ if (confirm) {
+ if (!selectedItems().count()) {
+ BtBookmarkItemBase* f = dynamic_cast<BtBookmarkItemBase*>(currentItem());
+ if (f) {
+ currentItem()->setSelected(true);
+ }
+ else {
+ return;
+ }
+ }
+
+ 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) {
+ return;
+ }
+ }
+
+ while (selectedItems().size() > 0) {
+ delete selectedItems().at(0); // deleting all does not work because it may cause double deletion
+ }
}
@@ -698,16 +696,15 @@ The default implementation would drag items, but we don't call it. Instead we cr
a BibleTime mimedata object. It can be dragged and dropped to a text view or somewhere else.
The internal drag is handled differently, it doesn't use the mimedata (see dropEvent()).
*/
-void CBookmarkIndex::startDrag(Qt::DropActions)
-{
- qDebug("CBookmarkIndex::startDrag");
+void CBookmarkIndex::startDrag(Qt::DropActions) {
+ qDebug("CBookmarkIndex::startDrag");
- QMimeData* mData = dragObject(); // create the data which can be used in other widgets
- QDrag* drag = new QDrag(this);
- drag->setMimeData(mData);
- drag->exec();
+ QMimeData* mData = dragObject(); // create the data which can be used in other widgets
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(mData);
+ drag->exec();
- viewport()->update(); // because of the arrow
+ viewport()->update(); // because of the arrow
}
@@ -717,84 +714,83 @@ void CBookmarkIndex::startDrag(Qt::DropActions)
/* Returns true if more than one entry is supported by this action type. Returns false for actions which support only one entry, e.g. about module etc. */
bool CBookmarkIndex::isMultiAction( const BtBookmarkItemBase::MenuAction type ) const {
- switch (type) {
- case BtBookmarkItemBase::NewFolder:
- return false;
- case BtBookmarkItemBase::ChangeFolder:
- return false;
-
- case BtBookmarkItemBase::ChangeBookmark:
- return false;
- case BtBookmarkItemBase::ImportBookmarks:
- return false;
- case BtBookmarkItemBase::ExportBookmarks:
- return false;
- case BtBookmarkItemBase::PrintBookmarks:
- return true;
-
- case BtBookmarkItemBase::DeleteEntries:
- return true;
- }
-
- return false;
+ switch (type) {
+ case BtBookmarkItemBase::NewFolder:
+ return false;
+ case BtBookmarkItemBase::ChangeFolder:
+ return false;
+
+ case BtBookmarkItemBase::ChangeBookmark:
+ return false;
+ case BtBookmarkItemBase::ImportBookmarks:
+ return false;
+ case BtBookmarkItemBase::ExportBookmarks:
+ return false;
+ case BtBookmarkItemBase::PrintBookmarks:
+ return true;
+
+ case BtBookmarkItemBase::DeleteEntries:
+ return true;
+ }
+
+ return false;
}
/* Saves the bookmarks to the default bookmarks file. */
void CBookmarkIndex::saveBookmarks() {
- qDebug("CBookmarkIndex::saveBookmarks()");
- BtBookmarkLoader loader;
- loader.saveTreeFromRootItem(invisibleRootItem());
- //qDebug("CBookmarkIndex::saveBookmarks end");
+ qDebug("CBookmarkIndex::saveBookmarks()");
+ BtBookmarkLoader loader;
+ loader.saveTreeFromRootItem(invisibleRootItem());
+ //qDebug("CBookmarkIndex::saveBookmarks end");
}
-void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event)
-{
- //qDebug() << "CBookmarkIndex::mouseMoveEvent";
-
- // 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");
- if ( !(event->modifiers() & Qt::ShiftModifier)) {
- m_magTimer.start(); // see the ctor for the timer properties
- }
- }
- m_previousEventItem = itemUnderPointer;
-
- // Clear the extra item text unless we are on top of it
- if ( (itemUnderPointer != m_extraItem) && !m_extraItem->text(0).isNull()) {
- m_extraItem->setText(0, QString::null);
- }
-
- QTreeWidget::mouseMoveEvent(event);
+void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) {
+ //qDebug() << "CBookmarkIndex::mouseMoveEvent";
+
+ // 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");
+ if ( !(event->modifiers() & Qt::ShiftModifier)) {
+ m_magTimer.start(); // see the ctor for the timer properties
+ }
+ }
+ m_previousEventItem = itemUnderPointer;
+
+ // Clear the extra item text unless we are on top of it
+ if ( (itemUnderPointer != m_extraItem) && !m_extraItem->text(0).isNull()) {
+ m_extraItem->setText(0, QString::null);
+ }
+
+ QTreeWidget::mouseMoveEvent(event);
}
-void CBookmarkIndex::magTimeout()
-{
- //qDebug("CBookmarkIndex::magTimeout");
-
- QTreeWidgetItem* itemUnderPointer = 0;
- if (underMouse()) {
- itemUnderPointer = itemAt(mapFromGlobal(QCursor::pos()));
- }
- // if the mouse pointer have been over the same item since the timer was started
- if (itemUnderPointer && (m_previousEventItem == itemUnderPointer)) {
- BtBookmarkItem* bitem = dynamic_cast<BtBookmarkItem*>(itemUnderPointer);
- if (bitem) {
- //qDebug("CBookmarkIndex::timerEvent: update the infodisplay");
- // Update the mag
- if (bitem->module()) {
- (CPointers::infoDisplay())->setInfo(
- InfoDisplay::CInfoDisplay::CrossReference,
- bitem->module()->name() + ":" + bitem->key()
- );
- } else {
- (CPointers::infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
- }
-
- }
- }
+void CBookmarkIndex::magTimeout() {
+ //qDebug("CBookmarkIndex::magTimeout");
+
+ QTreeWidgetItem* itemUnderPointer = 0;
+ if (underMouse()) {
+ itemUnderPointer = itemAt(mapFromGlobal(QCursor::pos()));
+ }
+ // if the mouse pointer have been over the same item since the timer was started
+ if (itemUnderPointer && (m_previousEventItem == itemUnderPointer)) {
+ BtBookmarkItem* bitem = dynamic_cast<BtBookmarkItem*>(itemUnderPointer);
+ if (bitem) {
+ //qDebug("CBookmarkIndex::timerEvent: update the infodisplay");
+ // Update the mag
+ if (bitem->module()) {
+ (CPointers::infoDisplay())->setInfo(
+ InfoDisplay::CInfoDisplay::CrossReference,
+ bitem->module()->name() + ":" + bitem->key()
+ );
+ }
+ else {
+ (CPointers::infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
+ }
+
+ }
+ }
}
/*
@@ -808,43 +804,43 @@ If moreThanOneFolder or targetIncluded is detected the creation of list is stopp
and the list is incomplete.
*/
QList<QTreeWidgetItem*> CBookmarkIndex::addItemsToDropTree(
- QTreeWidgetItem* target, bool& bookmarksOnly, bool& targetIncluded, bool& moreThanOneFolder)
-{
- qDebug() << "CBookmarkIndex::addItemsToDropTree";
- QList<QTreeWidgetItem*> selectedList = selectedItems();
- QList<QTreeWidgetItem*> newList;
-
- foreach(QTreeWidgetItem* item, selectedList) {
- qDebug() << "go through all items:" << item;
- if ( BtBookmarkFolder* folder = dynamic_cast<BtBookmarkFolder*>(item)) {
- bookmarksOnly = false;
- if (selectedList.count() > 1) { // only one item allowed if a folder is selected
- qDebug() << "one folder and something else is selected";
- moreThanOneFolder = true;
- break;
- }
- if (folder->hasDescendant(target)) { // dropping to self or descendand not allowed
- qDebug() << "addItemsToDropTree: target is included";
- targetIncluded = true;
- break;
- }
- } else {
- qDebug() << "append new QTreeWidget item (should be BtBookmarkItem?)";
- newList.append(new BtBookmarkItem( *(dynamic_cast<BtBookmarkItem*>(item)) ));
- }
- }
- if (!bookmarksOnly && selectedList.count() == 1) {
- qDebug() << "exactly one folder";
- BtBookmarkFolder* folder = dynamic_cast<BtBookmarkFolder*>(selectedList.value(0));
- BtBookmarkFolder* copy = folder->deepCopy();
- newList.append(copy);
- }
- if (!bookmarksOnly && selectedList.count() > 1) {
- // wrong amount of items
- qDebug() << "one folder and something else is selected 2";
- moreThanOneFolder = true;
- }
- qDebug() << "return the new list" << newList;
- return newList;
+ QTreeWidgetItem* target, bool& bookmarksOnly, bool& targetIncluded, bool& moreThanOneFolder) {
+ qDebug() << "CBookmarkIndex::addItemsToDropTree";
+ QList<QTreeWidgetItem*> selectedList = selectedItems();
+ QList<QTreeWidgetItem*> newList;
+
+ foreach(QTreeWidgetItem* item, selectedList) {
+ qDebug() << "go through all items:" << item;
+ if ( BtBookmarkFolder* folder = dynamic_cast<BtBookmarkFolder*>(item)) {
+ bookmarksOnly = false;
+ if (selectedList.count() > 1) { // only one item allowed if a folder is selected
+ qDebug() << "one folder and something else is selected";
+ moreThanOneFolder = true;
+ break;
+ }
+ if (folder->hasDescendant(target)) { // dropping to self or descendand not allowed
+ qDebug() << "addItemsToDropTree: target is included";
+ targetIncluded = true;
+ break;
+ }
+ }
+ else {
+ qDebug() << "append new QTreeWidget item (should be BtBookmarkItem?)";
+ newList.append(new BtBookmarkItem( *(dynamic_cast<BtBookmarkItem*>(item)) ));
+ }
+ }
+ if (!bookmarksOnly && selectedList.count() == 1) {
+ qDebug() << "exactly one folder";
+ BtBookmarkFolder* folder = dynamic_cast<BtBookmarkFolder*>(selectedList.value(0));
+ BtBookmarkFolder* copy = folder->deepCopy();
+ newList.append(copy);
+ }
+ if (!bookmarksOnly && selectedList.count() > 1) {
+ // wrong amount of items
+ qDebug() << "one folder and something else is selected 2";
+ moreThanOneFolder = true;
+ }
+ qDebug() << "return the new list" << newList;
+ return newList;
}
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
index 340fabc..748e75d 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
@@ -42,140 +42,142 @@ class QMouseEvent;
* @author The BibleTime team
*/
class CBookmarkIndex : public QTreeWidget {
- Q_OBJECT
+ Q_OBJECT
-public:
- CBookmarkIndex(QWidget *parent);
- virtual ~CBookmarkIndex();
+ public:
+ CBookmarkIndex(QWidget *parent);
+ virtual ~CBookmarkIndex();
- void initTree();
+ void initTree();
- /**
- * Saves the bookmarks to disk
- */
- void saveBookmarks();
+ /**
+ * Saves the bookmarks to disk
+ */
+ void saveBookmarks();
-signals:
- /**
- * Is emitted when a module should be opened,
- */
- void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
+ signals:
+ /**
+ * Is emitted when a module should be opened,
+ */
+ void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
-protected: // Protected methods
+ protected: // Protected methods
- /** A hack to get the modifiers. */
- virtual void mouseReleaseEvent(QMouseEvent* event);
+ /** A hack to get the modifiers. */
+ virtual void mouseReleaseEvent(QMouseEvent* event);
- /** Needed to paint an drag pointer arrow. */
- virtual void paintEvent(QPaintEvent* event);
+ /** Needed to paint an drag pointer arrow. */
+ virtual void paintEvent(QPaintEvent* event);
- /** Initialize the SIGNAL<->SLOT connections. */
- void initConnections();
+ /** Initialize the SIGNAL<->SLOT connections. */
+ void initConnections();
- /** Returns the drag object for the current selection. */
- virtual QMimeData* dragObject();
+ /** Returns the drag object for the current selection. */
+ virtual QMimeData* dragObject();
- /**
- * D'n'd methods are reimplementations from QTreeWidget or its ancestors.
- * In these we handle creating, moving and copying bookmarks with d'n'd.
- */
- virtual void dragEnterEvent( QDragEnterEvent* event );
- virtual void dragMoveEvent( QDragMoveEvent* event );
- virtual void dropEvent( QDropEvent* event );
- virtual void dragLeaveEvent( QDragLeaveEvent* event );
+ /**
+ * D'n'd methods are reimplementations from QTreeWidget or its ancestors.
+ * In these we handle creating, moving and copying bookmarks with d'n'd.
+ */
+ virtual void dragEnterEvent( QDragEnterEvent* event );
+ virtual void dragMoveEvent( QDragMoveEvent* event );
+ virtual void dropEvent( QDropEvent* event );
+ virtual void dragLeaveEvent( QDragLeaveEvent* event );
- /** Returns the correct action object for the given type of action. */
- QAction* action( BtBookmarkItemBase::MenuAction type ) const;
+ /** Returns the correct action object for the given type of action. */
+ QAction* action( BtBookmarkItemBase::MenuAction type ) const;
- /** Reimplementation from QAbstractItemView. Takes care of movable items. */
- virtual void startDrag(Qt::DropActions supportedActions);
+ /** Reimplementation from QAbstractItemView. Takes care of movable items. */
+ virtual void startDrag(Qt::DropActions supportedActions);
- /** Handle mouse moving (mag updates) */
- virtual void mouseMoveEvent(QMouseEvent* event);
+ /** Handle mouse moving (mag updates) */
+ virtual void mouseMoveEvent(QMouseEvent* event);
-protected slots:
+ protected slots:
- /** Prevents annoying folder collapsing while dropping. */
- void expandAutoCollapsedItem(QTreeWidgetItem* i) {expandItem(i);}
+ /** Prevents annoying folder collapsing while dropping. */
+ void expandAutoCollapsedItem(QTreeWidgetItem* i) {
+ expandItem(i);
+ }
- /** Is called when an item was clicked or activated. */
- void slotExecuted( QTreeWidgetItem* );
+ /** Is called when an item was clicked or activated. */
+ void slotExecuted( QTreeWidgetItem* );
- /** Shows the context menu at the given position. */
- void contextMenu(const QPoint&);
+ /** Shows the context menu at the given position. */
+ void contextMenu(const QPoint&);
- /** Adds a new subfolder to the current item. */
- void createNewFolder();
+ /** Adds a new subfolder to the current item. */
+ void createNewFolder();
- /** Opens a dialog to change the current folder. */
- void changeFolder();
+ /** Opens a dialog to change the current folder. */
+ void changeFolder();
- /** Exports the bookmarks from the selected folder. */
- void exportBookmarks();
+ /** Exports the bookmarks from the selected folder. */
+ void exportBookmarks();
- /** Changes the current bookmark. */
- void changeBookmark();
+ /** Changes the current bookmark. */
+ void changeBookmark();
- /** Helps with the extra item. */
- void slotItemEntered(QTreeWidgetItem*, int);
+ /** Helps with the extra item. */
+ void slotItemEntered(QTreeWidgetItem*, int);
- /** Import bookmarks from a file and add them to the selected folder. */
- void importBookmarks();
+ /** Import bookmarks from a file and add them to the selected folder. */
+ void importBookmarks();
- /** Deletes the selected entries. */
- void deleteEntries(bool confirm=true);
+ /** Deletes the selected entries. */
+ void deleteEntries(bool confirm = true);
- /** Prints the selected bookmarks. */
- void printBookmarks();
+ /** Prints the selected bookmarks. */
+ void printBookmarks();
- /** Slot for the mag update timer. */
- void magTimeout();
+ /** Slot for the mag update timer. */
+ void magTimeout();
-private:
+ private:
- /** Initializes the view. */
- void initView();
+ /** Initializes the view. */
+ void initView();
- /** Convenience function for creating a new action. */
- QAction* newQAction(const QString& text, const QString& pix, int shortcut, const QObject* receiver, const char* slot, QObject* parent);
+ /** Convenience function for creating a new action. */
+ QAction* newQAction(const QString& text, const QString& pix, int shortcut, const QObject* receiver, const char* slot, QObject* parent);
- /**
- * Returns true if more than one entry is supported by this action type.
- * Returns false for actions which support only one entry.
- */
- bool isMultiAction( const BtBookmarkItemBase::MenuAction type ) const;
+ /**
+ * Returns true if more than one entry is supported by this action type.
+ * Returns false for actions which support only one entry.
+ */
+ bool isMultiAction( const BtBookmarkItemBase::MenuAction type ) const;
- /** A helper function for d'n'd which creates a new bookmark item when drop happens. */
- void createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent);
+ /** A helper function for d'n'd which creates a new bookmark item when drop happens. */
+ void createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent);
- /**
- * Returns a list of new items created from the selection.
- * Sets flags which indicate whether the selection was legal for dropping.
- */
- QList<QTreeWidgetItem*> addItemsToDropTree(QTreeWidgetItem* target, bool& bookmarksOnly, bool& targetIncluded, bool& moreThanOneFolder);
+ /**
+ * Returns a list of new items created from the selection.
+ * Sets flags which indicate whether the selection was legal for dropping.
+ */
+ QList<QTreeWidgetItem*> addItemsToDropTree(QTreeWidgetItem* target, bool& bookmarksOnly, bool& targetIncluded, bool& moreThanOneFolder);
- struct Actions {
- QAction* newFolder;
- QAction* changeFolder;
+ struct Actions {
+ QAction* newFolder;
+ QAction* changeFolder;
- QAction* changeBookmark;
- QAction* importBookmarks;
- QAction* exportBookmarks;
- QAction* printBookmarks;
+ QAction* changeBookmark;
+ QAction* importBookmarks;
+ QAction* exportBookmarks;
+ QAction* printBookmarks;
- QAction* deleteEntries;
- }
- m_actions;
+ QAction* deleteEntries;
+ }
+ m_actions;
- QMenu* m_popup;
- QTimer m_magTimer;
- int m_mouseReleaseEventModifiers;
- QTreeWidgetItem* m_previousEventItem;
- QPoint m_dragMovementPosition;
- QPoint m_dragStartPosition;
- QTreeWidgetItem* m_extraItem;
+ QMenu* m_popup;
+ QTimer m_magTimer;
+ int m_mouseReleaseEventModifiers;
+ QTreeWidgetItem* m_previousEventItem;
+ QPoint m_dragMovementPosition;
+ QPoint m_dragStartPosition;
+ QTreeWidgetItem* m_extraItem;
};
#endif
diff --git a/src/frontend/mainindex/bookshelf/actionenum.h b/src/frontend/mainindex/bookshelf/actionenum.h
index 919e8ac..e95f3d7 100644
--- a/src/frontend/mainindex/bookshelf/actionenum.h
+++ b/src/frontend/mainindex/bookshelf/actionenum.h
@@ -11,14 +11,14 @@
#define ACTIONENUM_H
enum IndexAction {
- EditModule,
- UnlockModule,
- HideModules,
- ShowAllModules,
- SearchModules,
- UpdateModules,
- Grouping,
- AboutModule
+ 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
index 632817e..56cc5fc 100644
--- a/src/frontend/mainindex/bookshelf/btindexfolder.cpp
+++ b/src/frontend/mainindex/bookshelf/btindexfolder.cpp
@@ -12,8 +12,7 @@
#include "util/directoryutil.h"
BTIndexFolder::BTIndexFolder(BTModuleTreeItem* treeItem, QTreeWidgetItem* parent)
- : BTIndexItem(parent)
-{
- setText(0, treeItem->text());
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(treeItem->iconName()));
+ : 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
index 6c8f672..c85e31d 100644
--- a/src/frontend/mainindex/bookshelf/btindexfolder.h
+++ b/src/frontend/mainindex/bookshelf/btindexfolder.h
@@ -19,12 +19,11 @@ class BTModuleTreeItem;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class BTIndexFolder : public BTIndexItem
-{
-public:
- BTIndexFolder(BTModuleTreeItem* treeItem, QTreeWidgetItem* p);
+class BTIndexFolder : public BTIndexItem {
+ public:
+ BTIndexFolder(BTModuleTreeItem* treeItem, QTreeWidgetItem* p);
- ~BTIndexFolder() {}
+ ~BTIndexFolder() {}
};
#endif
diff --git a/src/frontend/mainindex/bookshelf/btindexitem.cpp b/src/frontend/mainindex/bookshelf/btindexitem.cpp
index 2356f84..859c150 100644
--- a/src/frontend/mainindex/bookshelf/btindexitem.cpp
+++ b/src/frontend/mainindex/bookshelf/btindexitem.cpp
@@ -15,5 +15,4 @@
BTIndexItem::BTIndexItem(QTreeWidgetItem* parent)
- : QTreeWidgetItem(parent)
-{}
+ : QTreeWidgetItem(parent) {}
diff --git a/src/frontend/mainindex/bookshelf/btindexitem.h b/src/frontend/mainindex/bookshelf/btindexitem.h
index d9e74ad..88609a3 100644
--- a/src/frontend/mainindex/bookshelf/btindexitem.h
+++ b/src/frontend/mainindex/bookshelf/btindexitem.h
@@ -22,23 +22,26 @@ 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;}
+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
index 91a9f2f..d8c2301 100644
--- a/src/frontend/mainindex/bookshelf/btindexmodule.cpp
+++ b/src/frontend/mainindex/bookshelf/btindexmodule.cpp
@@ -22,72 +22,68 @@
BTIndexModule::BTIndexModule(BTModuleTreeItem* treeItem, QTreeWidgetItem* previous)
- : BTIndexItem(previous)
-{
- //qDebug("BTIndexModule::BTIndexModule");
- setText(0, treeItem->text()); //set text
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(treeItem->iconName()) );
- m_moduleInfo = treeItem->moduleInfo();
- setToolTip(0, CToolClass::moduleToolTip(moduleInfo()) );
-
- setFlags(Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsSelectable);
- if (!m_moduleInfo->isHidden()) {
- setFlags(flags()|Qt::ItemIsEnabled);
- }
+ : BTIndexItem(previous) {
+ //qDebug("BTIndexModule::BTIndexModule");
+ setText(0, treeItem->text()); //set text
+ setIcon(0, util::filesystem::DirectoryUtil::getIcon(treeItem->iconName()) );
+ m_moduleInfo = treeItem->moduleInfo();
+ setToolTip(0, CToolClass::moduleToolTip(moduleInfo()) );
+
+ setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsSelectable);
+ if (!m_moduleInfo->isHidden()) {
+ setFlags(flags() | Qt::ItemIsEnabled);
+ }
}
-BTIndexModule::~BTIndexModule()
-{
+BTIndexModule::~BTIndexModule() {
}
-bool BTIndexModule::enableAction(QAction* action) const
-{
- if (!action->isEnabled()) {
- IndexAction actionType = (IndexAction)action->property("indexActionType").toInt();
-
- switch (actionType) {
- case EditModule:
- if (moduleInfo()->isWritable()) action->setEnabled(true);
- break;
- case UnlockModule:
- if (moduleInfo()->isEncrypted()) action->setEnabled(true);
- break;
- case HideModules:
- if (!m_moduleInfo->isHidden()) action->setEnabled(true);
- case UpdateModules:
- break;
- case AboutModule:
- case Grouping:
- case SearchModules:
- case ShowAllModules: break;
- }
- }
- return true; //TODO: check, is this correct?
+bool BTIndexModule::enableAction(QAction* action) const {
+ if (!action->isEnabled()) {
+ IndexAction actionType = (IndexAction)action->property("indexActionType").toInt();
+
+ switch (actionType) {
+ case EditModule:
+ if (moduleInfo()->isWritable()) action->setEnabled(true);
+ break;
+ case UnlockModule:
+ if (moduleInfo()->isEncrypted()) action->setEnabled(true);
+ break;
+ case HideModules:
+ if (!m_moduleInfo->isHidden()) action->setEnabled(true);
+ case UpdateModules:
+ break;
+ case AboutModule:
+ case Grouping:
+ case SearchModules:
+ case ShowAllModules:
+ break;
+ }
+ }
+ return true; //TODO: check, is this correct?
}
-bool BTIndexModule::acceptDrop(const QMimeData* data)
-{
- //TODO: check the module type of the reference, accept only proper type.
- // Bible accepts biblical references and plain text (for search),
- // but it could accept a lexicon entry too for search, especially a Strong's entry.
- // Lexicon could accept lexicon references but also biblical references to find all places where
- // the verse is referred to. Same with genbooks.
-
- const BTMimeData* btData = dynamic_cast<const BTMimeData*>(data);
- if (btData) {
- return true;
- }
- if (data->hasText()) {
- return true;
- }
- return false;
+bool BTIndexModule::acceptDrop(const QMimeData* data) {
+ //TODO: check the module type of the reference, accept only proper type.
+ // Bible accepts biblical references and plain text (for search),
+ // but it could accept a lexicon entry too for search, especially a Strong's entry.
+ // Lexicon could accept lexicon references but also biblical references to find all places where
+ // the verse is referred to. Same with genbooks.
+
+ const BTMimeData* btData = dynamic_cast<const BTMimeData*>(data);
+ if (btData) {
+ return true;
+ }
+ if (data->hasText()) {
+ return true;
+ }
+ return false;
}
-CSwordModuleInfo* BTIndexModule::moduleInfo() const
-{
- return m_moduleInfo;
+CSwordModuleInfo* BTIndexModule::moduleInfo() const {
+ return m_moduleInfo;
}
diff --git a/src/frontend/mainindex/bookshelf/btindexmodule.h b/src/frontend/mainindex/bookshelf/btindexmodule.h
index cbd711c..d8991ca 100644
--- a/src/frontend/mainindex/bookshelf/btindexmodule.h
+++ b/src/frontend/mainindex/bookshelf/btindexmodule.h
@@ -21,19 +21,18 @@ class QAction;
class QMimeData;
-class BTIndexModule : public BTIndexItem
-{
-public:
- BTIndexModule(BTModuleTreeItem* treeItem, QTreeWidgetItem* previous);
+class BTIndexModule : public BTIndexItem {
+ public:
+ BTIndexModule(BTModuleTreeItem* treeItem, QTreeWidgetItem* previous);
- ~BTIndexModule();
+ ~BTIndexModule();
- virtual bool enableAction(QAction* action) const;
- virtual bool acceptDrop(const QMimeData* data);
- CSwordModuleInfo* moduleInfo() const;
+ virtual bool enableAction(QAction* action) const;
+ virtual bool acceptDrop(const QMimeData* data);
+ CSwordModuleInfo* moduleInfo() const;
-private:
- CSwordModuleInfo* m_moduleInfo;
+ private:
+ CSwordModuleInfo* m_moduleInfo;
};
#endif
diff --git a/src/frontend/mainindex/bookshelf/cbookshelfindex.cpp b/src/frontend/mainindex/bookshelf/cbookshelfindex.cpp
index 1c6db2a..ebd0ee0 100644
--- a/src/frontend/mainindex/bookshelf/cbookshelfindex.cpp
+++ b/src/frontend/mainindex/bookshelf/cbookshelfindex.cpp
@@ -45,17 +45,16 @@
CBookshelfIndex::CBookshelfIndex(QWidget *parent)
- : QTreeWidget(parent),
- m_searchDialog(0),
- m_autoOpenFolder(0),
- m_autoOpenTimer(this)
-{
- m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
- m_showHidden = CBTConfig::get(CBTConfig::bookshelfShowHidden);
- setContextMenuPolicy(Qt::CustomContextMenu);
- initView();
- initConnections();
- initTree();
+ : QTreeWidget(parent),
+ m_searchDialog(0),
+ m_autoOpenFolder(0),
+ m_autoOpenTimer(this) {
+ m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
+ m_showHidden = CBTConfig::get(CBTConfig::bookshelfShowHidden);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ initView();
+ initConnections();
+ initTree();
}
CBookshelfIndex::~CBookshelfIndex() {}
@@ -63,579 +62,572 @@ CBookshelfIndex::~CBookshelfIndex() {}
/** Initializes the view. */
-void CBookshelfIndex::initView()
-{
+void CBookshelfIndex::initView() {
// qDebug("CBookshelfIndex::initView");
- header()->hide();
+ header()->hide();
- setFocusPolicy(Qt::WheelFocus);
- setAcceptDrops( false ); // TODO: accept drops
- setDragEnabled( true );
- setDropIndicatorShown( true );
+ setFocusPolicy(Qt::WheelFocus);
+ setAcceptDrops( false ); // TODO: accept drops
+ setDragEnabled( true );
+ setDropIndicatorShown( true );
- setItemsExpandable(true);
- viewport()->setAcceptDrops(false); //TODO: accept drops
- setRootIsDecorated(false);
- setAllColumnsShowFocus(true);
- setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setItemsExpandable(true);
+ viewport()->setAcceptDrops(false); //TODO: accept drops
+ setRootIsDecorated(false);
+ setAllColumnsShowFocus(true);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
- //setup the popup menu
- m_popup = new QMenu(viewport());
- m_popup->setTitle(tr("Bookshelf"));
+ //setup the popup menu
+ m_popup = new QMenu(viewport());
+ m_popup->setTitle(tr("Bookshelf"));
- initActions();
+ initActions();
// qDebug("CBookshelfIndex::initView end");
}
-void CBookshelfIndex::initActions()
-{
-
- // Each action has a type attached to it as a dynamic property, see actionenum.h.
- // Menuitem and its subitems can have the same type.
- // Actions can have also "singleItemAction" property if
- // it supports only one item.
- // See contextMenu() and BTIndexItem for how these properties are used later.
-
- // Actions are added to the popup menu and also to a list for easy foreach access.
-
- QMenu* actionMenu = 0;
- QAction* action = 0;
-
- // -------------------------Grouping --------------------------------------
- actionMenu = new QMenu(tr("Grouping"), this);
- actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::grouping::icon));
- actionMenu->setProperty("indexActionType", QVariant(Grouping));
-
- m_groupingGroup = new QActionGroup(this);
- QObject::connect(m_groupingGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionChangeGrouping(QAction*)) );
-
- //TODO: set the inital checked state
- action = newQAction(tr("Category/Language"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
- action->setCheckable(true);
- action->setProperty("indexActionType", QVariant(Grouping));
- action->setProperty("grouping", BTModuleTreeItem::CatLangMod);
- actionMenu->addAction(action);
- m_groupingGroup->addAction(action);
- if (m_grouping == BTModuleTreeItem::CatLangMod) action->setChecked(true);
- m_actionList.append(action);
-
- action = newQAction(tr("Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
- action->setCheckable(true);
- m_groupingGroup->addAction(action);
- if (m_grouping == BTModuleTreeItem::CatMod) action->setChecked(true);
- action->setProperty("indexActionType", QVariant(Grouping));
- action->setProperty("grouping", BTModuleTreeItem::CatMod);
- actionMenu->addAction(action);
- m_actionList.append(action);
-
- action = newQAction(tr("Language/Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
- action->setCheckable(true);
- m_groupingGroup->addAction(action);
- if (m_grouping == BTModuleTreeItem::LangCatMod) action->setChecked(true);
- actionMenu->addAction(action);
- action->setProperty("indexActionType", QVariant(Grouping));
- action->setProperty("grouping", BTModuleTreeItem::LangCatMod);
- m_actionList.append(action);
-
- action = newQAction(tr("Language"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
- action->setCheckable(true);
- m_groupingGroup->addAction(action);
- if (m_grouping == BTModuleTreeItem::LangMod) action->setChecked(true);
- actionMenu->addAction(action);
- action->setProperty("indexActionType", QVariant(Grouping));
- action->setProperty("grouping", BTModuleTreeItem::LangMod);
- m_actionList.append(action);
-
- action = newQAction(tr("Works only"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
- action->setCheckable(true);
- m_groupingGroup->addAction(action);
- if (m_grouping == BTModuleTreeItem::Mod) action->setChecked(true);
- actionMenu->addAction(action);
- action->setProperty("indexActionType", QVariant(Grouping));
- action->setProperty("grouping", BTModuleTreeItem::Mod);
- m_actionList.append(action);
-
- action = m_popup->addMenu(actionMenu);
- action->setProperty("indexActionType", QVariant(Grouping));
- m_actionList.append(action);
-
-
- // ------------Hide---------------------
- action = newQAction(tr("Hide/unhide works..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionHideModules()), this);
- action->setProperty("indexActionType", QVariant(HideModules));
- //action->setProperty("multiItemAction", QVariant(true));
- m_popup->addAction(action);
- m_actionList.append(action);
+void CBookshelfIndex::initActions() {
+
+ // Each action has a type attached to it as a dynamic property, see actionenum.h.
+ // Menuitem and its subitems can have the same type.
+ // Actions can have also "singleItemAction" property if
+ // it supports only one item.
+ // See contextMenu() and BTIndexItem for how these properties are used later.
+
+ // Actions are added to the popup menu and also to a list for easy foreach access.
+
+ QMenu* actionMenu = 0;
+ QAction* action = 0;
+
+ // -------------------------Grouping --------------------------------------
+ actionMenu = new QMenu(tr("Grouping"), this);
+ actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::grouping::icon));
+ actionMenu->setProperty("indexActionType", QVariant(Grouping));
+
+ m_groupingGroup = new QActionGroup(this);
+ QObject::connect(m_groupingGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionChangeGrouping(QAction*)) );
+
+ //TODO: set the inital checked state
+ action = newQAction(tr("Category/Language"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
+ action->setCheckable(true);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ action->setProperty("grouping", BTModuleTreeItem::CatLangMod);
+ actionMenu->addAction(action);
+ m_groupingGroup->addAction(action);
+ if (m_grouping == BTModuleTreeItem::CatLangMod) action->setChecked(true);
+ m_actionList.append(action);
+
+ action = newQAction(tr("Category"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
+ action->setCheckable(true);
+ m_groupingGroup->addAction(action);
+ if (m_grouping == BTModuleTreeItem::CatMod) action->setChecked(true);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ action->setProperty("grouping", BTModuleTreeItem::CatMod);
+ actionMenu->addAction(action);
+ m_actionList.append(action);
+
+ action = newQAction(tr("Language/Category"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
+ action->setCheckable(true);
+ m_groupingGroup->addAction(action);
+ if (m_grouping == BTModuleTreeItem::LangCatMod) action->setChecked(true);
+ actionMenu->addAction(action);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ action->setProperty("grouping", BTModuleTreeItem::LangCatMod);
+ m_actionList.append(action);
+
+ action = newQAction(tr("Language"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
+ action->setCheckable(true);
+ m_groupingGroup->addAction(action);
+ if (m_grouping == BTModuleTreeItem::LangMod) action->setChecked(true);
+ actionMenu->addAction(action);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ action->setProperty("grouping", BTModuleTreeItem::LangMod);
+ m_actionList.append(action);
+
+ action = newQAction(tr("Works only"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
+ action->setCheckable(true);
+ m_groupingGroup->addAction(action);
+ if (m_grouping == BTModuleTreeItem::Mod) action->setChecked(true);
+ actionMenu->addAction(action);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ action->setProperty("grouping", BTModuleTreeItem::Mod);
+ m_actionList.append(action);
+
+ action = m_popup->addMenu(actionMenu);
+ action->setProperty("indexActionType", QVariant(Grouping));
+ m_actionList.append(action);
+
+
+ // ------------Hide---------------------
+ action = newQAction(tr("Hide/unhide works..."), CResMgr::mainIndex::search::icon, 0, this, SLOT(actionHideModules()), this);
+ action->setProperty("indexActionType", QVariant(HideModules));
+ //action->setProperty("multiItemAction", QVariant(true));
+ m_popup->addAction(action);
+ m_actionList.append(action);
// -------------------Show hidden---------------------------
- action = newQAction(tr("Show hidden"),CResMgr::mainIndex::search::icon, 0, 0, 0, this);
- action->setProperty("indexActionType", QVariant(ShowAllModules));
- action->setCheckable(true);
- QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(actionShowModules(bool)));
- if (m_showHidden) action->setChecked(true); else action->setChecked(false);
- m_popup->addAction(action);
- m_actionList.append(action);
+ action = newQAction(tr("Show hidden"), CResMgr::mainIndex::search::icon, 0, 0, 0, this);
+ action->setProperty("indexActionType", QVariant(ShowAllModules));
+ action->setCheckable(true);
+ QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(actionShowModules(bool)));
+ if (m_showHidden) action->setChecked(true);
+ else action->setChecked(false);
+ m_popup->addAction(action);
+ m_actionList.append(action);
- m_popup->addSeparator();
+ m_popup->addSeparator();
- //------------------------------------------------------------
- //----------------- Actions for items ------------------------
+ //------------------------------------------------------------
+ //----------------- Actions for items ------------------------
- // -------------------------Edit module --------------------------------
- actionMenu = new QMenu(tr("Edit"), this);
- actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::editModuleMenu::icon) );
+ // -------------------------Edit module --------------------------------
+ actionMenu = new QMenu(tr("Edit"), this);
+ actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::editModuleMenu::icon) );
// actionMenu->setDelayed(false);
- actionMenu->setProperty("indexActionType", QVariant(EditModule));
- actionMenu->setProperty("singleItemAction", QVariant(true));
- //m_actionList.append(actionMenu);
-
- action = newQAction(tr("Plain text..."),CResMgr::mainIndex::editModulePlain::icon, 0, this, SLOT(actionEditModulePlain()), this);
- actionMenu->addAction(action);
- m_actionList.append(action);
- action->setProperty("indexActionType", QVariant(EditModule));
- action->setProperty("singleItemAction", QVariant(true));
-
- action = newQAction(tr("HTML..."),CResMgr::mainIndex::editModuleHTML::icon, 0, this, SLOT(actionEditModuleHTML()), this);
- actionMenu->addAction(action);
- m_actionList.append(action);
- action->setProperty("indexActionType", QVariant(EditModule));
- action->setProperty("singleItemAction", QVariant(true));
-
- m_actionList.append(m_popup->addMenu(actionMenu));
-
-
- // ------------------------ Misc actions -------------------------------------
- action = newQAction(tr("Search..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionSearchInModules()), this);
- action->setProperty("indexActionType", QVariant(SearchModules));
- action->setProperty("multiItemAction", QVariant(true));
- m_popup->addAction(action);
- m_actionList.append(action);
-
- action = newQAction(tr("Unlock..."),CResMgr::mainIndex::unlockModule::icon, 0, this, SLOT(actionUnlockModule()), this);
- m_popup->addAction(action);
- action->setProperty("indexActionType", QVariant(UnlockModule));
- action->setProperty("singleItemAction", QVariant(true));
- m_actionList.append(action);
-
- action = newQAction(tr("About..."),CResMgr::mainIndex::aboutModule::icon, 0, this, SLOT(actionAboutModule()), this);
- m_popup->addAction(action);
- action->setProperty("singleItemAction", QVariant(true));
- action->setProperty("indexActionType", QVariant(AboutModule));
- m_actionList.append(action);
-
-
+ actionMenu->setProperty("indexActionType", QVariant(EditModule));
+ actionMenu->setProperty("singleItemAction", QVariant(true));
+ //m_actionList.append(actionMenu);
+
+ action = newQAction(tr("Plain text..."), CResMgr::mainIndex::editModulePlain::icon, 0, this, SLOT(actionEditModulePlain()), this);
+ actionMenu->addAction(action);
+ m_actionList.append(action);
+ action->setProperty("indexActionType", QVariant(EditModule));
+ action->setProperty("singleItemAction", QVariant(true));
+
+ action = newQAction(tr("HTML..."), CResMgr::mainIndex::editModuleHTML::icon, 0, this, SLOT(actionEditModuleHTML()), this);
+ actionMenu->addAction(action);
+ m_actionList.append(action);
+ action->setProperty("indexActionType", QVariant(EditModule));
+ action->setProperty("singleItemAction", QVariant(true));
+
+ m_actionList.append(m_popup->addMenu(actionMenu));
+
+
+ // ------------------------ Misc actions -------------------------------------
+ action = newQAction(tr("Search..."), CResMgr::mainIndex::search::icon, 0, this, SLOT(actionSearchInModules()), this);
+ action->setProperty("indexActionType", QVariant(SearchModules));
+ action->setProperty("multiItemAction", QVariant(true));
+ m_popup->addAction(action);
+ m_actionList.append(action);
+
+ action = newQAction(tr("Unlock..."), CResMgr::mainIndex::unlockModule::icon, 0, this, SLOT(actionUnlockModule()), this);
+ m_popup->addAction(action);
+ action->setProperty("indexActionType", QVariant(UnlockModule));
+ action->setProperty("singleItemAction", QVariant(true));
+ m_actionList.append(action);
+
+ action = newQAction(tr("About..."), CResMgr::mainIndex::aboutModule::icon, 0, this, SLOT(actionAboutModule()), this);
+ m_popup->addAction(action);
+ action->setProperty("singleItemAction", QVariant(true));
+ action->setProperty("indexActionType", QVariant(AboutModule));
+ m_actionList.append(action);
+
+
}
/** Convenience function for creating a new QAction.
* Should be replaced with something better; it was easier to make a new function
* than to modify all QAction constructors.
*/
-QAction* CBookshelfIndex::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);
- if (receiver && !QString(slot).isEmpty())
- {
- QObject::connect(action, SIGNAL(triggered()), receiver, slot);
- }
- return action;
+QAction* CBookshelfIndex::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);
+ if (receiver && !QString(slot).isEmpty()) {
+ QObject::connect(action, SIGNAL(triggered()), receiver, slot);
+ }
+ return action;
}
/** Initialize the SIGNAL<->SLOT connections */
-void CBookshelfIndex::initConnections()
-{
- //Connect this to the backend module list changes.
- bool ok;
- ok = connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reloadSword(CSwordBackend::SetupChangedReason)));
- Q_ASSERT(ok);
-
- ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
- Q_ASSERT(ok);
-
- // Single/double click item activation is style dependend
- if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0)
- {
- ok = connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
- Q_ASSERT(ok);
- }
-
- ok = connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&)));
- Q_ASSERT(ok);
-
- ok = connect(&m_autoOpenTimer, SIGNAL(timeout()), this, SLOT(autoOpenTimeout()));
- Q_ASSERT(ok);
-
- ok = connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(slotModifySelection()));
- Q_ASSERT(ok);
+void CBookshelfIndex::initConnections() {
+ //Connect this to the backend module list changes.
+ bool ok;
+ ok = connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reloadSword(CSwordBackend::SetupChangedReason)));
+ Q_ASSERT(ok);
+
+ ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
+ Q_ASSERT(ok);
+
+ // Single/double click item activation is style dependend
+ if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0) {
+ ok = connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
+ Q_ASSERT(ok);
+ }
+
+ ok = connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&)));
+ Q_ASSERT(ok);
+
+ ok = connect(&m_autoOpenTimer, SIGNAL(timeout()), this, SLOT(autoOpenTimeout()));
+ Q_ASSERT(ok);
+
+ ok = connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(slotModifySelection()));
+ Q_ASSERT(ok);
}
-void CBookshelfIndex::slotModifySelection()
-{
- // This creates recursion if a folder is selected, but not infinite.
- //qDebug("CBookshelfIndex::slotModifySelection");
- QList<QTreeWidgetItem*> selection = selectedItems();
- foreach (QTreeWidgetItem* item, selection) {
- BTIndexFolder* folder = dynamic_cast<BTIndexFolder*>(item);
- if (folder) {
- item->setSelected(false);
- break;
- }
- }
+void CBookshelfIndex::slotModifySelection() {
+ // This creates recursion if a folder is selected, but not infinite.
+ //qDebug("CBookshelfIndex::slotModifySelection");
+ QList<QTreeWidgetItem*> selection = selectedItems();
+ foreach (QTreeWidgetItem* item, selection) {
+ BTIndexFolder* folder = dynamic_cast<BTIndexFolder*>(item);
+ if (folder) {
+ item->setSelected(false);
+ break;
+ }
+ }
}
/**
* Hack to get single click and selection working. See slotExecuted.
*/
void CBookshelfIndex::mouseReleaseEvent(QMouseEvent* event) {
- //qDebug("CBookshelfIndex::mouseReleaseEvent");
- //qDebug() << event->type() << event->modifiers();
- if (itemAt(event->pos())) {
- if (m_frozenModules.contains( itemAt(event->pos())->text(0) )) {
- //do nothing
- event->accept();
- return;
- }
- }
- m_mouseReleaseEventModifiers = event->modifiers();
- QTreeWidget::mouseReleaseEvent(event);
+ //qDebug("CBookshelfIndex::mouseReleaseEvent");
+ //qDebug() << event->type() << event->modifiers();
+ if (itemAt(event->pos())) {
+ if (m_frozenModules.contains( itemAt(event->pos())->text(0) )) {
+ //do nothing
+ event->accept();
+ return;
+ }
+ }
+ m_mouseReleaseEventModifiers = event->modifiers();
+ QTreeWidget::mouseReleaseEvent(event);
}
/** Called when an item is clicked with mouse or activated with keyboard. */
-void CBookshelfIndex::slotExecuted( QTreeWidgetItem* i )
-{
- qDebug("CBookshelfIndex::slotExecuted");
-
- //HACK: checking the modifier keys from the last mouseReleaseEvent
- //depends on executing order: mouseReleaseEvent first, then itemClicked signal
- int modifiers = m_mouseReleaseEventModifiers;
- m_mouseReleaseEventModifiers = Qt::NoModifier;
- if (modifiers != Qt::NoModifier) {
- return;
- }
-
- BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(i);
- if (!btItem) {
- qWarning("item was not BTIndexItem!");
- return;
- }
-
- if (BTIndexModule* m = dynamic_cast<BTIndexModule*>(i)) { //clicked on a module
- CSwordModuleInfo* mod = m->moduleInfo();
- if (!m_frozenModules.contains(mod->name())) {
- m_frozenModules.insert(mod->name());
- QList<CSwordModuleInfo*> modules;
- modules.append(mod);
- qDebug("will emit createReadDisplayWindow");
- emit createReadDisplayWindow(modules, QString::null);
-
- }
- } else {
- i->setExpanded( !i->isExpanded() );
- }
+void CBookshelfIndex::slotExecuted( QTreeWidgetItem* i ) {
+ qDebug("CBookshelfIndex::slotExecuted");
+
+ //HACK: checking the modifier keys from the last mouseReleaseEvent
+ //depends on executing order: mouseReleaseEvent first, then itemClicked signal
+ int modifiers = m_mouseReleaseEventModifiers;
+ m_mouseReleaseEventModifiers = Qt::NoModifier;
+ if (modifiers != Qt::NoModifier) {
+ return;
+ }
+
+ BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(i);
+ if (!btItem) {
+ qWarning("item was not BTIndexItem!");
+ return;
+ }
+
+ if (BTIndexModule* m = dynamic_cast<BTIndexModule*>(i)) { //clicked on a module
+ CSwordModuleInfo* mod = m->moduleInfo();
+ if (!m_frozenModules.contains(mod->name())) {
+ m_frozenModules.insert(mod->name());
+ QList<CSwordModuleInfo*> modules;
+ modules.append(mod);
+ qDebug("will emit createReadDisplayWindow");
+ emit createReadDisplayWindow(modules, QString::null);
+
+ }
+ }
+ else {
+ i->setExpanded( !i->isExpanded() );
+ }
}
-void CBookshelfIndex::unfreezeModules(QList<CSwordModuleInfo*> modules)
-{
- foreach (CSwordModuleInfo* mInfo, modules) {
- m_frozenModules.remove(mInfo->name());
- }
+void CBookshelfIndex::unfreezeModules(QList<CSwordModuleInfo*> modules) {
+ foreach (CSwordModuleInfo* mInfo, modules) {
+ m_frozenModules.remove(mInfo->name());
+ }
}
/** Reimplementation. Returns the drag object for the current selection. */
-QMimeData* CBookshelfIndex::dragObject()
-{
- //TODO: we have to add a mime type "module" if we want to for example enable draggin a module to a displaywindow
- return 0;
+QMimeData* CBookshelfIndex::dragObject() {
+ //TODO: we have to add a mime type "module" if we want to for example enable draggin a module to a displaywindow
+ return 0;
}
/** Reimplementation from QTreeWidget. Returns true if the drag is acceptable for the widget. */
-void CBookshelfIndex::dragEnterEvent( QDragEnterEvent* event )
-{
- //qDebug("CBookshelfIndex::dragEnterEvent");
- event->acceptProposedAction();
+void CBookshelfIndex::dragEnterEvent( QDragEnterEvent* event ) {
+ //qDebug("CBookshelfIndex::dragEnterEvent");
+ event->acceptProposedAction();
}
-void CBookshelfIndex::dragMoveEvent( QDragMoveEvent* event )
-{
- const QPoint pos = event->pos();
-
- BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
- //TODO: implement accepting drop in item
- if (i && i->acceptDrop(event->mimeData()) ) {
- event->acceptProposedAction();
- } else {
- event->ignore();
- }
+void CBookshelfIndex::dragMoveEvent( QDragMoveEvent* event ) {
+ const QPoint pos = event->pos();
+
+ BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
+ //TODO: implement accepting drop in item
+ if (i && i->acceptDrop(event->mimeData()) ) {
+ event->acceptProposedAction();
+ }
+ else {
+ event->ignore();
+ }
}
-void CBookshelfIndex::dropEvent( QDropEvent* event )
-{
- const QPoint pos = event->pos();
-
- BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
- //TODO: implement accepting drop in item
- if (i && i->acceptDrop(event->mimeData()) ) {
- QMenu* menu = new QMenu(this);
- QAction* openAction = menu->addAction("Open reference in new subwindow");
- QAction* searchRefAction = menu->addAction("Search for reference as crossreference");
- QAction* searchAction = menu->addAction("Search text");
- QAction* selectedAction = menu->exec(this->mapToGlobal(pos));
- if (selectedAction == openAction) {;}
- if (selectedAction == searchAction) {;}
- if (selectedAction == searchRefAction) {;}
- event->acceptProposedAction();
- } else {
- event->ignore();
- }
+void CBookshelfIndex::dropEvent( QDropEvent* event ) {
+ const QPoint pos = event->pos();
+
+ BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
+ //TODO: implement accepting drop in item
+ if (i && i->acceptDrop(event->mimeData()) ) {
+ QMenu* menu = new QMenu(this);
+ QAction* openAction = menu->addAction("Open reference in new subwindow");
+ QAction* searchRefAction = menu->addAction("Search for reference as crossreference");
+ QAction* searchAction = menu->addAction("Search text");
+ QAction* selectedAction = menu->exec(this->mapToGlobal(pos));
+ if (selectedAction == openAction) {
+ ;
+ }
+ if (selectedAction == searchAction) {
+ ;
+ }
+ if (selectedAction == searchRefAction) {
+ ;
+ }
+ event->acceptProposedAction();
+ }
+ else {
+ event->ignore();
+ }
}
-void CBookshelfIndex::changeEvent(QEvent* e)
-{
- if (e->type() == QEvent::StyleChange) {
- // Single/double click item activation is style dependend
- QObject::disconnect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
- if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0) {
- QObject::connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
- }
- }
- QTreeWidget::changeEvent(e);
+void CBookshelfIndex::changeEvent(QEvent* e) {
+ if (e->type() == QEvent::StyleChange) {
+ // Single/double click item activation is style dependend
+ QObject::disconnect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
+ if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0) {
+ QObject::connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
+ }
+ }
+ QTreeWidget::changeEvent(e);
}
/** No descriptions */
void CBookshelfIndex::initTree() {
- qDebug("CBookshelfIndex::initTree");
-
- //first clean the tree
- clear();
- //m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
-
- BTModuleTreeItem::HiddenOff hiddenFilter;
- QList<BTModuleTreeItem::Filter*> filters;
- if (!m_showHidden) {
- filters.append(&hiddenFilter);
- }
- BTModuleTreeItem root(filters, m_grouping);
- addToTree(&root, this->invisibleRootItem());
+ qDebug("CBookshelfIndex::initTree");
+
+ //first clean the tree
+ clear();
+ //m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
+
+ BTModuleTreeItem::HiddenOff hiddenFilter;
+ QList<BTModuleTreeItem::Filter*> filters;
+ if (!m_showHidden) {
+ filters.append(&hiddenFilter);
+ }
+ BTModuleTreeItem root(filters, m_grouping);
+ addToTree(&root, this->invisibleRootItem());
}
-void CBookshelfIndex::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem)
-{
- foreach (BTModuleTreeItem* i, item->children()) {
- if (i->type() == BTModuleTreeItem::Module) {
- addToTree(i, new BTIndexModule(i, widgetItem));
- }
- else
- addToTree(i, new BTIndexFolder(i, widgetItem));
- }
- // Possible TODO: if item is Language and it's under Category and Category is Glossaries,
- // add the second language name - but how to add other language group?
- // do we have to modify btmoduletreeitem?
+void CBookshelfIndex::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
+ foreach (BTModuleTreeItem* i, item->children()) {
+ if (i->type() == BTModuleTreeItem::Module) {
+ addToTree(i, new BTIndexModule(i, widgetItem));
+ }
+ else
+ addToTree(i, new BTIndexFolder(i, widgetItem));
+ }
+ // Possible TODO: if item is Language and it's under Category and Category is Glossaries,
+ // add the second language name - but how to add other language group?
+ // do we have to modify btmoduletreeitem?
}
/** No descriptions */
void CBookshelfIndex::emitModulesChosen( QList<CSwordModuleInfo*> modules, QString key ) {
- emit createReadDisplayWindow(modules, key);
+ emit createReadDisplayWindow(modules, key);
}
/** Shows the context menu at the given position. */
void CBookshelfIndex::contextMenu(const QPoint& p) {
- qDebug("CBookshelfIndex::contextMenu");
- qDebug() << "list of actions: ";
- foreach (QAction* action, m_actionList) {
- qDebug() << action->text();
- }
- //setup menu entries depending on current selection
- QTreeWidgetItem* i = itemAt(p);
- qDebug() << "item at point: " << i;
- QList<QTreeWidgetItem *> items = selectedItems();
- //The item which was clicked may not be selected - but don't add folder
- if (i && !dynamic_cast<BTIndexFolder*>(i) && !items.contains(i))
- items.append(i);
-
- // disable those menu entries which are item dependent,
- // dis/enable some others
- qDebug()<<"grouping action type:"<<(int)Grouping;
- foreach (QAction* action, m_actionList) {
- IndexAction actionType = (IndexAction)action->property("indexActionType").toInt();
- qDebug() << "action type:" << actionType;
- if ( actionType == Grouping ) {
- qDebug()<<"grouping action, enabling...";
- action->setEnabled(true);
- qDebug()<< action->isEnabled();
- }
- else if (actionType == ShowAllModules) {
- //enabled only if there are hidden modules
- if (!CBTConfig::get(CBTConfig::hiddenModules).empty()) {
- action->setEnabled(true);
- } else {
- action->setEnabled(false);
- }
- action->setChecked(m_showHidden);
-
- }
- else if (actionType == SearchModules) {
- action->setText(tr("Search"));
- if (items.count() > 0)
- action->setEnabled(true);
- else action->setEnabled(false);
- }
- else if (actionType == HideModules) {
- //action->setText(tr("Hide"));
- action->setEnabled(true);
- }
- else action->setEnabled(false);
- }
-
-
- if (items.count() == 0) {
- //special handling for no selection: do nothing
- }
-
- if (items.count() == 1) {
- //special handling for one selected item
- qDebug("there was one selected item");
- BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(items.at(0));
-
- if (btItem && !dynamic_cast<BTIndexFolder*>(btItem)) {
- foreach (QAction* action, m_actionList) {
- if ( (IndexAction)action->property("indexActionType").toInt() == AboutModule ) {
- qDebug() << "enabling action" << action->text();
- action->setEnabled(true);
- }
- else if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
- // Change the text of the menu item to reflect the module name
- BTIndexModule* modItem = dynamic_cast<BTIndexModule*>(btItem);
- if (modItem) {
- CSwordModuleInfo* info = modItem->moduleInfo();
- action->setText(tr("Search in %1...").arg(info->name()));
- }
- }
- else {
- qDebug() << "ask item" << items.at(0)->text(0) << "to enable the action" << action->text();
- btItem->enableAction(action);
- }
- qDebug() << "action enabled is: " << action->isEnabled();
- }
- }
- }
- else { // more than one item
- foreach (QAction* action, m_actionList) {
- // Change the text of some menu items to reflect multiple selection
- if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
- action->setText(tr("Search in selected..."));
- }
- // Enable items
- foreach(QTreeWidgetItem* item, items) {
- BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(item);
- if (btItem && !action->property("singleItemAction").isValid()) {
- btItem->enableAction(action);
- }
- }
- }
- }
-
- //finally, open the popup
- m_popup->exec(mapToGlobal(p));
+ qDebug("CBookshelfIndex::contextMenu");
+ qDebug() << "list of actions: ";
+ foreach (QAction* action, m_actionList) {
+ qDebug() << action->text();
+ }
+ //setup menu entries depending on current selection
+ QTreeWidgetItem* i = itemAt(p);
+ qDebug() << "item at point: " << i;
+ QList<QTreeWidgetItem *> items = selectedItems();
+ //The item which was clicked may not be selected - but don't add folder
+ if (i && !dynamic_cast<BTIndexFolder*>(i) && !items.contains(i))
+ items.append(i);
+
+ // disable those menu entries which are item dependent,
+ // dis/enable some others
+ qDebug() << "grouping action type:" << (int)Grouping;
+ foreach (QAction* action, m_actionList) {
+ IndexAction actionType = (IndexAction)action->property("indexActionType").toInt();
+ qDebug() << "action type:" << actionType;
+ if ( actionType == Grouping ) {
+ qDebug() << "grouping action, enabling...";
+ action->setEnabled(true);
+ qDebug() << action->isEnabled();
+ }
+ else if (actionType == ShowAllModules) {
+ //enabled only if there are hidden modules
+ if (!CBTConfig::get(CBTConfig::hiddenModules).empty()) {
+ action->setEnabled(true);
+ }
+ else {
+ action->setEnabled(false);
+ }
+ action->setChecked(m_showHidden);
+
+ }
+ else if (actionType == SearchModules) {
+ action->setText(tr("Search"));
+ if (items.count() > 0)
+ action->setEnabled(true);
+ else action->setEnabled(false);
+ }
+ else if (actionType == HideModules) {
+ //action->setText(tr("Hide"));
+ action->setEnabled(true);
+ }
+ else action->setEnabled(false);
+ }
+
+
+ if (items.count() == 0) {
+ //special handling for no selection: do nothing
+ }
+
+ if (items.count() == 1) {
+ //special handling for one selected item
+ qDebug("there was one selected item");
+ BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(items.at(0));
+
+ if (btItem && !dynamic_cast<BTIndexFolder*>(btItem)) {
+ foreach (QAction* action, m_actionList) {
+ if ( (IndexAction)action->property("indexActionType").toInt() == AboutModule ) {
+ qDebug() << "enabling action" << action->text();
+ action->setEnabled(true);
+ }
+ else if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
+ // Change the text of the menu item to reflect the module name
+ BTIndexModule* modItem = dynamic_cast<BTIndexModule*>(btItem);
+ if (modItem) {
+ CSwordModuleInfo* info = modItem->moduleInfo();
+ action->setText(tr("Search in %1...").arg(info->name()));
+ }
+ }
+ else {
+ qDebug() << "ask item" << items.at(0)->text(0) << "to enable the action" << action->text();
+ btItem->enableAction(action);
+ }
+ qDebug() << "action enabled is: " << action->isEnabled();
+ }
+ }
+ }
+ else { // more than one item
+ foreach (QAction* action, m_actionList) {
+ // Change the text of some menu items to reflect multiple selection
+ if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
+ action->setText(tr("Search in selected..."));
+ }
+ // Enable items
+ foreach(QTreeWidgetItem* item, items) {
+ BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(item);
+ if (btItem && !action->property("singleItemAction").isValid()) {
+ btItem->enableAction(action);
+ }
+ }
+ }
+ }
+
+ //finally, open the popup
+ m_popup->exec(mapToGlobal(p));
}
-void CBookshelfIndex::actionChangeGrouping(QAction* action)
-{
- BTModuleTreeItem::Grouping grouping = (BTModuleTreeItem::Grouping)action->property("grouping").toInt();
- m_grouping = grouping;
- CBTConfig::set(CBTConfig::bookshelfGrouping, grouping);
- initTree();
+void CBookshelfIndex::actionChangeGrouping(QAction* action) {
+ BTModuleTreeItem::Grouping grouping = (BTModuleTreeItem::Grouping)action->property("grouping").toInt();
+ m_grouping = grouping;
+ CBTConfig::set(CBTConfig::bookshelfGrouping, grouping);
+ initTree();
}
/** Opens the searchdialog for the selected modules. */
void CBookshelfIndex::actionSearchInModules() {
- QList<QTreeWidgetItem *> items = selectedItems();
- QListIterator<QTreeWidgetItem *> it(items);
- QList<CSwordModuleInfo*> modules;
- while(it.hasNext()) {
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
- if (i->moduleInfo()) {
- modules.append(i->moduleInfo());
- }
- }
- }
-
- if (modules.isEmpty()) { //get a list of useful default modules for the search if no modules were selected
- CSwordModuleInfo* m = CBTConfig::get(CBTConfig::standardBible);
- if (m) {
- modules.append(m);
- }
- }
-
- Search::CSearchDialog::openDialog(modules, QString::null);
+ QList<QTreeWidgetItem *> items = selectedItems();
+ QListIterator<QTreeWidgetItem *> it(items);
+ QList<CSwordModuleInfo*> modules;
+ while (it.hasNext()) {
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
+ if (i->moduleInfo()) {
+ modules.append(i->moduleInfo());
+ }
+ }
+ }
+
+ if (modules.isEmpty()) { //get a list of useful default modules for the search if no modules were selected
+ CSwordModuleInfo* m = CBTConfig::get(CBTConfig::standardBible);
+ if (m) {
+ modules.append(m);
+ }
+ }
+
+ Search::CSearchDialog::openDialog(modules, QString::null);
}
/** Unlocks the current module. */
void CBookshelfIndex::actionUnlockModule() {
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
- bool ok = false;
- const QString unlockKey =
- QInputDialog::getText(
- this,
- tr("Unlock Work"),
- tr("Enter the unlock key for this work."),
- QLineEdit::Normal,
- i->moduleInfo()->config(CSwordModuleInfo::CipherKey),
- &ok
- );
-
- if (ok) {
- i->moduleInfo()->unlock( unlockKey );
- CPointers::backend()->reloadModules(CSwordBackend::OtherChange);
- }
- }
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
+ bool ok = false;
+ const QString unlockKey =
+ QInputDialog::getText(
+ this,
+ tr("Unlock Work"),
+ tr("Enter the unlock key for this work."),
+ QLineEdit::Normal,
+ i->moduleInfo()->config(CSwordModuleInfo::CipherKey),
+ &ok
+ );
+
+ if (ok) {
+ i->moduleInfo()->unlock( unlockKey );
+ CPointers::backend()->reloadModules(CSwordBackend::OtherChange);
+ }
+ }
}
-void CBookshelfIndex::actionShowModules(bool checked)
-{
- qDebug("CBookshelfIndex::actionShowModules");
- m_showHidden = checked;
- CBTConfig::set(CBTConfig::bookshelfShowHidden, m_showHidden);
- // show hidden status is changed, notify others who may rebuild their module lists
- CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
+void CBookshelfIndex::actionShowModules(bool checked) {
+ qDebug("CBookshelfIndex::actionShowModules");
+ m_showHidden = checked;
+ CBTConfig::set(CBTConfig::bookshelfShowHidden, m_showHidden);
+ // show hidden status is changed, notify others who may rebuild their module lists
+ CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
}
-void CBookshelfIndex::actionHideModules()
-{
- qDebug("CBookshelfIndex::actionHideModules");
- QString current;
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
- current = i->text(0);
- }
-
- QString title(tr("Hide/Unhide Works"));
- QString label(tr("Select the works to be hidden."));
- CHideModuleChooserDialog* dlg = new CHideModuleChooserDialog(this, title, label, current);
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>)),
- this, SLOT(setHiddenModules(QList<CSwordModuleInfo*>)));
- int code = dlg->exec();
- if (code == QDialog::Accepted) {
- // notify all who may rebuild their module lists
- CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
- }
+void CBookshelfIndex::actionHideModules() {
+ qDebug("CBookshelfIndex::actionHideModules");
+ QString current;
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
+ current = i->text(0);
+ }
+
+ QString title(tr("Hide/Unhide Works"));
+ QString label(tr("Select the works to be hidden."));
+ CHideModuleChooserDialog* dlg = new CHideModuleChooserDialog(this, title, label, current);
+ connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>)),
+ this, SLOT(setHiddenModules(QList<CSwordModuleInfo*>)));
+ int code = dlg->exec();
+ if (code == QDialog::Accepted) {
+ // notify all who may rebuild their module lists
+ CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
+ }
}
/** Shows information about the current module. */
void CBookshelfIndex::actionAboutModule() {
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
- BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, i->moduleInfo());
- dialog->show();
- dialog->raise();
- }
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
+ BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, i->moduleInfo());
+ dialog->show();
+ dialog->raise();
+ }
}
/** Reimplementation. Takes care of movable items. */
@@ -652,7 +644,7 @@ void CBookshelfIndex::contentsDragMoveEvent( QDragMoveEvent* /*event*/ ) {
// if (m_autoOpenFolder != i) {
// m_autoOpenTimer.stop();
// }
-//
+//
// m_autoOpenFolder = i;
// m_autoOpenTimer.start( 400 );
// }
@@ -663,16 +655,16 @@ void CBookshelfIndex::contentsDragMoveEvent( QDragMoveEvent* /*event*/ ) {
// else {
// m_autoOpenFolder = 0;
// }
-//
+//
// QTreeWidget::contentsDragMoveEvent(event);
}
void CBookshelfIndex::autoOpenTimeout() {
- m_autoOpenTimer.stop();
- if (m_autoOpenFolder && !m_autoOpenFolder->isExpanded() && m_autoOpenFolder->childCount()) {
- m_autoOpenFolder->setExpanded(true);
- }
+ m_autoOpenTimer.stop();
+ if (m_autoOpenFolder && !m_autoOpenFolder->isExpanded() && m_autoOpenFolder->childCount()) {
+ m_autoOpenFolder->setExpanded(true);
+ }
}
/** No descriptions */
@@ -684,39 +676,39 @@ void CBookshelfIndex::contentsDragLeaveEvent( QDragLeaveEvent* /*e*/ ) {
/** Opens an editor window to edit the modules content. */
void CBookshelfIndex::actionEditModulePlain() {
- QList<CSwordModuleInfo*> modules;
- QList<QTreeWidgetItem *> items = selectedItems();
- QListIterator<QTreeWidgetItem *> it(items);
- //loop through items
- while(it.hasNext()) {
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
- modules.append(i->moduleInfo());
- }
- }
- if (modules.count() == 1) {
- emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::PlainTextWindow);
- };
+ QList<CSwordModuleInfo*> modules;
+ QList<QTreeWidgetItem *> items = selectedItems();
+ QListIterator<QTreeWidgetItem *> it(items);
+ //loop through items
+ while (it.hasNext()) {
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
+ modules.append(i->moduleInfo());
+ }
+ }
+ if (modules.count() == 1) {
+ emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::PlainTextWindow);
+ };
}
/** Opens an editor window to edit the modules content. */
void CBookshelfIndex::actionEditModuleHTML() {
- QList<CSwordModuleInfo*> modules;
- QList<QTreeWidgetItem *> items = selectedItems();
- QListIterator<QTreeWidgetItem *> it(items);
- while(it.hasNext()) {
- if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
- modules.append(i->moduleInfo());
- }
- }
-
- if (modules.count() == 1) {
- emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::HTMLWindow);
- }
+ QList<CSwordModuleInfo*> modules;
+ QList<QTreeWidgetItem *> items = selectedItems();
+ QListIterator<QTreeWidgetItem *> it(items);
+ while (it.hasNext()) {
+ if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
+ modules.append(i->moduleInfo());
+ }
+ }
+
+ if (modules.count() == 1) {
+ emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::HTMLWindow);
+ }
}
/** Reloads the main index's Sword dependend things like modules */
void CBookshelfIndex::reloadSword(CSwordBackend::SetupChangedReason) {
- //reload the modules
- qDebug("CBookshelfIndex::reloadSword");
- initTree();
+ //reload the modules
+ qDebug("CBookshelfIndex::reloadSword");
+ initTree();
}
diff --git a/src/frontend/mainindex/bookshelf/cbookshelfindex.h b/src/frontend/mainindex/bookshelf/cbookshelfindex.h
index bd21069..b5e821f 100644
--- a/src/frontend/mainindex/bookshelf/cbookshelfindex.h
+++ b/src/frontend/mainindex/bookshelf/cbookshelfindex.h
@@ -45,161 +45,161 @@ class BTModuleTreeItem;
* @author The BibleTime team
*/
class CBookshelfIndex : public QTreeWidget {
- Q_OBJECT
-
-public:
- CBookshelfIndex(QWidget *parent);
- virtual ~CBookshelfIndex();
-
- void initTree();
- /**
- * Opens the searchdialog using the given modules using the given search text.
- */
- void emitModulesChosen( QList<CSwordModuleInfo*> modules, QString key );
-
- /** Helper method for "freezing" modules while opening them in windows. */
- void unfreezeModules(QList<CSwordModuleInfo*>);
-
-public slots:
-
- /**
- * Reloads the main index's Sword dependend things like modules
- */
- void reloadSword(CSwordBackend::SetupChangedReason);
-
- /**
- * Opens the searchdialog for the selected modules.
- */
- void actionSearchInModules();
-
-protected:
-
- /** Handle mouse clicks.*/
- virtual void mouseReleaseEvent(QMouseEvent* event);
-
- /** Empty re-implementation to prevent unwanted opening of folders with some styles.*/
- virtual void mouseDoubleClickEvent(QMouseEvent*) {}
-
- /**
- * Initialize the SIGNAL<->SLOT connections
- */
- void initConnections();
- /**
- * Reimplementation. Returns the drag object for the current selection.
- */
- virtual QMimeData* dragObject();
- /**
- * Reimplementation from QTreeWidget (QAbstractItemView). Returns true if the drag is acceptable for the listview.
- */
- virtual void dragEnterEvent( QDragEnterEvent* event );
- virtual void dragMoveEvent( QDragMoveEvent* event );
- virtual void dropEvent( QDropEvent* event );
-
- /** Receive style change event to change single/double click activation behaviour. */
- virtual void changeEvent(QEvent*);
-
- /**
- * Reimplementation from QAbstractItemView. Takes care of movable items.
- */
- virtual void startDrag(Qt::DropActions supportedActions);
- /**
- * TODO: qt4 Reimplementation to support the items dragEnter and dragLeave functions.
- */
- virtual void contentsDragMoveEvent( QDragMoveEvent* event );
- /**
- * Reimplementation.
- */
- virtual void contentsDragLeaveEvent( QDragLeaveEvent* e );
-
-
-protected slots: // Protected slots
- /**
- * Called when the selection is changed.
- */
- void slotModifySelection();
- /**
- * Is called when an item was clicked or activated.
- */
- void slotExecuted( QTreeWidgetItem* );
-
- /**
- * Shows the context menu at the given position.
- */
- void contextMenu(const QPoint&);
-
- /**
- * Changes the grouping.
- */
- void actionChangeGrouping(QAction* action);
-
- /**
- * Shows information about the current module.
- */
-
- /**
- * Show or hide the hidden modules, depending on the action check state.
- */
- void actionShowModules(bool checked);
-
- /**
- * Set the selected modules hidden.
- */
- void actionHideModules();
-
-
- void actionAboutModule();
- /**
- * Unlocks the current module.
- */
- void actionUnlockModule();
- void autoOpenTimeout();
-
- /**
- * Opens a plain text editor window to edit the modules content.
- */
- void actionEditModulePlain();
- /**
- * Opens an HTML editor window to edit the modules content.
- */
- void actionEditModuleHTML();
-
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
-
-
-private:
- CSearchDialog* m_searchDialog;
- //ToolTip* m_toolTip;
- bool m_itemsMovable;
- QTreeWidgetItem* m_autoOpenFolder;
- QTimer m_autoOpenTimer;
- BTModuleTreeItem::Grouping m_grouping; //temporary solution - this should be in config
- QActionGroup* m_groupingGroup;
- int m_mouseReleaseEventModifiers;
- bool m_showHidden;
- QSet<QString> m_frozenModules;
-
- /**
- * Initializes the view.
- */
- void initView();
- void initActions();
-
- /** Convenience function for creating a new QAction. */
- QAction* newQAction(const QString& text, const QString& pix, int shortcut, const QObject* receiver, const char* slot, QObject* parent);
-
- QList<QAction*> m_actionList;
-
- QMenu* m_popup;
-
-signals:
- /**
- * Is emitted when a module should be opened,
- */
- void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
- /**
- * Is emitted when a write window should be created.
- */
- void createWriteDisplayWindow( CSwordModuleInfo*, const QString&, const CDisplayWindow::WriteWindowType& );
+ Q_OBJECT
+
+ public:
+ CBookshelfIndex(QWidget *parent);
+ virtual ~CBookshelfIndex();
+
+ void initTree();
+ /**
+ * Opens the searchdialog using the given modules using the given search text.
+ */
+ void emitModulesChosen( QList<CSwordModuleInfo*> modules, QString key );
+
+ /** Helper method for "freezing" modules while opening them in windows. */
+ void unfreezeModules(QList<CSwordModuleInfo*>);
+
+ public slots:
+
+ /**
+ * Reloads the main index's Sword dependend things like modules
+ */
+ void reloadSword(CSwordBackend::SetupChangedReason);
+
+ /**
+ * Opens the searchdialog for the selected modules.
+ */
+ void actionSearchInModules();
+
+ protected:
+
+ /** Handle mouse clicks.*/
+ virtual void mouseReleaseEvent(QMouseEvent* event);
+
+ /** Empty re-implementation to prevent unwanted opening of folders with some styles.*/
+ virtual void mouseDoubleClickEvent(QMouseEvent*) {}
+
+ /**
+ * Initialize the SIGNAL<->SLOT connections
+ */
+ void initConnections();
+ /**
+ * Reimplementation. Returns the drag object for the current selection.
+ */
+ virtual QMimeData* dragObject();
+ /**
+ * Reimplementation from QTreeWidget (QAbstractItemView). Returns true if the drag is acceptable for the listview.
+ */
+ virtual void dragEnterEvent( QDragEnterEvent* event );
+ virtual void dragMoveEvent( QDragMoveEvent* event );
+ virtual void dropEvent( QDropEvent* event );
+
+ /** Receive style change event to change single/double click activation behaviour. */
+ virtual void changeEvent(QEvent*);
+
+ /**
+ * Reimplementation from QAbstractItemView. Takes care of movable items.
+ */
+ virtual void startDrag(Qt::DropActions supportedActions);
+ /**
+ * TODO: qt4 Reimplementation to support the items dragEnter and dragLeave functions.
+ */
+ virtual void contentsDragMoveEvent( QDragMoveEvent* event );
+ /**
+ * Reimplementation.
+ */
+ virtual void contentsDragLeaveEvent( QDragLeaveEvent* e );
+
+
+ protected slots: // Protected slots
+ /**
+ * Called when the selection is changed.
+ */
+ void slotModifySelection();
+ /**
+ * Is called when an item was clicked or activated.
+ */
+ void slotExecuted( QTreeWidgetItem* );
+
+ /**
+ * Shows the context menu at the given position.
+ */
+ void contextMenu(const QPoint&);
+
+ /**
+ * Changes the grouping.
+ */
+ void actionChangeGrouping(QAction* action);
+
+ /**
+ * Shows information about the current module.
+ */
+
+ /**
+ * Show or hide the hidden modules, depending on the action check state.
+ */
+ void actionShowModules(bool checked);
+
+ /**
+ * Set the selected modules hidden.
+ */
+ void actionHideModules();
+
+
+ void actionAboutModule();
+ /**
+ * Unlocks the current module.
+ */
+ void actionUnlockModule();
+ void autoOpenTimeout();
+
+ /**
+ * Opens a plain text editor window to edit the modules content.
+ */
+ void actionEditModulePlain();
+ /**
+ * Opens an HTML editor window to edit the modules content.
+ */
+ void actionEditModuleHTML();
+
+ void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+
+
+ private:
+ CSearchDialog* m_searchDialog;
+ //ToolTip* m_toolTip;
+ bool m_itemsMovable;
+ QTreeWidgetItem* m_autoOpenFolder;
+ QTimer m_autoOpenTimer;
+ BTModuleTreeItem::Grouping m_grouping; //temporary solution - this should be in config
+ QActionGroup* m_groupingGroup;
+ int m_mouseReleaseEventModifiers;
+ bool m_showHidden;
+ QSet<QString> m_frozenModules;
+
+ /**
+ * Initializes the view.
+ */
+ void initView();
+ void initActions();
+
+ /** Convenience function for creating a new QAction. */
+ QAction* newQAction(const QString& text, const QString& pix, int shortcut, const QObject* receiver, const char* slot, QObject* parent);
+
+ QList<QAction*> m_actionList;
+
+ QMenu* m_popup;
+
+ signals:
+ /**
+ * Is emitted when a module should be opened,
+ */
+ void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
+ /**
+ * Is emitted when a write window should be created.
+ */
+ void createWriteDisplayWindow( CSwordModuleInfo*, const QString&, const CDisplayWindow::WriteWindowType& );
};
diff --git a/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp b/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp
index 0a923c4..2888020 100644
--- a/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp
+++ b/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp
@@ -31,40 +31,38 @@
CHideModuleChooserDialog::CHideModuleChooserDialog( QWidget* parent, QString title, QString label, QString currentModule)
- : CModuleChooserDialog(parent, title, label),
- m_currentModule(currentModule),
- m_focusItem(0)
-{
- QObject::connect(this, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(applyHiddenModules(QList<CSwordModuleInfo*>)));
- init();
- if (m_focusItem) {
- treeWidget()->scrollToItem(m_focusItem);
- }
+ : CModuleChooserDialog(parent, title, label),
+ m_currentModule(currentModule),
+ m_focusItem(0) {
+ QObject::connect(this, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(applyHiddenModules(QList<CSwordModuleInfo*>)));
+ init();
+ if (m_focusItem) {
+ treeWidget()->scrollToItem(m_focusItem);
+ }
}
-void CHideModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem)
-{
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- if (btItem->moduleInfo()->isHidden())
- widgetItem->setCheckState(0, Qt::Checked);
- else
- widgetItem->setCheckState(0, Qt::Unchecked);
- if (m_currentModule == widgetItem->text(0)) {
- m_focusItem = widgetItem;
- }
+void CHideModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) {
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ if (btItem->moduleInfo()->isHidden())
+ widgetItem->setCheckState(0, Qt::Checked);
+ else
+ widgetItem->setCheckState(0, Qt::Unchecked);
+ if (m_currentModule == widgetItem->text(0)) {
+ m_focusItem = widgetItem;
+ }
}
-void CHideModuleChooserDialog::applyHiddenModules(QList<CSwordModuleInfo*> hiddenModules)
-{
- qDebug("CHideModuleChooserDialog::applyHiddenModules");
- QList<CSwordModuleInfo*> allModules = CPointers::backend()->moduleList();
- foreach(CSwordModuleInfo* i, allModules) {
- if (hiddenModules.contains(i)) {
- i->setHidden(true);
- } else {
- i->setHidden(false);
- }
+void CHideModuleChooserDialog::applyHiddenModules(QList<CSwordModuleInfo*> hiddenModules) {
+ qDebug("CHideModuleChooserDialog::applyHiddenModules");
+ QList<CSwordModuleInfo*> allModules = CPointers::backend()->moduleList();
+ foreach(CSwordModuleInfo* i, allModules) {
+ if (hiddenModules.contains(i)) {
+ i->setHidden(true);
+ }
+ else {
+ i->setHidden(false);
+ }
- }
+ }
}
diff --git a/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h b/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h
index 9fd7e8c..3b7984e 100644
--- a/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h
+++ b/src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h
@@ -20,22 +20,21 @@ class BTModuleTreeItem;
-class CHideModuleChooserDialog : public CModuleChooserDialog
-{
- Q_OBJECT
-public:
- CHideModuleChooserDialog(QWidget* parent, QString title, QString label, QString currentModule);
- ~CHideModuleChooserDialog() {}
-
-protected:
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
-protected slots:
- void applyHiddenModules(QList<CSwordModuleInfo*> hiddenModules);
-
-
-private:
- QString m_currentModule;
- QTreeWidgetItem* m_focusItem;
+class CHideModuleChooserDialog : public CModuleChooserDialog {
+ Q_OBJECT
+ public:
+ CHideModuleChooserDialog(QWidget* parent, QString title, QString label, QString currentModule);
+ ~CHideModuleChooserDialog() {}
+
+ protected:
+ virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
+ protected slots:
+ void applyHiddenModules(QList<CSwordModuleInfo*> hiddenModules);
+
+
+ private:
+ QString m_currentModule;
+ QTreeWidgetItem* m_focusItem;
};
diff --git a/src/frontend/mainindex/btbookshelfview.cpp b/src/frontend/mainindex/btbookshelfview.cpp
index 52d0ec4..b770f13 100644
--- a/src/frontend/mainindex/btbookshelfview.cpp
+++ b/src/frontend/mainindex/btbookshelfview.cpp
@@ -19,8 +19,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
BtBookshelfView::BtBookshelfView(QWidget *parent)
- : QTreeView(parent)
-{
+ : QTreeView(parent) {
header()->hide();
/*
@@ -41,7 +40,7 @@ BtBookshelfView::~BtBookshelfView() {
CSwordModuleInfo *BtBookshelfView::getModule(const QModelIndex &index) const {
return (CSwordModuleInfo *) model()
- ->data(index, BtBookshelfModel::ModulePointerRole).value<void*>();
+ ->data(index, BtBookshelfModel::ModulePointerRole).value<void*>();
}
void BtBookshelfView::keyPressEvent(QKeyEvent *event) {
@@ -54,25 +53,26 @@ void BtBookshelfView::keyPressEvent(QKeyEvent *event) {
QPoint p(viewport()->mapToGlobal(itemRect.bottomLeft()));
if (i == 0) {
emit contextMenuActivated(p);
- } else {
+ }
+ else {
emit moduleContextMenuActivated(i, p);
}
}
event->accept();
break;
case Qt::Key_Return:
- case Qt::Key_Enter:
- {
- QModelIndex i(currentIndex());
- CSwordModuleInfo *m(getModule(i));
- if (m != 0) {
- emit moduleActivated(m);
- } else {
- setExpanded(i, !isExpanded(i));
- }
+ case Qt::Key_Enter: {
+ QModelIndex i(currentIndex());
+ CSwordModuleInfo *m(getModule(i));
+ if (m != 0) {
+ emit moduleActivated(m);
}
- event->accept();
- break;
+ else {
+ setExpanded(i, !isExpanded(i));
+ }
+ }
+ event->accept();
+ break;
default:
QTreeView::keyPressEvent(event);
break;
@@ -88,11 +88,13 @@ void BtBookshelfView::mousePressEvent(QMouseEvent *event) {
CSwordModuleInfo *i(getModule(clickedItemIndex));
if (i == 0) {
emit contextMenuActivated(mapToGlobal(event->pos()));
- } else {
+ }
+ else {
emit moduleContextMenuActivated(i, mapToGlobal(event->pos()));
}
event->accept();
- } else {
+ }
+ else {
QTreeView::mousePressEvent(event);
}
}
diff --git a/src/frontend/mainindex/btbookshelfview.h b/src/frontend/mainindex/btbookshelfview.h
index 80c7f31..112178a 100644
--- a/src/frontend/mainindex/btbookshelfview.h
+++ b/src/frontend/mainindex/btbookshelfview.h
@@ -18,7 +18,7 @@
class CSwordModuleInfo;
class BtBookshelfView: public QTreeView {
- Q_OBJECT
+ Q_OBJECT
public:
BtBookshelfView(QWidget *parent = 0);
virtual ~BtBookshelfView();
diff --git a/src/frontend/profile/cprofile.cpp b/src/frontend/profile/cprofile.cpp
index f6c8be1..95ce53d 100644
--- a/src/frontend/profile/cprofile.cpp
+++ b/src/frontend/profile/cprofile.cpp
@@ -21,412 +21,406 @@
namespace Profile {
CProfile::CProfile( const QString& file, const QString& name )
- : m_name(name.isEmpty() ? QObject::tr("unknown") : name),
- m_filename(file),
- m_fullscreen(false),
- m_geometry(10,20,640,480),
- m_mdiArrangementMode((CMDIArea::MDIArrangementMode)0) //0 is not a valid enum entry, means "unknown"
-{
- if (!m_filename.isEmpty() && name.isEmpty()) {
- loadBasics();
- }
- else if (m_filename.isEmpty() && !name.isEmpty()) {
- m_filename = name;
- m_filename.replace(QRegExp("\\s=#."),"_");
- m_filename = util::filesystem::DirectoryUtil::getUserSessionsDir().absolutePath() + "/" + m_filename + ".xml";
- init(m_filename);
- }
- else {
- qWarning("CProfile: empty file name!");
- }
+ : m_name(name.isEmpty() ? QObject::tr("unknown") : name),
+ m_filename(file),
+ m_fullscreen(false),
+ m_geometry(10, 20, 640, 480),
+ m_mdiArrangementMode((CMDIArea::MDIArrangementMode)0) { //0 is not a valid enum entry, means "unknown"
+ if (!m_filename.isEmpty() && name.isEmpty()) {
+ loadBasics();
+ }
+ else if (m_filename.isEmpty() && !name.isEmpty()) {
+ m_filename = name;
+ m_filename.replace(QRegExp("\\s=#."), "_");
+ m_filename = util::filesystem::DirectoryUtil::getUserSessionsDir().absolutePath() + "/" + m_filename + ".xml";
+ init(m_filename);
+ }
+ else {
+ qWarning("CProfile: empty file name!");
+ }
}
CProfile::~CProfile() {
- qDeleteAll(m_profileWindows); //there's no autodelete feature in qt4
- m_profileWindows.clear(); //delete all CProfileWindows objects
+ qDeleteAll(m_profileWindows); //there's no autodelete feature in qt4
+ m_profileWindows.clear(); //delete all CProfileWindows objects
}
/** Loads the profile from the file given in the constructor. */
QList<CProfileWindow*> CProfile::load() {
- QFile file(m_filename);
- if (!file.exists())
- {
- //qWarning() << "Standard profile not found at filename " << m_filename;
- return QList<CProfileWindow*>();
- }
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- if( document.tagName() != "BibleTimeProfile" && document.tagName() != "BibleTime" ) { //BibleTime was used in syntax version 1.0
- qWarning("CProfile::load: Missing BibleTime doc");
- return m_profileWindows;
- }
- if (document.hasAttribute("name")) {
- m_name = document.attribute("name");
- }
-
- //load settings of the main window
- {
- // see if there's a section with the name MAINWINDOW
- QDomElement elem = document.firstChild().toElement();
- QDomElement mainWindow;
- while (!elem.isNull()) {
- if (elem.tagName() == "MAINWINDOW") {
- mainWindow = elem;
- break; //found the element
- }
- elem = elem.nextSibling().toElement();
- }
- if (!mainWindow.isNull()) { //was found
- setFullscreen( (bool)mainWindow.attribute("fullscreen").toInt());
-
- QByteArray bstate;
- bstate += mainWindow.attribute("state");
- setMainwindowState(QByteArray::fromHex(bstate));
-
- QDomElement geometry_element = mainWindow.namedItem("GEOMETRY").toElement();
- QRect rect;
- if(!geometry_element.isNull()) {
- if (geometry_element.hasAttribute("x")) {
- rect.setX(geometry_element.attribute("x").toInt());
- }
- if (geometry_element.hasAttribute("y")) {
- rect.setY(geometry_element.attribute("y").toInt());
- }
- if (geometry_element.hasAttribute("width")) {
- rect.setWidth(geometry_element.attribute("width").toInt());
- }
- if (geometry_element.hasAttribute("height")) {
- rect.setHeight(geometry_element.attribute("height").toInt());
- }
- if (geometry_element.hasAttribute("isMaximized")) {
- this->setMaximized( static_cast<bool>(geometry_element.attribute("isMaximized").toInt()) );
- }
- setGeometry(rect);
- }
-
- QDomElement mdi_element = mainWindow.namedItem("MDI").toElement();
- if(!mdi_element.isNull()) {
- if (mdi_element.hasAttribute("ArrangementMode")) {
- this->setMDIArrangementMode((CMDIArea::MDIArrangementMode)mdi_element.attribute("ArrangementMode").toInt());
- }
- }
- }
- }
-
- m_profileWindows.clear();
- QDomElement elem = document.firstChild().toElement();
- while (!elem.isNull()) {
- CProfileWindow* p = 0;
- if (elem.tagName() == "BIBLE") {
- p = new CProfileWindow(CSwordModuleInfo::Bible);
- }
- else if (elem.tagName() == "COMMENTARY") {
- p = new CProfileWindow(CSwordModuleInfo::Commentary);
- }
- else if (elem.tagName() == "LEXICON") {
- p = new CProfileWindow(CSwordModuleInfo::Lexicon);
- }
- else if (elem.tagName() == "BOOK") {
- p = new CProfileWindow(CSwordModuleInfo::GenericBook);
- }
-
- if (p) {
- m_profileWindows.append(p);
-
- if (elem.hasAttribute("windowSettings")) {
- p->setWindowSettings( elem.attribute("windowSettings").toInt() );
- }
- if (elem.hasAttribute("writeWindowType")) {
- p->setWriteWindowType( elem.attribute("writeWindowType").toInt() );
- }
- if (elem.hasAttribute("hasFocus")) {
- p->setFocus( static_cast<bool>(elem.attribute("hasFocus").toInt()) );
- }
-
- QRect rect;
-
- QDomElement object = elem.namedItem("GEOMETRY").toElement();
- if(!object.isNull()) {
- if (object.hasAttribute("x")) {
- rect.setX(object.attribute("x").toInt());
- }
- if (object.hasAttribute("y")) {
- rect.setY(object.attribute("y").toInt());
- }
- if (object.hasAttribute("width")) {
- rect.setWidth(object.attribute("width").toInt());
- }
- if (object.hasAttribute("height")) {
- rect.setHeight(object.attribute("height").toInt());
- }
- if (object.hasAttribute("isMaximized")) {
- p->setMaximized( static_cast<bool>(object.attribute("isMaximized").toInt()) );
- }
- }
- p->setGeometry(rect);
-
- object = elem.namedItem("MODULES").toElement();
- if(!object.isNull()) {
- if (object.hasAttribute("list")) {
- const QString sep = object.hasAttribute("separator") ? object.attribute("separator") : "|";
- QStringList modules = object.attribute("list").split(sep);
- p->setModules(modules);
- }
- }
-
- object = elem.namedItem("KEY").toElement();
- if(!object.isNull()) {
- if (object.hasAttribute("name"))
- p->setKey(object.attribute("name"));
- }
-
- object = elem.namedItem("SCROLLBARS").toElement();
- if(!object.isNull()) {
- int horizontal = 0, vertical = 0;
- if (object.hasAttribute("horizontal"))
- horizontal = object.attribute("horizontal").toInt();
- if (object.hasAttribute("vertical"))
- vertical = object.attribute("vertical").toInt();
-
- p->setScrollbarPositions(horizontal, vertical);
- }
- }
- elem = elem.nextSibling().toElement();
- }
- return m_profileWindows;
+ QFile file(m_filename);
+ if (!file.exists()) {
+ //qWarning() << "Standard profile not found at filename " << m_filename;
+ return QList<CProfileWindow*>();
+ }
+
+ QDomDocument doc;
+ if (file.open(QIODevice::ReadOnly)) {
+ QTextStream t( &file );
+ t.setCodec("UTF-8");
+ doc.setContent(t.readAll());
+ file.close();
+ }
+
+ QDomElement document = doc.documentElement();
+ if ( document.tagName() != "BibleTimeProfile" && document.tagName() != "BibleTime" ) { //BibleTime was used in syntax version 1.0
+ qWarning("CProfile::load: Missing BibleTime doc");
+ return m_profileWindows;
+ }
+ if (document.hasAttribute("name")) {
+ m_name = document.attribute("name");
+ }
+
+ //load settings of the main window
+ {
+ // see if there's a section with the name MAINWINDOW
+ QDomElement elem = document.firstChild().toElement();
+ QDomElement mainWindow;
+ while (!elem.isNull()) {
+ if (elem.tagName() == "MAINWINDOW") {
+ mainWindow = elem;
+ break; //found the element
+ }
+ elem = elem.nextSibling().toElement();
+ }
+ if (!mainWindow.isNull()) { //was found
+ setFullscreen( (bool)mainWindow.attribute("fullscreen").toInt());
+
+ QByteArray bstate;
+ bstate += mainWindow.attribute("state");
+ setMainwindowState(QByteArray::fromHex(bstate));
+
+ QDomElement geometry_element = mainWindow.namedItem("GEOMETRY").toElement();
+ QRect rect;
+ if (!geometry_element.isNull()) {
+ if (geometry_element.hasAttribute("x")) {
+ rect.setX(geometry_element.attribute("x").toInt());
+ }
+ if (geometry_element.hasAttribute("y")) {
+ rect.setY(geometry_element.attribute("y").toInt());
+ }
+ if (geometry_element.hasAttribute("width")) {
+ rect.setWidth(geometry_element.attribute("width").toInt());
+ }
+ if (geometry_element.hasAttribute("height")) {
+ rect.setHeight(geometry_element.attribute("height").toInt());
+ }
+ if (geometry_element.hasAttribute("isMaximized")) {
+ this->setMaximized( static_cast<bool>(geometry_element.attribute("isMaximized").toInt()) );
+ }
+ setGeometry(rect);
+ }
+
+ QDomElement mdi_element = mainWindow.namedItem("MDI").toElement();
+ if (!mdi_element.isNull()) {
+ if (mdi_element.hasAttribute("ArrangementMode")) {
+ this->setMDIArrangementMode((CMDIArea::MDIArrangementMode)mdi_element.attribute("ArrangementMode").toInt());
+ }
+ }
+ }
+ }
+
+ m_profileWindows.clear();
+ QDomElement elem = document.firstChild().toElement();
+ while (!elem.isNull()) {
+ CProfileWindow* p = 0;
+ if (elem.tagName() == "BIBLE") {
+ p = new CProfileWindow(CSwordModuleInfo::Bible);
+ }
+ else if (elem.tagName() == "COMMENTARY") {
+ p = new CProfileWindow(CSwordModuleInfo::Commentary);
+ }
+ else if (elem.tagName() == "LEXICON") {
+ p = new CProfileWindow(CSwordModuleInfo::Lexicon);
+ }
+ else if (elem.tagName() == "BOOK") {
+ p = new CProfileWindow(CSwordModuleInfo::GenericBook);
+ }
+
+ if (p) {
+ m_profileWindows.append(p);
+
+ if (elem.hasAttribute("windowSettings")) {
+ p->setWindowSettings( elem.attribute("windowSettings").toInt() );
+ }
+ if (elem.hasAttribute("writeWindowType")) {
+ p->setWriteWindowType( elem.attribute("writeWindowType").toInt() );
+ }
+ if (elem.hasAttribute("hasFocus")) {
+ p->setFocus( static_cast<bool>(elem.attribute("hasFocus").toInt()) );
+ }
+
+ QRect rect;
+
+ QDomElement object = elem.namedItem("GEOMETRY").toElement();
+ if (!object.isNull()) {
+ if (object.hasAttribute("x")) {
+ rect.setX(object.attribute("x").toInt());
+ }
+ if (object.hasAttribute("y")) {
+ rect.setY(object.attribute("y").toInt());
+ }
+ if (object.hasAttribute("width")) {
+ rect.setWidth(object.attribute("width").toInt());
+ }
+ if (object.hasAttribute("height")) {
+ rect.setHeight(object.attribute("height").toInt());
+ }
+ if (object.hasAttribute("isMaximized")) {
+ p->setMaximized( static_cast<bool>(object.attribute("isMaximized").toInt()) );
+ }
+ }
+ p->setGeometry(rect);
+
+ object = elem.namedItem("MODULES").toElement();
+ if (!object.isNull()) {
+ if (object.hasAttribute("list")) {
+ const QString sep = object.hasAttribute("separator") ? object.attribute("separator") : "|";
+ QStringList modules = object.attribute("list").split(sep);
+ p->setModules(modules);
+ }
+ }
+
+ object = elem.namedItem("KEY").toElement();
+ if (!object.isNull()) {
+ if (object.hasAttribute("name"))
+ p->setKey(object.attribute("name"));
+ }
+
+ object = elem.namedItem("SCROLLBARS").toElement();
+ if (!object.isNull()) {
+ int horizontal = 0, vertical = 0;
+ if (object.hasAttribute("horizontal"))
+ horizontal = object.attribute("horizontal").toInt();
+ if (object.hasAttribute("vertical"))
+ vertical = object.attribute("vertical").toInt();
+
+ p->setScrollbarPositions(horizontal, vertical);
+ }
+ }
+ elem = elem.nextSibling().toElement();
+ }
+ return m_profileWindows;
}
/** Saves the profile to the file given in the constructor. */
bool CProfile::save(QList<CProfileWindow*> windows) {
- /** Save the settings using a XML file
- * Save the CProfileWindow objects using a XML file which name is in m_filename
- */
- bool ret = false;
- QDomDocument doc("DOC");
- doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
-
- QDomElement content = doc.createElement("BibleTimeProfile");
- content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
- content.setAttribute("name", m_name);
- doc.appendChild(content);
-
- //save mainwindow settings
- {
- QDomElement mainWindow = doc.createElement("MAINWINDOW");
- mainWindow.setAttribute("fullscreen", fullscreen());
-
- QString sstate = QString(getMainwindowState().toHex());
- mainWindow.setAttribute("state", sstate);
-
- QDomElement geometry = doc.createElement("GEOMETRY");
- mainWindow.appendChild(geometry);
- const QRect r = this->geometry();
- geometry.setAttribute("x",r.x());
- geometry.setAttribute("y",r.y());
- geometry.setAttribute("width",r.width());
- geometry.setAttribute("height",r.height());
- geometry.setAttribute("isMaximized",static_cast<int>(this->maximized()));
-
- QDomElement mdi = doc.createElement("MDI");
- mainWindow.appendChild(mdi);
- mdi.setAttribute("ArrangementMode",static_cast<int>(this->getMDIArrangementMode()));
-
- content.appendChild(mainWindow);
- }
-
- //for (CProfileWindow* p = windows.first(); p; p = windows.next()) {
- foreach(CProfileWindow* p, windows) {
- QDomElement window;
- switch (p->type()) {
- case CSwordModuleInfo::Bible:
- window = doc.createElement("BIBLE");
- break;
- case CSwordModuleInfo::Commentary:
- window = doc.createElement("COMMENTARY");
- break;
- case CSwordModuleInfo::Lexicon:
- window = doc.createElement("LEXICON");
- break;
- case CSwordModuleInfo::GenericBook:
- window = doc.createElement("BOOK");
- break;
- default:
- break;
- }
- if (window.isNull())
- break;
- window.setAttribute("windowSettings", p->windowSettings());
- window.setAttribute("writeWindowType", p->writeWindowType());
- window.setAttribute("hasFocus", p->hasFocus());
-
- //save geomtery
- const QRect r = p->geometry();
- QDomElement geometry = doc.createElement("GEOMETRY");
- geometry.setAttribute("x",r.x());
- geometry.setAttribute("y",r.y());
- geometry.setAttribute("width",r.width());
- geometry.setAttribute("height",r.height());
- geometry.setAttribute("isMaximized",static_cast<int>(p->maximized()));
- window.appendChild( geometry );
-
- QDomElement modules = doc.createElement("MODULES");
- modules.setAttribute("separator", "|");
- modules.setAttribute("list", p->modules().join("|"));
- window.appendChild( modules );
-
- QDomElement key = doc.createElement("KEY");
- key.setAttribute("name", p->key());
- window.appendChild( key );
-
- QDomElement scrollbars = doc.createElement("SCROLLBARS");
- scrollbars.setAttribute("horizontal", p->scrollbarPositions().horizontal);
- scrollbars.setAttribute("vertical", p->scrollbarPositions().vertical);
- window.appendChild( scrollbars );
-
- content.appendChild( window );
- }
-
- QFile file(m_filename);
- if ( file.open(QIODevice::WriteOnly) ) {
- ret = true;
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
- else
- ret = false;
-
- return ret;
+ /** Save the settings using a XML file
+ * Save the CProfileWindow objects using a XML file which name is in m_filename
+ */
+ bool ret = false;
+ QDomDocument doc("DOC");
+ doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement content = doc.createElement("BibleTimeProfile");
+ content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
+ content.setAttribute("name", m_name);
+ doc.appendChild(content);
+
+ //save mainwindow settings
+ {
+ QDomElement mainWindow = doc.createElement("MAINWINDOW");
+ mainWindow.setAttribute("fullscreen", fullscreen());
+
+ QString sstate = QString(getMainwindowState().toHex());
+ mainWindow.setAttribute("state", sstate);
+
+ QDomElement geometry = doc.createElement("GEOMETRY");
+ mainWindow.appendChild(geometry);
+ const QRect r = this->geometry();
+ geometry.setAttribute("x", r.x());
+ geometry.setAttribute("y", r.y());
+ geometry.setAttribute("width", r.width());
+ geometry.setAttribute("height", r.height());
+ geometry.setAttribute("isMaximized", static_cast<int>(this->maximized()));
+
+ QDomElement mdi = doc.createElement("MDI");
+ mainWindow.appendChild(mdi);
+ mdi.setAttribute("ArrangementMode", static_cast<int>(this->getMDIArrangementMode()));
+
+ content.appendChild(mainWindow);
+ }
+
+ //for (CProfileWindow* p = windows.first(); p; p = windows.next()) {
+ foreach(CProfileWindow* p, windows) {
+ QDomElement window;
+ switch (p->type()) {
+ case CSwordModuleInfo::Bible:
+ window = doc.createElement("BIBLE");
+ break;
+ case CSwordModuleInfo::Commentary:
+ window = doc.createElement("COMMENTARY");
+ break;
+ case CSwordModuleInfo::Lexicon:
+ window = doc.createElement("LEXICON");
+ break;
+ case CSwordModuleInfo::GenericBook:
+ window = doc.createElement("BOOK");
+ break;
+ default:
+ break;
+ }
+ if (window.isNull())
+ break;
+ window.setAttribute("windowSettings", p->windowSettings());
+ window.setAttribute("writeWindowType", p->writeWindowType());
+ window.setAttribute("hasFocus", p->hasFocus());
+
+ //save geomtery
+ const QRect r = p->geometry();
+ QDomElement geometry = doc.createElement("GEOMETRY");
+ geometry.setAttribute("x", r.x());
+ geometry.setAttribute("y", r.y());
+ geometry.setAttribute("width", r.width());
+ geometry.setAttribute("height", r.height());
+ geometry.setAttribute("isMaximized", static_cast<int>(p->maximized()));
+ window.appendChild( geometry );
+
+ QDomElement modules = doc.createElement("MODULES");
+ modules.setAttribute("separator", "|");
+ modules.setAttribute("list", p->modules().join("|"));
+ window.appendChild( modules );
+
+ QDomElement key = doc.createElement("KEY");
+ key.setAttribute("name", p->key());
+ window.appendChild( key );
+
+ QDomElement scrollbars = doc.createElement("SCROLLBARS");
+ scrollbars.setAttribute("horizontal", p->scrollbarPositions().horizontal);
+ scrollbars.setAttribute("vertical", p->scrollbarPositions().vertical);
+ window.appendChild( scrollbars );
+
+ content.appendChild( window );
+ }
+
+ QFile file(m_filename);
+ if ( file.open(QIODevice::WriteOnly) ) {
+ ret = true;
+ QTextStream t( &file );
+ t.setCodec("UTF-8");
+ t << doc.toString();
+ file.close();
+ }
+ else
+ ret = false;
+
+ return ret;
}
/** Saves the profile to the file given in the constructor. */
bool CProfile::save() {
- return save(m_profileWindows);
+ return save(m_profileWindows);
}
/** Returns the filename used for this profile. */
const QString& CProfile::filename() {
- return m_filename;
+ return m_filename;
}
/** Returns the name of this profile. */
const QString& CProfile::name() {
- return m_name;
+ return m_name;
}
/** Initializes the XML for the first time (use to create a new profile) */
void CProfile::init(const QString file) {
- const QString oldFile = m_filename;
- m_filename = file;
- save(QList<CProfileWindow*>());
- m_filename = oldFile;
+ const QString oldFile = m_filename;
+ m_filename = file;
+ save(QList<CProfileWindow*>());
+ m_filename = oldFile;
}
/** Changes the name of this profile. */
void CProfile::setName( const QString& newName ) {
- m_name = newName;
- saveBasics(); //save chanegd name
+ m_name = newName;
+ saveBasics(); //save chanegd name
}
/** Loads the basic settings requires for proper operation. */
void CProfile::loadBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
- QDomElement document = doc.documentElement();
- if (document.hasAttribute("name"))
- m_name = document.attribute("name");
+ QFile file(m_filename);
+ if (!file.exists())
+ return;
+
+ QDomDocument doc;
+ if (file.open(QIODevice::ReadOnly)) {
+ QTextStream t( &file );
+ t.setCodec("UTF-8");
+ doc.setContent(t.readAll());
+ file.close();
+ }
+ QDomElement document = doc.documentElement();
+ if (document.hasAttribute("name"))
+ m_name = document.attribute("name");
}
void CProfile::saveBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t(&file);
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- document.setAttribute("name", m_name);
-
- if (file.open(QIODevice::WriteOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
+ QFile file(m_filename);
+ if (!file.exists())
+ return;
+
+ QDomDocument doc;
+ if (file.open(QIODevice::ReadOnly)) {
+ QTextStream t(&file);
+ t.setCodec("UTF-8");
+ doc.setContent(t.readAll());
+ file.close();
+ }
+
+ QDomElement document = doc.documentElement();
+ document.setAttribute("name", m_name);
+
+ if (file.open(QIODevice::WriteOnly)) {
+ QTextStream t( &file );
+ t.setCodec("UTF-8");
+ t << doc.toString();
+ file.close();
+ }
}
/** Returns true if the main window was in fullscreen mode as the profile was saved. */
bool CProfile::fullscreen() const {
- return m_fullscreen;
+ return m_fullscreen;
}
/** Set the parameter to true if the main window coveres the full screen size. */
void CProfile::setFullscreen( const bool fullscreen ) {
- m_fullscreen = fullscreen;
+ m_fullscreen = fullscreen;
}
/** Returns true if the main window was maximized as the profile was saved. */
bool CProfile::maximized() const {
- return m_maximized;
+ return m_maximized;
}
/** Set the parameter to true if the main window is maximized. */
void CProfile::setMaximized( const bool maximized ) {
- m_maximized = maximized;
+ m_maximized = maximized;
}
/** Returns the geometry of the main window */
const QRect CProfile::geometry() {
- return m_geometry;
+ return m_geometry;
}
/** Stes the geoemtry of the main window */
void CProfile::setGeometry( const QRect rect ) {
- m_geometry = rect;
+ m_geometry = rect;
}
-void CProfile::setMDIArrangementMode(const CMDIArea::MDIArrangementMode newArrangementMode)
-{
- m_mdiArrangementMode = newArrangementMode;
+void CProfile::setMDIArrangementMode(const CMDIArea::MDIArrangementMode newArrangementMode) {
+ m_mdiArrangementMode = newArrangementMode;
}
-CMDIArea::MDIArrangementMode CProfile::getMDIArrangementMode(void)
-{
- return m_mdiArrangementMode;
+CMDIArea::MDIArrangementMode CProfile::getMDIArrangementMode(void) {
+ return m_mdiArrangementMode;
}
-void CProfile::setMainwindowState(const QByteArray& state)
-{
- m_mainwindowState = state;
+void CProfile::setMainwindowState(const QByteArray& state) {
+ m_mainwindowState = state;
}
-QByteArray CProfile::getMainwindowState()
-{
- return m_mainwindowState;
+QByteArray CProfile::getMainwindowState() {
+ return m_mainwindowState;
}
diff --git a/src/frontend/profile/cprofile.h b/src/frontend/profile/cprofile.h
index 6e375f9..49f241a 100644
--- a/src/frontend/profile/cprofile.h
+++ b/src/frontend/profile/cprofile.h
@@ -23,96 +23,96 @@ namespace Profile {
* @author The BibleTime team
*/
class CProfile {
-public:
- CProfile(const QString& fileName, const QString& name = QString::null);
- ~CProfile();
+ public:
+ CProfile(const QString& fileName, const QString& name = QString::null);
+ ~CProfile();
- /**
- * Saves the profile to the file given in the constructor.
- * @param windows The list of windows available in the profile.
- */
- bool save( QList<CProfileWindow*> windows );
- /**
- * Saves the profile to the file given in the constructor.
- */
- bool save();
- /**
- * Loads the profile from the file given in the constructor.
- * @return The list of profiled window which exist in the profile.
- */
- QList<CProfileWindow*> load();
- /**
- * Returns the name of this profile.
- */
- const QString& name();
- /**
- * Returns the filename used for this profile.
- */
- const QString& filename();
- /**
- * Initializes the XML for the first time (use to create a new profile)
- */
- void init(const QString);
- /**
- * Chnages the name of this profile.
- */
- void setName( const QString& );
- /**
- * Returns true if the main window was in fullscreen mode as the profile was saved.
- */
- bool fullscreen() const;
- /**
- * Set the parameter to true if the main window coveres the full screen size.
- */
- void setFullscreen( const bool fullscreen );
- /**
- * Returns true if the main window was maximized as the profile was saved.
- */
- bool maximized() const;
- /**
- * Set the parameter to true if the main window is maximized.
- */
- void setMaximized( const bool maximized );
- /**
- * Sets the geoemtry of the main window
- */
- void setGeometry( const QRect rect );
- /**
- * Returns the geometry of the main window
- */
- const QRect geometry();
- /**
- * Sets the MDI arrangement mode
- */
- void setMDIArrangementMode(const CMDIArea::MDIArrangementMode);
- /**
- * Returns mdi arrangement mode
- */
- CMDIArea::MDIArrangementMode getMDIArrangementMode(void);
- /**
- * set mainwindow saveState - position of docking windows and toolbar
- */
- void setMainwindowState(const QByteArray& state);
- /**
- * Return mainwindow saveState - position of docking windows and toolbar
- */
- QByteArray getMainwindowState();
+ /**
+ * Saves the profile to the file given in the constructor.
+ * @param windows The list of windows available in the profile.
+ */
+ bool save( QList<CProfileWindow*> windows );
+ /**
+ * Saves the profile to the file given in the constructor.
+ */
+ bool save();
+ /**
+ * Loads the profile from the file given in the constructor.
+ * @return The list of profiled window which exist in the profile.
+ */
+ QList<CProfileWindow*> load();
+ /**
+ * Returns the name of this profile.
+ */
+ const QString& name();
+ /**
+ * Returns the filename used for this profile.
+ */
+ const QString& filename();
+ /**
+ * Initializes the XML for the first time (use to create a new profile)
+ */
+ void init(const QString);
+ /**
+ * Chnages the name of this profile.
+ */
+ void setName( const QString& );
+ /**
+ * Returns true if the main window was in fullscreen mode as the profile was saved.
+ */
+ bool fullscreen() const;
+ /**
+ * Set the parameter to true if the main window coveres the full screen size.
+ */
+ void setFullscreen( const bool fullscreen );
+ /**
+ * Returns true if the main window was maximized as the profile was saved.
+ */
+ bool maximized() const;
+ /**
+ * Set the parameter to true if the main window is maximized.
+ */
+ void setMaximized( const bool maximized );
+ /**
+ * Sets the geoemtry of the main window
+ */
+ void setGeometry( const QRect rect );
+ /**
+ * Returns the geometry of the main window
+ */
+ const QRect geometry();
+ /**
+ * Sets the MDI arrangement mode
+ */
+ void setMDIArrangementMode(const CMDIArea::MDIArrangementMode);
+ /**
+ * Returns mdi arrangement mode
+ */
+ CMDIArea::MDIArrangementMode getMDIArrangementMode(void);
+ /**
+ * set mainwindow saveState - position of docking windows and toolbar
+ */
+ void setMainwindowState(const QByteArray& state);
+ /**
+ * Return mainwindow saveState - position of docking windows and toolbar
+ */
+ QByteArray getMainwindowState();
-private:
- /**
- * Loads the basic settings requires for proper operation.
- */
- void loadBasics();
- void saveBasics();
+ private:
+ /**
+ * Loads the basic settings requires for proper operation.
+ */
+ void loadBasics();
+ void saveBasics();
- QList<CProfileWindow*> m_profileWindows;
- QString m_name;
- QString m_filename;
- bool m_fullscreen;
- bool m_maximized;
- QRect m_geometry;
- CMDIArea::MDIArrangementMode m_mdiArrangementMode;
- QByteArray m_mainwindowState;
+ QList<CProfileWindow*> m_profileWindows;
+ QString m_name;
+ QString m_filename;
+ bool m_fullscreen;
+ bool m_maximized;
+ QRect m_geometry;
+ CMDIArea::MDIArrangementMode m_mdiArrangementMode;
+ QByteArray m_mainwindowState;
};
} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilemgr.cpp b/src/frontend/profile/cprofilemgr.cpp
index 783e371..0666fd8 100644
--- a/src/frontend/profile/cprofilemgr.cpp
+++ b/src/frontend/profile/cprofilemgr.cpp
@@ -21,110 +21,108 @@
namespace Profile {
CProfileMgr::CProfileMgr() : m_startupProfile(0) {
- //m_profiles.setAutoDelete(true);
-
- m_profilePath = util::filesystem::DirectoryUtil::getUserSessionsDir().absolutePath() + "/";
-
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- if ((*it) != "_startup_.xml") {
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- else {
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
+ //m_profiles.setAutoDelete(true);
+
+ m_profilePath = util::filesystem::DirectoryUtil::getUserSessionsDir().absolutePath() + "/";
+
+ QDir d( m_profilePath );
+ QStringList files = d.entryList(QStringList("*.xml"));
+ for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
+ if ((*it) != "_startup_.xml") {
+ m_profiles.append(new CProfile(m_profilePath + *it));
+ }
+ else {
+ m_startupProfile = new CProfile(m_profilePath + *it);
+ }
+ }
}
CProfileMgr::~CProfileMgr() {
- qDeleteAll(m_profiles);
- m_profiles.clear();
- delete m_startupProfile;
+ qDeleteAll(m_profiles);
+ m_profiles.clear();
+ delete m_startupProfile;
}
/** Returns a list of available profiles. */
const QList<CProfile*>& CProfileMgr::profiles() {
- return m_profiles;
+ return m_profiles;
}
/** Creates a new profile with the name "name" (first parameter). @return The profile object */
CProfile* CProfileMgr::create( const QString name ) {
- CProfile* p = new CProfile(QString::null, name);
- m_profiles.append(p);
+ CProfile* p = new CProfile(QString::null, name);
+ m_profiles.append(p);
- return p;
+ return p;
}
/** Removes the profile from the list and from the directory containg the profile files. */
-bool CProfileMgr::remove( CProfile* p )
-{
- bool ret = false;
- QFile f( p->filename() );
- if (f.exists())
- f.remove();
-
- int i = m_profiles.indexOf(p);
- if (i != -1)
- delete m_profiles.takeAt(i);
-
- ret = true;
- return ret;
+bool CProfileMgr::remove( CProfile* p ) {
+ bool ret = false;
+ QFile f( p->filename() );
+ if (f.exists())
+ f.remove();
+
+ int i = m_profiles.indexOf(p);
+ if (i != -1)
+ delete m_profiles.takeAt(i);
+
+ ret = true;
+ return ret;
}
-bool CProfileMgr::remove( const QString& profile)
-{
- bool ret = false;
- QListIterator<CProfile*> it(m_profiles);
- while (it.hasNext()) {
- CProfile* p = it.next();
- if (p->name() == profile) {
- remove(p);
- ret = true;
- }
- }
- return ret;
+bool CProfileMgr::remove( const QString& profile) {
+ bool ret = false;
+ QListIterator<CProfile*> it(m_profiles);
+ while (it.hasNext()) {
+ CProfile* p = it.next();
+ if (p->name() == profile) {
+ remove(p);
+ ret = true;
+ }
+ }
+ return ret;
}
/** Returns the profile with the desired name. If there's no such profile 0 is returned. */
CProfile* CProfileMgr::profile(const QString& name) {
- QListIterator<CProfile*> it(m_profiles);
- while (it.hasNext()) {
- CProfile* p = it.next();
- if (p && p->name() == name) {
- return p;
- }
- }
-
- return 0;
+ QListIterator<CProfile*> it(m_profiles);
+ while (it.hasNext()) {
+ CProfile* p = it.next();
+ if (p && p->name() == name) {
+ return p;
+ }
+ }
+
+ return 0;
}
/** Returns the startup profile if it exists, otherwise return 0. */
CProfile* CProfileMgr::startupProfile() {
- if (!m_startupProfile) {
- m_startupProfile = new CProfile(QString::null, "_startup_");
- }
+ if (!m_startupProfile) {
+ m_startupProfile = new CProfile(QString::null, "_startup_");
+ }
- return m_startupProfile;
+ return m_startupProfile;
}
/** Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile. */
void CProfileMgr::refresh() {
- qDeleteAll(m_profiles);
- m_profiles.clear(); //delete all profiles
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- CProfile p(m_profilePath + *it);
- if (p.name() == "_startup_") { //new startup profile
- if (!m_startupProfile) { //don't put this in the if clause above,it doesn't work!
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
- else if (!profile(p.name())) { //don't have it already
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- }
+ qDeleteAll(m_profiles);
+ m_profiles.clear(); //delete all profiles
+ QDir d( m_profilePath );
+ QStringList files = d.entryList(QStringList("*.xml"));
+ for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
+ CProfile p(m_profilePath + *it);
+ if (p.name() == "_startup_") { //new startup profile
+ if (!m_startupProfile) { //don't put this in the if clause above,it doesn't work!
+ m_startupProfile = new CProfile(m_profilePath + *it);
+ }
+ }
+ else if (!profile(p.name())) { //don't have it already
+ m_profiles.append(new CProfile(m_profilePath + *it));
+ }
+ }
}
} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilemgr.h b/src/frontend/profile/cprofilemgr.h
index 934d09a..344333d 100644
--- a/src/frontend/profile/cprofilemgr.h
+++ b/src/frontend/profile/cprofilemgr.h
@@ -24,43 +24,43 @@ namespace Profile {
* @author The BibleTime team
*/
class CProfileMgr {
-public:
- CProfileMgr();
- ~CProfileMgr();
+ public:
+ CProfileMgr();
+ ~CProfileMgr();
- /** Creates a new profile with the name "name" (first parameter).
- * @return The profile object
- */
- CProfile* create( const QString name );
- /**
- * @return a list of available profiles
- */
- const QList<CProfile*>& profiles();
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( CProfile* p );
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( const QString& );
- /**
- * Returns the profile with the desired name. If there's no such profile 0 is returned.
- */
- CProfile* profile(const QString&);
- /**
- * Returns the startup profile if it exists, otherwise return 0.
- */
- CProfile* startupProfile();
- /**
- * Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile.
- */
- void refresh();
+ /** Creates a new profile with the name "name" (first parameter).
+ * @return The profile object
+ */
+ CProfile* create( const QString name );
+ /**
+ * @return a list of available profiles
+ */
+ const QList<CProfile*>& profiles();
+ /**
+ * Removes the profile from the list and from the directory containg the profile files.
+ */
+ bool remove( CProfile* p );
+ /**
+ * Removes the profile from the list and from the directory containg the profile files.
+ */
+ bool remove( const QString& );
+ /**
+ * Returns the profile with the desired name. If there's no such profile 0 is returned.
+ */
+ CProfile* profile(const QString&);
+ /**
+ * Returns the startup profile if it exists, otherwise return 0.
+ */
+ CProfile* startupProfile();
+ /**
+ * Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile.
+ */
+ void refresh();
-protected:
- QList<CProfile*> m_profiles;
- QString m_profilePath;
- CProfile* m_startupProfile;
+ protected:
+ QList<CProfile*> m_profiles;
+ QString m_profilePath;
+ CProfile* m_startupProfile;
};
} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilewindow.cpp b/src/frontend/profile/cprofilewindow.cpp
index f405923..16b440e 100644
--- a/src/frontend/profile/cprofilewindow.cpp
+++ b/src/frontend/profile/cprofilewindow.cpp
@@ -23,112 +23,112 @@
namespace Profile {
CProfileWindow::CProfileWindow(CSwordModuleInfo::ModuleType type)
-: m_type(type),
-m_windowGeometry(),
-m_moduleList(),
-m_key(QString::null),
-m_maximized(false),
-m_hasFocus(false),
-m_windowSettings(0),
-m_writeWindowType(0) {
- m_scrollbarPos.horizontal = 0;
- m_scrollbarPos.vertical = 0;
+ : m_type(type),
+ m_windowGeometry(),
+ m_moduleList(),
+ m_key(QString::null),
+ m_maximized(false),
+ m_hasFocus(false),
+ m_windowSettings(0),
+ m_writeWindowType(0) {
+ m_scrollbarPos.horizontal = 0;
+ m_scrollbarPos.vertical = 0;
}
CProfileWindow::~CProfileWindow() {}
/** Returns the size of the window including the x,y coordinates. */
const QRect& CProfileWindow::geometry() const {
- return m_windowGeometry;
+ return m_windowGeometry;
}
/** Sets the size of the window. */
void CProfileWindow::setGeometry( const QRect& rect ) {
- m_windowGeometry = rect;
+ m_windowGeometry = rect;
}
/** Returns the type of the managed window (bible window, commentary window or lexicon window). */
CSwordModuleInfo::ModuleType CProfileWindow::type() const {
- if (m_type != CSwordModuleInfo::Unknown)
- return m_type;
- return CSwordModuleInfo::Unknown;
+ if (m_type != CSwordModuleInfo::Unknown)
+ return m_type;
+ return CSwordModuleInfo::Unknown;
}
/** Sets the modules. */
void CProfileWindow::setModules( const QStringList& modules ) {
- m_moduleList = modules; //copy module pointers into our own list
+ m_moduleList = modules; //copy module pointers into our own list
}
/** Returns a list of module names which are chosen in the managed window profile. */
const QStringList& CProfileWindow::modules() const {
- return m_moduleList;
+ return m_moduleList;
}
/** Returns the current key set in the modules. */
const QString& CProfileWindow::key() const {
- return m_key;
+ return m_key;
}
/** Set the key used in the modules. */
void CProfileWindow::setKey( const QString& key ) {
- m_key = key;
+ m_key = key;
}
/** Sets the current position of the scrollbars. */
void CProfileWindow::setScrollbarPositions(const int& horizontal, const int& vertical) {
- // m_scrollbarPos = {x,y};
- m_scrollbarPos.horizontal = horizontal;
- m_scrollbarPos.vertical = vertical;
+ // m_scrollbarPos = {x,y};
+ m_scrollbarPos.horizontal = horizontal;
+ m_scrollbarPos.vertical = vertical;
}
/** Returns tghe position of the scrollbars */
const CProfileWindow::ScrollbarPos& CProfileWindow::scrollbarPositions() const {
- return m_scrollbarPos;
+ return m_scrollbarPos;
}
/** Sets the type of the used modules. */
void CProfileWindow::setType(const CSwordModuleInfo::ModuleType& type) {
- m_type = type;
+ m_type = type;
}
/** Returns true if the window is maximized. */
const bool& CProfileWindow::maximized() const {
- return m_maximized;
+ return m_maximized;
}
/** Sets the windows maximized state to true or false. */
void CProfileWindow::setMaximized( const bool& maximized ) {
- m_maximized = maximized;
+ m_maximized = maximized;
}
/** Returns true if the window is maximized. */
const bool& CProfileWindow::hasFocus() const {
- return m_hasFocus;
+ return m_hasFocus;
}
/** Sets the windows maximized state to true or false. */
void CProfileWindow::setFocus( const bool& hasFocus ) {
- m_hasFocus = hasFocus;
+ m_hasFocus = hasFocus;
}
/** Returns an integer with the window specific settings */
const int& CProfileWindow::windowSettings() const {
- return m_windowSettings;
+ return m_windowSettings;
}
/** Sets the window specific settings. */
void CProfileWindow::setWindowSettings( const int& settings ) {
- m_windowSettings = settings;
+ m_windowSettings = settings;
}
/** Tells this profile window to represent a write window. */
void CProfileWindow::setWriteWindowType( const int& writeWindowType ) {
- m_writeWindowType = writeWindowType;
+ m_writeWindowType = writeWindowType;
}
/** Returns whether this profile window represents a write window. */
const int& CProfileWindow::writeWindowType() const {
- return m_writeWindowType;
+ return m_writeWindowType;
}
} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilewindow.h b/src/frontend/profile/cprofilewindow.h
index 090d991..4b3a700 100644
--- a/src/frontend/profile/cprofilewindow.h
+++ b/src/frontend/profile/cprofilewindow.h
@@ -27,97 +27,97 @@ namespace Profile {
* @author The BibleTime team
*/
class CProfileWindow {
-public:
- struct ScrollbarPos {
- int horizontal; //the position of the horizontal scrollbar
- int vertical; //the position of the vertical scrollbar
- };
+ public:
+ struct ScrollbarPos {
+ int horizontal; //the position of the horizontal scrollbar
+ int vertical; //the position of the vertical scrollbar
+ };
- CProfileWindow(CSwordModuleInfo::ModuleType type = CSwordModuleInfo::Unknown);
- ~CProfileWindow();
- /**
- * Sets the modules.
- */
- void setModules( const QStringList& modules );
- /**
- * Returns the type of the managed window (bible window, commentary window or lexicon window).
- */
- CSwordModuleInfo::ModuleType type() const;
- /**
- * Sets the type of the used modules.
- */
- void setType(const CSwordModuleInfo::ModuleType& type);
- /**
- * Sets the size of the window.
- */
- void setGeometry( const QRect& s );
- /**
- * Returns the size of the window including the x,y coordinates.
- */
- const QRect& geometry() const;
- /**
- * Returns a list of module names which are chosen in the managed window profile.
- */
- const QStringList& modules() const;
- /**
- * Set the key used in the modules.
- */
- void setKey( const QString& );
- /**
- * Returns the current key set in the modules.
- */
- const QString& key() const;
- /**
- * Sets the current position of the scrollbars.
- */
- void setScrollbarPositions(const int& x, const int& y);
- /**
- * Sets the windows maximized state to true or false.
- */
- void setMaximized( const bool& maximized );
- /**
- * Sets the windows hasFocus state to true or false.
- */
- void setFocus( const bool& hasFocus );
- /**
- * Sets the window specific settings.
- */
- void setWindowSettings( const int& settings );
- /**
- * Returns an integer with the window specific settings
- */
- const int& windowSettings() const;
- /**
- * Returns true if the window is maximized.
- */
- const bool& maximized() const;
- /**
- * Returns true if the window has the focus in the MDI area.
- */
- const bool& hasFocus() const;
- /**
- * Returns tghe position of the scrollbars
- */
- const CProfileWindow::ScrollbarPos& scrollbarPositions() const;
- /**
- * Returns whether this profile window represents a write window.
- */
- const int& writeWindowType() const;
- /**
- * Tells this profile window to represent a write window.
- */
- void setWriteWindowType( const int& writeWindowType );
+ CProfileWindow(CSwordModuleInfo::ModuleType type = CSwordModuleInfo::Unknown);
+ ~CProfileWindow();
+ /**
+ * Sets the modules.
+ */
+ void setModules( const QStringList& modules );
+ /**
+ * Returns the type of the managed window (bible window, commentary window or lexicon window).
+ */
+ CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Sets the type of the used modules.
+ */
+ void setType(const CSwordModuleInfo::ModuleType& type);
+ /**
+ * Sets the size of the window.
+ */
+ void setGeometry( const QRect& s );
+ /**
+ * Returns the size of the window including the x,y coordinates.
+ */
+ const QRect& geometry() const;
+ /**
+ * Returns a list of module names which are chosen in the managed window profile.
+ */
+ const QStringList& modules() const;
+ /**
+ * Set the key used in the modules.
+ */
+ void setKey( const QString& );
+ /**
+ * Returns the current key set in the modules.
+ */
+ const QString& key() const;
+ /**
+ * Sets the current position of the scrollbars.
+ */
+ void setScrollbarPositions(const int& x, const int& y);
+ /**
+ * Sets the windows maximized state to true or false.
+ */
+ void setMaximized( const bool& maximized );
+ /**
+ * Sets the windows hasFocus state to true or false.
+ */
+ void setFocus( const bool& hasFocus );
+ /**
+ * Sets the window specific settings.
+ */
+ void setWindowSettings( const int& settings );
+ /**
+ * Returns an integer with the window specific settings
+ */
+ const int& windowSettings() const;
+ /**
+ * Returns true if the window is maximized.
+ */
+ const bool& maximized() const;
+ /**
+ * Returns true if the window has the focus in the MDI area.
+ */
+ const bool& hasFocus() const;
+ /**
+ * Returns tghe position of the scrollbars
+ */
+ const CProfileWindow::ScrollbarPos& scrollbarPositions() const;
+ /**
+ * Returns whether this profile window represents a write window.
+ */
+ const int& writeWindowType() const;
+ /**
+ * Tells this profile window to represent a write window.
+ */
+ void setWriteWindowType( const int& writeWindowType );
-private:
- CSwordModuleInfo::ModuleType m_type;
- QRect m_windowGeometry;
- QStringList m_moduleList;
- QString m_key;
- ScrollbarPos m_scrollbarPos;
- bool m_maximized;
- bool m_hasFocus;
- int m_windowSettings;
- int m_writeWindowType;
+ private:
+ CSwordModuleInfo::ModuleType m_type;
+ QRect m_windowGeometry;
+ QStringList m_moduleList;
+ QString m_key;
+ ScrollbarPos m_scrollbarPos;
+ bool m_maximized;
+ bool m_hasFocus;
+ int m_windowSettings;
+ int m_writeWindowType;
};
} //end of namespace Profile
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index 7ce07e8..76483de 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
@@ -23,62 +23,58 @@
namespace Search {
-static const int DIALOG_HEIGHT=400;
-static const int DIALOG_BORDER=30;
+static const int DIALOG_HEIGHT = 400;
+static const int DIALOG_BORDER = 30;
CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules, QWidget* parentDialog )
- : QDialog(parentDialog)
-{
- initView();
- m_analysis->reset();
- m_analysis->analyse(modules);
-
- // Set initial width based on the search data, but limit to the
- // width of the desktop
- int width = (int)( m_analysis->width()+DIALOG_BORDER );
- int desktopWidth = QApplication::desktop()->screenGeometry(this).width();
- if (width > desktopWidth)
- width = desktopWidth;
- resize(width, DIALOG_HEIGHT);
+ : QDialog(parentDialog) {
+ initView();
+ m_analysis->reset();
+ m_analysis->analyse(modules);
+
+ // Set initial width based on the search data, but limit to the
+ // width of the desktop
+ int width = (int)( m_analysis->width() + DIALOG_BORDER );
+ int desktopWidth = QApplication::desktop()->screenGeometry(this).width();
+ if (width > desktopWidth)
+ width = desktopWidth;
+ resize(width, DIALOG_HEIGHT);
}
/** Initializes this dialog. */
-void CSearchAnalysisDialog::initView()
-{
+void CSearchAnalysisDialog::initView() {
- QVBoxLayout *vboxLayout = new QVBoxLayout(this);
+ QVBoxLayout *vboxLayout = new QVBoxLayout(this);
- m_analysis = new CSearchAnalysisScene(this);
- m_analysisView = new CSearchAnalysisView(m_analysis, this);
+ m_analysis = new CSearchAnalysisScene(this);
+ m_analysisView = new CSearchAnalysisView(m_analysis, this);
//// m_analysisView->show();
- vboxLayout->addWidget(m_analysisView);
-
- m_buttonBox = new QDialogButtonBox(this);
- m_buttonBox->setOrientation(Qt::Horizontal);
- m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
- m_buttonBox->addButton(QDialogButtonBox::Save);
- //tr("Save as HTML"),
- util::prepareDialogBox(m_buttonBox);
- vboxLayout->addWidget(m_buttonBox);
-
- bool ok = QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- Q_ASSERT(ok);
- ok = QObject::connect(m_buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
- Q_ASSERT(ok);
+ vboxLayout->addWidget(m_analysisView);
+
+ m_buttonBox = new QDialogButtonBox(this);
+ m_buttonBox->setOrientation(Qt::Horizontal);
+ m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
+ m_buttonBox->addButton(QDialogButtonBox::Save);
+ //tr("Save as HTML"),
+ util::prepareDialogBox(m_buttonBox);
+ vboxLayout->addWidget(m_buttonBox);
+
+ bool ok = QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ Q_ASSERT(ok);
+ ok = QObject::connect(m_buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ Q_ASSERT(ok);
}
-void CSearchAnalysisDialog::buttonClicked(QAbstractButton* button)
-{
- if (m_buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
- m_analysis->saveAsHTML();
- }
+void CSearchAnalysisDialog::buttonClicked(QAbstractButton* button) {
+ if (m_buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
+ m_analysis->saveAsHTML();
+ }
}
-void CSearchAnalysisDialog::resizeEvent(QResizeEvent* event)
-{
- QDialog::resizeEvent(event);
- m_analysis->resizeHeight(height());
+void CSearchAnalysisDialog::resizeEvent(QResizeEvent* event) {
+ QDialog::resizeEvent(event);
+ m_analysis->resizeHeight(height());
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index c24c554..7c48c15 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -15,7 +15,7 @@ class CSwordModuleInfo;
#include <QDialog>
#include <QObject>
-
+
class QAbstractButton;
class QDialogButtonBox;
@@ -29,28 +29,27 @@ class CSearchAnalysisScene;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CSearchAnalysisDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- CSearchAnalysisDialog(QList<CSwordModuleInfo*> modules, QWidget* parentDialog);
- ~CSearchAnalysisDialog() {}
-
-protected: // Protected methods
- /**
- * Initializes this dialog.
- */
- void initView();
- void resizeEvent(QResizeEvent* event);
-
-private slots:
- void buttonClicked(QAbstractButton* button);
-
-private:
- CSearchAnalysisScene* m_analysis;
- CSearchAnalysisView* m_analysisView;
- QDialogButtonBox* m_buttonBox;
+class CSearchAnalysisDialog : public QDialog {
+ Q_OBJECT
+
+ public:
+ CSearchAnalysisDialog(QList<CSwordModuleInfo*> modules, QWidget* parentDialog);
+ ~CSearchAnalysisDialog() {}
+
+ protected: // Protected methods
+ /**
+ * Initializes this dialog.
+ */
+ void initView();
+ void resizeEvent(QResizeEvent* event);
+
+ private slots:
+ void buttonClicked(QAbstractButton* button);
+
+ private:
+ CSearchAnalysisScene* m_analysis;
+ CSearchAnalysisView* m_analysisView;
+ QDialogButtonBox* m_buttonBox;
};
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index 713a98b..fb3810d 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
@@ -43,127 +43,125 @@ const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;
CSearchAnalysisItem::CSearchAnalysisItem(const int moduleCount, const QString &bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules)
- : QGraphicsRectItem(),
- m_moduleList( modules ),
- m_scaleFactor(scaleFactor),
- m_bookName(bookname),
- m_moduleCount(moduleCount),
- m_bufferPixmap(0)
-{
- m_resultCountArray.resize(m_moduleCount);
- int index = 0;
- for (index = 0; index < m_moduleCount; ++index) m_resultCountArray[index] = 0;
+ : QGraphicsRectItem(),
+ m_moduleList( modules ),
+ m_scaleFactor(scaleFactor),
+ m_bookName(bookname),
+ m_moduleCount(moduleCount),
+ m_bufferPixmap(0) {
+ m_resultCountArray.resize(m_moduleCount);
+ int index = 0;
+ for (index = 0; index < m_moduleCount; ++index) m_resultCountArray[index] = 0;
}
-CSearchAnalysisItem::~CSearchAnalysisItem()
-{
- delete m_bufferPixmap;
+CSearchAnalysisItem::~CSearchAnalysisItem() {
+ delete m_bufferPixmap;
}
/** Sets the resultcount of this item for the given module */
void CSearchAnalysisItem::setCountForModule( const int moduleIndex, const int count) {
- m_resultCountArray[moduleIndex] = count;
+ m_resultCountArray[moduleIndex] = count;
}
/** Returns the resultcount of this item for the given module */
int CSearchAnalysisItem::getCountForModule( const int moduleIndex) {
- return m_resultCountArray[moduleIndex];
+ return m_resultCountArray[moduleIndex];
}
bool CSearchAnalysisItem::hasHitsInAnyModule() {
- foreach (const int hits, m_resultCountArray){
- if (hits) return true;
- }
- return false;
+ foreach (const int hits, m_resultCountArray) {
+ if (hits) return true;
+ }
+ return false;
}
/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
- QFont f = painter->font();
- f.setPointSize(ITEM_TEXT_SIZE);
- painter->setFont(f);
-
- /**
- * We have to paint so many bars as we have modules available (we use m_moduleCount)
- * We paint inside the area which is given by height and width of this rectangle item
- */
- int index = 0;
- int drawn = 0;
- int Value = 0;
-
- //find out the biggest value
- for (index=0;index < m_moduleCount; index++) {
- if (m_resultCountArray[index] > Value) {
- Value = m_resultCountArray[index];
- }
- };
-
- while (drawn < m_moduleCount) {
- for (index = 0; index < m_moduleCount; index++) {
- if (m_resultCountArray[index] == Value) {
- QPoint p1((int)rect().x() + (m_moduleCount-drawn-1)*BAR_DELTAX,
- (int)rect().height() + (int)y() - BAR_LOWER_BORDER - (m_moduleCount-drawn)*BAR_DELTAY);
- QPoint p2(p1.x() + BAR_WIDTH,
- p1.y() - (int)( !m_resultCountArray[index] ? 0 : ((m_resultCountArray[index])*(*m_scaleFactor))) );
- QRect r(p1, p2);
- painter->fillRect(r, QBrush(CSearchAnalysisScene::getColor(index)) );
- painter->drawRect(r);
- drawn++;
- }
- }
- //finds the next smaller value
- int newValue = 0;
- for (index=0;index < m_moduleCount; index++)
- if (m_resultCountArray[index] < Value && m_resultCountArray[index] >= newValue)
- newValue = m_resultCountArray[index];
- Value = newValue;
- }
- if (!m_bufferPixmap) {
- m_bufferPixmap = new QPixmap(width(),BAR_LOWER_BORDER);
- //m_bufferPixmap->resize(width(),BAR_LOWER_BORDER);
- m_bufferPixmap->fill();
- QPainter p(m_bufferPixmap);
- f = p.font();
- f.setPointSize(ITEM_TEXT_SIZE);
- p.setFont(f);
- p.rotate(90);
- p.drawText(QPoint(5,0), m_bookName);
- }
- painter->drawPixmap(QPoint(int(rect().x()),int(rect().height()+y()-BAR_LOWER_BORDER)), *m_bufferPixmap);
+ QFont f = painter->font();
+ f.setPointSize(ITEM_TEXT_SIZE);
+ painter->setFont(f);
+
+ /**
+ * We have to paint so many bars as we have modules available (we use m_moduleCount)
+ * We paint inside the area which is given by height and width of this rectangle item
+ */
+ int index = 0;
+ int drawn = 0;
+ int Value = 0;
+
+ //find out the biggest value
+ for (index = 0;index < m_moduleCount; index++) {
+ if (m_resultCountArray[index] > Value) {
+ Value = m_resultCountArray[index];
+ }
+ };
+
+ while (drawn < m_moduleCount) {
+ for (index = 0; index < m_moduleCount; index++) {
+ if (m_resultCountArray[index] == Value) {
+ QPoint p1((int)rect().x() + (m_moduleCount - drawn - 1)*BAR_DELTAX,
+ (int)rect().height() + (int)y() - BAR_LOWER_BORDER - (m_moduleCount - drawn)*BAR_DELTAY);
+ QPoint p2(p1.x() + BAR_WIDTH,
+ p1.y() - (int)( !m_resultCountArray[index] ? 0 : ((m_resultCountArray[index])*(*m_scaleFactor))) );
+ QRect r(p1, p2);
+ painter->fillRect(r, QBrush(CSearchAnalysisScene::getColor(index)) );
+ painter->drawRect(r);
+ drawn++;
+ }
+ }
+ //finds the next smaller value
+ int newValue = 0;
+ for (index = 0;index < m_moduleCount; index++)
+ if (m_resultCountArray[index] < Value && m_resultCountArray[index] >= newValue)
+ newValue = m_resultCountArray[index];
+ Value = newValue;
+ }
+ if (!m_bufferPixmap) {
+ m_bufferPixmap = new QPixmap(width(), BAR_LOWER_BORDER);
+ //m_bufferPixmap->resize(width(),BAR_LOWER_BORDER);
+ m_bufferPixmap->fill();
+ QPainter p(m_bufferPixmap);
+ f = p.font();
+ f.setPointSize(ITEM_TEXT_SIZE);
+ p.setFont(f);
+ p.rotate(90);
+ p.drawText(QPoint(5, 0), m_bookName);
+ }
+ painter->drawPixmap(QPoint(int(rect().x()), int(rect().height() + y() - BAR_LOWER_BORDER)), *m_bufferPixmap);
}
/** Returns the width of this item. */
int CSearchAnalysisItem::width() {
- return m_moduleCount*(m_moduleCount>1 ? BAR_DELTAX : 0) + BAR_WIDTH;
+ return m_moduleCount*(m_moduleCount > 1 ? BAR_DELTAX : 0) + BAR_WIDTH;
}
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
- QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
- toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
-
- //ToDo: Fix that loop
- int i = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
-
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
- CSwordModuleInfo* info = (*it);
- const QColor c = CSearchAnalysisScene::getColor(i);
-
- toolTipString.append(
- QString("<tr bgcolor=\"white\"><td><b><font color=\"#%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
- .arg(QString().sprintf("%02X%02X%02X",c.red(),c.green(),c.blue()))
- .arg(info ? info->name() : QString::null)
- .arg( m_resultCountArray[i] )
- .arg( (info && m_resultCountArray[i])? ((double)m_resultCountArray[i] / (double)info->searchResult().Count())*(double)100 : 0.0, 0, 'g', 2)
- );
- ++i;
- }
-
- toolTipString += "</table>";
-
- return toolTipString;
+ QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
+ toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
+
+ //ToDo: Fix that loop
+ int i = 0;
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
+
+ for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
+ CSwordModuleInfo* info = (*it);
+ const QColor c = CSearchAnalysisScene::getColor(i);
+
+ toolTipString.append(
+ QString("<tr bgcolor=\"white\"><td><b><font color=\"#%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
+ .arg(QString().sprintf("%02X%02X%02X", c.red(), c.green(), c.blue()))
+ .arg(info ? info->name() : QString::null)
+ .arg( m_resultCountArray[i] )
+ .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)info->searchResult().Count())*(double)100 : 0.0, 0, 'g', 2)
+ );
+ ++i;
+ }
+
+ toolTipString += "</table>";
+
+ return toolTipString;
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index 5926f43..30ba9a3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -20,43 +20,42 @@ namespace Search {
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CSearchAnalysisItem : public QGraphicsRectItem
-{
-public:
+class CSearchAnalysisItem : public QGraphicsRectItem {
+ public:
- CSearchAnalysisItem(const int moduleCount, const QString& bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules);
- ~CSearchAnalysisItem();
- /**
- * Sets the resultcount of this item
- */
- void setCountForModule( const int moduleIndex, const int count);
+ CSearchAnalysisItem(const int moduleCount, const QString& bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules);
+ ~CSearchAnalysisItem();
+ /**
+ * Sets the resultcount of this item
+ */
+ void setCountForModule( const int moduleIndex, const int count);
- /**
- * Returns the resultcount of this item
- */
- int getCountForModule( const int moduleIndex);
- /**
- * Does one of the modules contain hits?
- */
- bool hasHitsInAnyModule();
- /**
- * Returns the width of this item.
- */
- virtual int width();
- /**
- * Returns the tooltip for this item.
- */
- const QString getToolTip();
+ /**
+ * Returns the resultcount of this item
+ */
+ int getCountForModule( const int moduleIndex);
+ /**
+ * Does one of the modules contain hits?
+ */
+ bool hasHitsInAnyModule();
+ /**
+ * Returns the width of this item.
+ */
+ virtual int width();
+ /**
+ * Returns the tooltip for this item.
+ */
+ const QString getToolTip();
-private:
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
+ private:
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
- double *m_scaleFactor;
- QString m_bookName;
- int m_moduleCount;
- QVector<int> m_resultCountArray;
- QPixmap* m_bufferPixmap;
+ QList<CSwordModuleInfo*>* m_moduleList;
+ double *m_scaleFactor;
+ QString m_bookName;
+ int m_moduleCount;
+ QVector<int> m_resultCountArray;
+ QPixmap* m_bufferPixmap;
};
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index 461e65a..cb25dab 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
@@ -40,44 +40,43 @@ const int LEGEND_WIDTH = 85;
CSearchAnalysisLegendItem::CSearchAnalysisLegendItem(QList<CSwordModuleInfo*> *list )
- : QGraphicsRectItem()
-{
- m_moduleList = list;
+ : QGraphicsRectItem() {
+ m_moduleList = list;
}
/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
- painter->save();
-
- //the outer rectangle
- QPoint p1( (int)(rect().x()), (int)(rect().y()) );
- QPoint p2( (int)(rect().x() + rect().width() ), (int)(rect().y() + rect().height()));
- QRect r(p1, p2);
- r = r.normalized();
- painter->drawRect(r);
-
- QFont f = painter->font();
- f.setPointSize(ITEM_TEXT_SIZE);
- painter->setFont(f);
-
- // for (unsigned int index=0; index < m_moduleList->count(); index++){
- int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
- // the module color indicators
- QPoint p1( (int)(rect().x()) + LEGEND_INNER_BORDER, (int)(rect().y()) + LEGEND_INNER_BORDER + moduleIndex*(LEGEND_DELTAY + ITEM_TEXT_SIZE) );
- QPoint p2(p1.x() + ITEM_TEXT_SIZE, p1.y() + ITEM_TEXT_SIZE);
- QRect r(p1,p2);
- painter->fillRect(r, QBrush(CSearchAnalysisScene::getColor(moduleIndex)) );
- r = r.normalized();
- painter->drawRect(r);
-
- QPoint p3( p2.x() + LEGEND_INNER_BORDER, p2.y() );
- painter->drawText(p3, (*it)->name() );
-
- ++moduleIndex;
- }
- painter->restore();
+ painter->save();
+
+ //the outer rectangle
+ QPoint p1( (int)(rect().x()), (int)(rect().y()) );
+ QPoint p2( (int)(rect().x() + rect().width() ), (int)(rect().y() + rect().height()));
+ QRect r(p1, p2);
+ r = r.normalized();
+ painter->drawRect(r);
+
+ QFont f = painter->font();
+ f.setPointSize(ITEM_TEXT_SIZE);
+ painter->setFont(f);
+
+ // for (unsigned int index=0; index < m_moduleList->count(); index++){
+ int moduleIndex = 0;
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
+ for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
+ // the module color indicators
+ QPoint p1( (int)(rect().x()) + LEGEND_INNER_BORDER, (int)(rect().y()) + LEGEND_INNER_BORDER + moduleIndex*(LEGEND_DELTAY + ITEM_TEXT_SIZE) );
+ QPoint p2(p1.x() + ITEM_TEXT_SIZE, p1.y() + ITEM_TEXT_SIZE);
+ QRect r(p1, p2);
+ painter->fillRect(r, QBrush(CSearchAnalysisScene::getColor(moduleIndex)) );
+ r = r.normalized();
+ painter->drawRect(r);
+
+ QPoint p3( p2.x() + LEGEND_INNER_BORDER, p2.y() );
+ painter->drawText(p3, (*it)->name() );
+
+ ++moduleIndex;
+ }
+ painter->restore();
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index 879f239..a9eebc2 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -19,14 +19,13 @@ namespace Search {
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CSearchAnalysisLegendItem : public QGraphicsRectItem
-{
-public:
- CSearchAnalysisLegendItem(QList<CSwordModuleInfo*>* list );
-
-private:
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
+class CSearchAnalysisLegendItem : public QGraphicsRectItem {
+ public:
+ CSearchAnalysisLegendItem(QList<CSwordModuleInfo*>* list );
+
+ private:
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
+ QList<CSwordModuleInfo*>* m_moduleList;
};
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index 7bc3ab2..ce093f7 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
@@ -47,246 +47,243 @@ const int LEGEND_WIDTH = 85;
CSearchAnalysisScene::CSearchAnalysisScene(QObject *parent )
- : QGraphicsScene(parent),
- m_scaleFactor(0.0),
- m_legend(0)
-{
- setBackgroundBrush(QBrush(Qt::white));
- setSceneRect(0,0,1,1);
+ : QGraphicsScene(parent),
+ m_scaleFactor(0.0),
+ m_legend(0) {
+ setBackgroundBrush(QBrush(Qt::white));
+ setSceneRect(0, 0, 1, 1);
}
QHash<QString, CSearchAnalysisItem*>* CSearchAnalysisScene::getSearchAnalysisItemList() {
- // Returns pointer to the search analysis items
- return &m_itemList;
+ // Returns pointer to the search analysis items
+ return &m_itemList;
}
/** Starts the analysis of the search result. This should be called only once because QCanvas handles the updates automatically. */
void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
- /**
- * Steps of analysing our search result;
- * -Create the items for all available books ("Genesis" - "Revelation")
- * -Iterate through all modules we analyse
- * -Go through all books of this module
- * -Find out how many times we found the book
- * -Set the count to the items which belongs to the book
- */
- setModules(modules);
-
- m_lastPosList.clear();
- const int numberOfModules = m_moduleList.count();
- if (!numberOfModules)
- return;
- m_legend = new CSearchAnalysisLegendItem(&m_moduleList);
- addItem(m_legend);
- m_legend->setRect(LEFT_BORDER, UPPER_BORDER,
- LEGEND_WIDTH, LEGEND_INNER_BORDER*2 + ITEM_TEXT_SIZE*numberOfModules + LEGEND_DELTAY*(numberOfModules-1) );
- m_legend->show();
-
- int xPos = (int)(LEFT_BORDER + m_legend->rect().width() + SPACE_BETWEEN_PARTS);
- int moduleIndex = 0;
- m_maxCount = 0;
- int count = 0;
- CSwordVerseKey key(0);
- key.key("Genesis 1:1");
-
- CSearchAnalysisItem* analysisItem = m_itemList[key.book()];
- bool ok = true;
- while (ok && analysisItem) {
- moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
- qApp->processEvents( QEventLoop::AllEvents );
- if (!m_lastPosList.contains(*it)) {
- m_lastPosList.insert(*it,0);
- }
-
- analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), *it)));
- m_maxCount = (count > m_maxCount) ? count : m_maxCount;
-
- ++moduleIndex;
- }
- if (analysisItem->hasHitsInAnyModule())
- {
- analysisItem->setRect(xPos, UPPER_BORDER, analysisItem->rect().width(), analysisItem->rect().height());
- QString tip = analysisItem->getToolTip();
- analysisItem->setToolTip(tip);
- analysisItem->show();
- xPos += (int)analysisItem->width() + SPACE_BETWEEN_PARTS;
- }
- ok = key.next(CSwordVerseKey::UseBook);
- analysisItem = m_itemList[key.book()];
- }
- setSceneRect(0,0, xPos+BAR_WIDTH+(m_moduleList.count()-1)*BAR_DELTAX+RIGHT_BORDER, height() );
- slotResized();
+ /**
+ * Steps of analysing our search result;
+ * -Create the items for all available books ("Genesis" - "Revelation")
+ * -Iterate through all modules we analyse
+ * -Go through all books of this module
+ * -Find out how many times we found the book
+ * -Set the count to the items which belongs to the book
+ */
+ setModules(modules);
+
+ m_lastPosList.clear();
+ const int numberOfModules = m_moduleList.count();
+ if (!numberOfModules)
+ return;
+ m_legend = new CSearchAnalysisLegendItem(&m_moduleList);
+ addItem(m_legend);
+ m_legend->setRect(LEFT_BORDER, UPPER_BORDER,
+ LEGEND_WIDTH, LEGEND_INNER_BORDER*2 + ITEM_TEXT_SIZE*numberOfModules + LEGEND_DELTAY*(numberOfModules - 1) );
+ m_legend->show();
+
+ int xPos = (int)(LEFT_BORDER + m_legend->rect().width() + SPACE_BETWEEN_PARTS);
+ int moduleIndex = 0;
+ m_maxCount = 0;
+ int count = 0;
+ CSwordVerseKey key(0);
+ key.key("Genesis 1:1");
+
+ CSearchAnalysisItem* analysisItem = m_itemList[key.book()];
+ bool ok = true;
+ while (ok && analysisItem) {
+ moduleIndex = 0;
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
+ for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ qApp->processEvents( QEventLoop::AllEvents );
+ if (!m_lastPosList.contains(*it)) {
+ m_lastPosList.insert(*it, 0);
+ }
+
+ analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), *it)));
+ m_maxCount = (count > m_maxCount) ? count : m_maxCount;
+
+ ++moduleIndex;
+ }
+ if (analysisItem->hasHitsInAnyModule()) {
+ analysisItem->setRect(xPos, UPPER_BORDER, analysisItem->rect().width(), analysisItem->rect().height());
+ QString tip = analysisItem->getToolTip();
+ analysisItem->setToolTip(tip);
+ analysisItem->show();
+ xPos += (int)analysisItem->width() + SPACE_BETWEEN_PARTS;
+ }
+ ok = key.next(CSwordVerseKey::UseBook);
+ analysisItem = m_itemList[key.book()];
+ }
+ setSceneRect(0, 0, xPos + BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX + RIGHT_BORDER, height() );
+ slotResized();
}
/** Sets the module list used for the analysis. */
void CSearchAnalysisScene::setModules(QList<CSwordModuleInfo*> modules) {
- m_moduleList.clear();
- foreach (CSwordModuleInfo * mod, modules) {
- if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
- m_moduleList.append(mod);
- }
- }
-
- m_itemList.clear();
- CSearchAnalysisItem* analysisItem = 0;
- CSwordVerseKey key(0);
- key.key("Genesis 1:1");
- do {
- analysisItem = new CSearchAnalysisItem(m_moduleList.count(), key.book(), &m_scaleFactor, &m_moduleList);
- addItem(analysisItem);
- analysisItem->hide();
- m_itemList.insert(key.book(), analysisItem);
- }
- while (key.next(CSwordVerseKey::UseBook));
- update();
+ m_moduleList.clear();
+ foreach (CSwordModuleInfo * mod, modules) {
+ if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
+ m_moduleList.append(mod);
+ }
+ }
+
+ m_itemList.clear();
+ CSearchAnalysisItem* analysisItem = 0;
+ CSwordVerseKey key(0);
+ key.key("Genesis 1:1");
+ do {
+ analysisItem = new CSearchAnalysisItem(m_moduleList.count(), key.book(), &m_scaleFactor, &m_moduleList);
+ addItem(analysisItem);
+ analysisItem->hide();
+ m_itemList.insert(key.book(), analysisItem);
+ }
+ while (key.next(CSwordVerseKey::UseBook));
+ update();
}
/** Sets back the items and deletes things to cleanup */
void CSearchAnalysisScene::reset() {
- m_scaleFactor = 0.0;
+ m_scaleFactor = 0.0;
- QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList ); // iterator for items
- while ( it.hasNext() ) {
- it.next();
- if (it.value()) it.value()->hide();
- }
- m_lastPosList.clear();
+ QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList ); // iterator for items
+ while ( it.hasNext() ) {
+ it.next();
+ if (it.value()) it.value()->hide();
+ }
+ m_lastPosList.clear();
- if (m_legend) m_legend->hide();
+ if (m_legend) m_legend->hide();
- delete m_legend;
- m_legend = 0;
+ delete m_legend;
+ m_legend = 0;
- update();
+ update();
}
/** No descriptions */
void CSearchAnalysisScene::slotResized() {
- m_scaleFactor = (double)( (double)(height()-UPPER_BORDER-LOWER_BORDER-BAR_LOWER_BORDER-100-(m_moduleList.count()-1)*BAR_DELTAY)
- /(double)m_maxCount);
- QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList );
- while ( it.hasNext() ) {
- it.next();
- if (it.value()) {
- it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_moduleList.count()-1)*BAR_DELTAX, height()-LOWER_BORDER-BAR_LOWER_BORDER);
- }
- }
- update();
+ m_scaleFactor = (double)( (double)(height() - UPPER_BORDER - LOWER_BORDER - BAR_LOWER_BORDER - 100 - (m_moduleList.count() - 1) * BAR_DELTAY)
+ / (double)m_maxCount);
+ QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList );
+ while ( it.hasNext() ) {
+ it.next();
+ if (it.value()) {
+ it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX, height() - LOWER_BORDER - BAR_LOWER_BORDER);
+ }
+ }
+ update();
}
/** This function returns a color for each module */
QColor CSearchAnalysisScene::getColor(int index) {
- switch (index) {
- case 0:
- return Qt::red;
- case 1:
- return Qt::darkGreen;
- case 2:
- return Qt::blue;
- case 3:
- return Qt::cyan;
- case 4:
- return Qt::magenta;
- case 5:
- return Qt::darkRed;
- case 6:
- return Qt::darkGray;
- case 7:
- return Qt::black;
- case 8:
- return Qt::darkCyan;
- case 9:
- return Qt::darkMagenta;
- default:
- return Qt::red;
- }
+ switch (index) {
+ case 0:
+ return Qt::red;
+ case 1:
+ return Qt::darkGreen;
+ case 2:
+ return Qt::blue;
+ case 3:
+ return Qt::cyan;
+ case 4:
+ return Qt::magenta;
+ case 5:
+ return Qt::darkRed;
+ case 6:
+ return Qt::darkGray;
+ case 7:
+ return Qt::black;
+ case 8:
+ return Qt::darkCyan;
+ case 9:
+ return Qt::darkMagenta;
+ default:
+ return Qt::red;
+ }
}
/** Returns the count of the book in the module */
unsigned int CSearchAnalysisScene::getCount( const QString book, CSwordModuleInfo* module ) {
- sword::ListKey& result = module->searchResult();
- const int length = book.length();
- unsigned int i = m_lastPosList[module];
- unsigned int count = 0;
- const unsigned int resultCount = result.Count();
- while (i < resultCount) {
- if ( strncmp(book.toUtf8(), (const char*)*result.GetElement(i), length) )
- break;
- i++;
- ++count;
- }
- m_lastPosList.insert(module,i);
- return count;
+ sword::ListKey& result = module->searchResult();
+ const int length = book.length();
+ unsigned int i = m_lastPosList[module];
+ unsigned int count = 0;
+ const unsigned int resultCount = result.Count();
+ while (i < resultCount) {
+ if ( strncmp(book.toUtf8(), (const char*)*result.GetElement(i), length) )
+ break;
+ i++;
+ ++count;
+ }
+ m_lastPosList.insert(module, i);
+ return count;
}
void CSearchAnalysisScene::saveAsHTML() {
- const QString fileName = QFileDialog::getSaveFileName(0, tr("Save Search Analysis"), QString::null, tr("HTML files (*.html;*.HTML;*.HTM;*.htm)") );
- if (fileName.isEmpty()) return;
-
- int count = 0;
- QString countStr = "";
- QString m_searchAnalysisHTML = "";
- QString tableTitle = "";
- QString tableTotals = "";
- QString VerseRange = "";
- const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
- const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
- CSwordVerseKey key(0);
- sword::ListKey searchResult;
-
- key.key("Genesis 1:1");
-
- CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
-
- QString text = "<html>\n<head>\n<title>" + tr("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
- text += "<table>\n<tr><th>" + tr("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";
-
- tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
- tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
-
- foreach (CSwordModuleInfo* mod, m_moduleList) {
- tableTitle += QString("<th align=\"left\">") + mod->name() + QString("</th>");
- searchResult = mod->searchResult();
- countStr.setNum(searchResult.Count());
-
- tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
- }
- tableTitle += QString("</tr>\n");
- tableTotals += QString("</tr>\n");
-
- m_searchAnalysisHTML = "";
- bool ok = true;
- while (ok) {
- m_searchAnalysisHTML += QString("<tr><td>") + key.book() + QString("</td>");
- analysisItem = m_itemList.value( key.book() );
-
- int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
- count = analysisItem->getCountForModule(moduleIndex);
- countStr.setNum(count);
- m_searchAnalysisHTML += QString("<td align=\"right\">") + countStr + QString("</td>");
-
- ++moduleIndex;
- }
- m_searchAnalysisHTML += QString("</tr>\n");
- ok = key.next(CSwordVerseKey::UseBook);
- }
-
- text += QString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + QString("</table>\n");
- text += QString("<center>") + tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>") + QString("</center>");
- text += QString("</body></html>");
-
- CToolClass::savePlainFile(fileName, text, false, QTextCodec::codecForName("UTF8"));
+ const QString fileName = QFileDialog::getSaveFileName(0, tr("Save Search Analysis"), QString::null, tr("HTML files (*.html;*.HTML;*.HTM;*.htm)") );
+ if (fileName.isEmpty()) return;
+
+ int count = 0;
+ QString countStr = "";
+ QString m_searchAnalysisHTML = "";
+ QString tableTitle = "";
+ QString tableTotals = "";
+ QString VerseRange = "";
+ const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
+ const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
+ CSwordVerseKey key(0);
+ sword::ListKey searchResult;
+
+ key.key("Genesis 1:1");
+
+ CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
+
+ QString text = "<html>\n<head>\n<title>" + tr("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
+ text += "<table>\n<tr><th>" + tr("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";
+
+ tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
+ tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
+
+ foreach (CSwordModuleInfo* mod, m_moduleList) {
+ tableTitle += QString("<th align=\"left\">") + mod->name() + QString("</th>");
+ searchResult = mod->searchResult();
+ countStr.setNum(searchResult.Count());
+
+ tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
+ }
+ tableTitle += QString("</tr>\n");
+ tableTotals += QString("</tr>\n");
+
+ m_searchAnalysisHTML = "";
+ bool ok = true;
+ while (ok) {
+ m_searchAnalysisHTML += QString("<tr><td>") + key.book() + QString("</td>");
+ analysisItem = m_itemList.value( key.book() );
+
+ int moduleIndex = 0;
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
+ for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ count = analysisItem->getCountForModule(moduleIndex);
+ countStr.setNum(count);
+ m_searchAnalysisHTML += QString("<td align=\"right\">") + countStr + QString("</td>");
+
+ ++moduleIndex;
+ }
+ m_searchAnalysisHTML += QString("</tr>\n");
+ ok = key.next(CSwordVerseKey::UseBook);
+ }
+
+ text += QString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + QString("</table>\n");
+ text += QString("<center>") + tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>") + QString("</center>");
+ text += QString("</body></html>");
+
+ CToolClass::savePlainFile(fileName, text, false, QTextCodec::codecForName("UTF8"));
}
-void CSearchAnalysisScene::resizeHeight(int height)
-{
- setSceneRect(0,0, sceneRect().width(), height);
- slotResized();
+void CSearchAnalysisScene::resizeHeight(int height) {
+ setSceneRect(0, 0, sceneRect().width(), height);
+ slotResized();
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index 755dacf..63abdb9 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -28,57 +28,57 @@ class CSearchAnalysisLegendItem;
@author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisScene : public QGraphicsScene {
- Q_OBJECT
-public:
- CSearchAnalysisScene(QObject* parent);
-
- virtual ~CSearchAnalysisScene() {}
-
- /**
- * Starts the analysis of the search result.
- * This should be called only once because
- * QCanvas handles the updates automatically.
- */
- void analyse(QList<CSwordModuleInfo*> modules);
- /**
- * This function returns a color for each module
- * @return The color at position index in the list
- */
- static QColor getColor(int index);
- /**
- * This function returns a pointer to the list of AnalysisItems
- */
- QHash<QString, CSearchAnalysisItem*>* getSearchAnalysisItemList();
- void reset();
- /**
- * resize the height of the scene
- */
- void resizeHeight(int height);
-
-public slots:
- void saveAsHTML();
-
-protected slots: // Protected slots
- /**
- * No descriptions
- */
- void slotResized();
-
-protected:
- void setModules(QList<CSwordModuleInfo*> modules);
-
-private:
- /**
- * Returns the count of the book in the module
- */
- unsigned int getCount( const QString book, CSwordModuleInfo* module );
-
- QList<CSwordModuleInfo*> m_moduleList;
- QHash<QString, CSearchAnalysisItem*> m_itemList;
- QMap<CSwordModuleInfo*,unsigned int> m_lastPosList;
- int m_maxCount;
- double m_scaleFactor;
- CSearchAnalysisLegendItem* m_legend;
+ Q_OBJECT
+ public:
+ CSearchAnalysisScene(QObject* parent);
+
+ virtual ~CSearchAnalysisScene() {}
+
+ /**
+ * Starts the analysis of the search result.
+ * This should be called only once because
+ * QCanvas handles the updates automatically.
+ */
+ void analyse(QList<CSwordModuleInfo*> modules);
+ /**
+ * This function returns a color for each module
+ * @return The color at position index in the list
+ */
+ static QColor getColor(int index);
+ /**
+ * This function returns a pointer to the list of AnalysisItems
+ */
+ QHash<QString, CSearchAnalysisItem*>* getSearchAnalysisItemList();
+ void reset();
+ /**
+ * resize the height of the scene
+ */
+ void resizeHeight(int height);
+
+ public slots:
+ void saveAsHTML();
+
+ protected slots: // Protected slots
+ /**
+ * No descriptions
+ */
+ void slotResized();
+
+ protected:
+ void setModules(QList<CSwordModuleInfo*> modules);
+
+ private:
+ /**
+ * Returns the count of the book in the module
+ */
+ unsigned int getCount( const QString book, CSwordModuleInfo* module );
+
+ QList<CSwordModuleInfo*> m_moduleList;
+ QHash<QString, CSearchAnalysisItem*> m_itemList;
+ QMap<CSwordModuleInfo*, unsigned int> m_lastPosList;
+ int m_maxCount;
+ double m_scaleFactor;
+ CSearchAnalysisLegendItem* m_legend;
};
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index 0d58c78..f43f133 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
@@ -18,23 +18,22 @@
namespace Search {
CSearchAnalysisView::CSearchAnalysisView(CSearchAnalysisScene* scene, QWidget* parent)
- : QGraphicsView(scene, parent)
-{
- setFocusPolicy(Qt::WheelFocus);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- resize(sizeHint());
+ : QGraphicsView(scene, parent) {
+ setFocusPolicy(Qt::WheelFocus);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ resize(sizeHint());
}
/** Returns the sizeHint for this view */
QSize CSearchAnalysisView::sizeHint() const {
- return QGraphicsView::sizeHint();
+ return QGraphicsView::sizeHint();
}
/** No descriptions */
void CSearchAnalysisView::resizeEvent( QResizeEvent* e) {
- QGraphicsView::resizeEvent(e);
- scene()->setSceneRect(0,0, scene()->sceneRect().width(), viewport()->height() );
+ QGraphicsView::resizeEvent(e);
+ scene()->setSceneRect(0, 0, scene()->sceneRect().width(), viewport()->height() );
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index 35c4419..6b75dfa 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -22,30 +22,29 @@ class CSearchAnalysisScene;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CSearchAnalysisView : public QGraphicsView
-{
-public:
- CSearchAnalysisView(CSearchAnalysisScene* scene, QWidget* parent);
-
- ~CSearchAnalysisView() {}
-
-/**
- * Returns the sizeHint for this view
- * We give back the size of the parent widgetas default.
- * This is a reimplementation from QCanvasView::sizeHint().
- */
- virtual QSize sizeHint() const;
-
- /**
- * Returns the item at position p or 0 if there is no item.
- */
- //CSearchAnalysisItem* itemAt( const QPoint& p );
-
-protected:
- /**
- * Reimplementation.
- */
- virtual void resizeEvent(QResizeEvent* e);
+class CSearchAnalysisView : public QGraphicsView {
+ public:
+ CSearchAnalysisView(CSearchAnalysisScene* scene, QWidget* parent);
+
+ ~CSearchAnalysisView() {}
+
+ /**
+ * Returns the sizeHint for this view
+ * We give back the size of the parent widgetas default.
+ * This is a reimplementation from QCanvasView::sizeHint().
+ */
+ virtual QSize sizeHint() const;
+
+ /**
+ * Returns the item at position p or 0 if there is no item.
+ */
+ //CSearchAnalysisItem* itemAt( const QPoint& p );
+
+ protected:
+ /**
+ * Reimplementation.
+ */
+ virtual void resizeEvent(QResizeEvent* e);
};
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index a4dbfd4..d6c3b4f 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.cpp
+++ b/src/frontend/searchdialog/btsearchoptionsarea.cpp
@@ -34,469 +34,461 @@
namespace Search {
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
- : QWidget(parent)
-{
- initView();
- initConnections();
- readSettings();
+ : QWidget(parent) {
+ initView();
+ initConnections();
+ readSettings();
}
BtSearchOptionsArea::~BtSearchOptionsArea() {
- saveSettings();
+ saveSettings();
}
QString BtSearchOptionsArea::searchText() const {
- return m_searchTextCombo->currentText();
+ return m_searchTextCombo->currentText();
}
-BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType()
-{
- if (m_typeAndButton->isChecked()) {
- return BtSearchOptionsArea::AndType;
- }
- if (m_typeOrButton->isChecked()) {
- return BtSearchOptionsArea::OrType;
- }
- return BtSearchOptionsArea::FullType;
+BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType() {
+ if (m_typeAndButton->isChecked()) {
+ return BtSearchOptionsArea::AndType;
+ }
+ if (m_typeOrButton->isChecked()) {
+ return BtSearchOptionsArea::OrType;
+ }
+ return BtSearchOptionsArea::FullType;
}
QPushButton* BtSearchOptionsArea::searchButton() const {
- return m_searchButton;
+ return m_searchButton;
}
void BtSearchOptionsArea::setSearchText(const QString& text) {
- bool found = false;
- int i = 0;
- for (i = 0; !found && i < m_searchTextCombo->count(); ++i) {
- if (m_searchTextCombo->itemText(i) == text) {
- found = true;
- }
- }
- // This is needed because in the for loop i is incremented before the comparison (++i)
- // As a result the index i is actually one greater than expected.
- i--;
- if (!found) {
- i = 0;
- m_searchTextCombo->insertItem(0, text );
- }
-
- m_searchTextCombo->setCurrentIndex(i);
- m_searchTextCombo->setFocus();
+ bool found = false;
+ int i = 0;
+ for (i = 0; !found && i < m_searchTextCombo->count(); ++i) {
+ if (m_searchTextCombo->itemText(i) == text) {
+ found = true;
+ }
+ }
+ // This is needed because in the for loop i is incremented before the comparison (++i)
+ // As a result the index i is actually one greater than expected.
+ i--;
+ if (!found) {
+ i = 0;
+ m_searchTextCombo->insertItem(0, text );
+ }
+
+ m_searchTextCombo->setCurrentIndex(i);
+ m_searchTextCombo->setFocus();
}
-void BtSearchOptionsArea::initView()
-{
- QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- this->setSizePolicy(sizePolicy);
- hboxLayout = new QHBoxLayout(this);
+void BtSearchOptionsArea::initView() {
+ QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ this->setSizePolicy(sizePolicy);
+ hboxLayout = new QHBoxLayout(this);
- searchGroupBox = new QGroupBox(this);
+ searchGroupBox = new QGroupBox(this);
- gridLayout = new QGridLayout(searchGroupBox);
+ gridLayout = new QGridLayout(searchGroupBox);
- gridLayout->setHorizontalSpacing(3);
+ gridLayout->setHorizontalSpacing(3);
- // ******** label for search text editor***********
+ // ******** label for search text editor***********
m_searchTextLabel = new QLabel(tr("Search for:"), searchGroupBox);
- m_searchTextLabel->setWordWrap(false);
- gridLayout->addWidget(m_searchTextLabel, 0, 0);
-
- // **********Buttons******************
-
- m_searchButton = new QPushButton(this);
- m_searchButton->setText(tr("&Search"));
- m_searchButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::icon));
- m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
- gridLayout->addWidget(m_searchButton, 0, 2);
-
- m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
- m_chooseModulesButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::chooseworks_icon));
- m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
- gridLayout->addWidget(m_chooseModulesButton, 2, 2);
-
- m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
- m_chooseRangeButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::setupscope_icon));
- m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
- gridLayout->addWidget(m_chooseRangeButton, 3, 2);
-
- // ************* Search type (AND/OR) selector ***************************************
- QHBoxLayout* typeSelectorLayout = new QHBoxLayout();
- int tsLeft, tsTop, tsRight, tsBottom;
- // Added space looks nicer and enhances readability
- typeSelectorLayout->getContentsMargins(&tsLeft, &tsTop, &tsRight, &tsBottom);
- typeSelectorLayout->setContentsMargins(tsLeft, 0, tsRight, tsBottom + CToolClass::mWidth(this,1) );
- typeSelectorLayout->setSpacing(typeSelectorLayout->spacing()+CToolClass::mWidth(this,1));
- QHBoxLayout* fullButtonLayout = new QHBoxLayout();
- fullButtonLayout->setSpacing(CToolClass::mWidth(this,1)/2);
- m_typeAndButton = new QRadioButton(tr("All words"));
- m_typeAndButton->setChecked(true);
- m_typeOrButton = new QRadioButton(tr("Some words"));
- m_typeFreeButton = new QRadioButton(tr("Free"));
-
- m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
- m_typeOrButton->setToolTip(tr("Some of the words (OR is added between the words)"));
- m_typeFreeButton->setToolTip(tr("Full lucene syntax"));
-
- m_helpLabel = new QLabel(tr(" (<a href='syntax_help'>full syntax</a>)"));
- m_helpLabel->setToolTip(tr("Click the link to get help for search syntax"));
-
- typeSelectorLayout->addWidget(m_typeAndButton);
- typeSelectorLayout->addWidget(m_typeOrButton);
- fullButtonLayout->addWidget(m_typeFreeButton);
- fullButtonLayout->addWidget(m_helpLabel);
- typeSelectorLayout->addLayout(fullButtonLayout);
- gridLayout->addLayout(typeSelectorLayout, 1,1, 1,-1, Qt::AlignLeft|Qt::AlignTop);
-
- // ************* Label for search range/scope selector *************
- m_searchScopeLabel = new QLabel(tr("Scope:"), searchGroupBox);
- m_searchScopeLabel->setWordWrap(false);
- gridLayout->addWidget(m_searchScopeLabel, 3, 0);
-
- // ***********Range/scope selector combo box***********
- m_rangeChooserCombo = new QComboBox(searchGroupBox);
- QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed);
- sizePolicy2.setHorizontalStretch(0);
- sizePolicy2.setVerticalStretch(0);
- sizePolicy2.setHeightForWidth(m_rangeChooserCombo->sizePolicy().hasHeightForWidth());
- m_rangeChooserCombo->setSizePolicy(sizePolicy2);
- m_rangeChooserCombo->setToolTip(tr("Choose the scope (books/chapters/verses to search in).<br />Applicable for Bibles and commentaries."));
- gridLayout->addWidget(m_rangeChooserCombo, 3, 1);
-
- // ************* Search text combo box *******************
- m_searchTextCombo = new CHistoryComboBox(searchGroupBox);
- sizePolicy2.setHeightForWidth(m_searchTextCombo->sizePolicy().hasHeightForWidth());
- m_searchTextCombo->setSizePolicy(sizePolicy2);
- m_searchTextCombo->setFocusPolicy(Qt::WheelFocus);
- m_searchTextCombo->setProperty("sizeLimit", QVariant(25));
- m_searchTextCombo->setProperty("duplicatesEnabled", QVariant(false));
- m_searchTextCombo->setToolTip(tr("The text you want to search for"));
- m_searchTextCombo->setInsertPolicy(QComboBox::NoInsert);
- gridLayout->addWidget(m_searchTextCombo, 0, 1);
-
- m_modulesLabel = new QLabel(tr("Works:"), searchGroupBox);
- gridLayout->addWidget(m_modulesLabel, 2, 0);
-
- m_modulesCombo = new QComboBox(searchGroupBox);
- m_modulesCombo->setDuplicatesEnabled(false);
- gridLayout->addWidget(m_modulesCombo, 2, 1);
-
- hboxLayout->addWidget(searchGroupBox);
-
- // Set the minimum size before the widgets are populated with data.
- // Otherwise we will get problems with sizing.
- setMinimumSize(minimumSizeHint());
-
- refreshRanges();
- //set the initial focus
- m_searchTextCombo->setFocus();
- // event filter to prevent the Return/Enter presses in the combo box doing something
- // in the parent widget
- m_searchTextCombo->installEventFilter(this);
+ m_searchTextLabel->setWordWrap(false);
+ gridLayout->addWidget(m_searchTextLabel, 0, 0);
+
+ // **********Buttons******************
+
+ m_searchButton = new QPushButton(this);
+ m_searchButton->setText(tr("&Search"));
+ m_searchButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::icon));
+ m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
+ gridLayout->addWidget(m_searchButton, 0, 2);
+
+ m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
+ m_chooseModulesButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::chooseworks_icon));
+ m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
+ gridLayout->addWidget(m_chooseModulesButton, 2, 2);
+
+ m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
+ m_chooseRangeButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::setupscope_icon));
+ m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
+ gridLayout->addWidget(m_chooseRangeButton, 3, 2);
+
+ // ************* Search type (AND/OR) selector ***************************************
+ QHBoxLayout* typeSelectorLayout = new QHBoxLayout();
+ int tsLeft, tsTop, tsRight, tsBottom;
+ // Added space looks nicer and enhances readability
+ typeSelectorLayout->getContentsMargins(&tsLeft, &tsTop, &tsRight, &tsBottom);
+ typeSelectorLayout->setContentsMargins(tsLeft, 0, tsRight, tsBottom + CToolClass::mWidth(this, 1) );
+ typeSelectorLayout->setSpacing(typeSelectorLayout->spacing() + CToolClass::mWidth(this, 1));
+ QHBoxLayout* fullButtonLayout = new QHBoxLayout();
+ fullButtonLayout->setSpacing(CToolClass::mWidth(this, 1) / 2);
+ m_typeAndButton = new QRadioButton(tr("All words"));
+ m_typeAndButton->setChecked(true);
+ m_typeOrButton = new QRadioButton(tr("Some words"));
+ m_typeFreeButton = new QRadioButton(tr("Free"));
+
+ m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
+ m_typeOrButton->setToolTip(tr("Some of the words (OR is added between the words)"));
+ m_typeFreeButton->setToolTip(tr("Full lucene syntax"));
+
+ m_helpLabel = new QLabel(tr(" (<a href='syntax_help'>full syntax</a>)"));
+ m_helpLabel->setToolTip(tr("Click the link to get help for search syntax"));
+
+ typeSelectorLayout->addWidget(m_typeAndButton);
+ typeSelectorLayout->addWidget(m_typeOrButton);
+ fullButtonLayout->addWidget(m_typeFreeButton);
+ fullButtonLayout->addWidget(m_helpLabel);
+ typeSelectorLayout->addLayout(fullButtonLayout);
+ gridLayout->addLayout(typeSelectorLayout, 1, 1, 1, -1, Qt::AlignLeft | Qt::AlignTop);
+
+ // ************* Label for search range/scope selector *************
+ m_searchScopeLabel = new QLabel(tr("Scope:"), searchGroupBox);
+ m_searchScopeLabel->setWordWrap(false);
+ gridLayout->addWidget(m_searchScopeLabel, 3, 0);
+
+ // ***********Range/scope selector combo box***********
+ m_rangeChooserCombo = new QComboBox(searchGroupBox);
+ QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ sizePolicy2.setHorizontalStretch(0);
+ sizePolicy2.setVerticalStretch(0);
+ sizePolicy2.setHeightForWidth(m_rangeChooserCombo->sizePolicy().hasHeightForWidth());
+ m_rangeChooserCombo->setSizePolicy(sizePolicy2);
+ m_rangeChooserCombo->setToolTip(tr("Choose the scope (books/chapters/verses to search in).<br />Applicable for Bibles and commentaries."));
+ gridLayout->addWidget(m_rangeChooserCombo, 3, 1);
+
+ // ************* Search text combo box *******************
+ m_searchTextCombo = new CHistoryComboBox(searchGroupBox);
+ sizePolicy2.setHeightForWidth(m_searchTextCombo->sizePolicy().hasHeightForWidth());
+ m_searchTextCombo->setSizePolicy(sizePolicy2);
+ m_searchTextCombo->setFocusPolicy(Qt::WheelFocus);
+ m_searchTextCombo->setProperty("sizeLimit", QVariant(25));
+ m_searchTextCombo->setProperty("duplicatesEnabled", QVariant(false));
+ m_searchTextCombo->setToolTip(tr("The text you want to search for"));
+ m_searchTextCombo->setInsertPolicy(QComboBox::NoInsert);
+ gridLayout->addWidget(m_searchTextCombo, 0, 1);
+
+ m_modulesLabel = new QLabel(tr("Works:"), searchGroupBox);
+ gridLayout->addWidget(m_modulesLabel, 2, 0);
+
+ m_modulesCombo = new QComboBox(searchGroupBox);
+ m_modulesCombo->setDuplicatesEnabled(false);
+ gridLayout->addWidget(m_modulesCombo, 2, 1);
+
+ hboxLayout->addWidget(searchGroupBox);
+
+ // Set the minimum size before the widgets are populated with data.
+ // Otherwise we will get problems with sizing.
+ setMinimumSize(minimumSizeHint());
+
+ refreshRanges();
+ //set the initial focus
+ m_searchTextCombo->setFocus();
+ // event filter to prevent the Return/Enter presses in the combo box doing something
+ // in the parent widget
+ m_searchTextCombo->installEventFilter(this);
}
-void BtSearchOptionsArea::initConnections()
-{
- QObject::connect( m_searchTextCombo->lineEdit(), SIGNAL(returnPressed ()),
- this, SLOT( slotSearchTextEditReturnPressed() )
- );
- connect(m_chooseModulesButton, SIGNAL(clicked()), this, SLOT(chooseModules()));
- connect(m_chooseRangeButton, SIGNAL(clicked()), this, SLOT(setupRanges()));
- connect(m_modulesCombo, SIGNAL(activated(int)), this, SLOT(moduleListTextSelected(int) ) );
- connect(m_helpLabel, SIGNAL(linkActivated(QString)), this, SLOT(syntaxHelp()));
- connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
+void BtSearchOptionsArea::initConnections() {
+ QObject::connect( m_searchTextCombo->lineEdit(), SIGNAL(returnPressed ()),
+ this, SLOT( slotSearchTextEditReturnPressed() )
+ );
+ connect(m_chooseModulesButton, SIGNAL(clicked()), this, SLOT(chooseModules()));
+ connect(m_chooseRangeButton, SIGNAL(clicked()), this, SLOT(setupRanges()));
+ connect(m_modulesCombo, SIGNAL(activated(int)), this, SLOT(moduleListTextSelected(int) ) );
+ connect(m_helpLabel, SIGNAL(linkActivated(QString)), this, SLOT(syntaxHelp()));
+ connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
}
/** Sets the modules used by the search. */
-void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules )
-{
- qDebug("BtSearchOptionsArea::setModules");
- qDebug() << modules;
- QString t;
-
- m_modules.clear(); //remove old modules
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
-
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- //ToDo: Check for containsRef compat
- if (*it == 0) { //don't operate on null modules.
- continue;
- }
- qDebug() << "new module:" << (*it)->name();
- if ( !m_modules.contains(*it) ) {
- m_modules.append( *it );
- t.append( (*it)->name() );
- if (*it != modules.last()) {
- t += QString::fromLatin1(", "); // so that it will become a readable list (WLC, LXX, GerLut...)
- }
- }
- };
- //m_modulesLabel->setText(t);
- int existingIndex = m_modulesCombo->findText(t);
- qDebug() << "index of the module list string which already exists in combobox:" << existingIndex;
- if (existingIndex >= 0) {
- m_modulesCombo->removeItem(existingIndex);
- }
- if (m_modulesCombo->count() > 10) {
- m_modulesCombo->removeItem(m_modulesCombo->count()-1);
- }
- m_modulesCombo->insertItem(0, t);
- m_modulesCombo->setItemData(0, t, Qt::ToolTipRole);
- m_modulesCombo->setCurrentIndex(0);
- m_modulesCombo->setToolTip(t);
- //Save the list in config here, not when deleting, because the history may be used
- // elsewhere while the dialog is still open
- QStringList historyList;
- for (int i = 0; i < m_modulesCombo->count(); ++i) {
- historyList.append(m_modulesCombo->itemText(i));
- }
- CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
- emit( sigSetSearchButtonStatus( (modules.count() != 0) ) );
+void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules ) {
+ qDebug("BtSearchOptionsArea::setModules");
+ qDebug() << modules;
+ QString t;
+
+ m_modules.clear(); //remove old modules
+ QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+
+ for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ //ToDo: Check for containsRef compat
+ if (*it == 0) { //don't operate on null modules.
+ continue;
+ }
+ qDebug() << "new module:" << (*it)->name();
+ if ( !m_modules.contains(*it) ) {
+ m_modules.append( *it );
+ t.append( (*it)->name() );
+ if (*it != modules.last()) {
+ t += QString::fromLatin1(", "); // so that it will become a readable list (WLC, LXX, GerLut...)
+ }
+ }
+ };
+ //m_modulesLabel->setText(t);
+ int existingIndex = m_modulesCombo->findText(t);
+ qDebug() << "index of the module list string which already exists in combobox:" << existingIndex;
+ if (existingIndex >= 0) {
+ m_modulesCombo->removeItem(existingIndex);
+ }
+ if (m_modulesCombo->count() > 10) {
+ m_modulesCombo->removeItem(m_modulesCombo->count() - 1);
+ }
+ m_modulesCombo->insertItem(0, t);
+ m_modulesCombo->setItemData(0, t, Qt::ToolTipRole);
+ m_modulesCombo->setCurrentIndex(0);
+ m_modulesCombo->setToolTip(t);
+ //Save the list in config here, not when deleting, because the history may be used
+ // elsewhere while the dialog is still open
+ QStringList historyList;
+ for (int i = 0; i < m_modulesCombo->count(); ++i) {
+ historyList.append(m_modulesCombo->itemText(i));
+ }
+ CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
+ emit( sigSetSearchButtonStatus( (modules.count() != 0) ) );
}
// Catch activated signal of module selector combobox
-void BtSearchOptionsArea::moduleListTextSelected(int index)
-{
- qDebug("BtSearchOptionsArea::moduleListTextSelected");
- //create the module list
- QString text = m_modulesCombo->itemText(index);
- qDebug() << text;
- QStringList moduleNamesList = text.split(", ");
- QList<CSwordModuleInfo*> moduleList;
- foreach(QString name, moduleNamesList) {
- moduleList.append(CPointers::backend()->findModuleByName(name));
- }
- //set the list and the combobox list and text
- setModules(moduleList);
+void BtSearchOptionsArea::moduleListTextSelected(int index) {
+ qDebug("BtSearchOptionsArea::moduleListTextSelected");
+ //create the module list
+ QString text = m_modulesCombo->itemText(index);
+ qDebug() << text;
+ QStringList moduleNamesList = text.split(", ");
+ QList<CSwordModuleInfo*> moduleList;
+ foreach(QString name, moduleNamesList) {
+ moduleList.append(CPointers::backend()->findModuleByName(name));
+ }
+ //set the list and the combobox list and text
+ setModules(moduleList);
}
void BtSearchOptionsArea::chooseModules() {
- QString title(tr("Works to Search in"));
- QString label(tr("Select the works which should be searched."));
- CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
- dlg->exec();
+ QString title(tr("Works to Search in"));
+ QString label(tr("Select the works which should be searched."));
+ CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
+ connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
+ dlg->exec();
}
QList<CSwordModuleInfo*> BtSearchOptionsArea::modules() const {
- return m_modules;
+ return m_modules;
}
void BtSearchOptionsArea::reset() {
- m_rangeChooserCombo->setCurrentIndex(0);
- m_searchTextCombo->clearEditText();
+ m_rangeChooserCombo->setCurrentIndex(0);
+ m_searchTextCombo->clearEditText();
}
void BtSearchOptionsArea::saveSettings() {
- CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
- SearchType t = FullType;
- if (m_typeAndButton->isChecked()) {
- t = AndType;
- }
- if (m_typeOrButton->isChecked()) {
- t = OrType;
- }
- CBTConfig::set(CBTConfig::searchType, t);
+ CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
+ SearchType t = FullType;
+ if (m_typeAndButton->isChecked()) {
+ t = AndType;
+ }
+ if (m_typeOrButton->isChecked()) {
+ t = OrType;
+ }
+ CBTConfig::set(CBTConfig::searchType, t);
}
void BtSearchOptionsArea::readSettings() {
- QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
- //for some reason the slot was called when setting the upmost item
- disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- for (int i=0; i<texts.size(); i++)
- {
- if (texts.at(i).size() > 0)
- m_searchTextCombo->addItem(texts.at(i));
- }
- connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
-
- m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
- for (int i = 0; i < m_modulesCombo->count(); ++i) {
- m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
- }
-
- int stype = CBTConfig::get(CBTConfig::searchType);
- switch (stype) {
- case AndType: m_typeAndButton->setChecked(true);
- break;
- case OrType: m_typeOrButton->setChecked(true);
- break;
- default: m_typeFreeButton->setChecked(true);
- }
+ QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
+ //for some reason the slot was called when setting the upmost item
+ disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
+ for (int i = 0; i < texts.size(); i++) {
+ if (texts.at(i).size() > 0)
+ m_searchTextCombo->addItem(texts.at(i));
+ }
+ connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
+
+ m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
+ for (int i = 0; i < m_modulesCombo->count(); ++i) {
+ m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
+ }
+
+ int stype = CBTConfig::get(CBTConfig::searchType);
+ switch (stype) {
+ case AndType:
+ m_typeAndButton->setChecked(true);
+ break;
+ case OrType:
+ m_typeOrButton->setChecked(true);
+ break;
+ default:
+ m_typeFreeButton->setChecked(true);
+ }
}
void BtSearchOptionsArea::aboutToShow() {
- m_searchTextCombo->setFocus();
+ m_searchTextCombo->setFocus();
}
void BtSearchOptionsArea::setupRanges() {
- CRangeChooserDialog* chooser = new CRangeChooserDialog(this);
- chooser->exec();
+ CRangeChooserDialog* chooser = new CRangeChooserDialog(this);
+ chooser->exec();
- refreshRanges();
+ refreshRanges();
}
void BtSearchOptionsArea::syntaxHelp() {
- QString style = QString(
- "<style type='text/css'>"
- "h1 a {font-size: medium}"
- "table {margin-left: 20px}"
- "td {"
- " border-width: 3px 3px 3px 3px;"
- " border-style: solid solid solid solid;"
- " border-color: white white white white;"
- " background-color: #faf0e6;"
- "}"
- "p#links {margin-left: 20px}"
- "</style>");
-
- //: Don't translate words inside <> tags!
- //: Translate 'All words' etc. indentically to the Search dialog options.
- QString intro = tr(
- "<p>"
- "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
- "</p>");
-
- QString links = tr(
- "<p id='links'>"
- "<A href='#allsome'>Which words to find</A><br />"
- "<A href='#grouping'>Grouping and order</A><br />"
- "<A href='#wildcards'>Wildcards (partial words)</A><br />"
- "<A href='#fields'>Text fields (different parts of text)</A><br/>"
- "<A href='#lucene'>Other syntax features</A><br/>"
- "</p>");
-
- //: Syntax words (AND, OR...) must not be translated.
- QString whichwords = tr(
- "<h1><A name='allsome'>Which words to find</A></h1>"
- "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
-
- //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
- QString whichwordstable = tr(
- "<p><table><tr>"
- "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
- "</tr><tr>"
- "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
- "</tr><tr>"
- "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr><tr>"
- "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr></table></p>");
-
- QString grouping = tr(
- "<h1><A name='grouping'>Grouping and order</A></h1>"
- "<p>Words can be grouped with <strong>parenthesis</strong>. "
- "Strict word order can be defined with <strong>quotes</strong>.</p>");
-
- QString groupingtable = tr(
- "<p><table><tr>"
- "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
- "</tr><tr>"
- "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
- "</tr><tr>"
- "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
- "</tr></table></p>");
-
- QString wildcards = tr(
- "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
- "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
-
- QString wildcardstable = tr(
- "<p><table><tr>"
- "<td>a*</td><td>All words beginning with 'a'</td>"
- "</tr><tr>"
- "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
- "</tr><tr>"
- "<td>a?</td><td>'at' and 'an'</td>"
- "</tr><tr>"
- "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
- "</tr></table></p>");
-
- QString fields = tr(
- "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
- "<p>Available text fields:<br /><table>"
- "<tr><td>heading:</td><td>Searches headings</td></tr>"
- "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
- "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
- "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
-
- QString fieldstable = tr(
- "<p>Examples:<br /><table>"
- "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
- "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
- "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
- "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
- "</tr></table></p>");
-
- QString lucene = tr(
- "<h1><A name='lucene'>Other syntax features</A></h1>"
- "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
-
- QString syntax = style + intro + links + whichwords + whichwordstable +
- grouping + groupingtable + wildcards + wildcardstable +
- fields + fieldstable + lucene;
-
- BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
- dlg->setHtml(syntax);
- dlg->show();
+ QString style = QString(
+ "<style type='text/css'>"
+ "h1 a {font-size: medium}"
+ "table {margin-left: 20px}"
+ "td {"
+ " border-width: 3px 3px 3px 3px;"
+ " border-style: solid solid solid solid;"
+ " border-color: white white white white;"
+ " background-color: #faf0e6;"
+ "}"
+ "p#links {margin-left: 20px}"
+ "</style>");
+
+ //: Don't translate words inside <> tags!
+ //: Translate 'All words' etc. indentically to the Search dialog options.
+ QString intro = tr(
+ "<p>"
+ "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
+ "</p>");
+
+ QString links = tr(
+ "<p id='links'>"
+ "<A href='#allsome'>Which words to find</A><br />"
+ "<A href='#grouping'>Grouping and order</A><br />"
+ "<A href='#wildcards'>Wildcards (partial words)</A><br />"
+ "<A href='#fields'>Text fields (different parts of text)</A><br/>"
+ "<A href='#lucene'>Other syntax features</A><br/>"
+ "</p>");
+
+ //: Syntax words (AND, OR...) must not be translated.
+ QString whichwords = tr(
+ "<h1><A name='allsome'>Which words to find</A></h1>"
+ "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
+
+ //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
+ QString whichwordstable = tr(
+ "<p><table><tr>"
+ "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
+ "</tr><tr>"
+ "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
+ "</tr><tr>"
+ "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
+ "</tr><tr>"
+ "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
+ "</tr></table></p>");
+
+ QString grouping = tr(
+ "<h1><A name='grouping'>Grouping and order</A></h1>"
+ "<p>Words can be grouped with <strong>parenthesis</strong>. "
+ "Strict word order can be defined with <strong>quotes</strong>.</p>");
+
+ QString groupingtable = tr(
+ "<p><table><tr>"
+ "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
+ "</tr><tr>"
+ "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
+ "</tr><tr>"
+ "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
+ "</tr></table></p>");
+
+ QString wildcards = tr(
+ "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
+ "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
+
+ QString wildcardstable = tr(
+ "<p><table><tr>"
+ "<td>a*</td><td>All words beginning with 'a'</td>"
+ "</tr><tr>"
+ "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
+ "</tr><tr>"
+ "<td>a?</td><td>'at' and 'an'</td>"
+ "</tr><tr>"
+ "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
+ "</tr></table></p>");
+
+ QString fields = tr(
+ "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
+ "<p>Available text fields:<br /><table>"
+ "<tr><td>heading:</td><td>Searches headings</td></tr>"
+ "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
+ "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
+ "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
+
+ QString fieldstable = tr(
+ "<p>Examples:<br /><table>"
+ "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
+ "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
+ "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
+ "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
+ "</tr></table></p>");
+
+ QString lucene = tr(
+ "<h1><A name='lucene'>Other syntax features</A></h1>"
+ "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
+
+ QString syntax = style + intro + links + whichwords + whichwordstable +
+ grouping + groupingtable + wildcards + wildcardstable +
+ fields + fieldstable + lucene;
+
+ BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
+ dlg->setHtml(syntax);
+ dlg->show();
}
void BtSearchOptionsArea::refreshRanges() {
- //the first option is fixed, the others can be edited using the "Setup ranges" button.
- m_rangeChooserCombo->clear();
- m_rangeChooserCombo->insertItem(0, QString("[") + tr("No search scope") + QString("]"));
- //TODO: what about this?
- //m_rangeChooserCombo->insertItem(tr("Last search result"));
+ //the first option is fixed, the others can be edited using the "Setup ranges" button.
+ m_rangeChooserCombo->clear();
+ m_rangeChooserCombo->insertItem(0, QString("[") + tr("No search scope") + QString("]"));
+ //TODO: what about this?
+ //m_rangeChooserCombo->insertItem(tr("Last search result"));
- //insert the user-defined ranges
- m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
+ //insert the user-defined ranges
+ m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
}
sword::ListKey BtSearchOptionsArea::searchScope() {
- if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
- QString scope = map[ m_rangeChooserCombo->currentText() ];
- if (!scope.isEmpty()) {
- return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
- }
- }
- return sword::ListKey();
+ if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
+ CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
+ QString scope = map[ m_rangeChooserCombo->currentText() ];
+ if (!scope.isEmpty()) {
+ return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
+ }
+ }
+ return sword::ListKey();
}
bool BtSearchOptionsArea::hasSearchScope() {
- return (searchScope().Count() > 0);
+ return (searchScope().Count() > 0);
}
-void BtSearchOptionsArea::addToHistory(const QString& text)
-{
- m_searchTextCombo->addToHistory(text);
+void BtSearchOptionsArea::addToHistory(const QString& text) {
+ m_searchTextCombo->addToHistory(text);
}
-void BtSearchOptionsArea::slotSearchTextEditReturnPressed()
-{
- qDebug("BtSearchOptionsArea::slotSearchTextEditReturnPressed");
- m_searchTextCombo->addToHistory( m_searchTextCombo->currentText() );
- emit sigStartSearch();
+void BtSearchOptionsArea::slotSearchTextEditReturnPressed() {
+ qDebug("BtSearchOptionsArea::slotSearchTextEditReturnPressed");
+ m_searchTextCombo->addToHistory( m_searchTextCombo->currentText() );
+ emit sigStartSearch();
}
-bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event)
-{
- if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
- //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
- if (obj == m_searchTextCombo->view() || obj == m_searchTextCombo || obj == m_searchTextCombo->lineEdit()) {
- //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
- obj->event(event);
- // don't handle this event in parent
- event->accept();
- return true;
- }
- }
- return QWidget::eventFilter(obj, event);
+bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event) {
+ if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
+ //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
+ if (obj == m_searchTextCombo->view() || obj == m_searchTextCombo || obj == m_searchTextCombo->lineEdit()) {
+ //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
+ obj->event(event);
+ // don't handle this event in parent
+ event->accept();
+ return true;
+ }
+ }
+ return QWidget::eventFilter(obj, event);
}
-void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/)
-{
+void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
// static const QRegExp re("\\b(AND|OR)\\b");
// qDebug() << "new text:" << newText;
// qDebug() << "contains:" << (newText.contains(re));
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index 30f6654..38bba54 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -31,117 +31,116 @@ class QEvent;
namespace Search {
-class BtSearchOptionsArea : public QWidget
-{
- Q_OBJECT
-public:
-
- enum SearchType {AndType, OrType, FullType};
-
- friend class CSearchDialog;
-
- BtSearchOptionsArea(QWidget *parent=0);
- ~BtSearchOptionsArea();
- /*
- * Add text to search combox box history
- */
- void addToHistory(const QString& text);
- /**
- * Sets the search text used in the page.
- */
- void setSearchText(const QString& text);
- /**
- * Returns the search text set in this page.
- */
- QString searchText() const;
-
- SearchType searchType();
-
- QPushButton* searchButton() const;
-
- /**
- * Returns the list of used modules.
- */
- QList<CSwordModuleInfo*> modules() const;
-
- /**
- * Sets all options back to the default.
- */
- void reset();
- /**
- * Returns the selected search scope if a search scope was selected.
- */
- sword::ListKey searchScope();
-
- bool hasSearchScope();
-
-
-protected:
- /**
- * Initializes this page.
- */
- void initView();
- void initConnections();
- /**
- * Reads the settings of the last searchdialog session.
- */
- void readSettings();
- /**
- * Reads the settings for the searchdialog from disk.
- */
- void saveSettings();
- bool eventFilter(QObject* obj, QEvent* event);
-public slots:
- /**
- * Sets the modules used by the search.
- */
- void setModules( QList<CSwordModuleInfo*> modules );
-
- /** Sets the modules when user selects them from the combobox.*/
- void moduleListTextSelected(int index);
-
- /**
- * Reimplementation.
- */
- void aboutToShow();
- /**
- * Refreshes the list of ranges and the range combobox.
- */
- void refreshRanges();
- /**
- * Opens the modules chooser dialog.
- */
- void chooseModules();
-
-protected slots:
- void setupRanges();
- void syntaxHelp();
- void slotSearchTextEditReturnPressed();
- void slotValidateText(const QString& newText);
-
-signals:
- void sigSetSearchButtonStatus(bool);
- void sigStartSearch();
-
-private:
- QList<CSwordModuleInfo*> m_modules;
-
- QHBoxLayout *hboxLayout;
- QGroupBox *searchGroupBox;
- QGridLayout *gridLayout;
- QLabel *m_searchTextLabel;
- QPushButton* m_searchButton;
- QLabel* m_helpLabel;
- QRadioButton* m_typeAndButton;
- QRadioButton* m_typeOrButton;
- QRadioButton* m_typeFreeButton;
- QPushButton *m_chooseModulesButton;
- QPushButton *m_chooseRangeButton;
- QLabel *m_searchScopeLabel;
- QComboBox *m_rangeChooserCombo;
- CHistoryComboBox *m_searchTextCombo;
- QLabel *m_modulesLabel;
- QComboBox* m_modulesCombo;
+class BtSearchOptionsArea : public QWidget {
+ Q_OBJECT
+ public:
+
+ enum SearchType {AndType, OrType, FullType};
+
+ friend class CSearchDialog;
+
+ BtSearchOptionsArea(QWidget *parent = 0);
+ ~BtSearchOptionsArea();
+ /*
+ * Add text to search combox box history
+ */
+ void addToHistory(const QString& text);
+ /**
+ * Sets the search text used in the page.
+ */
+ void setSearchText(const QString& text);
+ /**
+ * Returns the search text set in this page.
+ */
+ QString searchText() const;
+
+ SearchType searchType();
+
+ QPushButton* searchButton() const;
+
+ /**
+ * Returns the list of used modules.
+ */
+ QList<CSwordModuleInfo*> modules() const;
+
+ /**
+ * Sets all options back to the default.
+ */
+ void reset();
+ /**
+ * Returns the selected search scope if a search scope was selected.
+ */
+ sword::ListKey searchScope();
+
+ bool hasSearchScope();
+
+
+ protected:
+ /**
+ * Initializes this page.
+ */
+ void initView();
+ void initConnections();
+ /**
+ * Reads the settings of the last searchdialog session.
+ */
+ void readSettings();
+ /**
+ * Reads the settings for the searchdialog from disk.
+ */
+ void saveSettings();
+ bool eventFilter(QObject* obj, QEvent* event);
+ public slots:
+ /**
+ * Sets the modules used by the search.
+ */
+ void setModules( QList<CSwordModuleInfo*> modules );
+
+ /** Sets the modules when user selects them from the combobox.*/
+ void moduleListTextSelected(int index);
+
+ /**
+ * Reimplementation.
+ */
+ void aboutToShow();
+ /**
+ * Refreshes the list of ranges and the range combobox.
+ */
+ void refreshRanges();
+ /**
+ * Opens the modules chooser dialog.
+ */
+ void chooseModules();
+
+ protected slots:
+ void setupRanges();
+ void syntaxHelp();
+ void slotSearchTextEditReturnPressed();
+ void slotValidateText(const QString& newText);
+
+ signals:
+ void sigSetSearchButtonStatus(bool);
+ void sigStartSearch();
+
+ private:
+ QList<CSwordModuleInfo*> m_modules;
+
+ QHBoxLayout *hboxLayout;
+ QGroupBox *searchGroupBox;
+ QGridLayout *gridLayout;
+ QLabel *m_searchTextLabel;
+ QPushButton* m_searchButton;
+ QLabel* m_helpLabel;
+ QRadioButton* m_typeAndButton;
+ QRadioButton* m_typeOrButton;
+ QRadioButton* m_typeFreeButton;
+ QPushButton *m_chooseModulesButton;
+ QPushButton *m_chooseRangeButton;
+ QLabel *m_searchScopeLabel;
+ QComboBox *m_rangeChooserCombo;
+ CHistoryComboBox *m_searchTextCombo;
+ QLabel *m_modulesLabel;
+ QComboBox* m_modulesCombo;
};
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 585d5d3..04e0415 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -34,517 +34,506 @@
namespace Search {
BtSearchResultArea::BtSearchResultArea(QWidget *parent)
- : QWidget(parent)
-{
- qDebug("BtSearchResultArea::BtSearchResultArea");
- initView();
- initConnections();
- qDebug("BtSearchResultArea::BtSearchResultArea end");
+ : QWidget(parent) {
+ qDebug("BtSearchResultArea::BtSearchResultArea");
+ initView();
+ initConnections();
+ qDebug("BtSearchResultArea::BtSearchResultArea end");
}
-BtSearchResultArea::~BtSearchResultArea()
-{
- saveDialogSettings();
+BtSearchResultArea::~BtSearchResultArea() {
+ saveDialogSettings();
}
-void BtSearchResultArea::initView()
-{
- QVBoxLayout *mainLayout;
- QWidget *resultListsWidget;
- QVBoxLayout *resultListsWidgetLayout;
-
- //Size is calculated from the font rather than set in pixels,
- // maybe this is better in different kinds of displays?
- int mWidth = CToolClass::mWidth(this, 1);
- this->setMinimumSize(QSize(mWidth*40, mWidth*15));
- mainLayout = new QVBoxLayout(this);
- mainSplitter = new QSplitter(this);
- mainSplitter->setOrientation(Qt::Horizontal);
-
- resultListsWidget = new QWidget(mainSplitter);
-
- resultListsWidgetLayout = new QVBoxLayout(resultListsWidget);
- resultListsWidgetLayout->setContentsMargins(0, 0, 0, 0);
-
- //Splitter for two result lists
- resultListSplitter = new QSplitter(resultListsWidget);
- resultListSplitter->setOrientation(Qt::Vertical);
- m_moduleListBox = new CModuleResultView(resultListSplitter);
- resultListSplitter->addWidget(m_moduleListBox);
- m_resultListBox = new CSearchResultView(resultListSplitter);
- resultListSplitter->addWidget(m_resultListBox);
- resultListsWidgetLayout->addWidget(resultListSplitter);
-
- mainSplitter->addWidget(resultListsWidget);
-
- //Preview ("info") area
- m_displayFrame = new QFrame(mainSplitter);
- m_displayFrame->setFrameShape(QFrame::NoFrame);
- m_displayFrame->setFrameShadow(QFrame::Plain);
- mainSplitter->addWidget(m_displayFrame);
-
- mainLayout->addWidget(mainSplitter);
-
- QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
- frameLayout->setContentsMargins(0,0,0,0);
- m_previewDisplay = CDisplay::createReadInstance(0, m_displayFrame);
- m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
- frameLayout->addWidget(m_previewDisplay->view());
-
- loadDialogSettings();
+void BtSearchResultArea::initView() {
+ QVBoxLayout *mainLayout;
+ QWidget *resultListsWidget;
+ QVBoxLayout *resultListsWidgetLayout;
+
+ //Size is calculated from the font rather than set in pixels,
+ // maybe this is better in different kinds of displays?
+ int mWidth = CToolClass::mWidth(this, 1);
+ this->setMinimumSize(QSize(mWidth*40, mWidth*15));
+ mainLayout = new QVBoxLayout(this);
+ mainSplitter = new QSplitter(this);
+ mainSplitter->setOrientation(Qt::Horizontal);
+
+ resultListsWidget = new QWidget(mainSplitter);
+
+ resultListsWidgetLayout = new QVBoxLayout(resultListsWidget);
+ resultListsWidgetLayout->setContentsMargins(0, 0, 0, 0);
+
+ //Splitter for two result lists
+ resultListSplitter = new QSplitter(resultListsWidget);
+ resultListSplitter->setOrientation(Qt::Vertical);
+ m_moduleListBox = new CModuleResultView(resultListSplitter);
+ resultListSplitter->addWidget(m_moduleListBox);
+ m_resultListBox = new CSearchResultView(resultListSplitter);
+ resultListSplitter->addWidget(m_resultListBox);
+ resultListsWidgetLayout->addWidget(resultListSplitter);
+
+ mainSplitter->addWidget(resultListsWidget);
+
+ //Preview ("info") area
+ m_displayFrame = new QFrame(mainSplitter);
+ m_displayFrame->setFrameShape(QFrame::NoFrame);
+ m_displayFrame->setFrameShadow(QFrame::Plain);
+ mainSplitter->addWidget(m_displayFrame);
+
+ mainLayout->addWidget(mainSplitter);
+
+ QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
+ frameLayout->setContentsMargins(0, 0, 0, 0);
+ m_previewDisplay = CDisplay::createReadInstance(0, m_displayFrame);
+ m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
+ frameLayout->addWidget(m_previewDisplay->view());
+
+ loadDialogSettings();
}
-void BtSearchResultArea::setSearchResult(QList<CSwordModuleInfo*> modules)
-{
- const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
- reset(); //clear current modules
+void BtSearchResultArea::setSearchResult(QList<CSwordModuleInfo*> modules) {
+ const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
+ reset(); //clear current modules
- m_modules = modules;
- //pre-select the first module in the list
- //this will pre-select and display the first hit of that module
- m_moduleListBox->setupTree(modules, searchedText);
- m_moduleListBox->setCurrentItem(m_moduleListBox->topLevelItem(0), 0);
+ m_modules = modules;
+ //pre-select the first module in the list
+ //this will pre-select and display the first hit of that module
+ m_moduleListBox->setupTree(modules, searchedText);
+ m_moduleListBox->setCurrentItem(m_moduleListBox->topLevelItem(0), 0);
- qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
+ qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
}
-void BtSearchResultArea::reset()
-{
- m_moduleListBox->clear();
- m_resultListBox->clear();
- m_previewDisplay->setText("<html><head/><body></body></html>");
- qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(false);
- m_modules.clear();
+void BtSearchResultArea::reset() {
+ m_moduleListBox->clear();
+ m_resultListBox->clear();
+ m_previewDisplay->setText("<html><head/><body></body></html>");
+ qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(false);
+ m_modules.clear();
}
-void BtSearchResultArea::clearPreview(){
- m_previewDisplay->setText("<html><head/><body></body></html>");
+void BtSearchResultArea::clearPreview() {
+ m_previewDisplay->setText("<html><head/><body></body></html>");
}
-void BtSearchResultArea::updatePreview(const QString& key)
-{
- using namespace Rendering;
-
- CSwordModuleInfo* module = m_moduleListBox->activeModule();
- if ( module ) {
- const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
-
- QString text;
- CDisplayRendering render;
-
- QList<CSwordModuleInfo*> modules;
- modules.append(module);
-
- CTextRendering::KeyTreeItem::Settings settings;
-
- //for bibles render 5 context verses
- if (module->type() == CSwordModuleInfo::Bible) {
- CSwordVerseKey vk(module);
- vk.Headings(1);
- vk.key(key);
-
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
-
- //first go back and then go forward the keys to be in context
- vk.previous(CSwordVerseKey::UseVerse);
- vk.previous(CSwordVerseKey::UseVerse);
-
- //include Headings in display, they are indexed and searched too
- if (vk.Verse() == 1){
- if (vk.Chapter() == 1){
- vk.Chapter(0);
- }
- vk.Verse(0);
- }
-
- const QString startKey = vk.key();
-
- vk.key(key);
-
- vk.next(CSwordVerseKey::UseVerse);
- vk.next(CSwordVerseKey::UseVerse);
- const QString endKey = vk.key();
-
- settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::CompleteShort;
- text = render.renderKeyRange(startKey, endKey, modules, key, settings);
- }
- //for commentaries only one verse, but with heading
- else if (module->type() == CSwordModuleInfo::Commentary) {
- CSwordVerseKey vk(module);
- vk.Headings(1);
- vk.key(key);
-
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
-
- //include Headings in display, they are indexed and searched too
- if (vk.Verse() == 1){
- if (vk.Chapter() == 1){
- vk.Chapter(0);
- }
- vk.Verse(0);
- }
- const QString startKey = vk.key();
-
- vk.key(key);
- const QString endKey = vk.key();
-
- settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::NoKey;
- text = render.renderKeyRange(startKey, endKey, modules, key, settings);
- }
- else {
- text = render.renderSingleKey(key, modules, settings);
- }
-
- m_previewDisplay->setText( highlightSearchedText(text, searchedText) );
- m_previewDisplay->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key) );
- }
+void BtSearchResultArea::updatePreview(const QString& key) {
+ using namespace Rendering;
+
+ CSwordModuleInfo* module = m_moduleListBox->activeModule();
+ if ( module ) {
+ const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
+
+ QString text;
+ CDisplayRendering render;
+
+ QList<CSwordModuleInfo*> modules;
+ modules.append(module);
+
+ CTextRendering::KeyTreeItem::Settings settings;
+
+ //for bibles render 5 context verses
+ if (module->type() == CSwordModuleInfo::Bible) {
+ CSwordVerseKey vk(module);
+ vk.Headings(1);
+ vk.key(key);
+
+ ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+
+ //first go back and then go forward the keys to be in context
+ vk.previous(CSwordVerseKey::UseVerse);
+ vk.previous(CSwordVerseKey::UseVerse);
+
+ //include Headings in display, they are indexed and searched too
+ if (vk.Verse() == 1) {
+ if (vk.Chapter() == 1) {
+ vk.Chapter(0);
+ }
+ vk.Verse(0);
+ }
+
+ const QString startKey = vk.key();
+
+ vk.key(key);
+
+ vk.next(CSwordVerseKey::UseVerse);
+ vk.next(CSwordVerseKey::UseVerse);
+ const QString endKey = vk.key();
+
+ settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::CompleteShort;
+ text = render.renderKeyRange(startKey, endKey, modules, key, settings);
+ }
+ //for commentaries only one verse, but with heading
+ else if (module->type() == CSwordModuleInfo::Commentary) {
+ CSwordVerseKey vk(module);
+ vk.Headings(1);
+ vk.key(key);
+
+ ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+
+ //include Headings in display, they are indexed and searched too
+ if (vk.Verse() == 1) {
+ if (vk.Chapter() == 1) {
+ vk.Chapter(0);
+ }
+ vk.Verse(0);
+ }
+ const QString startKey = vk.key();
+
+ vk.key(key);
+ const QString endKey = vk.key();
+
+ settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::NoKey;
+ text = render.renderKeyRange(startKey, endKey, modules, key, settings);
+ }
+ else {
+ text = render.renderSingleKey(key, modules, settings);
+ }
+
+ m_previewDisplay->setText( highlightSearchedText(text, searchedText) );
+ m_previewDisplay->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key) );
+ }
}
QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
- QString token;
- QStringList tokenList;
- int cnt, pos;
-
- token = "";
- cnt = 0;
- while(cnt < queryString.length()) {
- // add to token
- if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
- token = token + queryString[cnt];
- cnt++;
- }
- // token break
- else if (queryString[cnt] == ' ') {
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- token = "";
- cnt++;
- }
- // clucene appears to ignore quoted strings in the sence
- // that it treats all the words within quoted strings as
- // regular tokens and not as a single token.
- else if (queryString[cnt] == '"') {
- cnt++;
- }
- // wild card - treat as a special token break
- //else if (queryString[cnt] == '*') {
- // token = token + queryString[cnt];
- // token = token.simplified();
- // if ((token != "*") && (token != ""))
- // tokenList.append(token);
- // // start next token with wildcard (kin*m -> kin* *m)
- // token = "*";
- // cnt++;
- //}
- // the ! token is also a token break
- else if (queryString[cnt] == '!') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("!");
- token = "";
- cnt++;
- }
- // the - token is also a token break
- else if (queryString[cnt] == '-') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("-");
- token = "";
- cnt++;
- }
- // the + token is also a token break
- else if (queryString[cnt] == '+') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the + token
- tokenList.append("+");
- token = "";
- cnt++;
- }
- // the || token is also a token break
- else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("||");
- token = "";
- cnt += 2;
- }
- // the && token is also a token break
- else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("&&");
- token = "";
- cnt += 2;
- }
- else cnt++;
- }
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
-
- cnt = 0;
- QStringList::iterator it;
- for ( it = tokenList.begin(); it != tokenList.end(); it++ ) {
- //-----------------------------------------------------------
- // remove all the NOT(!) tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- //-----------------------------------------------------------
- // remove all the operator tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
- ((*it) == "AND") || ((*it) == "&&") )
- {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- // if the token contains a ^ then trim the remainder of the
- // token from the ^
- //What??? error: invalid conversion from ‘const void*’ to ‘int’
- // and how come "contains" returns bool but is used as int?
- //else if ( (pos = (*it).contains("^")) >= 0 ) {
- else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
- (*it) = (*it).left(pos - 1);
- }
- // if the token contains a ~ then trim the remainder of the
- // token from the ~
- else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
- (*it) = (*it).left(pos - 2) + "*";
- }
- }
- return(tokenList);
+ QString token;
+ QStringList tokenList;
+ int cnt, pos;
+
+ token = "";
+ cnt = 0;
+ while (cnt < queryString.length()) {
+ // add to token
+ if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
+ token = token + queryString[cnt];
+ cnt++;
+ }
+ // token break
+ else if (queryString[cnt] == ' ') {
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ token = "";
+ cnt++;
+ }
+ // clucene appears to ignore quoted strings in the sence
+ // that it treats all the words within quoted strings as
+ // regular tokens and not as a single token.
+ else if (queryString[cnt] == '"') {
+ cnt++;
+ }
+ // wild card - treat as a special token break
+ //else if (queryString[cnt] == '*') {
+ // token = token + queryString[cnt];
+ // token = token.simplified();
+ // if ((token != "*") && (token != ""))
+ // tokenList.append(token);
+ // // start next token with wildcard (kin*m -> kin* *m)
+ // token = "*";
+ // cnt++;
+ //}
+ // the ! token is also a token break
+ else if (queryString[cnt] == '!') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the ! token
+ tokenList.append("!");
+ token = "";
+ cnt++;
+ }
+ // the - token is also a token break
+ else if (queryString[cnt] == '-') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the ! token
+ tokenList.append("-");
+ token = "";
+ cnt++;
+ }
+ // the + token is also a token break
+ else if (queryString[cnt] == '+') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the + token
+ tokenList.append("+");
+ token = "";
+ cnt++;
+ }
+ // the || token is also a token break
+ else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the || token
+ tokenList.append("||");
+ token = "";
+ cnt += 2;
+ }
+ // the && token is also a token break
+ else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the || token
+ tokenList.append("&&");
+ token = "";
+ cnt += 2;
+ }
+ else cnt++;
+ }
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+
+ cnt = 0;
+ QStringList::iterator it;
+ for ( it = tokenList.begin(); it != tokenList.end(); it++ ) {
+ //-----------------------------------------------------------
+ // remove all the NOT(!) tokens - these do not need to be
+ // highlighted in the highlighter
+ //-----------------------------------------------------------
+ if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ it--;
+ }
+ //-----------------------------------------------------------
+ // remove all the operator tokens - these do not need to be
+ // highlighted in the highlighter
+ //-----------------------------------------------------------
+ else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
+ ((*it) == "AND") || ((*it) == "&&") ) {
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ it--;
+ }
+ // if the token contains a ^ then trim the remainder of the
+ // token from the ^
+ //What??? error: invalid conversion from ‘const void*’ to ‘int’
+ // and how come "contains" returns bool but is used as int?
+ //else if ( (pos = (*it).contains("^")) >= 0 ) {
+ else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
+ (*it) = (*it).left(pos - 1);
+ }
+ // if the token contains a ~ then trim the remainder of the
+ // token from the ~
+ else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
+ (*it) = (*it).left(pos - 2) + "*";
+ }
+ }
+ return(tokenList);
}
QString BtSearchResultArea::highlightSearchedText(const QString& content, const QString& searchedText) {
- QString ret = content;
-
- const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-
- // int index = 0;
- int index = ret.indexOf("<body", 0);
- int matchLen = 0;
- int length = searchedText.length();
-
- // Highlighting constants -
- // TODO: We need to make the highlight color configurable.
- const QString rep1("<span style=\"background-color:#FFFF66;\">");
- const QString rep2("</span>");
- const unsigned int repLength = rep1.length() + rep1.length();
- const QString rep3("style=\"background-color:#FFFF66;\" ");
- const unsigned int rep3Length = rep3.length();
-
-
- QString newSearchText;
-
- newSearchText = searchedText;
-
- // find the strongs search lemma and highlight it
- // search the searched text for "strong:" until it is not found anymore
- QStringList list;
-
- // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
- // TODO: find all possible seperators
- QString regExp = "\\s";
- list = searchedText.split(QRegExp(regExp));
- foreach (QString newSearchText, list) {
- int sstIndex; // strong search text index for finding "strong:"
- int idx1, idx2;
- QString sNumber, lemmaText;
-
- sstIndex = newSearchText.indexOf("strong:");
- if (sstIndex == -1)
- continue;
-
- // set the start index to the start of <body>
- int strongIndex = index;
-
- // Get the strongs number from the search text.
- // First, find the first space after "strong:"
- sstIndex = sstIndex + 7;
- // get the strongs number -> the text following "strong:" to the end of the string.
- sNumber = newSearchText.mid(sstIndex, -1);
- // find all the "lemma=" inside the the content
- while((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
- // get the strongs number after the lemma and compare it with the
- // strongs number we are looking for
- idx1 = ret.indexOf("\"", strongIndex) + 1;
- idx2 = ret.indexOf("\"", idx1 + 1);
- lemmaText = ret.mid(idx1, idx2 - idx1);
-
- // this is interesting because we could have a strongs number like: G3218|G300
- // To handle this we will use some extra cpu cycles and do a partial match against
- // the lemmaText
- if (lemmaText.contains(sNumber)) {
- // strongs number is found now we need to highlight it
- // I believe the easiest way is to insert rep3 just before "lemma="
- ret = ret.insert(strongIndex, rep3);
- strongIndex += rep3Length;
- }
- strongIndex += 6; // 6 is the length of "lemma="
- }
- }
- //---------------------------------------------------------------------
- // now that the strong: stuff is out of the way continue with
- // other search options
- //---------------------------------------------------------------------
-
- // try to figure out how to use the lucene query parser
-
- //using namespace lucene::queryParser;
- //using namespace lucene::search;
- //using namespace lucene::analysis;
- //using namespace lucene::util;
-
- //wchar_t *buf;
- //char buf8[1000];
- //standard::WhitespaceAnalyzer analyzer;
- //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //boost::scoped_ptr<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
- //StringReader reader(m_wcharBuffer);
- //TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
- //Token token;
- //while(tokenStream->next(&token) != 0) {
- // lucene_wcstoutf8(buf8, token.termText(), 1000);
- // printf("%s\n", buf8);
- //}
-
- //===========================================================
- // since I could not figure out the lucene query parser, I
- // made a simple parser.
- //===========================================================
- QStringList words = QueryParser(newSearchText);
- foreach (QString word, words) { //search for every word in the list
- QRegExp findExp;
- if (word.contains("*")) {
- length = word.length() - 1;
- word.replace('*', "\\S*"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(TRUE);
- }
- else {
- length = word.length();
- findExp = QRegExp("\\b" + word + "\\b");
- }
-
- // index = 0; //for every word start at the beginning
- index = ret.indexOf("<body", 0);
- findExp.setCaseSensitivity(cs);
- //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
- while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
- matchLen = findExp.matchedLength();
- if (!CToolClass::inHTMLTag(index, ret)) {
- length = matchLen;
- ret = ret.insert( index+length, rep2 );
- ret = ret.insert( index, rep1 );
- index += repLength;
- }
- index += length;
- }
- }
- //qWarning("\n\n\n%s", ret.latin1());
- return ret;
+ QString ret = content;
+
+ const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
+
+ // int index = 0;
+ int index = ret.indexOf("<body", 0);
+ int matchLen = 0;
+ int length = searchedText.length();
+
+ // Highlighting constants -
+ // TODO: We need to make the highlight color configurable.
+ const QString rep1("<span style=\"background-color:#FFFF66;\">");
+ const QString rep2("</span>");
+ const unsigned int repLength = rep1.length() + rep1.length();
+ const QString rep3("style=\"background-color:#FFFF66;\" ");
+ const unsigned int rep3Length = rep3.length();
+
+
+ QString newSearchText;
+
+ newSearchText = searchedText;
+
+ // find the strongs search lemma and highlight it
+ // search the searched text for "strong:" until it is not found anymore
+ QStringList list;
+
+ // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
+ // TODO: find all possible seperators
+ QString regExp = "\\s";
+ list = searchedText.split(QRegExp(regExp));
+ foreach (QString newSearchText, list) {
+ int sstIndex; // strong search text index for finding "strong:"
+ int idx1, idx2;
+ QString sNumber, lemmaText;
+
+ sstIndex = newSearchText.indexOf("strong:");
+ if (sstIndex == -1)
+ continue;
+
+ // set the start index to the start of <body>
+ int strongIndex = index;
+
+ // Get the strongs number from the search text.
+ // First, find the first space after "strong:"
+ sstIndex = sstIndex + 7;
+ // get the strongs number -> the text following "strong:" to the end of the string.
+ sNumber = newSearchText.mid(sstIndex, -1);
+ // find all the "lemma=" inside the the content
+ while ((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
+ // get the strongs number after the lemma and compare it with the
+ // strongs number we are looking for
+ idx1 = ret.indexOf("\"", strongIndex) + 1;
+ idx2 = ret.indexOf("\"", idx1 + 1);
+ lemmaText = ret.mid(idx1, idx2 - idx1);
+
+ // this is interesting because we could have a strongs number like: G3218|G300
+ // To handle this we will use some extra cpu cycles and do a partial match against
+ // the lemmaText
+ if (lemmaText.contains(sNumber)) {
+ // strongs number is found now we need to highlight it
+ // I believe the easiest way is to insert rep3 just before "lemma="
+ ret = ret.insert(strongIndex, rep3);
+ strongIndex += rep3Length;
+ }
+ strongIndex += 6; // 6 is the length of "lemma="
+ }
+ }
+ //---------------------------------------------------------------------
+ // now that the strong: stuff is out of the way continue with
+ // other search options
+ //---------------------------------------------------------------------
+
+ // try to figure out how to use the lucene query parser
+
+ //using namespace lucene::queryParser;
+ //using namespace lucene::search;
+ //using namespace lucene::analysis;
+ //using namespace lucene::util;
+
+ //wchar_t *buf;
+ //char buf8[1000];
+ //standard::WhitespaceAnalyzer analyzer;
+ //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
+ //boost::scoped_ptr<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
+ //StringReader reader(m_wcharBuffer);
+ //TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
+ //Token token;
+ //while(tokenStream->next(&token) != 0) {
+ // lucene_wcstoutf8(buf8, token.termText(), 1000);
+ // printf("%s\n", buf8);
+ //}
+
+ //===========================================================
+ // since I could not figure out the lucene query parser, I
+ // made a simple parser.
+ //===========================================================
+ QStringList words = QueryParser(newSearchText);
+ foreach (QString word, words) { //search for every word in the list
+ QRegExp findExp;
+ if (word.contains("*")) {
+ length = word.length() - 1;
+ word.replace('*', "\\S*"); //match within a word
+ findExp = QRegExp(word);
+ findExp.setMinimal(TRUE);
+ }
+ else {
+ length = word.length();
+ findExp = QRegExp("\\b" + word + "\\b");
+ }
+
+ // index = 0; //for every word start at the beginning
+ index = ret.indexOf("<body", 0);
+ findExp.setCaseSensitivity(cs);
+ //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
+ while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
+ matchLen = findExp.matchedLength();
+ if (!CToolClass::inHTMLTag(index, ret)) {
+ length = matchLen;
+ ret = ret.insert( index + length, rep2 );
+ ret = ret.insert( index, rep1 );
+ index += repLength;
+ }
+ index += length;
+ }
+ }
+ //qWarning("\n\n\n%s", ret.latin1());
+ return ret;
}
/** Initializes the signal slot conections of the child widgets, */
-void BtSearchResultArea::initConnections()
-{
- connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
- connect(m_resultListBox, SIGNAL(keyDeselected()), this, SLOT(clearPreview()));
- connect(m_moduleListBox, SIGNAL(moduleSelected(CSwordModuleInfo*)), m_resultListBox, SLOT(setupTree(CSwordModuleInfo*)));
- connect(m_moduleListBox, SIGNAL(moduleChanged()), m_previewDisplay->connectionsProxy(), SLOT(clear()));
-
- // connect the strongs list
- connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, QStringList*)),
- m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, QStringList*)));
+void BtSearchResultArea::initConnections() {
+ connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
+ connect(m_resultListBox, SIGNAL(keyDeselected()), this, SLOT(clearPreview()));
+ connect(m_moduleListBox, SIGNAL(moduleSelected(CSwordModuleInfo*)), m_resultListBox, SLOT(setupTree(CSwordModuleInfo*)));
+ connect(m_moduleListBox, SIGNAL(moduleChanged()), m_previewDisplay->connectionsProxy(), SLOT(clear()));
+
+ // connect the strongs list
+ connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, QStringList*)),
+ m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, QStringList*)));
}
/** Shows a dialog with the search analysis of the current search. */
void BtSearchResultArea::showAnalysis() {
- CSearchAnalysisDialog dlg(m_modules, this);
- dlg.exec();
+ CSearchAnalysisDialog dlg(m_modules, this);
+ dlg.exec();
}
/**
* Load the settings from the resource file
*/
-void BtSearchResultArea::loadDialogSettings()
-{
- QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
- if (mainSplitterSizes.count() > 0) {
- mainSplitter->setSizes(mainSplitterSizes);
- } else {
- int w = this->size().width();
- int w2 = m_moduleListBox->sizeHint().width();
- mainSplitterSizes << w2 << w - w2;
- mainSplitter->setSizes(mainSplitterSizes);
- }
- QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) resultListSplitter->setSizes(resultSplitterSizes);
+void BtSearchResultArea::loadDialogSettings() {
+ QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
+ if (mainSplitterSizes.count() > 0) {
+ mainSplitter->setSizes(mainSplitterSizes);
+ }
+ else {
+ int w = this->size().width();
+ int w2 = m_moduleListBox->sizeHint().width();
+ mainSplitterSizes << w2 << w - w2;
+ mainSplitter->setSizes(mainSplitterSizes);
+ }
+ QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
+ if (resultSplitterSizes.count() > 0) resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
-void BtSearchResultArea::saveDialogSettings()
-{
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, resultListSplitter->sizes());
+void BtSearchResultArea::saveDialogSettings() {
+ CBTConfig::set(CBTConfig::searchMainSplitterSizes, mainSplitter->sizes());
+ CBTConfig::set(CBTConfig::searchResultSplitterSizes, resultListSplitter->sizes());
}
-StrongsResult::StrongsResult()
-{
+StrongsResult::StrongsResult() {
}
StrongsResult::StrongsResult(const QString& text, const QString &keyName)
- : text(text)
-{
- //keyNameList.clear();
- keyNameList.append(keyName);
+ : text(text) {
+ //keyNameList.clear();
+ keyNameList.append(keyName);
}
QString StrongsResult::keyText() const {
- return text;
+ return text;
}
int StrongsResult::keyCount() const {
- return keyNameList.count();
+ return keyNameList.count();
}
void StrongsResult::addKeyName(const QString& keyName) {
- if (keyNameList.indexOf(keyName) == -1)
- keyNameList.append(keyName);
+ if (keyNameList.indexOf(keyName) == -1)
+ keyNameList.append(keyName);
}
QStringList* StrongsResult::getKeyList() {
- return & keyNameList;
+ return & keyNameList;
}
@@ -552,106 +541,102 @@ QStringList* StrongsResult::getKeyList() {
/********************************************
************ StrongsResultClass *************
********************************************/
-void StrongsResultClass::initStrongsResults(void)
-{
- using namespace Rendering;
-
- CDisplayRendering render;
- QList<CSwordModuleInfo*> modules;
- CTextRendering::KeyTreeItem::Settings settings;
- QString rText, lText, key;
- bool found;
- int sIndex;
- int count;
- int index;
- QString text;
-
- modules.append(srModule);
- sword::ListKey& result = srModule->searchResult();
-
- count = result.Count();
- if (!count)
- return;
- qApp->processEvents( QEventLoop::AllEvents, 1 ); //1 ms only
- srList.clear();
- // for whatever reason the text "Parsing...translations." does not appear.
- // this is not critical but the text is necessary to get the dialog box
- // to be wide enough.
- QProgressDialog* progress = new QProgressDialog(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
- //0, "progressDialog", tr("Parsing Strong's Numbers"), tr("Parsing Strong's numbers for translations."), true);
-
- //progress->setAllowCancel(false);
- //progress->setMinimumDuration(0);
- progress->show();
- progress->raise();
- for (index = 0; index < count; index++){
- progress->setValue( index );
- qApp->processEvents(QEventLoop::AllEvents, 1 ); //1 ms only
-
- key = QString::fromUtf8(result.GetElement(index)->getText());
- text = render.renderSingleKey(key, modules, settings);
- sIndex = 0;
- while ((rText = getStrongsNumberText(text, &sIndex)) != "")
- {
- StrongsResultList::iterator it;
- found = FALSE;
- for ( it = srList.begin(); it != srList.end(); ++it )
- {
- lText = (*it).keyText();
- if (lText == rText)
- {
- found = TRUE;
- (*it).addKeyName(key);
- break;
- }
- }
- if (found == FALSE)
- srList.append( StrongsResult(rText, key) );
- }
- }
- delete progress;
- progress = 0;
- //qHeapSort(srList);
+void StrongsResultClass::initStrongsResults(void) {
+ using namespace Rendering;
+
+ CDisplayRendering render;
+ QList<CSwordModuleInfo*> modules;
+ CTextRendering::KeyTreeItem::Settings settings;
+ QString rText, lText, key;
+ bool found;
+ int sIndex;
+ int count;
+ int index;
+ QString text;
+
+ modules.append(srModule);
+ sword::ListKey& result = srModule->searchResult();
+
+ count = result.Count();
+ if (!count)
+ return;
+ qApp->processEvents( QEventLoop::AllEvents, 1 ); //1 ms only
+ srList.clear();
+ // for whatever reason the text "Parsing...translations." does not appear.
+ // this is not critical but the text is necessary to get the dialog box
+ // to be wide enough.
+ QProgressDialog* progress = new QProgressDialog(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
+ //0, "progressDialog", tr("Parsing Strong's Numbers"), tr("Parsing Strong's numbers for translations."), true);
+
+ //progress->setAllowCancel(false);
+ //progress->setMinimumDuration(0);
+ progress->show();
+ progress->raise();
+ for (index = 0; index < count; index++) {
+ progress->setValue( index );
+ qApp->processEvents(QEventLoop::AllEvents, 1 ); //1 ms only
+
+ key = QString::fromUtf8(result.GetElement(index)->getText());
+ text = render.renderSingleKey(key, modules, settings);
+ sIndex = 0;
+ while ((rText = getStrongsNumberText(text, &sIndex)) != "") {
+ StrongsResultList::iterator it;
+ found = FALSE;
+ for ( it = srList.begin(); it != srList.end(); ++it ) {
+ lText = (*it).keyText();
+ if (lText == rText) {
+ found = TRUE;
+ (*it).addKeyName(key);
+ break;
+ }
+ }
+ if (found == FALSE)
+ srList.append( StrongsResult(rText, key) );
+ }
+ }
+ delete progress;
+ progress = 0;
+ //qHeapSort(srList);
}
QString StrongsResultClass::getStrongsNumberText(const QString& verseContent, int *startIndex) {
- // get the strongs text
- int idx1, idx2, index;
- QString sNumber, strongsText;
- //const bool cs = CSwordModuleSearch::caseSensitive;
- const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-
- if (*startIndex == 0) {
- index = verseContent.indexOf("<body");
- }
- else {
- index = *startIndex;
- }
-
- // find all the "lemma=" inside the the content
- while((index = verseContent.indexOf("lemma=", index, cs)) != -1) {
- // get the strongs number after the lemma and compare it with the
- // strongs number we are looking for
- idx1 = verseContent.indexOf("\"", index) + 1;
- idx2 = verseContent.indexOf("\"", idx1 + 1);
- sNumber = verseContent.mid(idx1, idx2 - idx1);
- if (sNumber == lemmaText) {
- // strongs number is found now we need to get the text of this node
- // search right until the ">" is found. Get the text from here to
- // the next "<".
- index = verseContent.indexOf(">", index, cs) + 1;
- idx2 = verseContent.indexOf("<", index, cs);
- strongsText = verseContent.mid(index, idx2 - index);
- index = idx2;
- *startIndex = index;
-
- return(strongsText);
- }
- else {
- index += 6; // 6 is the length of "lemma="
- }
- }
- return QString::null;
+ // get the strongs text
+ int idx1, idx2, index;
+ QString sNumber, strongsText;
+ //const bool cs = CSwordModuleSearch::caseSensitive;
+ const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
+
+ if (*startIndex == 0) {
+ index = verseContent.indexOf("<body");
+ }
+ else {
+ index = *startIndex;
+ }
+
+ // find all the "lemma=" inside the the content
+ while ((index = verseContent.indexOf("lemma=", index, cs)) != -1) {
+ // get the strongs number after the lemma and compare it with the
+ // strongs number we are looking for
+ idx1 = verseContent.indexOf("\"", index) + 1;
+ idx2 = verseContent.indexOf("\"", idx1 + 1);
+ sNumber = verseContent.mid(idx1, idx2 - idx1);
+ if (sNumber == lemmaText) {
+ // strongs number is found now we need to get the text of this node
+ // search right until the ">" is found. Get the text from here to
+ // the next "<".
+ index = verseContent.indexOf(">", index, cs) + 1;
+ idx2 = verseContent.indexOf("<", index, cs);
+ strongsText = verseContent.mid(index, idx2 - index);
+ index = idx2;
+ *startIndex = index;
+
+ return(strongsText);
+ }
+ else {
+ index += 6; // 6 is the length of "lemma="
+ }
+ }
+ return QString::null;
}
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index 82eb2d4..cc87126 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -23,8 +23,8 @@
class CReadDisplay;
class CSwordModuleInfo;
namespace Search {
- class CModuleResultView;
- class CSearchResultView;
+class CModuleResultView;
+class CSearchResultView;
}
class QHBoxLayout;
@@ -47,28 +47,28 @@ namespace Search {
* To add a new verse to a strongs text result use addKeyName.
*/
class StrongsResult {
-public:
- StrongsResult();
- StrongsResult(const QString& text, const QString &keyName);
-
- QString keyText() const;
- int keyCount() const;
- void addKeyName(const QString& keyName);
- QStringList* getKeyList();
-
- /* ????
- bool operator==(const StrongsResult &l, const StrongsResult &r)
- { return (l.keyText() == r.keyText()); }
-
- bool operator<(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() < r->keyText()); }
-
- bool operator>(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() > r->keyText()); }
- */
-private:
- QString text;
- QStringList keyNameList;
+ public:
+ StrongsResult();
+ StrongsResult(const QString& text, const QString &keyName);
+
+ QString keyText() const;
+ int keyCount() const;
+ void addKeyName(const QString& keyName);
+ QStringList* getKeyList();
+
+ /* ????
+ bool operator==(const StrongsResult &l, const StrongsResult &r)
+ { return (l.keyText() == r.keyText()); }
+
+ bool operator<(const StrongsResult &l, const StrongsResult &r)
+ { return (l->keyText() < r->keyText()); }
+
+ bool operator>(const StrongsResult &l, const StrongsResult &r)
+ { return (l->keyText() > r->keyText()); }
+ */
+ private:
+ QString text;
+ QStringList keyNameList;
};
typedef QList<StrongsResult> StrongsResultList;
@@ -88,112 +88,114 @@ typedef QList<StrongsResult> StrongsResultList;
* To add a new verse to a strongs text result use addKeyName.
*/
class StrongsResultClass {
-public:
- StrongsResultClass(CSwordModuleInfo* module, const QString& strongsNumber)
- : srModule(module), lemmaText(strongsNumber)
- {
- initStrongsResults();
- }
-
- QString keyText(int index) const {
- return srList[index].keyText();
- }
- int keyCount(int index) const {
- return srList[index].keyCount();
- }
- QStringList* getKeyList(int index) {
- return srList[index].getKeyList();
- }
- int Count() const {
- return srList.count();
- }
-
-private:
- void initStrongsResults(void);
- QString getStrongsNumberText(const QString& verseContent, int *startIndex);
-
- StrongsResultList srList;
- CSwordModuleInfo* srModule;
- QString lemmaText;
+ public:
+ StrongsResultClass(CSwordModuleInfo* module, const QString& strongsNumber)
+ : srModule(module), lemmaText(strongsNumber) {
+ initStrongsResults();
+ }
+
+ QString keyText(int index) const {
+ return srList[index].keyText();
+ }
+ int keyCount(int index) const {
+ return srList[index].keyCount();
+ }
+ QStringList* getKeyList(int index) {
+ return srList[index].getKeyList();
+ }
+ int Count() const {
+ return srList.count();
+ }
+
+ private:
+ void initStrongsResults(void);
+ QString getStrongsNumberText(const QString& verseContent, int *startIndex);
+
+ StrongsResultList srList;
+ CSwordModuleInfo* srModule;
+ QString lemmaText;
};
/** The page of the search dialog which contains the search result part.
* @author The BibleTime team
*/
-class BtSearchResultArea : public QWidget
-{
- Q_OBJECT
-public:
- BtSearchResultArea(QWidget *parent=0);
- ~BtSearchResultArea();
- /**
- * Sets the modules which contain the result of each.
- */
- void setSearchResult(QList<CSwordModuleInfo*> modules);
-
- QSize sizeHint() const { return baseSize(); }
- QSize minimumSizeHint() const { return minimumSize(); }
-
-public slots:
- /**
- * Resets the current list of modules and the displayed list of found entries.
- */
- void reset();
-
-protected:
- /**
- * Initializes the view of this widget.
- */
- void initView();
- /**
- * Initializes the signal slot conections of the child widgets
- */
- void initConnections();
- /**
- * This function breakes the queryString into clucene tokens
- */
- QStringList QueryParser(const QString& queryString);
- /**
- * This function highlights the searched text in the content using the search type given by search flags
- */
- QString highlightSearchedText(const QString& content, const QString& searchedText);
-
- /**
- * Load the settings from the resource file
- */
- void loadDialogSettings();
- /**
- * Save the settings to the resource file
- */
- void saveDialogSettings();
-
-protected slots:
- /**
- * Update the preview of the selected key.
- */
- void updatePreview(const QString& key);
- /**
- * Clear the preview of the selected key.
- */
- void clearPreview();
- /**
- * Shows a dialog with the search analysis of the current search.
- */
- void showAnalysis();
-
-private:
-
- CModuleResultView* m_moduleListBox;
- CSearchResultView* m_resultListBox;
-
- QFrame *m_displayFrame;
- CReadDisplay* m_previewDisplay;
-
- QList<CSwordModuleInfo*> m_modules;
-
- QSplitter *mainSplitter;
- QSplitter *resultListSplitter;
+class BtSearchResultArea : public QWidget {
+ Q_OBJECT
+ public:
+ BtSearchResultArea(QWidget *parent = 0);
+ ~BtSearchResultArea();
+ /**
+ * Sets the modules which contain the result of each.
+ */
+ void setSearchResult(QList<CSwordModuleInfo*> modules);
+
+ QSize sizeHint() const {
+ return baseSize();
+ }
+ QSize minimumSizeHint() const {
+ return minimumSize();
+ }
+
+ public slots:
+ /**
+ * Resets the current list of modules and the displayed list of found entries.
+ */
+ void reset();
+
+ protected:
+ /**
+ * Initializes the view of this widget.
+ */
+ void initView();
+ /**
+ * Initializes the signal slot conections of the child widgets
+ */
+ void initConnections();
+ /**
+ * This function breakes the queryString into clucene tokens
+ */
+ QStringList QueryParser(const QString& queryString);
+ /**
+ * This function highlights the searched text in the content using the search type given by search flags
+ */
+ QString highlightSearchedText(const QString& content, const QString& searchedText);
+
+ /**
+ * Load the settings from the resource file
+ */
+ void loadDialogSettings();
+ /**
+ * Save the settings to the resource file
+ */
+ void saveDialogSettings();
+
+ protected slots:
+ /**
+ * Update the preview of the selected key.
+ */
+ void updatePreview(const QString& key);
+ /**
+ * Clear the preview of the selected key.
+ */
+ void clearPreview();
+ /**
+ * Shows a dialog with the search analysis of the current search.
+ */
+ void showAnalysis();
+
+ private:
+
+ CModuleResultView* m_moduleListBox;
+ CSearchResultView* m_resultListBox;
+
+ QFrame *m_displayFrame;
+ CReadDisplay* m_previewDisplay;
+
+ QList<CSwordModuleInfo*> m_modules;
+
+ QSplitter *mainSplitter;
+ QSplitter *resultListSplitter;
};
} //namespace Search
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index 953d9f3..ea854dc 100644
--- a/src/frontend/searchdialog/chistorycombobox.cpp
+++ b/src/frontend/searchdialog/chistorycombobox.cpp
@@ -14,35 +14,30 @@
namespace Search {
CHistoryComboBox::CHistoryComboBox( QWidget* parent)
- : QComboBox(parent)
-{
- setEditable(true);
- completer()->setCompletionMode(QCompleter::PopupCompletion);
+ : QComboBox(parent) {
+ setEditable(true);
+ completer()->setCompletionMode(QCompleter::PopupCompletion);
}
-CHistoryComboBox::~CHistoryComboBox()
-{
+CHistoryComboBox::~CHistoryComboBox() {
}
-void CHistoryComboBox::addToHistory(const QString& text)
-{
- int index = findText(text);
- if ( index >= 0)
- removeItem(index);
- insertItem(1, text);
- setCurrentIndex(1);
+void CHistoryComboBox::addToHistory(const QString& text) {
+ int index = findText(text);
+ if ( index >= 0)
+ removeItem(index);
+ insertItem(1, text);
+ setCurrentIndex(1);
}
-QStringList CHistoryComboBox::historyItems() const
-{
- QStringList items;
- for (int i=0; i<count(); i++)
- {
- QString text = itemText(i);
- if (text.size() > 0)
- items << text;
- }
- return items;
+QStringList CHistoryComboBox::historyItems() const {
+ QStringList items;
+ for (int i = 0; i < count(); i++) {
+ QString text = itemText(i);
+ if (text.size() > 0)
+ items << text;
+ }
+ return items;
}
} //end of namespace Search
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index 967c045..d2828d8 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -14,18 +14,17 @@
namespace Search {
-class CHistoryComboBox : public QComboBox
-{
- Q_OBJECT
-public:
- CHistoryComboBox(QWidget* parent = 0);
- ~CHistoryComboBox();
- void addToHistory(const QString& item);
- QStringList historyItems() const;
-
-protected:
-
-private:
+class CHistoryComboBox : public QComboBox {
+ Q_OBJECT
+ public:
+ CHistoryComboBox(QWidget* parent = 0);
+ ~CHistoryComboBox();
+ void addToHistory(const QString& item);
+ QStringList historyItems() const;
+
+ protected:
+
+ private:
};
} //end of namespace Search
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index 6c3053f..f243a61 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -34,262 +34,248 @@ namespace Search {
************ ModuleResultList **************
********************************************/
-CModuleResultView::CModuleResultView(QWidget* parent)
- : QTreeWidget(parent),
- strongsResults(0)
-{
- initView();
- initConnections();
+CModuleResultView::CModuleResultView(QWidget* parent)
+ : QTreeWidget(parent),
+ strongsResults(0) {
+ initView();
+ initConnections();
}
-CModuleResultView::~CModuleResultView()
-{}
+CModuleResultView::~CModuleResultView() {}
/** Initializes this widget. */
-void CModuleResultView::initView()
-{
- // see also csearchresultview.cpp
- setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
- setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
-
- setColumnWidth(0, CToolClass::mWidth(this, 8));
- setColumnWidth(1, CToolClass::mWidth(this, 4));
- QSize sz(CToolClass::mWidth(this, 13), CToolClass::mWidth(this, 5));
- //setMinimumSize(sz);
- m_size = sz;
- //TODO: sorting
- //setSorting(0, true);
- //setSorting(1, true);
-
- //setup the popup menu
- m_popup = new QMenu(this);
-
- m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(util::filesystem::DirectoryUtil::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
- m_actions.copy.result = new QAction(tr("Reference only"), this);
- QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
- m_actions.copyMenu->addAction(m_actions.copy.result);
- m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
- QObject::connect(m_actions.copy.resultWithText, SIGNAL(triggered()), this, SLOT(copyResultWithText()) );
- m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
- m_popup->addMenu(m_actions.copyMenu);
-
- m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(util::filesystem::DirectoryUtil::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
- m_actions.save.result = new QAction(tr("Reference only"), this);
- QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
- m_actions.saveMenu->addAction(m_actions.save.result);
- m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
- QObject::connect(m_actions.save.resultWithText, SIGNAL(triggered()), this, SLOT(saveResultWithText()) );
- m_actions.saveMenu->addAction(m_actions.save.resultWithText);
- m_popup->addMenu(m_actions.saveMenu);
-
- m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
- m_actions.print.result = new QAction(tr("Reference with text"), this);
- QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
- m_actions.printMenu->addAction(m_actions.print.result);
- m_popup->addMenu(m_actions.printMenu);
+void CModuleResultView::initView() {
+ // see also csearchresultview.cpp
+ setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
+ setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
+
+ setColumnWidth(0, CToolClass::mWidth(this, 8));
+ setColumnWidth(1, CToolClass::mWidth(this, 4));
+ QSize sz(CToolClass::mWidth(this, 13), CToolClass::mWidth(this, 5));
+ //setMinimumSize(sz);
+ m_size = sz;
+ //TODO: sorting
+ //setSorting(0, true);
+ //setSorting(1, true);
+
+ //setup the popup menu
+ m_popup = new QMenu(this);
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
+ m_actions.copyMenu->setIcon(util::filesystem::DirectoryUtil::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
+ m_actions.copy.result = new QAction(tr("Reference only"), this);
+ QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
+ m_actions.copyMenu->addAction(m_actions.copy.result);
+ m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
+ QObject::connect(m_actions.copy.resultWithText, SIGNAL(triggered()), this, SLOT(copyResultWithText()) );
+ m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
+ m_popup->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
+ m_actions.saveMenu->setIcon(util::filesystem::DirectoryUtil::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
+ m_actions.save.result = new QAction(tr("Reference only"), this);
+ QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
+ m_actions.saveMenu->addAction(m_actions.save.result);
+ m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
+ QObject::connect(m_actions.save.resultWithText, SIGNAL(triggered()), this, SLOT(saveResultWithText()) );
+ m_actions.saveMenu->addAction(m_actions.save.resultWithText);
+ m_popup->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
+ m_actions.printMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
+ m_actions.print.result = new QAction(tr("Reference with text"), this);
+ QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
+ m_actions.printMenu->addAction(m_actions.print.result);
+ m_popup->addMenu(m_actions.printMenu);
}
/** Initializes the connections of this widget, */
-void CModuleResultView::initConnections()
-{
- //TODO:
- connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
- this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
+void CModuleResultView::initConnections() {
+ //TODO:
+ connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+ this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
/** Setups the tree using the given list of modules. */
-void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText )
-{
- clear();
- //TODO: this class is for sorting
- //util::CSortListViewItem* item = 0;
- //util::CSortListViewItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
- QTreeWidgetItem* oldItem = 0;
-
- sword::ListKey result;
-
- if (strongsResults) {
- delete strongsResults;
- strongsResults = 0;
- }
-
- bool strongsAvailable = false;
-
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- // for (modules.first(); modules.current(); modules.next()) {
- result = (*it)->searchResult();
-
- item = new QTreeWidgetItem(this, QStringList((*it)->name()) << QString::number(result.Count()) );
- //TODO: item->setColumnSorting(1, util::CSortListViewItem::Number);
-
- item->setIcon(0,CToolClass::getIconForModule(*it) );
- oldItem = item;
- //----------------------------------------------------------------------
- // we need to make a decision here. Either don't show any Strong's
- // number translations, or show the first one in the search text, or
- // figure out how to show them all.
- // I choose option number 2 at this time.
- //----------------------------------------------------------------------
- int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
- if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
- QString sNumber;
- //--------------------------------------------------
- // get the strongs number from the search text
- //--------------------------------------------------
- // first find the first space after "strong:"
- // this should indicate a change in search token
- sstIndex = sstIndex + 7;
- sTokenIndex = searchedText.indexOf(" ", sstIndex);
- sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
-
- setupStrongsResults((*it), item, sNumber);
-
- //TODO: item->setOpen(true);
- strongsAvailable = true;
- }
- };
-
- //Allow to hide the module strongs if there are any available
- setRootIsDecorated( strongsAvailable );
+void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText ) {
+ clear();
+ //TODO: this class is for sorting
+ //util::CSortListViewItem* item = 0;
+ //util::CSortListViewItem* oldItem = 0;
+ QTreeWidgetItem* item = 0;
+ QTreeWidgetItem* oldItem = 0;
+
+ sword::ListKey result;
+
+ if (strongsResults) {
+ delete strongsResults;
+ strongsResults = 0;
+ }
+
+ bool strongsAvailable = false;
+
+ QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ // for (modules.first(); modules.current(); modules.next()) {
+ result = (*it)->searchResult();
+
+ item = new QTreeWidgetItem(this, QStringList((*it)->name()) << QString::number(result.Count()) );
+ //TODO: item->setColumnSorting(1, util::CSortListViewItem::Number);
+
+ item->setIcon(0, CToolClass::getIconForModule(*it) );
+ oldItem = item;
+ //----------------------------------------------------------------------
+ // we need to make a decision here. Either don't show any Strong's
+ // number translations, or show the first one in the search text, or
+ // figure out how to show them all.
+ // I choose option number 2 at this time.
+ //----------------------------------------------------------------------
+ int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
+ if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
+ QString sNumber;
+ //--------------------------------------------------
+ // get the strongs number from the search text
+ //--------------------------------------------------
+ // first find the first space after "strong:"
+ // this should indicate a change in search token
+ sstIndex = sstIndex + 7;
+ sTokenIndex = searchedText.indexOf(" ", sstIndex);
+ sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
+
+ setupStrongsResults((*it), item, sNumber);
+
+ //TODO: item->setOpen(true);
+ strongsAvailable = true;
+ }
+ };
+
+ //Allow to hide the module strongs if there are any available
+ setRootIsDecorated( strongsAvailable );
}
void CModuleResultView::setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent,
- const QString& sNumber)
-{
- QString lText;
- //TODO:
- //util::CSortListViewItem* item = 0;
- QTreeWidgetItem* item = 0;
-
- strongsResults = new StrongsResultClass(module, sNumber);
-
- for (int cnt = 0; cnt < strongsResults->Count(); ++cnt) {
- lText = strongsResults->keyText(cnt);
-
- item = new QTreeWidgetItem(parent, QStringList(lText) << QString::number(strongsResults->keyCount(cnt)));
- //TODO:
- //item->setColumnSorting(1, util::CSortListViewItem::Number);
- }
+ const QString& sNumber) {
+ QString lText;
+ //TODO:
+ //util::CSortListViewItem* item = 0;
+ QTreeWidgetItem* item = 0;
+
+ strongsResults = new StrongsResultClass(module, sNumber);
+
+ for (int cnt = 0; cnt < strongsResults->Count(); ++cnt) {
+ lText = strongsResults->keyText(cnt);
+
+ item = new QTreeWidgetItem(parent, QStringList(lText) << QString::number(strongsResults->keyCount(cnt)));
+ //TODO:
+ //item->setColumnSorting(1, util::CSortListViewItem::Number);
+ }
}
//TODO:
/** Is executed when an item was selected in the list. */
-void CModuleResultView::executed( QTreeWidgetItem* i, QTreeWidgetItem*)
-{
+void CModuleResultView::executed( QTreeWidgetItem* i, QTreeWidgetItem*) {
QString itemText, lText;
-
- if (!i){
- //Clear list
- emit moduleChanged();
- return;
- }
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(i->text(0))) {
- emit moduleChanged();
- emit moduleSelected(m);
- return;
- }
-
- if (!strongsResults) {
- return;
- }
-
- itemText = i->text(0);
- for (int cnt = 0; cnt < strongsResults->Count(); cnt++) {
- lText = strongsResults->keyText(cnt);
- if (lText == itemText) {
- //clear the verses list
- emit moduleChanged();
- emit strongsSelected(activeModule(), strongsResults->getKeyList(cnt));
- return;
- }
- }
+
+ if (!i) {
+ //Clear list
+ emit moduleChanged();
+ return;
+ }
+ if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(i->text(0))) {
+ emit moduleChanged();
+ emit moduleSelected(m);
+ return;
+ }
+
+ if (!strongsResults) {
+ return;
+ }
+
+ itemText = i->text(0);
+ for (int cnt = 0; cnt < strongsResults->Count(); cnt++) {
+ lText = strongsResults->keyText(cnt);
+ if (lText == itemText) {
+ //clear the verses list
+ emit moduleChanged();
+ emit strongsSelected(activeModule(), strongsResults->getKeyList(cnt));
+ return;
+ }
+ }
}
/** Returns the currently active module. */
-CSwordModuleInfo* CModuleResultView::activeModule()
-{
- Q_ASSERT(currentItem());
-
- QTreeWidgetItem* item = currentItem();
- if (!item) {
- return 0;
- }
-
- // we need to find the parent most node because that is the node
- // that is the module name.
- while (item->parent()) {
- item = item->parent();
- }
-
- if (item) {
- return CPointers::backend()->findModuleByName(item->text(0));
- }
-
- return 0;
+CSwordModuleInfo* CModuleResultView::activeModule() {
+ Q_ASSERT(currentItem());
+
+ QTreeWidgetItem* item = currentItem();
+ if (!item) {
+ return 0;
+ }
+
+ // we need to find the parent most node because that is the node
+ // that is the module name.
+ while (item->parent()) {
+ item = item->parent();
+ }
+
+ if (item) {
+ return CPointers::backend()->findModuleByName(item->text(0));
+ }
+
+ return 0;
}
/** Reimplementation from QWidget. */
-void CModuleResultView::contextMenuEvent( QContextMenuEvent * event )
-{
- qDebug("CModuleResultView::showPopup");
- //make sure that all entries have the correct status
- m_popup->exec(event->globalPos());
+void CModuleResultView::contextMenuEvent( QContextMenuEvent * event ) {
+ qDebug("CModuleResultView::showPopup");
+ //make sure that all entries have the correct status
+ m_popup->exec(event->globalPos());
}
/** Copies the whole search result into the clipboard. */
-void CModuleResultView::copyResult()
-{
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result,m,CExportManager::Text,false);
- };
+void CModuleResultView::copyResult() {
+ if (CSwordModuleInfo* m = activeModule()) {
+ sword::ListKey result = m->searchResult();
+ CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
+ mgr.copyKeyList(&result, m, CExportManager::Text, false);
+ };
}
/** Copies the whole search result with the text into the clipboard. */
-void CModuleResultView::copyResultWithText()
-{
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result,m,CExportManager::Text,true);
- };
+void CModuleResultView::copyResultWithText() {
+ if (CSwordModuleInfo* m = activeModule()) {
+ sword::ListKey result = m->searchResult();
+ CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
+ mgr.copyKeyList(&result, m, CExportManager::Text, true);
+ };
}
/** Saves the search result keys. */
-void CModuleResultView::saveResult()
-{
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result,m,CExportManager::Text,false);
- };
+void CModuleResultView::saveResult() {
+ if (CSwordModuleInfo* m = activeModule()) {
+ sword::ListKey result = m->searchResult();
+ CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
+ mgr.saveKeyList(&result, m, CExportManager::Text, false);
+ };
}
/** Saves the search result with it's text. */
-void CModuleResultView::saveResultWithText()
-{
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result,m,CExportManager::Text,true);
- };
+void CModuleResultView::saveResultWithText() {
+ if (CSwordModuleInfo* m = activeModule()) {
+ sword::ListKey result = m->searchResult();
+ CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
+ mgr.saveKeyList(&result, m, CExportManager::Text, true);
+ };
}
/** Appends the whole search result to the printer queue. */
-void CModuleResultView::printResult()
-{
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
- mgr.printKeyList(&result,m,CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults());
- };
+void CModuleResultView::printResult() {
+ if (CSwordModuleInfo* m = activeModule()) {
+ sword::ListKey result = m->searchResult();
+ CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
+ mgr.printKeyList(&result, m, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults());
+ };
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index c23d254..4295f82 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -36,98 +36,100 @@ namespace Search {
class CModuleResultView : public QTreeWidget {
- Q_OBJECT
-public:
- CModuleResultView(QWidget* parent);
- ~CModuleResultView();
-
- /**
- * Setups the tree using the given list of modules.
- */
- void setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText );
- /**
- * Returns the currently active module.
- */
- CSwordModuleInfo* activeModule();
-
- virtual QSize sizeHint() {return m_size;}
-
-protected:
- /**
- * Initializes this widget.
- */
- void initView();
- /**
- * Initializes the connections of this widget
- */
- void initConnections();
-
-
- void setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent, const QString& searchedText);
-
-protected slots:
- /**
- * Is executed when an item was selected in the list.
- */
- void executed(QTreeWidgetItem*, QTreeWidgetItem*);
- /**
- * Copies the whole search result with the text into the clipboard.
- */
- void copyResultWithText();
- /**
- * Copies the whole search result into the clipboard.
- */
- void copyResult();
- /**
- * This event handler (reimplemented from QWidget) opens the popup menu at the given position.
- */
- void contextMenuEvent( QContextMenuEvent * event );
- /**
- * Appends the whole search result to the printer queue.
- */
- void printResult();
- /**
- * Saves the search result with it's text.
- */
- void saveResultWithText();
- /**
- * Saves the search result keys.
- */
- void saveResult();
-
-signals:
- void moduleSelected(CSwordModuleInfo*);
- void moduleChanged();
- void strongsSelected(CSwordModuleInfo*, QStringList*);
-
-private:
- struct {
- QMenu* saveMenu;
- struct {
- QAction* result;
- QAction* resultWithText;
- }
- save;
-
- QMenu* printMenu;
- struct {
- QAction* result;
- }
- print;
-
- QMenu* copyMenu;
- struct {
- QAction* result;
- QAction* resultWithText;
- }
- copy;
-
- } m_actions;
-
- QMenu* m_popup;
-
- StrongsResultClass* strongsResults;
- QSize m_size;
+ Q_OBJECT
+ public:
+ CModuleResultView(QWidget* parent);
+ ~CModuleResultView();
+
+ /**
+ * Setups the tree using the given list of modules.
+ */
+ void setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText );
+ /**
+ * Returns the currently active module.
+ */
+ CSwordModuleInfo* activeModule();
+
+ virtual QSize sizeHint() {
+ return m_size;
+ }
+
+ protected:
+ /**
+ * Initializes this widget.
+ */
+ void initView();
+ /**
+ * Initializes the connections of this widget
+ */
+ void initConnections();
+
+
+ void setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent, const QString& searchedText);
+
+ protected slots:
+ /**
+ * Is executed when an item was selected in the list.
+ */
+ void executed(QTreeWidgetItem*, QTreeWidgetItem*);
+ /**
+ * Copies the whole search result with the text into the clipboard.
+ */
+ void copyResultWithText();
+ /**
+ * Copies the whole search result into the clipboard.
+ */
+ void copyResult();
+ /**
+ * This event handler (reimplemented from QWidget) opens the popup menu at the given position.
+ */
+ void contextMenuEvent( QContextMenuEvent * event );
+ /**
+ * Appends the whole search result to the printer queue.
+ */
+ void printResult();
+ /**
+ * Saves the search result with it's text.
+ */
+ void saveResultWithText();
+ /**
+ * Saves the search result keys.
+ */
+ void saveResult();
+
+ signals:
+ void moduleSelected(CSwordModuleInfo*);
+ void moduleChanged();
+ void strongsSelected(CSwordModuleInfo*, QStringList*);
+
+ private:
+ struct {
+ QMenu* saveMenu;
+ struct {
+ QAction* result;
+ QAction* resultWithText;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* result;
+ }
+ print;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* result;
+ QAction* resultWithText;
+ }
+ copy;
+
+ } m_actions;
+
+ QMenu* m_popup;
+
+ StrongsResultClass* strongsResults;
+ QSize m_size;
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 92a8dc0..58175f9 100644
--- a/src/frontend/searchdialog/crangechooserdialog.cpp
+++ b/src/frontend/searchdialog/crangechooserdialog.cpp
@@ -37,123 +37,119 @@ namespace Search {
/********** RangeItem ******************/
-CRangeChooserDialog::RangeItem::RangeItem(QListWidget* view, QListWidgetItem* /*afterThis*/, const QString caption, const QString range)
- : QListWidgetItem(view)
-{
- setCaption(caption);
- setRange(range);
+CRangeChooserDialog::RangeItem::RangeItem(QListWidget* view, QListWidgetItem* /*afterThis*/, const QString caption, const QString range)
+ : QListWidgetItem(view) {
+ setCaption(caption);
+ setRange(range);
}
CRangeChooserDialog::RangeItem::~RangeItem() {}
-const QString& CRangeChooserDialog::RangeItem::range() const
-{
- // qWarning("range is %s", (const char*)m_range.utf8());
- return m_range;
+const QString& CRangeChooserDialog::RangeItem::range() const {
+ // qWarning("range is %s", (const char*)m_range.utf8());
+ return m_range;
}
void CRangeChooserDialog::RangeItem::setRange(QString newRange) {
- m_range = newRange;
+ m_range = newRange;
}
QString CRangeChooserDialog::RangeItem::caption() const {
- return text();
+ return text();
}
void CRangeChooserDialog::RangeItem::setCaption(const QString newCaption) {
- setText(newCaption);
+ setText(newCaption);
}
/*********** Dialog ***************/
CRangeChooserDialog::CRangeChooserDialog( QWidget* parentDialog )
- : QDialog(parentDialog)
-{
- //Set the flag to destroy when closed - otherwise eats memory
- setAttribute(Qt::WA_DeleteOnClose);
- initView();
- initConnections();
-
- //add the existing scopes
- CBTConfig::StringMap map = CBTConfig::get
- (CBTConfig::searchScopes);
- CBTConfig::StringMap::Iterator it;
- for (it = map.begin(); it != map.end(); ++it) {
- new RangeItem(m_rangeList, 0, it.key(), it.value());
- };
-
- editRange(0);
- if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
- ) {
- nameChanged(i->caption());
- }
+ : QDialog(parentDialog) {
+ //Set the flag to destroy when closed - otherwise eats memory
+ setAttribute(Qt::WA_DeleteOnClose);
+ initView();
+ initConnections();
+
+ //add the existing scopes
+ CBTConfig::StringMap map = CBTConfig::get
+ (CBTConfig::searchScopes);
+ CBTConfig::StringMap::Iterator it;
+ for (it = map.begin(); it != map.end(); ++it) {
+ new RangeItem(m_rangeList, 0, it.key(), it.value());
+ };
+
+ editRange(0);
+ if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
+ ) {
+ nameChanged(i->caption());
+ }
}
/** Initializes the view of this object. */
-void CRangeChooserDialog::initView()
-{
- setWindowTitle(tr("Setup Search Scopes"));
+void CRangeChooserDialog::initView() {
+ setWindowTitle(tr("Setup Search Scopes"));
- QVBoxLayout* vboxLayout = new QVBoxLayout(this);
+ QVBoxLayout* vboxLayout = new QVBoxLayout(this);
- QHBoxLayout* hboxLayout = new QHBoxLayout();
- QVBoxLayout* vboxLayout1 = new QVBoxLayout();
- QLabel* rangeListLabel = new QLabel(tr("S&earch range:"), this);
- vboxLayout1->addWidget(rangeListLabel);
+ QHBoxLayout* hboxLayout = new QHBoxLayout();
+ QVBoxLayout* vboxLayout1 = new QVBoxLayout();
+ QLabel* rangeListLabel = new QLabel(tr("S&earch range:"), this);
+ vboxLayout1->addWidget(rangeListLabel);
- m_rangeList = new QListWidget(this);
- m_rangeList->setToolTip(tr("Select a scope from the list to edit the search ranges"));
- vboxLayout1->addWidget(m_rangeList);
+ m_rangeList = new QListWidget(this);
+ m_rangeList->setToolTip(tr("Select a scope from the list to edit the search ranges"));
+ vboxLayout1->addWidget(m_rangeList);
- QHBoxLayout* hboxLayout1 = new QHBoxLayout();
- m_newRangeButton = new QPushButton(tr("&Add new scope"), this);
- m_newRangeButton->setToolTip(tr("Add a new search scope. First enter an appropriate name, then edit the search ranges."));
- hboxLayout1->addWidget(m_newRangeButton);
- m_deleteRangeButton = new QPushButton(tr("Delete current &scope"), this);
- m_deleteRangeButton->setToolTip(tr("Delete the selected search scope"));
- hboxLayout1->addWidget(m_deleteRangeButton);
+ QHBoxLayout* hboxLayout1 = new QHBoxLayout();
+ m_newRangeButton = new QPushButton(tr("&Add new scope"), this);
+ m_newRangeButton->setToolTip(tr("Add a new search scope. First enter an appropriate name, then edit the search ranges."));
+ hboxLayout1->addWidget(m_newRangeButton);
+ m_deleteRangeButton = new QPushButton(tr("Delete current &scope"), this);
+ m_deleteRangeButton->setToolTip(tr("Delete the selected search scope"));
+ hboxLayout1->addWidget(m_deleteRangeButton);
- vboxLayout1->addLayout(hboxLayout1);
- hboxLayout->addLayout(vboxLayout1);
+ vboxLayout1->addLayout(hboxLayout1);
+ hboxLayout->addLayout(vboxLayout1);
- QVBoxLayout* vboxLayout2 = new QVBoxLayout();
- QHBoxLayout* hboxLayout2 = new QHBoxLayout();
- QLabel* nameEditLabel = new QLabel(tr("&Name:"), this);
- hboxLayout2->addWidget(nameEditLabel);
+ QVBoxLayout* vboxLayout2 = new QVBoxLayout();
+ QHBoxLayout* hboxLayout2 = new QHBoxLayout();
+ QLabel* nameEditLabel = new QLabel(tr("&Name:"), this);
+ hboxLayout2->addWidget(nameEditLabel);
- m_nameEdit = new QLineEdit(this);
- m_nameEdit->setToolTip(tr("Change the name of the selected search scope"));
- hboxLayout2->addWidget(m_nameEdit);
- vboxLayout2->addLayout(hboxLayout2);
+ m_nameEdit = new QLineEdit(this);
+ m_nameEdit->setToolTip(tr("Change the name of the selected search scope"));
+ hboxLayout2->addWidget(m_nameEdit);
+ vboxLayout2->addLayout(hboxLayout2);
- QLabel* rangeEditLabel = new QLabel(tr("Edi&t current range:"), this);
- vboxLayout2->addWidget(rangeEditLabel);
+ QLabel* rangeEditLabel = new QLabel(tr("Edi&t current range:"), this);
+ vboxLayout2->addWidget(rangeEditLabel);
- m_rangeEdit = new QTextEdit(this);
- m_rangeEdit->setToolTip(tr("Change the search ranges of the selected search scope item. Have a look at the predefined search scopes to see how search ranges are constructed."));
+ m_rangeEdit = new QTextEdit(this);
+ m_rangeEdit->setToolTip(tr("Change the search ranges of the selected search scope item. Have a look at the predefined search scopes to see how search ranges are constructed."));
- vboxLayout2->addWidget(m_rangeEdit);
+ vboxLayout2->addWidget(m_rangeEdit);
- QLabel* resultListLabel = new QLabel(tr("Parsed search range:"), this);
+ QLabel* resultListLabel = new QLabel(tr("Parsed search range:"), this);
vboxLayout2->addWidget(resultListLabel);
- m_resultList = new QListWidget(this);
- m_resultList->setToolTip(tr("The search ranges which will be used for the search, parsed to the canonical form"));
- vboxLayout2->addWidget(m_resultList);
+ m_resultList = new QListWidget(this);
+ m_resultList->setToolTip(tr("The search ranges which will be used for the search, parsed to the canonical form"));
+ vboxLayout2->addWidget(m_resultList);
- hboxLayout->addLayout(vboxLayout2);
- vboxLayout->addLayout(hboxLayout);
+ hboxLayout->addLayout(vboxLayout2);
+ vboxLayout->addLayout(hboxLayout);
- QFrame* line = new QFrame(this);
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
- vboxLayout->addWidget(line);
+ QFrame* line = new QFrame(this);
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ vboxLayout->addWidget(line);
m_buttonBox = new QDialogButtonBox(this);
m_buttonBox->setOrientation(Qt::Horizontal);
- m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults);
- util::prepareDialogBox(m_buttonBox);
+ m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok | QDialogButtonBox::RestoreDefaults);
+ util::prepareDialogBox(m_buttonBox);
vboxLayout->addWidget(m_buttonBox);
rangeListLabel->setBuddy(m_rangeList);
@@ -164,165 +160,156 @@ void CRangeChooserDialog::initView()
-void CRangeChooserDialog::initConnections()
-{
- // Signals from text/list widgets
- QObject::connect(m_rangeList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
- this, SLOT(editRange(QListWidgetItem*)));
+void CRangeChooserDialog::initConnections() {
+ // Signals from text/list widgets
+ QObject::connect(m_rangeList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
+ this, SLOT(editRange(QListWidgetItem*)));
- QObject::connect(m_rangeEdit, SIGNAL(textChanged()),
- this, SLOT(parseRange()));
- QObject::connect(m_rangeEdit, SIGNAL(textChanged()),
- this, SLOT(rangeChanged()));
+ QObject::connect(m_rangeEdit, SIGNAL(textChanged()),
+ this, SLOT(parseRange()));
+ QObject::connect(m_rangeEdit, SIGNAL(textChanged()),
+ this, SLOT(rangeChanged()));
- QObject::connect(m_nameEdit, SIGNAL(textChanged(const QString&)),
- this, SLOT(nameChanged(const QString&)));
+ QObject::connect(m_nameEdit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(nameChanged(const QString&)));
- // Buttons
- QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()));
- QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(close()));
- QObject::connect(m_newRangeButton, SIGNAL(clicked()), this, SLOT(addNewRange()));
- QObject::connect(m_deleteRangeButton, SIGNAL(clicked()), this, SLOT(deleteCurrentRange()));
- //restore defaults!
- QPushButton* defaultsButton = m_buttonBox->button(QDialogButtonBox::RestoreDefaults);
- QObject::connect(defaultsButton, SIGNAL(clicked()), this, SLOT(slotDefault()));
+ // Buttons
+ QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()));
+ QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(close()));
+ QObject::connect(m_newRangeButton, SIGNAL(clicked()), this, SLOT(addNewRange()));
+ QObject::connect(m_deleteRangeButton, SIGNAL(clicked()), this, SLOT(deleteCurrentRange()));
+ //restore defaults!
+ QPushButton* defaultsButton = m_buttonBox->button(QDialogButtonBox::RestoreDefaults);
+ QObject::connect(defaultsButton, SIGNAL(clicked()), this, SLOT(slotDefault()));
}
/** Adds a new range to the list. */
-void CRangeChooserDialog::addNewRange()
-{
- //qDebug("CRangeChooserDialog::addNewRange");
- //RangeItem* i = new RangeItem(m_rangeList, m_rangeList->lastItem(), tr("New range"));
- RangeItem* i = new RangeItem(m_rangeList, 0, tr("New range"));
- //use just setCurrentItem... m_rangeList->setSelected(i, true);
- m_rangeList->setCurrentItem(i);
- editRange(i);
-
- m_nameEdit->setFocus();
+void CRangeChooserDialog::addNewRange() {
+ //qDebug("CRangeChooserDialog::addNewRange");
+ //RangeItem* i = new RangeItem(m_rangeList, m_rangeList->lastItem(), tr("New range"));
+ RangeItem* i = new RangeItem(m_rangeList, 0, tr("New range"));
+ //use just setCurrentItem... m_rangeList->setSelected(i, true);
+ m_rangeList->setCurrentItem(i);
+ editRange(i);
+
+ m_nameEdit->setFocus();
}
/** No descriptions */
-void CRangeChooserDialog::editRange(QListWidgetItem* item)
-{
- //qDebug("CRangeChooserDialog::editRange");
- RangeItem* const range = dynamic_cast<RangeItem*>(item);
-
- m_nameEdit->setEnabled( range ); //only if an item is selected enable the edit part
- m_rangeEdit->setEnabled( range );
- m_resultList->setEnabled( range );
- m_deleteRangeButton->setEnabled( range );
-
- if (range) {
- m_nameEdit->setText(range->caption());
- m_rangeEdit->setText(range->range());
- }
+void CRangeChooserDialog::editRange(QListWidgetItem* item) {
+ //qDebug("CRangeChooserDialog::editRange");
+ RangeItem* const range = dynamic_cast<RangeItem*>(item);
+
+ m_nameEdit->setEnabled( range ); //only if an item is selected enable the edit part
+ m_rangeEdit->setEnabled( range );
+ m_resultList->setEnabled( range );
+ m_deleteRangeButton->setEnabled( range );
+
+ if (range) {
+ m_nameEdit->setText(range->caption());
+ m_rangeEdit->setText(range->range());
+ }
}
/** Parses the entered text and prints out the result in the list box below the edit area. */
-void CRangeChooserDialog::parseRange()
-{
- //qDebug("CRangeChooserDialog::parseRange");
- m_resultList->clear();
-
- //TODO: remove this hack:
- //HACK: repair range to work with Sword 1.5.6
- QString range( m_rangeEdit->toPlainText() );
- range.replace(QRegExp("\\s{0,}-\\s{0,}"), "-" );
-
- sword::VerseKey key;
- sword::ListKey verses = key.ParseVerseList((const char*)range.toUtf8(), "Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
- new QListWidgetItem(QString::fromUtf8(verses.GetElement(i)->getRangeText()), m_resultList );
- // qWarning("range=%s, text=%s",verses.GetElement(i)->getRangeText(), verses.GetElement(i)->getText() );
- }
+void CRangeChooserDialog::parseRange() {
+ //qDebug("CRangeChooserDialog::parseRange");
+ m_resultList->clear();
+
+ //TODO: remove this hack:
+ //HACK: repair range to work with Sword 1.5.6
+ QString range( m_rangeEdit->toPlainText() );
+ range.replace(QRegExp("\\s{0,}-\\s{0,}"), "-" );
+
+ sword::VerseKey key;
+ sword::ListKey verses = key.ParseVerseList((const char*)range.toUtf8(), "Genesis 1:1", true);
+ for (int i = 0; i < verses.Count(); ++i) {
+ new QListWidgetItem(QString::fromUtf8(verses.GetElement(i)->getRangeText()), m_resultList );
+ // qWarning("range=%s, text=%s",verses.GetElement(i)->getRangeText(), verses.GetElement(i)->getText() );
+ }
}
/** No descriptions */
-void CRangeChooserDialog::rangeChanged()
-{
- //qDebug("CRangeChooserDialog::rangeChanged");
- if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
- ) {
- QString range( m_rangeEdit->toPlainText() );
- //TODO: remove this hack:
- //HACK: repair range to work with Sword 1.5.6
- range.replace(QRegExp("\\s{0,}-\\s{0,}"), "-" );
- i->setRange(range);
- };
+void CRangeChooserDialog::rangeChanged() {
+ //qDebug("CRangeChooserDialog::rangeChanged");
+ if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
+ ) {
+ QString range( m_rangeEdit->toPlainText() );
+ //TODO: remove this hack:
+ //HACK: repair range to work with Sword 1.5.6
+ range.replace(QRegExp("\\s{0,}-\\s{0,}"), "-" );
+ i->setRange(range);
+ };
}
/** No descriptions */
-void CRangeChooserDialog::nameChanged(const QString& newCaption)
-{
- //qDebug("CRangeChooserDialog::nameChanged");
- m_rangeEdit->setEnabled(!newCaption.isEmpty());
- m_resultList->setEnabled(!newCaption.isEmpty());
- //m_resultList->header()->setEnabled(!newCaption.isEmpty());
-
- if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
- ) {
- if (!newCaption.isEmpty()) {
- //enable some items (see "else" below)
- m_newRangeButton->setEnabled(true);
- m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
- m_rangeList->setDisabled(false);
- i->setCaption(newCaption);
- }
- else { //invalid name
- i->setCaption(tr("<invalid name of search range>"));
- //disable some items to prevent saving invalid range
- m_newRangeButton->setEnabled(false);
- m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
- m_rangeList->setDisabled(true);
- };
- };
+void CRangeChooserDialog::nameChanged(const QString& newCaption) {
+ //qDebug("CRangeChooserDialog::nameChanged");
+ m_rangeEdit->setEnabled(!newCaption.isEmpty());
+ m_resultList->setEnabled(!newCaption.isEmpty());
+ //m_resultList->header()->setEnabled(!newCaption.isEmpty());
+
+ if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
+ ) {
+ if (!newCaption.isEmpty()) {
+ //enable some items (see "else" below)
+ m_newRangeButton->setEnabled(true);
+ m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
+ m_rangeList->setDisabled(false);
+ i->setCaption(newCaption);
+ }
+ else { //invalid name
+ i->setCaption(tr("<invalid name of search range>"));
+ //disable some items to prevent saving invalid range
+ m_newRangeButton->setEnabled(false);
+ m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
+ m_rangeList->setDisabled(true);
+ };
+ };
}
/** Deletes the selected range. */
-void CRangeChooserDialog::deleteCurrentRange()
-{
- //qDebug("CRangeChooserDialog::deleteCurrentRange");
- if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem()) ) {
- int row = m_rangeList->row(i);
- m_rangeList->takeItem(row);
- delete i;
- }
- editRange(m_rangeList->currentItem());
+void CRangeChooserDialog::deleteCurrentRange() {
+ //qDebug("CRangeChooserDialog::deleteCurrentRange");
+ if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem()) ) {
+ int row = m_rangeList->row(i);
+ m_rangeList->takeItem(row);
+ delete i;
+ }
+ editRange(m_rangeList->currentItem());
}
-void CRangeChooserDialog::slotOk()
-{
- m_rangeList->sortItems(); //sorted first because the order will be saved
- //save the new map of search scopes
- CBTConfig::StringMap map;
- for (int i = 0; i < m_rangeList->count(); i++){
- if ( RangeItem* item = dynamic_cast<RangeItem*>(m_rangeList->item(i)) ) {
- map[item->caption()] = item->range();
- };
- }
- CBTConfig::set
- (CBTConfig::searchScopes, map);
-
- QDialog::accept();
+void CRangeChooserDialog::slotOk() {
+ m_rangeList->sortItems(); //sorted first because the order will be saved
+ //save the new map of search scopes
+ CBTConfig::StringMap map;
+ for (int i = 0; i < m_rangeList->count(); i++) {
+ if ( RangeItem* item = dynamic_cast<RangeItem*>(m_rangeList->item(i)) ) {
+ map[item->caption()] = item->range();
+ };
+ }
+ CBTConfig::set
+ (CBTConfig::searchScopes, map);
+
+ QDialog::accept();
}
-void CRangeChooserDialog::slotDefault()
-{
- //qDebug("CRangeChooserDialog::slotDefault");
- m_rangeList->clear();
- CBTConfig::StringMap map = CBTConfig::getDefault(CBTConfig::searchScopes);
- CBTConfig::StringMap::Iterator it;
- for (it = map.begin(); it != map.end(); ++it) {
- new RangeItem(m_rangeList, 0, it.key(), it.value());
- };
- m_rangeList->setCurrentItem(0);
-
- editRange(0);
- if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
- ) {
- nameChanged(i->caption());
- }
+void CRangeChooserDialog::slotDefault() {
+ //qDebug("CRangeChooserDialog::slotDefault");
+ m_rangeList->clear();
+ CBTConfig::StringMap map = CBTConfig::getDefault(CBTConfig::searchScopes);
+ CBTConfig::StringMap::Iterator it;
+ for (it = map.begin(); it != map.end(); ++it) {
+ new RangeItem(m_rangeList, 0, it.key(), it.value());
+ };
+ m_rangeList->setCurrentItem(0);
+
+ editRange(0);
+ if (RangeItem* i = dynamic_cast<RangeItem*>(m_rangeList->currentItem())
+ ) {
+ nameChanged(i->caption());
+ }
}
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index 4859b15..8711eab 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -24,62 +24,61 @@ class QDialogButtonBox;
namespace Search {
-class CRangeChooserDialog : public QDialog
-{
- Q_OBJECT
-public:
- CRangeChooserDialog(QWidget* parentDialog);
- ~CRangeChooserDialog(){};
-
-protected: // Protected methods
-class RangeItem : public QListWidgetItem {
-public:
- RangeItem(QListWidget*, QListWidgetItem* afterThis = 0, const QString caption = QString::null, const QString range = QString::null);
- ~RangeItem();
- const QString& range() const;
- QString caption() const;
- void setRange(QString range);
- void setCaption(const QString);
-private:
- QString m_range;
- };
-
- /**
- * Initializes the connections of this widget.
- */
- void initConnections();
- /**
- * Initializes the view of this object.
- */
- void initView();
-
-protected slots: // Protected slots
- /**
- * Adds a new range to the list.
- */
- void addNewRange();
- void editRange(QListWidgetItem*);
- /**
- * Parses the entered text and prints out the result in the list box below the edit area.
- */
- void parseRange();
- void nameChanged(const QString&);
- void rangeChanged();
- /**
- * Deletes the selected range.
- */
- void deleteCurrentRange();
- virtual void slotDefault();
- virtual void slotOk();
-
-private:
- QListWidget* m_rangeList;
- QListWidget* m_resultList;
- QLineEdit* m_nameEdit;
- QTextEdit* m_rangeEdit;
- QPushButton* m_newRangeButton;
- QPushButton* m_deleteRangeButton;
- QDialogButtonBox* m_buttonBox;
+class CRangeChooserDialog : public QDialog {
+ Q_OBJECT
+ public:
+ CRangeChooserDialog(QWidget* parentDialog);
+ ~CRangeChooserDialog() {};
+
+ protected: // Protected methods
+ class RangeItem : public QListWidgetItem {
+ public:
+ RangeItem(QListWidget*, QListWidgetItem* afterThis = 0, const QString caption = QString::null, const QString range = QString::null);
+ ~RangeItem();
+ const QString& range() const;
+ QString caption() const;
+ void setRange(QString range);
+ void setCaption(const QString);
+ private:
+ QString m_range;
+ };
+
+ /**
+ * Initializes the connections of this widget.
+ */
+ void initConnections();
+ /**
+ * Initializes the view of this object.
+ */
+ void initView();
+
+ protected slots: // Protected slots
+ /**
+ * Adds a new range to the list.
+ */
+ void addNewRange();
+ void editRange(QListWidgetItem*);
+ /**
+ * Parses the entered text and prints out the result in the list box below the edit area.
+ */
+ void parseRange();
+ void nameChanged(const QString&);
+ void rangeChanged();
+ /**
+ * Deletes the selected range.
+ */
+ void deleteCurrentRange();
+ virtual void slotDefault();
+ virtual void slotOk();
+
+ private:
+ QListWidget* m_rangeList;
+ QListWidget* m_resultList;
+ QLineEdit* m_nameEdit;
+ QTextEdit* m_rangeEdit;
+ QPushButton* m_newRangeButton;
+ QPushButton* m_deleteRangeButton;
+ QDialogButtonBox* m_buttonBox;
};
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 5fd590e..221be09 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -37,267 +37,252 @@ namespace Search {
static CSearchDialog* m_staticDialog = 0;
-void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText, QWidget* parentDialog)
-{
- if (!m_staticDialog) {
- m_staticDialog = new CSearchDialog(parentDialog);
- };
- m_staticDialog->reset();
-
- if (modules.count()) {
- m_staticDialog->setModules(modules);
- }
- else {
- m_staticDialog->showModulesSelector();
- }
-
- m_staticDialog->setSearchText(searchText);
- if (m_staticDialog->isHidden()) {
- m_staticDialog->show();
- }
-
- if (modules.count() && !searchText.isEmpty()) {
- m_staticDialog->startSearch();
- }
- // moved these to after the startSearch() because
- // the progress dialog caused them to loose focus.
- m_staticDialog->raise();
- m_staticDialog->activateWindow();
+void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText, QWidget* parentDialog) {
+ if (!m_staticDialog) {
+ m_staticDialog = new CSearchDialog(parentDialog);
+ };
+ m_staticDialog->reset();
+
+ if (modules.count()) {
+ m_staticDialog->setModules(modules);
+ }
+ else {
+ m_staticDialog->showModulesSelector();
+ }
+
+ m_staticDialog->setSearchText(searchText);
+ if (m_staticDialog->isHidden()) {
+ m_staticDialog->show();
+ }
+
+ if (modules.count() && !searchText.isEmpty()) {
+ m_staticDialog->startSearch();
+ }
+ // moved these to after the startSearch() because
+ // the progress dialog caused them to loose focus.
+ m_staticDialog->raise();
+ m_staticDialog->activateWindow();
}
-CSearchDialog* CSearchDialog::getSearchDialog()
-{
- Q_ASSERT(m_staticDialog);
- return m_staticDialog;
+CSearchDialog* CSearchDialog::getSearchDialog() {
+ Q_ASSERT(m_staticDialog);
+ return m_staticDialog;
}
CSearchDialog::CSearchDialog(QWidget *parent)
- :QDialog(parent), /*m_searchButton(0),*/ m_closeButton(0),
- m_searchResultArea(0), m_searchOptionsArea(0)
-{
- setWindowIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::icon) );
- setWindowTitle(tr("Search"));
- setAttribute(Qt::WA_DeleteOnClose);
- m_searcher.connectFinished( this, SLOT(searchFinished()));
- initView();
- initConnections();
+ : QDialog(parent), /*m_searchButton(0),*/ m_closeButton(0),
+ m_searchResultArea(0), m_searchOptionsArea(0) {
+ setWindowIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::icon) );
+ setWindowTitle(tr("Search"));
+ setAttribute(Qt::WA_DeleteOnClose);
+ m_searcher.connectFinished( this, SLOT(searchFinished()));
+ initView();
+ initConnections();
}
-CSearchDialog::~CSearchDialog()
-{
- saveDialogSettings();
- m_staticDialog = 0;
+CSearchDialog::~CSearchDialog() {
+ saveDialogSettings();
+ m_staticDialog = 0;
}
/** Starts the search with the set modules and the set search text. */
-void CSearchDialog::startSearch()
-{
- QString originalSearchText(m_searchOptionsArea->searchText());
- QString searchText("");
-
- if (originalSearchText.isEmpty()) {
- return;
- }
-
- searchText = prepareSearchText(originalSearchText);
-
- // Insert search text into history list of combobox
- m_searchOptionsArea->addToHistory(originalSearchText);
-
- // check that we have the indices we need for searching
- if (!m_searcher.modulesHaveIndices( modules() ) ) {
- int result = QMessageBox::question(this, tr("Missing indices"),
- tr("One or more works need indexing before they can be searched.\n"
- "This could take a long time. Proceed with indexing?"),
- QMessageBox::Yes | QMessageBox::Default,
- QMessageBox::No | QMessageBox::Escape);
- // In SuSE 10.0 the result is the logical or of the button type, just like it is
- // inputed into the QMessageBox.
- if ( (result == (QMessageBox::Yes | QMessageBox::Default)) ||
- (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) {
- CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance();
- dlg->indexUnindexedModules( modules() );
- }
- else {
- return;
- }
- }
-
- if (m_searchOptionsArea->hasSearchScope()) {
- m_searcher.setSearchScope( m_searchOptionsArea->searchScope() );
- }
- else {
- m_searcher.resetSearchScope();
- }
-
- m_searcher.setModules( modules() );
- m_searcher.setSearchedText(searchText);
-
-
- //Just to be sure that it can't be clicked again, if the search happens to be a bit slow.
- m_searchOptionsArea->searchButton()->setEnabled(false);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(false);
-
- m_searcher.startSearch();
-
- m_searchOptionsArea->searchButton()->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setFocus();
+void CSearchDialog::startSearch() {
+ QString originalSearchText(m_searchOptionsArea->searchText());
+ QString searchText("");
+
+ if (originalSearchText.isEmpty()) {
+ return;
+ }
+
+ searchText = prepareSearchText(originalSearchText);
+
+ // Insert search text into history list of combobox
+ m_searchOptionsArea->addToHistory(originalSearchText);
+
+ // check that we have the indices we need for searching
+ if (!m_searcher.modulesHaveIndices( modules() ) ) {
+ int result = QMessageBox::question(this, tr("Missing indices"),
+ tr("One or more works need indexing before they can be searched.\n"
+ "This could take a long time. Proceed with indexing?"),
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No | QMessageBox::Escape);
+ // In SuSE 10.0 the result is the logical or of the button type, just like it is
+ // inputed into the QMessageBox.
+ if ( (result == (QMessageBox::Yes | QMessageBox::Default)) ||
+ (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) {
+ CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance();
+ dlg->indexUnindexedModules( modules() );
+ }
+ else {
+ return;
+ }
+ }
+
+ if (m_searchOptionsArea->hasSearchScope()) {
+ m_searcher.setSearchScope( m_searchOptionsArea->searchScope() );
+ }
+ else {
+ m_searcher.resetSearchScope();
+ }
+
+ m_searcher.setModules( modules() );
+ m_searcher.setSearchedText(searchText);
+
+
+ //Just to be sure that it can't be clicked again, if the search happens to be a bit slow.
+ m_searchOptionsArea->searchButton()->setEnabled(false);
+ m_searchOptionsArea->m_searchTextCombo->setEnabled(false);
+
+ m_searcher.startSearch();
+
+ m_searchOptionsArea->searchButton()->setEnabled(true);
+ m_searchOptionsArea->m_searchTextCombo->setEnabled(true);
+ m_searchOptionsArea->m_searchTextCombo->setFocus();
}
-QString CSearchDialog::prepareSearchText(const QString& orig)
-{
- qDebug() << "Original search text:" << orig;
- static const QRegExp syntaxCharacters("[+\\-()!\"~]");
- static const QRegExp andWords("\\band\\b", Qt::CaseInsensitive);
- static const QRegExp orWords("\\bor\\b", Qt::CaseInsensitive);
- QString text("");
- if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::AndType) {
- qDebug() << "AND type";
- text = orig.simplified();
- text.remove(syntaxCharacters);
- qDebug() << "After syntax characters removed:" << text;
- text.replace(andWords, "\"and\"");
- text.replace(orWords, "\"or\"");
- qDebug() << "After andor repclaced:" << text;
- text.replace(" ", " AND ");
- }
- if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::OrType) {
- text = orig.simplified();
- text.remove(syntaxCharacters);
- text.replace(andWords, "\"and\"");
- text.replace(orWords, "\"or\"");
- }
- if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::FullType) {
- text = orig;
- }
- qDebug() << "The final search string:" << text;
- return text;
+QString CSearchDialog::prepareSearchText(const QString& orig) {
+ qDebug() << "Original search text:" << orig;
+ static const QRegExp syntaxCharacters("[+\\-()!\"~]");
+ static const QRegExp andWords("\\band\\b", Qt::CaseInsensitive);
+ static const QRegExp orWords("\\bor\\b", Qt::CaseInsensitive);
+ QString text("");
+ if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::AndType) {
+ qDebug() << "AND type";
+ text = orig.simplified();
+ text.remove(syntaxCharacters);
+ qDebug() << "After syntax characters removed:" << text;
+ text.replace(andWords, "\"and\"");
+ text.replace(orWords, "\"or\"");
+ qDebug() << "After andor repclaced:" << text;
+ text.replace(" ", " AND ");
+ }
+ if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::OrType) {
+ text = orig.simplified();
+ text.remove(syntaxCharacters);
+ text.replace(andWords, "\"and\"");
+ text.replace(orWords, "\"or\"");
+ }
+ if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::FullType) {
+ text = orig;
+ }
+ qDebug() << "The final search string:" << text;
+ return text;
}
/** Starts the search with the given module list and given search text. */
-void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText)
-{
- m_searchResultArea->reset();
- m_searchOptionsArea->reset();
- setModules(modules);
- setSearchText(searchText);
-
- startSearch();
+void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText) {
+ m_searchResultArea->reset();
+ m_searchOptionsArea->reset();
+ setModules(modules);
+ setSearchText(searchText);
+
+ startSearch();
}
/** Returns the list of used modules. */
-QList<CSwordModuleInfo*> CSearchDialog::modules() const
-{
- return m_searchOptionsArea->modules();
+QList<CSwordModuleInfo*> CSearchDialog::modules() const {
+ return m_searchOptionsArea->modules();
}
/** Sets the list of modules for the search. */
-void CSearchDialog::setModules( const QList<CSwordModuleInfo*> modules )
-{
- m_searchOptionsArea->setModules(modules);
+void CSearchDialog::setModules( const QList<CSwordModuleInfo*> modules ) {
+ m_searchOptionsArea->setModules(modules);
}
/** Returns the search text which is set currently. */
-QString CSearchDialog::searchText() const
-{
- return m_searchOptionsArea->searchText();
+QString CSearchDialog::searchText() const {
+ return m_searchOptionsArea->searchText();
}
-sword::ListKey CSearchDialog::searchScope()
-{
- return m_searchOptionsArea->searchScope();
+sword::ListKey CSearchDialog::searchScope() {
+ return m_searchOptionsArea->searchScope();
}
/** Sets the search text which is used for the search. */
-void CSearchDialog::setSearchText( const QString searchText )
-{
- m_searchOptionsArea->setSearchText(searchText);
+void CSearchDialog::setSearchText( const QString searchText ) {
+ m_searchOptionsArea->setSearchText(searchText);
}
/** Initializes this object. */
-void CSearchDialog::initView()
-{
- QVBoxLayout* verticalLayout = new QVBoxLayout(this);
- setLayout(verticalLayout);
+void CSearchDialog::initView() {
+ QVBoxLayout* verticalLayout = new QVBoxLayout(this);
+ setLayout(verticalLayout);
+
+ m_searchOptionsArea = new BtSearchOptionsArea(this);
+ verticalLayout->addWidget(m_searchOptionsArea);
- m_searchOptionsArea = new BtSearchOptionsArea(this);
- verticalLayout->addWidget(m_searchOptionsArea);
+ m_searchResultArea = new BtSearchResultArea(this);
+ verticalLayout->addWidget(m_searchResultArea);
- m_searchResultArea = new BtSearchResultArea(this);
- verticalLayout->addWidget(m_searchResultArea);
-
- QHBoxLayout* horizontalLayout = new QHBoxLayout();
+ QHBoxLayout* horizontalLayout = new QHBoxLayout();
- m_analyseButton = new QPushButton(tr("&Analyze results..."), 0);
- m_analyseButton->setToolTip(tr("Show a graphical analyzis of the search result"));
- QSpacerItem* spacerItem = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
- horizontalLayout->addWidget(m_analyseButton);
- horizontalLayout->addItem(spacerItem);
+ m_analyseButton = new QPushButton(tr("&Analyze results..."), 0);
+ m_analyseButton->setToolTip(tr("Show a graphical analyzis of the search result"));
+ QSpacerItem* spacerItem = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ horizontalLayout->addWidget(m_analyseButton);
+ horizontalLayout->addItem(spacerItem);
- m_closeButton = new QPushButton(this);
- m_closeButton->setText(tr("&Close"));
- m_closeButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::close_icon));
- horizontalLayout->addWidget(m_closeButton);
+ m_closeButton = new QPushButton(this);
+ m_closeButton->setText(tr("&Close"));
+ m_closeButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::close_icon));
+ horizontalLayout->addWidget(m_closeButton);
- verticalLayout->addLayout(horizontalLayout);
+ verticalLayout->addLayout(horizontalLayout);
- loadDialogSettings();
+ loadDialogSettings();
}
void CSearchDialog::searchFinished() {
- if ( m_searcher.foundItems() ) {
- m_searchResultArea->setSearchResult(modules());
- }
- else {
- m_searchResultArea->reset();
- }
- m_staticDialog->raise();
- m_staticDialog->activateWindow();
+ if ( m_searcher.foundItems() ) {
+ m_searchResultArea->setSearchResult(modules());
+ }
+ else {
+ m_searchResultArea->reset();
+ }
+ m_staticDialog->raise();
+ m_staticDialog->activateWindow();
}
void CSearchDialog::showModulesSelector() {
- m_searchOptionsArea->chooseModules();
+ m_searchOptionsArea->chooseModules();
}
/** Initializes the signal slot connections */
void CSearchDialog::initConnections() {
- // Search button is clicked
- bool ok = connect(m_searchOptionsArea->searchButton(), SIGNAL(clicked()),this, SLOT(startSearch()));
- Q_ASSERT(ok);
- // Return/Enter is pressed in the search text field
- ok = connect(m_searchOptionsArea, SIGNAL(sigStartSearch()), this, SLOT(startSearch()) );
- Q_ASSERT(ok);
+ // Search button is clicked
+ bool ok = connect(m_searchOptionsArea->searchButton(), SIGNAL(clicked()), this, SLOT(startSearch()));
+ Q_ASSERT(ok);
+ // Return/Enter is pressed in the search text field
+ ok = connect(m_searchOptionsArea, SIGNAL(sigStartSearch()), this, SLOT(startSearch()) );
+ Q_ASSERT(ok);
ok = connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
- Q_ASSERT(ok);
+ Q_ASSERT(ok);
- connect(m_analyseButton, SIGNAL(clicked()), m_searchResultArea, SLOT(showAnalysis()));
+ connect(m_analyseButton, SIGNAL(clicked()), m_searchResultArea, SLOT(showAnalysis()));
}
/** Resets the parts to the default. */
void CSearchDialog::reset() {
- m_searchOptionsArea->reset();
- m_searchResultArea->reset();
+ m_searchOptionsArea->reset();
+ m_searchResultArea->reset();
}
void CSearchDialog::closeButtonClicked() {
- // With Qt::WA_DeleteOnClose set, the dialog will be deleted now
- m_staticDialog->close();
+ // With Qt::WA_DeleteOnClose set, the dialog will be deleted now
+ m_staticDialog->close();
}
-void CSearchDialog::loadDialogSettings()
-{
- resize(CBTConfig::get(CBTConfig::searchDialogWidth), CBTConfig::get(CBTConfig::searchDialogHeight));
- move(CBTConfig::get(CBTConfig::searchDialogX), CBTConfig::get(CBTConfig::searchDialogY));
+void CSearchDialog::loadDialogSettings() {
+ resize(CBTConfig::get(CBTConfig::searchDialogWidth), CBTConfig::get(CBTConfig::searchDialogHeight));
+ move(CBTConfig::get(CBTConfig::searchDialogX), CBTConfig::get(CBTConfig::searchDialogY));
}
-void CSearchDialog::saveDialogSettings()
-{
- CBTConfig::set(CBTConfig::searchDialogWidth, size().width());
- CBTConfig::set(CBTConfig::searchDialogHeight, size().height());
- CBTConfig::set(CBTConfig::searchDialogX, x());
- CBTConfig::set(CBTConfig::searchDialogY, y());
+void CSearchDialog::saveDialogSettings() {
+ CBTConfig::set(CBTConfig::searchDialogWidth, size().width());
+ CBTConfig::set(CBTConfig::searchDialogHeight, size().height());
+ CBTConfig::set(CBTConfig::searchDialogX, x());
+ CBTConfig::set(CBTConfig::searchDialogY, y());
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index de46ad3..a250bc7 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -23,8 +23,8 @@
//forward declarations
namespace Search {
- class BtSearchResultArea;
- class BtSearchOptionsArea;
+class BtSearchResultArea;
+class BtSearchOptionsArea;
}
class QWidget;
@@ -37,95 +37,95 @@ namespace Search {
*@author The BibleTime team
*/
class CSearchDialog : public QDialog {
- Q_OBJECT
-
-public:
- static void openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText = QString::null, QWidget* parentDialog = 0);
-
-protected:
- friend class CSearchAnalysisScene;
- friend class CSearchResultArea;
- friend class BtSearchResultArea;
- friend class BibleTime;
-
- /**
- * Only interesting for the class members! Useful to get the searched text etc.
- */
- static CSearchDialog* getSearchDialog();
-
- /**
- * The constructor of the dialog. It's protected because you should use the static public function openDialog.
- * The dialog destroys itself if it was closed.
- */
- CSearchDialog(QWidget *parent);
- ~CSearchDialog();
-
- /**
- * Initializes this object.
- */
- void initView();
- /**
- * Starts the search with the given module list and given search text.
- * Doesn't wait for the start button press, starts immediately
- */
- void startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText);
- /**Prepares the search string given by user for a specific search type */
- QString prepareSearchText(const QString& orig);
- /**
- * Sets the list of modules for the search.
- */
- void setModules( const QList<CSwordModuleInfo*> modules );
- /**
- * Returns the list of used modules.
- */
- QList<CSwordModuleInfo*> modules() const;
- /**
- * Sets the search text which is used for the search.
- */
- void setSearchText( const QString searchText );
- /**
- * Returns the search text which is set currently.
- */
- QString searchText() const;
- /**
- * Returns the used search scope as a list key
- */
- sword::ListKey searchScope();
-
- /**
- * Resets the parts to the default.
- */
- void reset();
- /**
- * Load the settings from the resource file
- */
- void loadDialogSettings();
- /**
- * Save the settings to the resource file
- */
- void saveDialogSettings();
-
-protected slots:
- /**
- * Starts the search with the set modules and the set search text.
- */
- void startSearch();
- void searchFinished();
- void showModulesSelector();
- /**
- * Initializes the signal slot connections
- */
- void initConnections();
-
- void closeButtonClicked();
-
-private:
- QPushButton* m_analyseButton;
- QPushButton* m_closeButton;
- BtSearchResultArea* m_searchResultArea;
- BtSearchOptionsArea* m_searchOptionsArea;
-
- CSwordModuleSearch m_searcher;
+ Q_OBJECT
+
+ public:
+ static void openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText = QString::null, QWidget* parentDialog = 0);
+
+ protected:
+ friend class CSearchAnalysisScene;
+ friend class CSearchResultArea;
+ friend class BtSearchResultArea;
+ friend class BibleTime;
+
+ /**
+ * Only interesting for the class members! Useful to get the searched text etc.
+ */
+ static CSearchDialog* getSearchDialog();
+
+ /**
+ * The constructor of the dialog. It's protected because you should use the static public function openDialog.
+ * The dialog destroys itself if it was closed.
+ */
+ CSearchDialog(QWidget *parent);
+ ~CSearchDialog();
+
+ /**
+ * Initializes this object.
+ */
+ void initView();
+ /**
+ * Starts the search with the given module list and given search text.
+ * Doesn't wait for the start button press, starts immediately
+ */
+ void startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText);
+ /**Prepares the search string given by user for a specific search type */
+ QString prepareSearchText(const QString& orig);
+ /**
+ * Sets the list of modules for the search.
+ */
+ void setModules( const QList<CSwordModuleInfo*> modules );
+ /**
+ * Returns the list of used modules.
+ */
+ QList<CSwordModuleInfo*> modules() const;
+ /**
+ * Sets the search text which is used for the search.
+ */
+ void setSearchText( const QString searchText );
+ /**
+ * Returns the search text which is set currently.
+ */
+ QString searchText() const;
+ /**
+ * Returns the used search scope as a list key
+ */
+ sword::ListKey searchScope();
+
+ /**
+ * Resets the parts to the default.
+ */
+ void reset();
+ /**
+ * Load the settings from the resource file
+ */
+ void loadDialogSettings();
+ /**
+ * Save the settings to the resource file
+ */
+ void saveDialogSettings();
+
+ protected slots:
+ /**
+ * Starts the search with the set modules and the set search text.
+ */
+ void startSearch();
+ void searchFinished();
+ void showModulesSelector();
+ /**
+ * Initializes the signal slot connections
+ */
+ void initConnections();
+
+ void closeButtonClicked();
+
+ private:
+ QPushButton* m_analyseButton;
+ QPushButton* m_closeButton;
+ BtSearchResultArea* m_searchResultArea;
+ BtSearchOptionsArea* m_searchOptionsArea;
+
+ CSwordModuleSearch m_searcher;
};
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp b/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
index cf68f6e..6c183ca 100644
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
+++ b/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
@@ -32,30 +32,27 @@
namespace Search {
CSearchModuleChooserDialog::CSearchModuleChooserDialog( QWidget* parent, QString title, QString label,
- QList<CSwordModuleInfo*> selectedModules)
- : CModuleChooserDialog(parent, title, label),
- m_selectedModules(selectedModules)
-{
- m_hiddenFilter = new BTModuleTreeItem::HiddenOff();
- QList<BTModuleTreeItem::Filter*> filters;
- filters.append(m_hiddenFilter);
- setFilters(filters);
- init();
+ QList<CSwordModuleInfo*> selectedModules)
+ : CModuleChooserDialog(parent, title, label),
+ m_selectedModules(selectedModules) {
+ m_hiddenFilter = new BTModuleTreeItem::HiddenOff();
+ QList<BTModuleTreeItem::Filter*> filters;
+ filters.append(m_hiddenFilter);
+ setFilters(filters);
+ init();
}
-CSearchModuleChooserDialog::~CSearchModuleChooserDialog()
-{
- //see the ctor
- delete m_hiddenFilter;
+CSearchModuleChooserDialog::~CSearchModuleChooserDialog() {
+ //see the ctor
+ delete m_hiddenFilter;
}
-void CSearchModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem)
-{
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- if (m_selectedModules.contains(btItem->moduleInfo()))
- widgetItem->setCheckState(0, Qt::Checked);
- else
- widgetItem->setCheckState(0, Qt::Unchecked);
+void CSearchModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) {
+ widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ if (m_selectedModules.contains(btItem->moduleInfo()))
+ widgetItem->setCheckState(0, Qt::Checked);
+ else
+ widgetItem->setCheckState(0, Qt::Unchecked);
}
} //end of namespace Search
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.h b/src/frontend/searchdialog/csearchmodulechooserdialog.h
index 8d5e32c..ab9f5cc 100644
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.h
+++ b/src/frontend/searchdialog/csearchmodulechooserdialog.h
@@ -1,7 +1,7 @@
//
// C++ Interface: cmodulechooserdialog
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2007
@@ -24,19 +24,18 @@ class BTModuleTreeItem;
namespace Search {
-class CSearchModuleChooserDialog : public CModuleChooserDialog
-{
- Q_OBJECT
-public:
- CSearchModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*> selectedModules);
- ~CSearchModuleChooserDialog();
+class CSearchModuleChooserDialog : public CModuleChooserDialog {
+ Q_OBJECT
+ public:
+ CSearchModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*> selectedModules);
+ ~CSearchModuleChooserDialog();
-protected: // Protected methods
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
+ protected: // Protected methods
+ virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
-private:
- QList<CSwordModuleInfo*> m_selectedModules;
- BTModuleTreeItem::HiddenOff* m_hiddenFilter;
+ private:
+ QList<CSwordModuleInfo*> m_selectedModules;
+ BTModuleTreeItem::HiddenOff* m_hiddenFilter;
};
} //end of namespace Search
diff --git a/src/frontend/searchdialog/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index 74561d6..f13b9d2 100644
--- a/src/frontend/searchdialog/csearchresultview.cpp
+++ b/src/frontend/searchdialog/csearchresultview.cpp
@@ -30,265 +30,259 @@ namespace Search {
CSearchResultView::CSearchResultView(QWidget* parent)
- : QTreeWidget(parent),
- m_module(0)
-{
- initView();
- initConnections();
+ : QTreeWidget(parent),
+ m_module(0) {
+ initView();
+ initConnections();
}
CSearchResultView::~CSearchResultView() {}
/** Initializes the view of this widget. */
-void CSearchResultView::initView()
-{
- setToolTip(tr("Search result of the selected work"));
- setHeaderLabel(tr("Results"));
- setDragEnabled(true);
- setRootIsDecorated( false );
- setSelectionMode(QAbstractItemView::ExtendedSelection);
-
- //setup the popup menu
- m_popup = new QMenu(this);
-
- m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
-
- m_actions.copy.result = new QAction(tr("Reference only"), this);
- QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyItems()) );
- m_actions.copyMenu->addAction(m_actions.copy.result);
-
- m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
- QObject::connect(m_actions.copy.resultWithText, SIGNAL(triggered()),
- this, SLOT(copyItemsWithText()));
- m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
-
- m_popup->addMenu(m_actions.copyMenu);
-
- m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
-
- m_actions.save.result = new QAction(tr("Reference only"), this);
- QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveItems()) );
- m_actions.saveMenu->addAction(m_actions.save.result);
-
- m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
- m_actions.saveMenu->addAction(m_actions.save.resultWithText);
- QObject::connect(m_actions.save.resultWithText, SIGNAL(triggered()), this, SLOT(saveItemsWithText()));
- m_popup->addMenu(m_actions.saveMenu);
-
- m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
-
- m_actions.print.result = new QAction(tr("Reference with text"), this);
- QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printItems()) );
- m_actions.printMenu->addAction(m_actions.print.result);
- m_popup->addMenu(m_actions.printMenu);
+void CSearchResultView::initView() {
+ setToolTip(tr("Search result of the selected work"));
+ setHeaderLabel(tr("Results"));
+ setDragEnabled(true);
+ setRootIsDecorated( false );
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ //setup the popup menu
+ m_popup = new QMenu(this);
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
+ m_actions.copyMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
+
+ m_actions.copy.result = new QAction(tr("Reference only"), this);
+ QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyItems()) );
+ m_actions.copyMenu->addAction(m_actions.copy.result);
+
+ m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
+ QObject::connect(m_actions.copy.resultWithText, SIGNAL(triggered()),
+ this, SLOT(copyItemsWithText()));
+ m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
+
+ m_popup->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
+ m_actions.saveMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
+
+ m_actions.save.result = new QAction(tr("Reference only"), this);
+ QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveItems()) );
+ m_actions.saveMenu->addAction(m_actions.save.result);
+
+ m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
+ m_actions.saveMenu->addAction(m_actions.save.resultWithText);
+ QObject::connect(m_actions.save.resultWithText, SIGNAL(triggered()), this, SLOT(saveItemsWithText()));
+ m_popup->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
+ m_actions.printMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
+
+ m_actions.print.result = new QAction(tr("Reference with text"), this);
+ QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printItems()) );
+ m_actions.printMenu->addAction(m_actions.print.result);
+ m_popup->addMenu(m_actions.printMenu);
}
/** No descriptions */
void CSearchResultView::initConnections() {
- // connect(this, SIGNAL(executed(QListViewItem*)),
- // this, SLOT(executed(QListViewItem*)));
- //TODO: are these right after porting?
- //items: current, previous
- connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
- this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
+ // connect(this, SIGNAL(executed(QListViewItem*)),
+ // this, SLOT(executed(QListViewItem*)));
+ //TODO: are these right after porting?
+ //items: current, previous
+ connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+ this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
/** Setups the list with the given module. */
void CSearchResultView::setupTree(CSwordModuleInfo* m) {
- clear();
-
- if (!m) return;
-
- m_module = m;
- sword::ListKey& result = m->searchResult();
- const int count = result.Count();
- if (!count) return;
-
- setUpdatesEnabled(false);
-
- QTreeWidgetItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
- for (int index = 0; index < count; index++) {
- item = new QTreeWidgetItem(this, oldItem);
- item->setText(0, QString::fromUtf8(result.GetElement(index)->getText()));
- oldItem = item;
- }
-
- setUpdatesEnabled(true);
- //pre-select the first item
- this->setCurrentItem(this->topLevelItem(0), 0);
+ clear();
+
+ if (!m) return;
+
+ m_module = m;
+ sword::ListKey& result = m->searchResult();
+ const int count = result.Count();
+ if (!count) return;
+
+ setUpdatesEnabled(false);
+
+ QTreeWidgetItem* oldItem = 0;
+ QTreeWidgetItem* item = 0;
+ for (int index = 0; index < count; index++) {
+ item = new QTreeWidgetItem(this, oldItem);
+ item->setText(0, QString::fromUtf8(result.GetElement(index)->getText()));
+ oldItem = item;
+ }
+
+ setUpdatesEnabled(true);
+ //pre-select the first item
+ this->setCurrentItem(this->topLevelItem(0), 0);
}
-void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, QStringList* vList)
-{
- clear();
- if (!m) {
- return;
- }
+void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, QStringList* vList) {
+ clear();
+ if (!m) {
+ return;
+ }
- m_module = m;
+ m_module = m;
- if (vList->count() <= 0) {
- return;
- }
+ if (vList->count() <= 0) {
+ return;
+ }
- setUpdatesEnabled(false);
+ setUpdatesEnabled(false);
- QTreeWidgetItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
+ QTreeWidgetItem* oldItem = 0;
+ QTreeWidgetItem* item = 0;
- foreach (QString s, *vList) {
- item = new QTreeWidgetItem(this, oldItem);
- item->setText(0, (s));
- oldItem = item;
- }
+ foreach (QString s, *vList) {
+ item = new QTreeWidgetItem(this, oldItem);
+ item->setText(0, (s));
+ oldItem = item;
+ }
- setUpdatesEnabled(true);
+ setUpdatesEnabled(true);
- //TODO:select the first item
- //setSelected(firstChild(), true);
- //executed(currentItem());
+ //TODO:select the first item
+ //setSelected(firstChild(), true);
+ //executed(currentItem());
}
//TODO: is this still valid?
/** Is connected to the signal executed, which is emitted when a mew item was chosen. */
void CSearchResultView::executed(QTreeWidgetItem* current, QTreeWidgetItem*) {
- if (current){
- emit keySelected(current->text(0));
- }
- else{
- emit keyDeselected();
- }
+ if (current) {
+ emit keySelected(current->text(0));
+ }
+ else {
+ emit keyDeselected();
+ }
}
//TODO: another function?
/** Reimplementation to show the popup menu. */
-void CSearchResultView::contextMenuEvent(QContextMenuEvent* event)
-{
- qDebug("CSearchResultView::showPopup");
- m_popup->exec(event->globalPos());
+void CSearchResultView::contextMenuEvent(QContextMenuEvent* event) {
+ qDebug("CSearchResultView::showPopup");
+ m_popup->exec(event->globalPos());
}
void CSearchResultView::printItems() {
- QList<QTreeWidgetItem*> items = selectedItems();
- CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
-
- QStringList list;
- foreach (QTreeWidgetItem* k, items) {
- list.append( k->text(0) );
- }
- mgr.printKeyList( list, module(), CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() );
+ QList<QTreeWidgetItem*> items = selectedItems();
+ CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
+
+ QStringList list;
+ foreach (QTreeWidgetItem* k, items) {
+ list.append( k->text(0) );
+ }
+ mgr.printKeyList( list, module(), CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() );
}
void CSearchResultView::saveItems() {
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
-
- CSwordModuleInfo* m = module();
- CSwordKey* k = 0;
- QList<QTreeWidgetItem*> items = selectedItems();
- QList<CSwordKey*> keys;
- foreach (QTreeWidgetItem* i, items) {
- k = CSwordKey::createInstance( m );
- k->key(i->text(0));
- keys.append( k );
- }
- mgr.saveKeyList( keys, CExportManager::Text, false);
-
- qDeleteAll(keys);
- keys.clear(); //delete all the keys we created
+ CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
+
+ CSwordModuleInfo* m = module();
+ CSwordKey* k = 0;
+ QList<QTreeWidgetItem*> items = selectedItems();
+ QList<CSwordKey*> keys;
+ foreach (QTreeWidgetItem* i, items) {
+ k = CSwordKey::createInstance( m );
+ k->key(i->text(0));
+ keys.append( k );
+ }
+ mgr.saveKeyList( keys, CExportManager::Text, false);
+
+ qDeleteAll(keys);
+ keys.clear(); //delete all the keys we created
}
void CSearchResultView::saveItemsWithText() {
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
-
- CSwordModuleInfo* m = module();
- CSwordKey* k = 0;
- QList<QTreeWidgetItem*> items = selectedItems();
- QList<CSwordKey*> keys;
- foreach (QTreeWidgetItem* i, items) {
- k = CSwordKey::createInstance( m );
- k->key(i->text(0));
- keys.append( k );
- };
- mgr.saveKeyList( keys, CExportManager::Text, true);
-
- qDeleteAll(keys);
- keys.clear(); //delete all the keys we created
+ CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
+
+ CSwordModuleInfo* m = module();
+ CSwordKey* k = 0;
+ QList<QTreeWidgetItem*> items = selectedItems();
+ QList<CSwordKey*> keys;
+ foreach (QTreeWidgetItem* i, items) {
+ k = CSwordKey::createInstance( m );
+ k->key(i->text(0));
+ keys.append( k );
+ };
+ mgr.saveKeyList( keys, CExportManager::Text, true);
+
+ qDeleteAll(keys);
+ keys.clear(); //delete all the keys we created
}
void CSearchResultView::copyItems() {
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
-
- CSwordModuleInfo* m = module();
- CSwordKey* k = 0;
- QList<QTreeWidgetItem*> items = selectedItems();
- QList<CSwordKey*> keys;
- foreach (QTreeWidgetItem* i, items) {
- k = CSwordKey::createInstance( m );
- k->key(i->text(0));
- keys.append( k );
- };
- mgr.copyKeyList( keys, CExportManager::Text, false);
-
- qDeleteAll(keys);
- keys.clear(); //delete all the keys we created
+ CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
+
+ CSwordModuleInfo* m = module();
+ CSwordKey* k = 0;
+ QList<QTreeWidgetItem*> items = selectedItems();
+ QList<CSwordKey*> keys;
+ foreach (QTreeWidgetItem* i, items) {
+ k = CSwordKey::createInstance( m );
+ k->key(i->text(0));
+ keys.append( k );
+ };
+ mgr.copyKeyList( keys, CExportManager::Text, false);
+
+ qDeleteAll(keys);
+ keys.clear(); //delete all the keys we created
}
void CSearchResultView::copyItemsWithText() {
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
-
- CSwordModuleInfo* m = module();
- CSwordKey* k = 0;
- QList<QTreeWidgetItem*> items = selectedItems();
- QList<CSwordKey*> keys;
- foreach (QTreeWidgetItem* i, items) {
- k = CSwordKey::createInstance( m );
- k->key(i->text(0));
- keys.append( k );
- };
- mgr.copyKeyList( keys, CExportManager::Text, true);
-
- qDeleteAll(keys);
- keys.clear(); //delete all the keys we created
+ CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
+
+ CSwordModuleInfo* m = module();
+ CSwordKey* k = 0;
+ QList<QTreeWidgetItem*> items = selectedItems();
+ QList<CSwordKey*> keys;
+ foreach (QTreeWidgetItem* i, items) {
+ k = CSwordKey::createInstance( m );
+ k->key(i->text(0));
+ keys.append( k );
+ };
+ mgr.copyKeyList( keys, CExportManager::Text, true);
+
+ qDeleteAll(keys);
+ keys.clear(); //delete all the keys we created
}
CSwordModuleInfo* CSearchResultView::module() {
- return m_module;
+ return m_module;
}
//TODO: port this to the new d'n'd
// Q3DragObject* CSearchResultView::dragObject() {
// //return a valid DragObject to make DnD possible!
-//
+//
// /*
// * First get all selected items and fill with them the dndItems list. The return the QDragObject we got from CDRagDropMgr
// */
// CDragDropMgr::ItemList dndItems;
-//
+//
// Q3PtrList<Q3ListViewItem> items = selectedItems();
// for (items.first(); items.current(); items.next()) {
// dndItems.append( CDragDropMgr::Item(m_module->name(), items.current()->text(0), QString::null) ); //no description
// };
-//
+//
// return CDragDropMgr::dragObject(dndItems, viewport());
// }
-QMimeData * CSearchResultView::mimeData ( const QList<QTreeWidgetItem *> items ) const
-{
- BTMimeData* mdata = new BTMimeData(m_module->name(), items.first()->text(0), QString::null);
- foreach (QTreeWidgetItem* i, items) {
- mdata->appendBookmark(m_module->name(), i->text(0), QString::null);
- }
- return mdata;
+QMimeData * CSearchResultView::mimeData ( const QList<QTreeWidgetItem *> items ) const {
+ BTMimeData* mdata = new BTMimeData(m_module->name(), items.first()->text(0), QString::null);
+ foreach (QTreeWidgetItem* i, items) {
+ mdata->appendBookmark(m_module->name(), i->text(0), QString::null);
+ }
+ return mdata;
}
-QStringList CSearchResultView::mimeTypes () const
-{
- return QStringList("BibleTime/Bookmark");
+QStringList CSearchResultView::mimeTypes () const {
+ return QStringList("BibleTime/Bookmark");
}
} //end of namespace
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 4d43bbf..071ccac 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -22,77 +22,77 @@ class CReadDisplay;
namespace Search {
class CSearchResultView : public QTreeWidget {
- Q_OBJECT
-public:
- CSearchResultView(QWidget* parent);
- virtual ~CSearchResultView();
- /** Returns the module which is currently used. */
- CSwordModuleInfo* module();
-
-protected: // Protected methods
- /**
- * Initializes the view of this widget.
- */
- void initView();
- void initConnections();
-
- //from QTreeWidget
- virtual QMimeData * mimeData ( const QList<QTreeWidgetItem *> items ) const;
- virtual QStringList mimeTypes () const;
-
-public slots: // Public slots
- void saveItems();
- /**
- * Setups the list with the given module.
- */
- void setupTree(CSwordModuleInfo*);
- void setupStrongsTree(CSwordModuleInfo*, QStringList*);
- void copyItemsWithText();
- void copyItems();
- void saveItemsWithText();
- /**
- * Reimplementation to show the popup menu.
- */
- virtual void contextMenuEvent(QContextMenuEvent* event);
-
-protected slots: // Protected slots
- void printItems();
-
- /**
- * Is connected to the signal which is emitted when a new item was chosen.
- */
- void executed(QTreeWidgetItem* current, QTreeWidgetItem*);
-
-private:
- struct {
- QMenu* saveMenu;
- struct {
- QAction* result;
- QAction* resultWithText;
- }
- save;
-
- QMenu* printMenu;
- struct {
- QAction* result;
- }
- print;
-
- QMenu* copyMenu;
- struct {
- QAction* result;
- QAction* resultWithText;
- }
- copy;
- }
- m_actions;
-
- QMenu* m_popup;
- CSwordModuleInfo* m_module;
-
-signals: // Signals
- void keySelected(const QString&);
- void keyDeselected();
+ Q_OBJECT
+ public:
+ CSearchResultView(QWidget* parent);
+ virtual ~CSearchResultView();
+ /** Returns the module which is currently used. */
+ CSwordModuleInfo* module();
+
+ protected: // Protected methods
+ /**
+ * Initializes the view of this widget.
+ */
+ void initView();
+ void initConnections();
+
+ //from QTreeWidget
+ virtual QMimeData * mimeData ( const QList<QTreeWidgetItem *> items ) const;
+ virtual QStringList mimeTypes () const;
+
+ public slots: // Public slots
+ void saveItems();
+ /**
+ * Setups the list with the given module.
+ */
+ void setupTree(CSwordModuleInfo*);
+ void setupStrongsTree(CSwordModuleInfo*, QStringList*);
+ void copyItemsWithText();
+ void copyItems();
+ void saveItemsWithText();
+ /**
+ * Reimplementation to show the popup menu.
+ */
+ virtual void contextMenuEvent(QContextMenuEvent* event);
+
+ protected slots: // Protected slots
+ void printItems();
+
+ /**
+ * Is connected to the signal which is emitted when a new item was chosen.
+ */
+ void executed(QTreeWidgetItem* current, QTreeWidgetItem*);
+
+ private:
+ struct {
+ QMenu* saveMenu;
+ struct {
+ QAction* result;
+ QAction* resultWithText;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* result;
+ }
+ print;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* result;
+ QAction* resultWithText;
+ }
+ copy;
+ }
+ m_actions;
+
+ QMenu* m_popup;
+ CSwordModuleInfo* m_module;
+
+ signals: // Signals
+ void keySelected(const QString&);
+ void keyDeselected();
};
} //end of namespace Search
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
index 399b5b1..4d16664 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.cpp
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -21,95 +21,88 @@
// dialog constructor
BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
- : QDialog(parent), m_primaryLabel(0), m_alternateLabel(0), m_primaryButton(0), m_alternateButton(0)
-{
- setWindowTitle(tr("Configure shortcuts"));
- setMinimumWidth(350);
+ : QDialog(parent), m_primaryLabel(0), m_alternateLabel(0), m_primaryButton(0), m_alternateButton(0) {
+ setWindowTitle(tr("Configure shortcuts"));
+ setMinimumWidth(350);
- QVBoxLayout* vLayout = new QVBoxLayout(this);
- setLayout(vLayout);
+ QVBoxLayout* vLayout = new QVBoxLayout(this);
+ setLayout(vLayout);
- QGridLayout* gridLayout = new QGridLayout();
- vLayout->addLayout(gridLayout);
+ QGridLayout* gridLayout = new QGridLayout();
+ vLayout->addLayout(gridLayout);
- m_primaryButton = new QRadioButton(tr("First shortcut"));
- m_primaryButton->setChecked(true);
- gridLayout->addWidget(m_primaryButton, 0, 0);
+ m_primaryButton = new QRadioButton(tr("First shortcut"));
+ m_primaryButton->setChecked(true);
+ gridLayout->addWidget(m_primaryButton, 0, 0);
- m_alternateButton = new QRadioButton(tr("Second shortcut"));
- gridLayout->addWidget(m_alternateButton, 1, 0);
+ m_alternateButton = new QRadioButton(tr("Second shortcut"));
+ gridLayout->addWidget(m_alternateButton, 1, 0);
- m_primaryLabel = new QLabel();
- m_primaryLabel->setMinimumWidth(100);
- m_primaryLabel->setFrameShape(QFrame::Panel);
- gridLayout->addWidget(m_primaryLabel, 0, 1);
+ m_primaryLabel = new QLabel();
+ m_primaryLabel->setMinimumWidth(100);
+ m_primaryLabel->setFrameShape(QFrame::Panel);
+ gridLayout->addWidget(m_primaryLabel, 0, 1);
- m_alternateLabel = new QLabel();
- m_alternateLabel->setMinimumWidth(100);
- m_alternateLabel->setFrameShape(QFrame::Panel);
- gridLayout->addWidget(m_alternateLabel, 1, 1);
+ m_alternateLabel = new QLabel();
+ m_alternateLabel->setMinimumWidth(100);
+ m_alternateLabel->setFrameShape(QFrame::Panel);
+ gridLayout->addWidget(m_alternateLabel, 1, 1);
- QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- vLayout->addWidget(buttons);
+ QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ vLayout->addWidget(buttons);
- connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
}
// get new primary key from dialog
-QString BtShortcutsDialog::getFirstKeys()
-{
- return m_primaryLabel->text();
+QString BtShortcutsDialog::getFirstKeys() {
+ return m_primaryLabel->text();
}
// set the initial value of the primary key
-void BtShortcutsDialog::setFirstKeys(const QString& keys)
-{
- m_primaryLabel->setText(keys);
+void BtShortcutsDialog::setFirstKeys(const QString& keys) {
+ m_primaryLabel->setText(keys);
}
- // get new second keys from dialog
-QString BtShortcutsDialog::getSecondKeys()
-{
- return m_alternateLabel->text();
+// get new second keys from dialog
+QString BtShortcutsDialog::getSecondKeys() {
+ return m_alternateLabel->text();
}
// set the initial value of the second keys
-void BtShortcutsDialog::setSecondKeys(const QString& keys)
-{
- m_alternateLabel->setText(keys);
+void BtShortcutsDialog::setSecondKeys(const QString& keys) {
+ m_alternateLabel->setText(keys);
}
// get key from users input, put into primary or alternate label for display to user
-void BtShortcutsDialog::keyReleaseEvent(QKeyEvent* event)
-{
- int key = event->key();
- if ( (key == Qt::Key_Shift) || (key == Qt::Key_Control) || (key == Qt::Key_Meta) || (key == Qt::Key_Alt) )
- return;
-
- QKeySequence keys(key);
- QString keyStr = keys.toString();
- if ( (event->modifiers() & Qt::AltModifier) == Qt::AltModifier)
- keyStr = "Alt+" + keyStr;
- if ( (event->modifiers() & Qt::ShiftModifier) == Qt::ShiftModifier)
- keyStr = "Shift+" + keyStr;
- if ( (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)
- keyStr = "Ctrl+" + keyStr;
-
- QKeySequence completeKeys(keyStr);
- QString completeStr = completeKeys.toString();
-
- keyChangeRequest(completeStr);
+void BtShortcutsDialog::keyReleaseEvent(QKeyEvent* event) {
+ int key = event->key();
+ if ( (key == Qt::Key_Shift) || (key == Qt::Key_Control) || (key == Qt::Key_Meta) || (key == Qt::Key_Alt) )
+ return;
+
+ QKeySequence keys(key);
+ QString keyStr = keys.toString();
+ if ( (event->modifiers() & Qt::AltModifier) == Qt::AltModifier)
+ keyStr = "Alt+" + keyStr;
+ if ( (event->modifiers() & Qt::ShiftModifier) == Qt::ShiftModifier)
+ keyStr = "Shift+" + keyStr;
+ if ( (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)
+ keyStr = "Ctrl+" + keyStr;
+
+ QKeySequence completeKeys(keyStr);
+ QString completeStr = completeKeys.toString();
+
+ keyChangeRequest(completeStr);
}
// complete the keyChangeRequest
-void BtShortcutsDialog::changeSelectedShortcut(const QString& keys)
-{
- if (m_primaryButton->isChecked())
- m_primaryLabel->setText(keys);
+void BtShortcutsDialog::changeSelectedShortcut(const QString& keys) {
+ if (m_primaryButton->isChecked())
+ m_primaryLabel->setText(keys);
- if (m_alternateButton->isChecked())
- m_alternateLabel->setText(keys);
+ if (m_alternateButton->isChecked())
+ m_alternateLabel->setText(keys);
}
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
index b9cd6f0..f2d439d 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.h
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -19,41 +19,40 @@ class QRadioButton;
// *************** BtShortcutsDialog ***************************************************************************
// A dialog to allow the user to input a shortcut for a primary and alternate key
-class BtShortcutsDialog : public QDialog
-{
- Q_OBJECT;
-public:
- BtShortcutsDialog(QWidget* parent);
+class BtShortcutsDialog : public QDialog {
+ Q_OBJECT;
+ public:
+ BtShortcutsDialog(QWidget* parent);
- // get new first keys from dialog
- QString getFirstKeys();
+ // get new first keys from dialog
+ QString getFirstKeys();
- // set the initial value of the first keys
- void setFirstKeys(const QString& keys);
-
- // get new second keys from dialog
- QString getSecondKeys();
+ // set the initial value of the first keys
+ void setFirstKeys(const QString& keys);
- // set the initial value of the second keys
- void setSecondKeys(const QString& keys);
+ // get new second keys from dialog
+ QString getSecondKeys();
- // change the First or Second shortcut in the dialog
- void changeSelectedShortcut(const QString& keys);
+ // set the initial value of the second keys
+ void setSecondKeys(const QString& keys);
-signals:
- // make a keyChangeRequest back to the application
- void keyChangeRequest(const QString& keys);
+ // change the First or Second shortcut in the dialog
+ void changeSelectedShortcut(const QString& keys);
-protected:
- // get key from users input, put into primary or alternate label for display to user
- void keyReleaseEvent(QKeyEvent* event);
+ signals:
+ // make a keyChangeRequest back to the application
+ void keyChangeRequest(const QString& keys);
-private:
- QLabel* m_primaryLabel;
- QLabel* m_alternateLabel;
- QRadioButton* m_primaryButton;
- QRadioButton* m_alternateButton;
+ protected:
+ // get key from users input, put into primary or alternate label for display to user
+ void keyReleaseEvent(QKeyEvent* event);
+
+ private:
+ QLabel* m_primaryLabel;
+ QLabel* m_alternateLabel;
+ QRadioButton* m_primaryButton;
+ QRadioButton* m_alternateButton;
};
#endif
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index 7d50247..0be1d0a 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.cpp
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -28,386 +28,351 @@
// BtShortcutsEditorItem is the widget for the first column of the BtShortcutsEditor
// It holds extra information about the action
-class BtShortcutsEditorItem : public QTableWidgetItem
-{
-public:
- BtShortcutsEditorItem(QAction* action);
- ~BtShortcutsEditorItem();
- void commitChanges();
- QKeySequence getDefaultKeys();
- void setDefaultKeys(QKeySequence keys);
- void setFirstHotkey(QKeySequence keys);
- void setSecondHotkey(const QString& keys);
- QAction* getAction();
- void deleteHotkeys();
-
-private:
- QAction *m_action;
- QKeySequence *m_newFirstHotkey;
- QKeySequence *m_newSecondHotkey;
- QKeySequence m_defaultKeys;
+class BtShortcutsEditorItem : public QTableWidgetItem {
+ public:
+ BtShortcutsEditorItem(QAction* action);
+ ~BtShortcutsEditorItem();
+ void commitChanges();
+ QKeySequence getDefaultKeys();
+ void setDefaultKeys(QKeySequence keys);
+ void setFirstHotkey(QKeySequence keys);
+ void setSecondHotkey(const QString& keys);
+ QAction* getAction();
+ void deleteHotkeys();
+
+ private:
+ QAction *m_action;
+ QKeySequence *m_newFirstHotkey;
+ QKeySequence *m_newSecondHotkey;
+ QKeySequence m_defaultKeys;
};
BtShortcutsEditorItem::BtShortcutsEditorItem(QAction* action)
- : m_action(action), m_newFirstHotkey(0), m_newSecondHotkey(0)
-{
- QList<QKeySequence> list = m_action->shortcuts();
- if (list.count()>0)
- m_newFirstHotkey = new QKeySequence(list.at(0));
- if (list.count()>1)
- m_newSecondHotkey = new QKeySequence(list.at(1));
+ : m_action(action), m_newFirstHotkey(0), m_newSecondHotkey(0) {
+ QList<QKeySequence> list = m_action->shortcuts();
+ if (list.count() > 0)
+ m_newFirstHotkey = new QKeySequence(list.at(0));
+ if (list.count() > 1)
+ m_newSecondHotkey = new QKeySequence(list.at(1));
}
-BtShortcutsEditorItem::~BtShortcutsEditorItem()
-{
- delete m_newFirstHotkey;
- delete m_newSecondHotkey;
+BtShortcutsEditorItem::~BtShortcutsEditorItem() {
+ delete m_newFirstHotkey;
+ delete m_newSecondHotkey;
}
-QAction* BtShortcutsEditorItem::getAction()
-{
- return m_action;
+QAction* BtShortcutsEditorItem::getAction() {
+ return m_action;
}
-QKeySequence BtShortcutsEditorItem::getDefaultKeys()
-{
- return m_defaultKeys;
+QKeySequence BtShortcutsEditorItem::getDefaultKeys() {
+ return m_defaultKeys;
}
-void BtShortcutsEditorItem::setDefaultKeys(QKeySequence keys)
-{
- m_defaultKeys = keys;
+void BtShortcutsEditorItem::setDefaultKeys(QKeySequence keys) {
+ m_defaultKeys = keys;
}
-void BtShortcutsEditorItem::setFirstHotkey(QKeySequence keys)
-{
- if (m_newFirstHotkey == 0)
- m_newFirstHotkey = new QKeySequence();
- *m_newFirstHotkey = keys;
+void BtShortcutsEditorItem::setFirstHotkey(QKeySequence keys) {
+ if (m_newFirstHotkey == 0)
+ m_newFirstHotkey = new QKeySequence();
+ *m_newFirstHotkey = keys;
}
-void BtShortcutsEditorItem::setSecondHotkey(const QString& keys)
-{
- if (m_newSecondHotkey == 0)
- m_newSecondHotkey = new QKeySequence();
- *m_newSecondHotkey = QKeySequence(keys);
+void BtShortcutsEditorItem::setSecondHotkey(const QString& keys) {
+ if (m_newSecondHotkey == 0)
+ m_newSecondHotkey = new QKeySequence();
+ *m_newSecondHotkey = QKeySequence(keys);
}
// Deletes hotkey information
-void BtShortcutsEditorItem::deleteHotkeys()
-{
- delete m_newFirstHotkey;
- m_newFirstHotkey = 0;
- delete m_newSecondHotkey;
- m_newSecondHotkey = 0;
+void BtShortcutsEditorItem::deleteHotkeys() {
+ delete m_newFirstHotkey;
+ m_newFirstHotkey = 0;
+ delete m_newSecondHotkey;
+ m_newSecondHotkey = 0;
}
// Moves the hotkey information into the QAction variable
-void BtShortcutsEditorItem::commitChanges()
-{
- QString actionName = text();
- QList<QKeySequence> list;
- if ( (m_newFirstHotkey != 0) && (*m_newFirstHotkey != QKeySequence()) )
- {
- list << *m_newFirstHotkey;
- }
- if ( (m_newSecondHotkey != 0) && (*m_newSecondHotkey != QKeySequence()) )
- list << *m_newSecondHotkey;
-
- if (m_action != 0)
- m_action->setShortcuts(list);
+void BtShortcutsEditorItem::commitChanges() {
+ QString actionName = text();
+ QList<QKeySequence> list;
+ if ( (m_newFirstHotkey != 0) && (*m_newFirstHotkey != QKeySequence()) ) {
+ list << *m_newFirstHotkey;
+ }
+ if ( (m_newSecondHotkey != 0) && (*m_newSecondHotkey != QKeySequence()) )
+ list << *m_newSecondHotkey;
+
+ if (m_action != 0)
+ m_action->setShortcuts(list);
}
// ******************* BtShortcutsEditor *******************************************************
BtShortcutsEditor::BtShortcutsEditor(BtActionCollection* collection, QWidget* parent)
- : QWidget(parent), m_dlg(new BtShortcutsDialog(this)), m_table(0), m_shortcutChooser(0), m_noneButton(0), m_defaultButton(0),
- m_customButton(0), m_defaultLabelValue(0), m_currentRow(-1)
-{
- init();
- addCollection(collection);
- bool ok = connect(m_dlg, SIGNAL(keyChangeRequest(const QString&)), this, SLOT(makeKeyChangeRequest(const QString&)) );
- Q_ASSERT(ok);
+ : QWidget(parent), m_dlg(new BtShortcutsDialog(this)), m_table(0), m_shortcutChooser(0), m_noneButton(0), m_defaultButton(0),
+ m_customButton(0), m_defaultLabelValue(0), m_currentRow(-1) {
+ init();
+ addCollection(collection);
+ bool ok = connect(m_dlg, SIGNAL(keyChangeRequest(const QString&)), this, SLOT(makeKeyChangeRequest(const QString&)) );
+ Q_ASSERT(ok);
}
BtShortcutsEditor::BtShortcutsEditor(QWidget* parent)
- : QWidget(parent), m_table(0)
-{
- init();
+ : QWidget(parent), m_table(0) {
+ init();
}
// initialize this widget
-void BtShortcutsEditor::init()
-{
- QVBoxLayout* vBox = new QVBoxLayout(this);
- setLayout(vBox);
+void BtShortcutsEditor::init() {
+ QVBoxLayout* vBox = new QVBoxLayout(this);
+ setLayout(vBox);
- m_table = createShortcutsTable();
- vBox->addWidget(m_table);
+ m_table = createShortcutsTable();
+ vBox->addWidget(m_table);
- m_shortcutChooser = createShortcutChooser();
- vBox->addWidget(m_shortcutChooser);
+ m_shortcutChooser = createShortcutChooser();
+ vBox->addWidget(m_shortcutChooser);
}
// get the shortcut editor item from the zeroth column of the table
-BtShortcutsEditorItem* BtShortcutsEditor::getShortcutsEditor(int row)
-{
- QTableWidgetItem* item = m_table->item(row,0);
- BtShortcutsEditorItem* btItem = dynamic_cast<BtShortcutsEditorItem*>(item);
- return btItem;
+BtShortcutsEditorItem* BtShortcutsEditor::getShortcutsEditor(int row) {
+ QTableWidgetItem* item = m_table->item(row, 0);
+ BtShortcutsEditorItem* btItem = dynamic_cast<BtShortcutsEditorItem*>(item);
+ return btItem;
}
// saves shortcut keys into the QAction
-void BtShortcutsEditor::commitChanges()
-{
- int rows = m_table->rowCount();
- for (int row=0; row<rows; row++)
- {
- BtShortcutsEditorItem* btItem = getShortcutsEditor(row);
- if (btItem != 0)
- btItem->commitChanges();
- }
+void BtShortcutsEditor::commitChanges() {
+ int rows = m_table->rowCount();
+ for (int row = 0; row < rows; row++) {
+ BtShortcutsEditorItem* btItem = getShortcutsEditor(row);
+ if (btItem != 0)
+ btItem->commitChanges();
+ }
}
// puts actions and shortcut keys into QTableWidget
-void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title)
-{
- QList<QAction*> actionList = collection->actions();
- int count;
- count = actionList.count();
- foreach (QAction *action, collection->actions())
- {
- if (action)
- {
- int count = m_table->rowCount();
- m_table->insertRow(count);
-
- QString name = action->text().remove('&');
- QList<QKeySequence> keys = action->shortcuts();
- QIcon icon = action->icon();
- QKeySequence defaultKeys = collection->getDefaultShortcut(action);
-
- BtShortcutsEditorItem* item = new BtShortcutsEditorItem(action);
- item->setText(name);
- item->setIcon(icon);
- item->setDefaultKeys(defaultKeys);
- item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
- m_table->setItem(count, 0, item);
-
- QTableWidgetItem* item1 = new QTableWidgetItem();
- item1->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
- item1->setToolTip(tr("Select to change key"));
- if (keys.count() > 0)
- item1->setText(keys[0].toString());
- m_table->setItem(count,1,item1);
-
- QTableWidgetItem* item2 = new QTableWidgetItem();
- item2->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
- item2->setToolTip(tr("Select to change key"));
- if (keys.count() > 1)
- item2->setText(keys[1].toString());
- m_table->setItem(count,2,item2);
- }
- }
- m_table->sortItems(0);
- m_table->selectRow(0);
- changeRow(0,0);
+void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title) {
+ QList<QAction*> actionList = collection->actions();
+ int count;
+ count = actionList.count();
+ foreach (QAction *action, collection->actions()) {
+ if (action) {
+ int count = m_table->rowCount();
+ m_table->insertRow(count);
+
+ QString name = action->text().remove('&');
+ QList<QKeySequence> keys = action->shortcuts();
+ QIcon icon = action->icon();
+ QKeySequence defaultKeys = collection->getDefaultShortcut(action);
+
+ BtShortcutsEditorItem* item = new BtShortcutsEditorItem(action);
+ item->setText(name);
+ item->setIcon(icon);
+ item->setDefaultKeys(defaultKeys);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ m_table->setItem(count, 0, item);
+
+ QTableWidgetItem* item1 = new QTableWidgetItem();
+ item1->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item1->setToolTip(tr("Select to change key"));
+ if (keys.count() > 0)
+ item1->setText(keys[0].toString());
+ m_table->setItem(count, 1, item1);
+
+ QTableWidgetItem* item2 = new QTableWidgetItem();
+ item2->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item2->setToolTip(tr("Select to change key"));
+ if (keys.count() > 1)
+ item2->setText(keys[1].toString());
+ m_table->setItem(count, 2, item2);
+ }
+ }
+ m_table->sortItems(0);
+ m_table->selectRow(0);
+ changeRow(0, 0);
}
// create the action and shortcuts table
-QTableWidget* BtShortcutsEditor::createShortcutsTable()
-{
- QTableWidget* table = new QTableWidget(this);
- table->setColumnCount(3);
- table->setAlternatingRowColors(true);
- table->setSelectionBehavior(QAbstractItemView::SelectRows);
- QStringList headerList;
- headerList << tr("Action\nname") << tr("First\nshortcut") << tr("Second\nshortcut");
- table->setHorizontalHeaderLabels(headerList);
- table->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
- table->horizontalHeader()->resizeSection(0, 180);
- table->horizontalHeader()->resizeSection(1, 100);
- table->horizontalHeader()->setStretchLastSection(true);
- table->verticalHeader()->setVisible(false);
- table->setShowGrid(false);
- bool ok = connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(changeRow(int,int)));
- Q_ASSERT(ok);
- return table;
+QTableWidget* BtShortcutsEditor::createShortcutsTable() {
+ QTableWidget* table = new QTableWidget(this);
+ table->setColumnCount(3);
+ table->setAlternatingRowColors(true);
+ table->setSelectionBehavior(QAbstractItemView::SelectRows);
+ QStringList headerList;
+ headerList << tr("Action\nname") << tr("First\nshortcut") << tr("Second\nshortcut");
+ table->setHorizontalHeaderLabels(headerList);
+ table->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ table->horizontalHeader()->resizeSection(0, 180);
+ table->horizontalHeader()->resizeSection(1, 100);
+ table->horizontalHeader()->setStretchLastSection(true);
+ table->verticalHeader()->setVisible(false);
+ table->setShowGrid(false);
+ bool ok = connect(table, SIGNAL(cellClicked(int, int)), this, SLOT(changeRow(int, int)));
+ Q_ASSERT(ok);
+ return table;
}
// called when a different action name row is selected
-void BtShortcutsEditor::changeRow(int row, int column)
-{
- BtShortcutsEditorItem* item = getShortcutsEditor(row);
- m_currentRow = row;
- QKeySequence defaultKeys = item->getDefaultKeys();
-
- m_defaultLabelValue->setText(defaultKeys);
-
- QTableWidgetItem* item1 = m_table->item(row,1);
- QString shortcut = item1->text();
-
- QTableWidgetItem* item2 = m_table->item(row,2);
- QString alternate = item2->text();
-
- QString bothKeys = shortcut;
- if (!alternate.isEmpty())
- bothKeys = bothKeys + "; " + alternate;
- m_customPushButton->setText(bothKeys);
-
- if ( bothKeys == defaultKeys.toString())
- m_defaultButton->setChecked(true);
- else if (bothKeys.isEmpty())
- m_noneButton->setChecked(true);
- else
- m_customButton->setChecked(true);
+void BtShortcutsEditor::changeRow(int row, int column) {
+ BtShortcutsEditorItem* item = getShortcutsEditor(row);
+ m_currentRow = row;
+ QKeySequence defaultKeys = item->getDefaultKeys();
+
+ m_defaultLabelValue->setText(defaultKeys);
+
+ QTableWidgetItem* item1 = m_table->item(row, 1);
+ QString shortcut = item1->text();
+
+ QTableWidgetItem* item2 = m_table->item(row, 2);
+ QString alternate = item2->text();
+
+ QString bothKeys = shortcut;
+ if (!alternate.isEmpty())
+ bothKeys = bothKeys + "; " + alternate;
+ m_customPushButton->setText(bothKeys);
+
+ if ( bothKeys == defaultKeys.toString())
+ m_defaultButton->setChecked(true);
+ else if (bothKeys.isEmpty())
+ m_noneButton->setChecked(true);
+ else
+ m_customButton->setChecked(true);
}
// create the area below the table where the shortcuts are edited
-QWidget* BtShortcutsEditor::createShortcutChooser()
-{
- QGroupBox* box = new QGroupBox(tr("Shortcut for selected action name"), this);
- box->setFlat(false);
- QVBoxLayout* vLayout = new QVBoxLayout(box);
- QHBoxLayout* hLayout = new QHBoxLayout();
- vLayout->addLayout(hLayout);
-
- m_noneButton = new QRadioButton(tr("None"), box);
- hLayout->addWidget(m_noneButton);
- bool ok = connect(m_noneButton, SIGNAL(clicked(bool)), this, SLOT(noneButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_defaultButton = new QRadioButton(tr("Default"), box);
- hLayout->addWidget(m_defaultButton);
- ok = connect(m_defaultButton, SIGNAL(clicked(bool)), this, SLOT(defaultButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_customButton = new QRadioButton(tr("Custom"), box);
- hLayout->addWidget(m_customButton);
- ok = connect(m_customButton, SIGNAL(clicked(bool)), this, SLOT(customButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_customPushButton = new QPushButton(box);
- m_customPushButton->setMinimumWidth(140);
- hLayout->addWidget(m_customPushButton);
-
- QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hLayout->addItem(spacer);
-
- QHBoxLayout* hLayout2 = new QHBoxLayout();
- vLayout->addLayout(hLayout2);
-
- QLabel* defaultLabel = new QLabel(tr("Default key:"), box);
- hLayout2->addWidget(defaultLabel);
-
- m_defaultLabelValue = new QLabel(box);
- hLayout2->addWidget(m_defaultLabelValue);
-
- QSpacerItem* spacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hLayout2->addItem(spacer2);
-
- return box;
+QWidget* BtShortcutsEditor::createShortcutChooser() {
+ QGroupBox* box = new QGroupBox(tr("Shortcut for selected action name"), this);
+ box->setFlat(false);
+ QVBoxLayout* vLayout = new QVBoxLayout(box);
+ QHBoxLayout* hLayout = new QHBoxLayout();
+ vLayout->addLayout(hLayout);
+
+ m_noneButton = new QRadioButton(tr("None"), box);
+ hLayout->addWidget(m_noneButton);
+ bool ok = connect(m_noneButton, SIGNAL(clicked(bool)), this, SLOT(noneButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_defaultButton = new QRadioButton(tr("Default"), box);
+ hLayout->addWidget(m_defaultButton);
+ ok = connect(m_defaultButton, SIGNAL(clicked(bool)), this, SLOT(defaultButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_customButton = new QRadioButton(tr("Custom"), box);
+ hLayout->addWidget(m_customButton);
+ ok = connect(m_customButton, SIGNAL(clicked(bool)), this, SLOT(customButtonClicked(bool)));
+ Q_ASSERT(ok);
+
+ m_customPushButton = new QPushButton(box);
+ m_customPushButton->setMinimumWidth(140);
+ hLayout->addWidget(m_customPushButton);
+
+ QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hLayout->addItem(spacer);
+
+ QHBoxLayout* hLayout2 = new QHBoxLayout();
+ vLayout->addLayout(hLayout2);
+
+ QLabel* defaultLabel = new QLabel(tr("Default key:"), box);
+ hLayout2->addWidget(defaultLabel);
+
+ m_defaultLabelValue = new QLabel(box);
+ hLayout2->addWidget(m_defaultLabelValue);
+
+ QSpacerItem* spacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ hLayout2->addItem(spacer2);
+
+ return box;
}
// called when the none radio button is clicked
-void BtShortcutsEditor::noneButtonClicked(bool checked)
-{
- if (m_currentRow < 0)
- return;
- BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
- m_customPushButton->setText("");
- item->deleteHotkeys();
- item->setFirstHotkey(QKeySequence(""));
- m_table->item(m_currentRow,1)->setText("");
- m_table->item(m_currentRow,2)->setText("");
+void BtShortcutsEditor::noneButtonClicked(bool checked) {
+ if (m_currentRow < 0)
+ return;
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ m_customPushButton->setText("");
+ item->deleteHotkeys();
+ item->setFirstHotkey(QKeySequence(""));
+ m_table->item(m_currentRow, 1)->setText("");
+ m_table->item(m_currentRow, 2)->setText("");
}
// called when the default radio button is clicked
-void BtShortcutsEditor::defaultButtonClicked(bool checked)
-{
- if (m_currentRow < 0)
- return;
- BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
- QKeySequence defaultKeys = item->getDefaultKeys();
- item->deleteHotkeys();
- item->setFirstHotkey(defaultKeys);
- m_customPushButton->setText(defaultKeys);
- m_table->item(m_currentRow,1)->setText(defaultKeys);
- m_table->item(m_currentRow,2)->setText("");
+void BtShortcutsEditor::defaultButtonClicked(bool checked) {
+ if (m_currentRow < 0)
+ return;
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ QKeySequence defaultKeys = item->getDefaultKeys();
+ item->deleteHotkeys();
+ item->setFirstHotkey(defaultKeys);
+ m_customPushButton->setText(defaultKeys);
+ m_table->item(m_currentRow, 1)->setText(defaultKeys);
+ m_table->item(m_currentRow, 2)->setText("");
}
// called when the custom radio button is clicked
-void BtShortcutsEditor::customButtonClicked(bool checked)
-{
- if (m_currentRow < 0)
- return;
-
- QString priKeys = m_table->item(m_currentRow,1)->text();
- QString altKeys = m_table->item(m_currentRow,2)->text();
- m_dlg->setSecondKeys(altKeys);
- m_dlg->setFirstKeys(priKeys);
- int code = m_dlg->exec();
- if (code == QDialog::Accepted)
- {
- QString newPriKeys = m_dlg->getFirstKeys();
- QString newAltKeys = m_dlg->getSecondKeys();
- if (newPriKeys == newAltKeys)
- newAltKeys = "";
- BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
- item->setFirstHotkey(newPriKeys);
- item->setSecondHotkey(newAltKeys);
- m_table->item(m_currentRow,1)->setText(newPriKeys);
- m_table->item(m_currentRow,2)->setText(newAltKeys);
- }
+void BtShortcutsEditor::customButtonClicked(bool checked) {
+ if (m_currentRow < 0)
+ return;
+
+ QString priKeys = m_table->item(m_currentRow, 1)->text();
+ QString altKeys = m_table->item(m_currentRow, 2)->text();
+ m_dlg->setSecondKeys(altKeys);
+ m_dlg->setFirstKeys(priKeys);
+ int code = m_dlg->exec();
+ if (code == QDialog::Accepted) {
+ QString newPriKeys = m_dlg->getFirstKeys();
+ QString newAltKeys = m_dlg->getSecondKeys();
+ if (newPriKeys == newAltKeys)
+ newAltKeys = "";
+ BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
+ item->setFirstHotkey(newPriKeys);
+ item->setSecondHotkey(newAltKeys);
+ m_table->item(m_currentRow, 1)->setText(newPriKeys);
+ m_table->item(m_currentRow, 2)->setText(newAltKeys);
+ }
}
// complete the keyChangeRequest
-void BtShortcutsEditor::makeKeyChangeRequest(const QString& keys)
-{
- // signal the application that this BtShortcutsEditor wants to change this shortcut (keys)
- // The application will check other BtShortcutsEditors and put out a message if the shortcut
- // is already in use. If the user requests reassignment, the application calls the BtShortcutsEditors to
- // reassign and set the shortcut.
- keyChangeRequest(this, keys);
+void BtShortcutsEditor::makeKeyChangeRequest(const QString& keys) {
+ // signal the application that this BtShortcutsEditor wants to change this shortcut (keys)
+ // The application will check other BtShortcutsEditors and put out a message if the shortcut
+ // is already in use. If the user requests reassignment, the application calls the BtShortcutsEditors to
+ // reassign and set the shortcut.
+ keyChangeRequest(this, keys);
}
// used by application to complete the keyChangeRequest signal
// stores "keys" into the custom shortcuts dialog field
-void BtShortcutsEditor::changeShortcutInDialog(const QString& keys)
-{
- m_dlg->changeSelectedShortcut(keys);
+void BtShortcutsEditor::changeShortcutInDialog(const QString& keys) {
+ m_dlg->changeSelectedShortcut(keys);
}
// clears any shortcut keys in the table matching the specified keys
-void BtShortcutsEditor::clearConflictWithKeys(const QString& keys)
-{
- QString conflict;
- for (int row=0; row<m_table->rowCount(); row++)
- {
- BtShortcutsEditorItem* item = getShortcutsEditor(row);
- if (m_table->item(row,1)->text() == keys)
- {
- m_table->item(row,1)->setText("");
- item->setFirstHotkey(QKeySequence(""));
- }
- if (m_table->item(row,2)->text() == keys)
- {
- m_table->item(row,2)->setText("");
- item->setSecondHotkey(QKeySequence(""));
- }
- }
+void BtShortcutsEditor::clearConflictWithKeys(const QString& keys) {
+ QString conflict;
+ for (int row = 0; row < m_table->rowCount(); row++) {
+ BtShortcutsEditorItem* item = getShortcutsEditor(row);
+ if (m_table->item(row, 1)->text() == keys) {
+ m_table->item(row, 1)->setText("");
+ item->setFirstHotkey(QKeySequence(""));
+ }
+ if (m_table->item(row, 2)->text() == keys) {
+ m_table->item(row, 2)->setText("");
+ item->setSecondHotkey(QKeySequence(""));
+ }
+ }
}
// finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
-QString BtShortcutsEditor::findConflictWithKeys(const QString& keys)
-{
- QString conflict;
- for (int i=0; i<m_table->rowCount(); i++)
- {
- if ( (m_table->item(i,1)->text() == keys) || (m_table->item(i,2)->text() == keys) )
- return m_table->item(i,0)->text();
- }
- return conflict;
+QString BtShortcutsEditor::findConflictWithKeys(const QString& keys) {
+ QString conflict;
+ for (int i = 0; i < m_table->rowCount(); i++) {
+ if ( (m_table->item(i, 1)->text() == keys) || (m_table->item(i, 2)->text() == keys) )
+ return m_table->item(i, 0)->text();
+ }
+ return conflict;
}
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
index 5003d6d..017ac19 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.h
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -23,73 +23,72 @@ class QTableWidget;
class QLabel;
// This class is the table in the center of the Shortcuts page of the config dialog
-class BtShortcutsEditor : public QWidget
-{
- Q_OBJECT
-public:
- BtShortcutsEditor(BtActionCollection* collection, QWidget* parent);
- BtShortcutsEditor(QWidget* parent);
+class BtShortcutsEditor : public QWidget {
+ Q_OBJECT
+ public:
+ BtShortcutsEditor(BtActionCollection* collection, QWidget* parent);
+ BtShortcutsEditor(QWidget* parent);
- // saves shortcut keys into the QAction
- void commitChanges();
+ // saves shortcut keys into the QAction
+ void commitChanges();
- // puts actions and shortcut keys into QTableWidget
- void addCollection(BtActionCollection* collection, const QString& title = QString());
+ // puts actions and shortcut keys into QTableWidget
+ void addCollection(BtActionCollection* collection, const QString& title = QString());
- // clears any shortcut keys in the table matching the specified keys
- void clearConflictWithKeys(const QString& keys);
+ // clears any shortcut keys in the table matching the specified keys
+ void clearConflictWithKeys(const QString& keys);
- // finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
- QString findConflictWithKeys(const QString& keys);
+ // finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
+ QString findConflictWithKeys(const QString& keys);
- // used by application to complete the keyChangeRequest signal
- // stores "keys" into the custom shortcuts dialog field
- void changeShortcutInDialog(const QString& keys);
+ // used by application to complete the keyChangeRequest signal
+ // stores "keys" into the custom shortcuts dialog field
+ void changeShortcutInDialog(const QString& keys);
-signals:
- // make a keyChangeRequest back to the application
- void keyChangeRequest(BtShortcutsEditor*, const QString& keys);
+ signals:
+ // make a keyChangeRequest back to the application
+ void keyChangeRequest(BtShortcutsEditor*, const QString& keys);
-private slots:
+ private slots:
- // called when a different action name row is selected
- void changeRow(int row, int column);
+ // called when a different action name row is selected
+ void changeRow(int row, int column);
- // called when the none radio button is clicked
- void noneButtonClicked(bool checked);
+ // called when the none radio button is clicked
+ void noneButtonClicked(bool checked);
- // called when the default radio button is clicked
- void defaultButtonClicked(bool checked);
+ // called when the default radio button is clicked
+ void defaultButtonClicked(bool checked);
- // called when the custom radio button is clicked
- void customButtonClicked(bool checked);
+ // called when the custom radio button is clicked
+ void customButtonClicked(bool checked);
- // makes the keyChangeRequest
- void makeKeyChangeRequest(const QString& keys);
+ // makes the keyChangeRequest
+ void makeKeyChangeRequest(const QString& keys);
-private:
-
- // create the action and shortcuts table
- QTableWidget* createShortcutsTable();
+ private:
- // create the area below the table where the shortcuts are edited
- QWidget* createShortcutChooser();
+ // create the action and shortcuts table
+ QTableWidget* createShortcutsTable();
- // get the shortcut editor item from the zeroth column of the table
- BtShortcutsEditorItem* getShortcutsEditor(int row);
+ // create the area below the table where the shortcuts are edited
+ QWidget* createShortcutChooser();
- // initialize this widget
- void init();
+ // get the shortcut editor item from the zeroth column of the table
+ BtShortcutsEditorItem* getShortcutsEditor(int row);
- BtShortcutsDialog* m_dlg;
- QTableWidget* m_table;
- QWidget* m_shortcutChooser;
- QRadioButton* m_noneButton;
- QRadioButton* m_defaultButton;
- QRadioButton* m_customButton;
- QPushButton* m_customPushButton;
- QLabel* m_defaultLabelValue;
- int m_currentRow;
+ // initialize this widget
+ void init();
+
+ BtShortcutsDialog* m_dlg;
+ QTableWidget* m_table;
+ QWidget* m_shortcutChooser;
+ QRadioButton* m_noneButton;
+ QRadioButton* m_defaultButton;
+ QRadioButton* m_customButton;
+ QPushButton* m_customPushButton;
+ QLabel* m_defaultLabelValue;
+ int m_currentRow;
};
#endif
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index df54571..cc8769b 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -29,250 +29,230 @@
#include <QMessageBox>
CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget* /* parent */ )
- : BtConfigPage()
-{
- QVBoxLayout* mainLayout = new QVBoxLayout(this);
- this->setLayout(mainLayout);
-
- QHBoxLayout* layoutForWindowTypeChooser = new QHBoxLayout();
- mainLayout->addLayout(layoutForWindowTypeChooser);
-
- QLabel* label = new QLabel(tr("Choose action group:"), this);
- layoutForWindowTypeChooser->addWidget(label);
-
- m_typeChooser = new QComboBox(this);
- layoutForWindowTypeChooser->addWidget(m_typeChooser);
-
- bool ok = connect(m_typeChooser, SIGNAL(activated(const QString&)),
- SLOT(slotKeyChooserTypeChanged(const QString&)) );
- Q_ASSERT(ok);
-
- m_keyChooserStack = new QStackedWidget(this);
-
- m_application.title = tr("Main Window");
- m_general = WindowType(tr("All text windows"));
- m_bible = WindowType(tr("Bible windows"));
- m_commentary = WindowType(tr("Commentary windows"));
- m_lexicon = WindowType(tr("Lexicon windows"));
- m_book = WindowType(tr("Book windows"));
-
- m_typeChooser->addItem(m_application.title);
- m_typeChooser->addItem(m_general.title);
- m_typeChooser->addItem(m_bible.title);
- m_typeChooser->addItem(m_commentary.title);
- m_typeChooser->addItem(m_lexicon.title);
- m_typeChooser->addItem(m_book.title);
-
- // create shortcuteditors
-
- // ------ Application -------------- //
- m_application.actionCollection = new BtActionCollection(this);
- BibleTime::insertKeyboardActions( m_application.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::application, m_application.actionCollection);
- m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection,m_keyChooserStack);
- m_keyChooserStack->addWidget(m_application.keyChooser);
- ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- // ----- All display windows ------ //
- m_general.actionCollection = new BtActionCollection(this);
- CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows,m_general.actionCollection);
- m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
- m_keyChooserStack->addWidget(m_general.keyChooser);
- ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- // ----- Bible windows ------ //
- m_bible.actionCollection = new BtActionCollection(this);
- CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow,m_bible.actionCollection);
- m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
- m_keyChooserStack->addWidget(m_bible.keyChooser);
- ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- // ----- Commentary windows ------ //
- m_commentary.actionCollection = new BtActionCollection(this);
- CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
- m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
- m_keyChooserStack->addWidget(m_commentary.keyChooser);
- ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- // ----- Lexicon windows ------ //
- m_lexicon.actionCollection = new BtActionCollection(this);
- CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection);
- m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack );
- m_keyChooserStack->addWidget(m_lexicon.keyChooser);
- ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- // ----- Book windows ------ //
- m_book.actionCollection= new BtActionCollection(this);
- CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, m_book.actionCollection);
- m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
- m_keyChooserStack->addWidget(m_book.keyChooser);
- ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
-
- mainLayout->addWidget(m_keyChooserStack);
- slotKeyChooserTypeChanged(m_application.title);
-
- m_typeChooser->setFocus(Qt::MouseFocusReason);
- qDebug("CAcceleratorSettingsPage::CAcceleratorSettingsPage end");
+ : BtConfigPage() {
+ QVBoxLayout* mainLayout = new QVBoxLayout(this);
+ this->setLayout(mainLayout);
+
+ QHBoxLayout* layoutForWindowTypeChooser = new QHBoxLayout();
+ mainLayout->addLayout(layoutForWindowTypeChooser);
+
+ QLabel* label = new QLabel(tr("Choose action group:"), this);
+ layoutForWindowTypeChooser->addWidget(label);
+
+ m_typeChooser = new QComboBox(this);
+ layoutForWindowTypeChooser->addWidget(m_typeChooser);
+
+ bool ok = connect(m_typeChooser, SIGNAL(activated(const QString&)),
+ SLOT(slotKeyChooserTypeChanged(const QString&)) );
+ Q_ASSERT(ok);
+
+ m_keyChooserStack = new QStackedWidget(this);
+
+ m_application.title = tr("Main Window");
+ m_general = WindowType(tr("All text windows"));
+ m_bible = WindowType(tr("Bible windows"));
+ m_commentary = WindowType(tr("Commentary windows"));
+ m_lexicon = WindowType(tr("Lexicon windows"));
+ m_book = WindowType(tr("Book windows"));
+
+ m_typeChooser->addItem(m_application.title);
+ m_typeChooser->addItem(m_general.title);
+ m_typeChooser->addItem(m_bible.title);
+ m_typeChooser->addItem(m_commentary.title);
+ m_typeChooser->addItem(m_lexicon.title);
+ m_typeChooser->addItem(m_book.title);
+
+ // create shortcuteditors
+
+ // ------ Application -------------- //
+ m_application.actionCollection = new BtActionCollection(this);
+ BibleTime::insertKeyboardActions( m_application.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::application, m_application.actionCollection);
+ m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_application.keyChooser);
+ ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- All display windows ------ //
+ m_general.actionCollection = new BtActionCollection(this);
+ CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::allWindows, m_general.actionCollection);
+ m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_general.keyChooser);
+ ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Bible windows ------ //
+ m_bible.actionCollection = new BtActionCollection(this);
+ CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection);
+ m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_bible.keyChooser);
+ ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Commentary windows ------ //
+ m_commentary.actionCollection = new BtActionCollection(this);
+ CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
+ m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_commentary.keyChooser);
+ ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Lexicon windows ------ //
+ m_lexicon.actionCollection = new BtActionCollection(this);
+ CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
+ CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection);
+ m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack );
+ m_keyChooserStack->addWidget(m_lexicon.keyChooser);
+ ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ // ----- Book windows ------ //
+ m_book.actionCollection = new BtActionCollection(this);
+ CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::bookWindow, m_book.actionCollection);
+ m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
+ m_keyChooserStack->addWidget(m_book.keyChooser);
+ ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
+ this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
+ Q_ASSERT(ok);
+
+ mainLayout->addWidget(m_keyChooserStack);
+ slotKeyChooserTypeChanged(m_application.title);
+
+ m_typeChooser->setFocus(Qt::MouseFocusReason);
+ qDebug("CAcceleratorSettingsPage::CAcceleratorSettingsPage end");
}
-CAcceleratorSettingsPage::~CAcceleratorSettingsPage()
-{
+CAcceleratorSettingsPage::~CAcceleratorSettingsPage() {
}
// complete the keyChangeRequest
-void CAcceleratorSettingsPage::completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys)
-{
- // check the BtShortcutsEditor's for shortcut conflicts
- // Either clear the conflicts and set the new shortcut or do nothing.
-
- QList<BtShortcutsEditor*> list = getShortcutsEditorListForGroup(shortcutsEditor);
- QString conflicts = findConflictsWithKeys(keys, list);
- if (!conflicts.isEmpty())
- {
- QString message = QObject::tr("This shortcut conflicts with the shortcut for the following actions:");
- message.append("\n");
- message.append(conflicts);
-
- QMessageBox msgBox(this);
- msgBox.setIcon(QMessageBox::Question);
- msgBox.setText(message);
- msgBox.setInformativeText(QObject::tr("Do you want to clear the conflicting shortcuts and continue?"));
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
- int ret = msgBox.exec();
- if ( ret == QMessageBox::Yes)
- {
- clearConflictsWithKeys(keys,list);
- shortcutsEditor->changeShortcutInDialog(keys);
- }
- }
- else
- {
- shortcutsEditor->changeShortcutInDialog(keys);
- }
+void CAcceleratorSettingsPage::completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys) {
+ // check the BtShortcutsEditor's for shortcut conflicts
+ // Either clear the conflicts and set the new shortcut or do nothing.
+
+ QList<BtShortcutsEditor*> list = getShortcutsEditorListForGroup(shortcutsEditor);
+ QString conflicts = findConflictsWithKeys(keys, list);
+ if (!conflicts.isEmpty()) {
+ QString message = QObject::tr("This shortcut conflicts with the shortcut for the following actions:");
+ message.append("\n");
+ message.append(conflicts);
+
+ QMessageBox msgBox(this);
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setText(message);
+ msgBox.setInformativeText(QObject::tr("Do you want to clear the conflicting shortcuts and continue?"));
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ msgBox.setDefaultButton(QMessageBox::Yes);
+ int ret = msgBox.exec();
+ if ( ret == QMessageBox::Yes) {
+ clearConflictsWithKeys(keys, list);
+ shortcutsEditor->changeShortcutInDialog(keys);
+ }
+ }
+ else {
+ shortcutsEditor->changeShortcutInDialog(keys);
+ }
}
-void CAcceleratorSettingsPage::clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list)
-{
- QString conflicts;
- for (int i=0; i<list.count(); i++)
- {
- list.at(i)->clearConflictWithKeys(keys);
- }
+void CAcceleratorSettingsPage::clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list) {
+ QString conflicts;
+ for (int i = 0; i < list.count(); i++) {
+ list.at(i)->clearConflictWithKeys(keys);
+ }
}
-QString CAcceleratorSettingsPage::findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list)
-{
- QString conflicts;
- for (int i=0; i<list.count(); i++)
- {
- QString conflict = list.at(i)->findConflictWithKeys(keys);
- if (!conflict.isEmpty())
- {
- QString conflictMsg(tr("\n \"%1\" in the \"%2\" group").arg(conflict).arg(getTitleForEditor(list.at(i))));
- conflicts.append(conflictMsg);
- }
- }
- return conflicts;
+QString CAcceleratorSettingsPage::findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list) {
+ QString conflicts;
+ for (int i = 0; i < list.count(); i++) {
+ QString conflict = list.at(i)->findConflictWithKeys(keys);
+ if (!conflict.isEmpty()) {
+ QString conflictMsg(tr("\n \"%1\" in the \"%2\" group").arg(conflict).arg(getTitleForEditor(list.at(i))));
+ conflicts.append(conflictMsg);
+ }
+ }
+ return conflicts;
}
-QString CAcceleratorSettingsPage::getTitleForEditor(BtShortcutsEditor* editor)
-{
- if (editor == m_application.keyChooser)
- return m_application.title;
- if (editor == m_general.keyChooser)
- return m_general.title;
- if (editor == m_bible.keyChooser)
- return m_bible.title;
- if (editor == m_commentary.keyChooser)
- return m_commentary.title;
- if (editor == m_application.keyChooser)
- return m_lexicon.title;
- if (editor == m_book.keyChooser)
- return m_book.title;
- return QString();
+QString CAcceleratorSettingsPage::getTitleForEditor(BtShortcutsEditor* editor) {
+ if (editor == m_application.keyChooser)
+ return m_application.title;
+ if (editor == m_general.keyChooser)
+ return m_general.title;
+ if (editor == m_bible.keyChooser)
+ return m_bible.title;
+ if (editor == m_commentary.keyChooser)
+ return m_commentary.title;
+ if (editor == m_application.keyChooser)
+ return m_lexicon.title;
+ if (editor == m_book.keyChooser)
+ return m_book.title;
+ return QString();
}
// Gets list of shortcuts editors that can conflict with a key change in the current shortcut editor
-QList<BtShortcutsEditor*> CAcceleratorSettingsPage::getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor)
-{
- QList<BtShortcutsEditor*> list;
-
- list.append(m_application.keyChooser);
- list.append(m_general.keyChooser);
- if ( (currentEditor == m_application.keyChooser) || (currentEditor == m_general.keyChooser) )
- {
- list.append(m_bible.keyChooser);
- list.append(m_commentary.keyChooser);
- list.append(m_lexicon.keyChooser);
- list.append(m_book.keyChooser);
- }
- else
- {
- list.append(currentEditor);
- }
- return list;
+QList<BtShortcutsEditor*> CAcceleratorSettingsPage::getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor) {
+ QList<BtShortcutsEditor*> list;
+
+ list.append(m_application.keyChooser);
+ list.append(m_general.keyChooser);
+ if ( (currentEditor == m_application.keyChooser) || (currentEditor == m_general.keyChooser) ) {
+ list.append(m_bible.keyChooser);
+ list.append(m_commentary.keyChooser);
+ list.append(m_lexicon.keyChooser);
+ list.append(m_book.keyChooser);
+ }
+ else {
+ list.append(currentEditor);
+ }
+ return list;
}
-void CAcceleratorSettingsPage::save()
-{
- if (m_application.keyChooser)
- m_application.keyChooser->commitChanges();
- if (m_general.keyChooser)
- m_general.keyChooser->commitChanges();
- if (m_bible.keyChooser)
- m_bible.keyChooser->commitChanges();
- if (m_commentary.keyChooser)
- m_commentary.keyChooser->commitChanges();
- if (m_lexicon.keyChooser)
- m_lexicon.keyChooser->commitChanges();
- if (m_book.keyChooser)
- m_book.keyChooser->commitChanges();
-
- CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
- CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
- CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
- CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
- CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
- CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
+void CAcceleratorSettingsPage::save() {
+ if (m_application.keyChooser)
+ m_application.keyChooser->commitChanges();
+ if (m_general.keyChooser)
+ m_general.keyChooser->commitChanges();
+ if (m_bible.keyChooser)
+ m_bible.keyChooser->commitChanges();
+ if (m_commentary.keyChooser)
+ m_commentary.keyChooser->commitChanges();
+ if (m_lexicon.keyChooser)
+ m_lexicon.keyChooser->commitChanges();
+ if (m_book.keyChooser)
+ m_book.keyChooser->commitChanges();
+
+ CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
+ CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
+ CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
+ CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
+ CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
+ CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
}
-void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title)
-{
- int index = m_typeChooser->currentIndex();
- m_keyChooserStack->setCurrentIndex(index);
+void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
+ int index = m_typeChooser->currentIndex();
+ m_keyChooserStack->setCurrentIndex(index);
}
-QString CAcceleratorSettingsPage::iconName()
-{
- return CResMgr::settings::keys::icon;
+QString CAcceleratorSettingsPage::iconName() {
+ return CResMgr::settings::keys::icon;
}
-QString CAcceleratorSettingsPage::label()
-{
- //: Empty string, don't translate
- return tr("");
+QString CAcceleratorSettingsPage::label() {
+ //: Empty string, don't translate
+ return tr("");
}
-QString CAcceleratorSettingsPage::header()
-{
- return tr("Shortcuts");
+QString CAcceleratorSettingsPage::header() {
+ return tr("Shortcuts");
}
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
index 4af867b..e06a9b9 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -27,56 +27,55 @@ class BtShortcutsEditor;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CAcceleratorSettingsPage : public BtConfigPage, CPointers
-{
- Q_OBJECT
-
-public:
- CAcceleratorSettingsPage(QWidget *parent);
- ~CAcceleratorSettingsPage();
- void save();
- QString iconName();
- QString label();
- QString header();
-
-protected slots:
-
- void slotKeyChooserTypeChanged(const QString& title);
-
- // complete the keyChangeRequest
- void completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys);
-
-private:
- struct WindowType {
- QPointer<BtShortcutsEditor> keyChooser;
- BtActionCollection* actionCollection;
- QString title;
-
- WindowType() {
- keyChooser = 0;
- actionCollection = 0;
- };
- WindowType(const QString& newTitle) {
- title = newTitle;
- keyChooser = 0;
- actionCollection = 0;
- }
- };
-
- void clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
- QString findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
- QList<BtShortcutsEditor*> getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor);
- QString getTitleForEditor(BtShortcutsEditor* editor);
-
- WindowType m_application;
- WindowType m_general;
- WindowType m_bible;
- WindowType m_commentary;
- WindowType m_lexicon;
- WindowType m_book;
-
- QComboBox* m_typeChooser;
- QStackedWidget* m_keyChooserStack;
+class CAcceleratorSettingsPage : public BtConfigPage, CPointers {
+ Q_OBJECT
+
+ public:
+ CAcceleratorSettingsPage(QWidget *parent);
+ ~CAcceleratorSettingsPage();
+ void save();
+ QString iconName();
+ QString label();
+ QString header();
+
+ protected slots:
+
+ void slotKeyChooserTypeChanged(const QString& title);
+
+ // complete the keyChangeRequest
+ void completeKeyChangeRequest(BtShortcutsEditor* shortcutsEditor, const QString& keys);
+
+ private:
+ struct WindowType {
+ QPointer<BtShortcutsEditor> keyChooser;
+ BtActionCollection* actionCollection;
+ QString title;
+
+ WindowType() {
+ keyChooser = 0;
+ actionCollection = 0;
+ };
+ WindowType(const QString& newTitle) {
+ title = newTitle;
+ keyChooser = 0;
+ actionCollection = 0;
+ }
+ };
+
+ void clearConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
+ QString findConflictsWithKeys(const QString& keys, const QList<BtShortcutsEditor*> list);
+ QList<BtShortcutsEditor*> getShortcutsEditorListForGroup(BtShortcutsEditor* currentEditor);
+ QString getTitleForEditor(BtShortcutsEditor* editor);
+
+ WindowType m_application;
+ WindowType m_general;
+ WindowType m_bible;
+ WindowType m_commentary;
+ WindowType m_lexicon;
+ WindowType m_book;
+
+ QComboBox* m_typeChooser;
+ QStackedWidget* m_keyChooserStack;
};
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index d942915..d06b342 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.cpp
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
@@ -26,88 +26,81 @@
#include <QLayout>
CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection* actionCollection )
- : BtConfigDialog(parent),
- m_actionCollection(actionCollection),
- m_displayPage(0),
- m_swordPage(0),
- m_acceleratorsPage(0),
- m_languagesPage(0),
- m_bbox(0)
-{
- setWindowTitle(tr("Configure BibleTime"));
- setAttribute(Qt::WA_DeleteOnClose);
-
- // Add "Display" page
- m_displayPage = new CDisplaySettingsPage(this);
- addPage(m_displayPage);
-
- // Add "Desk" (sword) page
- m_swordPage = new CSwordSettingsPage(this);
- addPage(m_swordPage);
-
- // Add "Languages" (fonts) page
- m_languagesPage = new CLanguageSettingsPage(this);
- addPage(m_languagesPage);
-
- // Add "Keyboard" (accelerators) page
- m_acceleratorsPage = new CAcceleratorSettingsPage(this);
- addPage(m_acceleratorsPage);
-
- // Dialog buttons
- m_bbox = new QDialogButtonBox(this);
- m_bbox->addButton(QDialogButtonBox::Ok);
- m_bbox->addButton(QDialogButtonBox::Apply);
- m_bbox->addButton(QDialogButtonBox::Cancel);
- util::prepareDialogBox(m_bbox);
- addButtonBox(m_bbox);
- bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
- Q_ASSERT(ok);
-
- loadDialogSettings();
-
- slotChangePage(0);
+ : BtConfigDialog(parent),
+ m_actionCollection(actionCollection),
+ m_displayPage(0),
+ m_swordPage(0),
+ m_acceleratorsPage(0),
+ m_languagesPage(0),
+ m_bbox(0) {
+ setWindowTitle(tr("Configure BibleTime"));
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ // Add "Display" page
+ m_displayPage = new CDisplaySettingsPage(this);
+ addPage(m_displayPage);
+
+ // Add "Desk" (sword) page
+ m_swordPage = new CSwordSettingsPage(this);
+ addPage(m_swordPage);
+
+ // Add "Languages" (fonts) page
+ m_languagesPage = new CLanguageSettingsPage(this);
+ addPage(m_languagesPage);
+
+ // Add "Keyboard" (accelerators) page
+ m_acceleratorsPage = new CAcceleratorSettingsPage(this);
+ addPage(m_acceleratorsPage);
+
+ // Dialog buttons
+ m_bbox = new QDialogButtonBox(this);
+ m_bbox->addButton(QDialogButtonBox::Ok);
+ m_bbox->addButton(QDialogButtonBox::Apply);
+ m_bbox->addButton(QDialogButtonBox::Cancel);
+ util::prepareDialogBox(m_bbox);
+ addButtonBox(m_bbox);
+ bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
+ Q_ASSERT(ok);
+
+ loadDialogSettings();
+
+ slotChangePage(0);
}
-CConfigurationDialog::~CConfigurationDialog()
-{
- saveDialogSettings();
+CConfigurationDialog::~CConfigurationDialog() {
+ saveDialogSettings();
}
/** Save the dialog settings **/
-void CConfigurationDialog::save()
-{
- m_acceleratorsPage->save();
- m_languagesPage->save();
- m_swordPage->save();
- m_displayPage->save();
- emit signalSettingsChanged( );
+void CConfigurationDialog::save() {
+ m_acceleratorsPage->save();
+ m_languagesPage->save();
+ m_swordPage->save();
+ m_displayPage->save();
+ emit signalSettingsChanged( );
}
/** Called if any button was clicked*/
-void CConfigurationDialog::slotButtonClicked(QAbstractButton* button)
-{
- if (button == static_cast<QAbstractButton*>(m_bbox->button(QDialogButtonBox::Cancel)))
- {
- close();
- return;
- }
-
- save();
-
- if (button == static_cast<QAbstractButton*>(m_bbox->button(QDialogButtonBox::Ok)))
- close();
+void CConfigurationDialog::slotButtonClicked(QAbstractButton* button) {
+ if (button == static_cast<QAbstractButton*>(m_bbox->button(QDialogButtonBox::Cancel))) {
+ close();
+ return;
+ }
+
+ save();
+
+ if (button == static_cast<QAbstractButton*>(m_bbox->button(QDialogButtonBox::Ok)))
+ close();
}
-void CConfigurationDialog::loadDialogSettings()
-{
- resize(CBTConfig::get(CBTConfig::configDialogWidth), CBTConfig::get(CBTConfig::configDialogHeight));
- move(CBTConfig::get(CBTConfig::configDialogPosX), CBTConfig::get(CBTConfig::configDialogPosY));
+void CConfigurationDialog::loadDialogSettings() {
+ resize(CBTConfig::get(CBTConfig::configDialogWidth), CBTConfig::get(CBTConfig::configDialogHeight));
+ move(CBTConfig::get(CBTConfig::configDialogPosX), CBTConfig::get(CBTConfig::configDialogPosY));
}
-void CConfigurationDialog::saveDialogSettings()
-{
- CBTConfig::set(CBTConfig::configDialogWidth, size().width());
- CBTConfig::set(CBTConfig::configDialogHeight, size().height());
- CBTConfig::set(CBTConfig::configDialogPosX, x());
- CBTConfig::set(CBTConfig::configDialogPosY, y());
+void CConfigurationDialog::saveDialogSettings() {
+ CBTConfig::set(CBTConfig::configDialogWidth, size().width());
+ CBTConfig::set(CBTConfig::configDialogHeight, size().height());
+ CBTConfig::set(CBTConfig::configDialogPosX, x());
+ CBTConfig::set(CBTConfig::configDialogPosY, y());
}
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index 0153a74..3fae5e3 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -26,32 +26,32 @@ class QDialogButtonBox;
class BtActionCollection;
class CConfigurationDialog : public BtConfigDialog {
- Q_OBJECT
+ Q_OBJECT
-public:
- CConfigurationDialog(QWidget *parent, BtActionCollection* actionCollection);
- virtual ~CConfigurationDialog();
- void save();
+ public:
+ CConfigurationDialog(QWidget *parent, BtActionCollection* actionCollection);
+ virtual ~CConfigurationDialog();
+ void save();
-protected slots:
- void slotButtonClicked(QAbstractButton *);
+ protected slots:
+ void slotButtonClicked(QAbstractButton *);
-private:
- BtActionCollection* m_actionCollection;
- CDisplaySettingsPage* m_displayPage;
- CSwordSettingsPage* m_swordPage;
- CAcceleratorSettingsPage* m_acceleratorsPage;
- CLanguageSettingsPage* m_languagesPage;
- QDialogButtonBox* m_bbox;
+ private:
+ BtActionCollection* m_actionCollection;
+ CDisplaySettingsPage* m_displayPage;
+ CSwordSettingsPage* m_swordPage;
+ CAcceleratorSettingsPage* m_acceleratorsPage;
+ CLanguageSettingsPage* m_languagesPage;
+ QDialogButtonBox* m_bbox;
- // Load the settings from the resource file
- void loadDialogSettings();
+ // Load the settings from the resource file
+ void loadDialogSettings();
- // Save the settings to the resource file
- void saveDialogSettings();
+ // Save the settings to the resource file
+ void saveDialogSettings();
-signals:
- void signalSettingsChanged();
+ signals:
+ void signalSettingsChanged();
};
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.cpp b/src/frontend/settingsdialogs/cdisplaysettings.cpp
index f04006e..e34eb8b 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.cpp
+++ b/src/frontend/settingsdialogs/cdisplaysettings.cpp
@@ -25,175 +25,163 @@
// ***********************
// Container for QWebView to control its size
-class CWebViewerWidget : public QWidget
-{
- public:
- CWebViewerWidget(QWidget* parent = 0);
- ~CWebViewerWidget();
- virtual QSize sizeHint () const;
+class CWebViewerWidget : public QWidget {
+ public:
+ CWebViewerWidget(QWidget* parent = 0);
+ ~CWebViewerWidget();
+ virtual QSize sizeHint () const;
};
CWebViewerWidget::CWebViewerWidget(QWidget* parent)
- : QWidget(parent)
-{
+ : QWidget(parent) {
}
-CWebViewerWidget::~CWebViewerWidget()
-{
+CWebViewerWidget::~CWebViewerWidget() {
}
-QSize CWebViewerWidget::sizeHint () const
-{
- return QSize(100,100);
+QSize CWebViewerWidget::sizeHint () const {
+ return QSize(100, 100);
}
// ************************
/** Initializes the startup section of the OD. */
CDisplaySettingsPage::CDisplaySettingsPage(QWidget* /*parent*/)
- : BtConfigPage()
-{
- QVBoxLayout* layout = new QVBoxLayout(this);
-
- { //startup logo
- m_showLogoCheck = new QCheckBox(this);
- m_showLogoCheck->setText(tr("Show startup logo"));
- m_showLogoCheck->setToolTip(tr("Show the BibleTime logo on startup"));
-
- m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
- layout->addWidget(m_showLogoCheck);
- }
- layout->addSpacing(20);
-
- layout->addWidget(
- CToolClass::explanationLabel(
- this,
- tr("Display templates"),
- tr("Display templates define how text is displayed.")
- )
- );
-
- QHBoxLayout* hboxlayout = new QHBoxLayout();
-
- m_styleChooserCombo = new QComboBox( this ); //create first to enable buddy for label
- connect( m_styleChooserCombo, SIGNAL( activated( int ) ),
- this, SLOT( updateStylePreview() ) );
-
- QLabel* availableLabel = new QLabel(tr("Available display styles:"), this);
- availableLabel->setBuddy(m_styleChooserCombo);
- hboxlayout->addWidget(availableLabel);
- hboxlayout->addWidget( m_styleChooserCombo );
- hboxlayout->addStretch();
- layout->addLayout( hboxlayout );
-
- QWidget* webViewWidget = new CWebViewerWidget(this);
- QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
- m_stylePreviewViewer = new QWebView(webViewWidget);
- QLabel* previewLabel = new QLabel(tr("Style preview"), webViewWidget);
- previewLabel->setBuddy(m_stylePreviewViewer);
- webViewLayout->addWidget(previewLabel);
- webViewLayout->addWidget(m_stylePreviewViewer);
- webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- layout->addWidget(webViewWidget);
-
- m_styleChooserCombo->addItems(
- CPointers::displayTemplateManager()->availableTemplates()
- );
-
- for (int i = 0; i < m_styleChooserCombo->count(); ++i)
- {
- if ( m_styleChooserCombo->itemText(i) == CBTConfig::get(CBTConfig::displayStyle) )
- {
- m_styleChooserCombo->setCurrentIndex( i );
- break;
- }
- }
-
- updateStylePreview(); //render it
+ : BtConfigPage() {
+ QVBoxLayout* layout = new QVBoxLayout(this);
+
+ { //startup logo
+ m_showLogoCheck = new QCheckBox(this);
+ m_showLogoCheck->setText(tr("Show startup logo"));
+ m_showLogoCheck->setToolTip(tr("Show the BibleTime logo on startup"));
+
+ m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
+ layout->addWidget(m_showLogoCheck);
+ }
+ layout->addSpacing(20);
+
+ layout->addWidget(
+ CToolClass::explanationLabel(
+ this,
+ tr("Display templates"),
+ tr("Display templates define how text is displayed.")
+ )
+ );
+
+ QHBoxLayout* hboxlayout = new QHBoxLayout();
+
+ m_styleChooserCombo = new QComboBox( this ); //create first to enable buddy for label
+ connect( m_styleChooserCombo, SIGNAL( activated( int ) ),
+ this, SLOT( updateStylePreview() ) );
+
+ QLabel* availableLabel = new QLabel(tr("Available display styles:"), this);
+ availableLabel->setBuddy(m_styleChooserCombo);
+ hboxlayout->addWidget(availableLabel);
+ hboxlayout->addWidget( m_styleChooserCombo );
+ hboxlayout->addStretch();
+ layout->addLayout( hboxlayout );
+
+ QWidget* webViewWidget = new CWebViewerWidget(this);
+ QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
+ m_stylePreviewViewer = new QWebView(webViewWidget);
+ QLabel* previewLabel = new QLabel(tr("Style preview"), webViewWidget);
+ previewLabel->setBuddy(m_stylePreviewViewer);
+ webViewLayout->addWidget(previewLabel);
+ webViewLayout->addWidget(m_stylePreviewViewer);
+ webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+ layout->addWidget(webViewWidget);
+
+ m_styleChooserCombo->addItems(
+ CPointers::displayTemplateManager()->availableTemplates()
+ );
+
+ for (int i = 0; i < m_styleChooserCombo->count(); ++i) {
+ if ( m_styleChooserCombo->itemText(i) == CBTConfig::get(CBTConfig::displayStyle) ) {
+ m_styleChooserCombo->setCurrentIndex( i );
+ break;
+ }
+ }
+
+ updateStylePreview(); //render it
}
-void CDisplaySettingsPage::updateStylePreview()
-{
- //update the style preview widget
- qDebug("CDisplaySettingsPage::updateStylePreview");
- using namespace Rendering;
-
- const QString styleName = m_styleChooserCombo->currentText();
- qDebug() << "style name: " << styleName;
- CTextRendering::KeyTree tree;
-
- CTextRendering::KeyTreeItem::Settings settings;
- settings.highlight = false;
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John316\" href=\"sword://Bible/WEB/John 3:16\">16</a></span>%1")
- .arg(tr("For God so loved the world, that he gave his one and only Son, that whoever believes in him should not perish, but have eternal life.")),
- settings));
-
- settings.highlight = true;
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John317\" href=\"sword://Bible/WEB/John 3:17\">17</a></span>%1")
- .arg(tr("For God didn't send his Son into the world to judge the world, but that the world should be saved through him.")),
- settings));
-
- settings.highlight = false;
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John318\" href=\"sword://Bible/WEB/John 3:18\">18</a></span>%1")
- .arg(tr("He who believes in him is not judged. He who doesn't believe has been judged already, because he has not believed in the name of the one and only Son of God.")),
- settings) );
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John319\" href=\"sword://Bible/WEB/John 3:19\">19</a></span>%1")
- .arg(tr("This is the judgment, that the light has come into the world, and men loved the darkness rather than the light; for their works were evil.")),
- settings));
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John320\" href=\"sword://Bible/WEB/John 3:20\">20</a></span>%1<br/>")
- .arg(tr("For everyone who does evil hates the light, and doesn't come to the light, lest his works would be exposed.")),
- settings));
-
- tree.append( new CTextRendering::KeyTreeItem(
- QString("\n<span class=\"entryname\"><a name=\"John321\" href=\"sword://Bible/WEB/John 3:21\">21</a></span>%1")
- .arg(tr("But he who does the truth comes to the light, that his works may be revealed, that they have been done in God.")),
- settings));
-
- const QString oldStyleName = CBTConfig::get
- (CBTConfig::displayStyle);
- //qDebug() << "old style name: " << oldStyleName;
- CBTConfig::set
- (CBTConfig::displayStyle, styleName);
- //qDebug() << "new style name: " << CBTConfig::get(CBTConfig::displayStyle);
- CDisplayRendering render;
- m_stylePreviewViewer->setHtml( render.renderKeyTree(tree));
-
- CBTConfig::set
- (CBTConfig::displayStyle, oldStyleName);
- qDebug("CDisplaySettingsPage::updateStylePreview end");
+void CDisplaySettingsPage::updateStylePreview() {
+ //update the style preview widget
+ qDebug("CDisplaySettingsPage::updateStylePreview");
+ using namespace Rendering;
+
+ const QString styleName = m_styleChooserCombo->currentText();
+ qDebug() << "style name: " << styleName;
+ CTextRendering::KeyTree tree;
+
+ CTextRendering::KeyTreeItem::Settings settings;
+ settings.highlight = false;
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John316\" href=\"sword://Bible/WEB/John 3:16\">16</a></span>%1")
+ .arg(tr("For God so loved the world, that he gave his one and only Son, that whoever believes in him should not perish, but have eternal life.")),
+ settings));
+
+ settings.highlight = true;
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John317\" href=\"sword://Bible/WEB/John 3:17\">17</a></span>%1")
+ .arg(tr("For God didn't send his Son into the world to judge the world, but that the world should be saved through him.")),
+ settings));
+
+ settings.highlight = false;
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John318\" href=\"sword://Bible/WEB/John 3:18\">18</a></span>%1")
+ .arg(tr("He who believes in him is not judged. He who doesn't believe has been judged already, because he has not believed in the name of the one and only Son of God.")),
+ settings) );
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John319\" href=\"sword://Bible/WEB/John 3:19\">19</a></span>%1")
+ .arg(tr("This is the judgment, that the light has come into the world, and men loved the darkness rather than the light; for their works were evil.")),
+ settings));
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John320\" href=\"sword://Bible/WEB/John 3:20\">20</a></span>%1<br/>")
+ .arg(tr("For everyone who does evil hates the light, and doesn't come to the light, lest his works would be exposed.")),
+ settings));
+
+ tree.append( new CTextRendering::KeyTreeItem(
+ QString("\n<span class=\"entryname\"><a name=\"John321\" href=\"sword://Bible/WEB/John 3:21\">21</a></span>%1")
+ .arg(tr("But he who does the truth comes to the light, that his works may be revealed, that they have been done in God.")),
+ settings));
+
+ const QString oldStyleName = CBTConfig::get
+ (CBTConfig::displayStyle);
+ //qDebug() << "old style name: " << oldStyleName;
+ CBTConfig::set
+ (CBTConfig::displayStyle, styleName);
+ //qDebug() << "new style name: " << CBTConfig::get(CBTConfig::displayStyle);
+ CDisplayRendering render;
+ m_stylePreviewViewer->setHtml( render.renderKeyTree(tree));
+
+ CBTConfig::set
+ (CBTConfig::displayStyle, oldStyleName);
+ qDebug("CDisplaySettingsPage::updateStylePreview end");
}
-void CDisplaySettingsPage::save()
-{
- CBTConfig::set
- ( CBTConfig::logo, m_showLogoCheck->isChecked() );
- CBTConfig::set
- ( CBTConfig::displayStyle, m_styleChooserCombo->currentText() );
+void CDisplaySettingsPage::save() {
+ CBTConfig::set
+ ( CBTConfig::logo, m_showLogoCheck->isChecked() );
+ CBTConfig::set
+ ( CBTConfig::displayStyle, m_styleChooserCombo->currentText() );
}
// implement the BtConfigPage methods
-QString CDisplaySettingsPage::iconName()
-{
- return CResMgr::settings::startup::icon;
+QString CDisplaySettingsPage::iconName() {
+ return CResMgr::settings::startup::icon;
}
-QString CDisplaySettingsPage::label()
-{
- //: Empty string, don't translate
- return tr("");
+QString CDisplaySettingsPage::label() {
+ //: Empty string, don't translate
+ return tr("");
}
-QString CDisplaySettingsPage::header()
-{
- return tr("Display");
+QString CDisplaySettingsPage::header() {
+ return tr("Display");
}
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.h b/src/frontend/settingsdialogs/cdisplaysettings.h
index faa929b..7d6800a 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.h
+++ b/src/frontend/settingsdialogs/cdisplaysettings.h
@@ -19,25 +19,24 @@ class QCheckBox;
class QComboBox;
class QWebView;
-class CDisplaySettingsPage : public BtConfigPage
-{
- Q_OBJECT
-
-public:
- CDisplaySettingsPage(QWidget* parent);
- void save();
- QString iconName();
- QString label();
- QString header();
-
-protected slots:
- /** Update the style preview widget. */
- void updateStylePreview();
-
-private:
- QCheckBox* m_showLogoCheck;
- QComboBox* m_styleChooserCombo;
- QWebView* m_stylePreviewViewer;
+class CDisplaySettingsPage : public BtConfigPage {
+ Q_OBJECT
+
+ public:
+ CDisplaySettingsPage(QWidget* parent);
+ void save();
+ QString iconName();
+ QString label();
+ QString header();
+
+ protected slots:
+ /** Update the style preview widget. */
+ void updateStylePreview();
+
+ private:
+ QCheckBox* m_showLogoCheck;
+ QComboBox* m_styleChooserCombo;
+ QWebView* m_stylePreviewViewer;
};
#endif
diff --git a/src/frontend/settingsdialogs/cfontchooser.cpp b/src/frontend/settingsdialogs/cfontchooser.cpp
index 4fa88c4..a2a8290 100644
--- a/src/frontend/settingsdialogs/cfontchooser.cpp
+++ b/src/frontend/settingsdialogs/cfontchooser.cpp
@@ -22,158 +22,146 @@
// ***********************
// Container for KHTHMView to control its size
-class WebViewerWidget : public QWidget
-{
- public:
- WebViewerWidget(QWidget* parent = 0);
- ~WebViewerWidget();
- virtual QSize sizeHint () const;
+class WebViewerWidget : public QWidget {
+ public:
+ WebViewerWidget(QWidget* parent = 0);
+ ~WebViewerWidget();
+ virtual QSize sizeHint () const;
};
WebViewerWidget::WebViewerWidget(QWidget* parent)
- : QWidget(parent)
-{
+ : QWidget(parent) {
}
-WebViewerWidget::~WebViewerWidget()
-{
+WebViewerWidget::~WebViewerWidget() {
}
-QSize WebViewerWidget::sizeHint () const
-{
- return QSize(100,100);
+QSize WebViewerWidget::sizeHint () const {
+ return QSize(100, 100);
}
// ************************
CFontChooser::CFontChooser(QWidget* parent)
- : QFrame(parent), m_fontWidget(0),
- m_fontListWidget(0), m_styleListWidget(0), m_sizeListWidget(0)
-{
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- createLayout();
- connectListWidgets();
- loadFonts();
- setFrameStyle(QFrame::Box);
- setFrameShadow(QFrame::Raised);
+ : QFrame(parent), m_fontWidget(0),
+ m_fontListWidget(0), m_styleListWidget(0), m_sizeListWidget(0) {
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ createLayout();
+ connectListWidgets();
+ loadFonts();
+ setFrameStyle(QFrame::Box);
+ setFrameShadow(QFrame::Raised);
}
-CFontChooser::~CFontChooser()
-{
+CFontChooser::~CFontChooser() {
}
-void CFontChooser::createFontAreaLayout()
-{
- QHBoxLayout* fontStyleSizeHBoxLayout = new QHBoxLayout();
+void CFontChooser::createFontAreaLayout() {
+ QHBoxLayout* fontStyleSizeHBoxLayout = new QHBoxLayout();
- // font column
- QVBoxLayout* fontLayout = new QVBoxLayout();
- fontStyleSizeHBoxLayout->addLayout(fontLayout);
+ // font column
+ QVBoxLayout* fontLayout = new QVBoxLayout();
+ fontStyleSizeHBoxLayout->addLayout(fontLayout);
- QLabel* fontLabel = new QLabel(tr("Font name:"));
- fontLayout->addWidget(fontLabel);
+ QLabel* fontLabel = new QLabel(tr("Font name:"));
+ fontLayout->addWidget(fontLabel);
- m_fontListWidget = new CListWidget();
- m_fontListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- m_fontListWidget->setMinimumHeight(50);
- fontLayout->addWidget(m_fontListWidget);
+ m_fontListWidget = new CListWidget();
+ m_fontListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_fontListWidget->setMinimumHeight(50);
+ fontLayout->addWidget(m_fontListWidget);
- // style column
- QVBoxLayout* styleLayout = new QVBoxLayout();
- fontStyleSizeHBoxLayout->addLayout(styleLayout);
+ // style column
+ QVBoxLayout* styleLayout = new QVBoxLayout();
+ fontStyleSizeHBoxLayout->addLayout(styleLayout);
- QLabel* styleLabel = new QLabel(tr("Font style:"));
- styleLayout->addWidget(styleLabel);
+ QLabel* styleLabel = new QLabel(tr("Font style:"));
+ styleLayout->addWidget(styleLabel);
- m_styleListWidget = new CListWidget();
- m_styleListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- m_styleListWidget->setMinimumHeight(50);
- m_styleListWidget->setCharWidth(12);
- styleLayout->addWidget(m_styleListWidget);
+ m_styleListWidget = new CListWidget();
+ m_styleListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_styleListWidget->setMinimumHeight(50);
+ m_styleListWidget->setCharWidth(12);
+ styleLayout->addWidget(m_styleListWidget);
- // size column
- QVBoxLayout* sizeLayout = new QVBoxLayout();
- fontStyleSizeHBoxLayout->addLayout(sizeLayout);
+ // size column
+ QVBoxLayout* sizeLayout = new QVBoxLayout();
+ fontStyleSizeHBoxLayout->addLayout(sizeLayout);
- QLabel* sizeLabel = new QLabel(tr("Size:"));
- sizeLayout->addWidget(sizeLabel);
+ QLabel* sizeLabel = new QLabel(tr("Size:"));
+ sizeLayout->addWidget(sizeLabel);
- m_sizeListWidget = new CListWidget();
- m_sizeListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- m_sizeListWidget->setMinimumHeight(50);
- m_sizeListWidget->setCharWidth(5);
- sizeLayout->addWidget(m_sizeListWidget);
+ m_sizeListWidget = new CListWidget();
+ m_sizeListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ m_sizeListWidget->setMinimumHeight(50);
+ m_sizeListWidget->setCharWidth(5);
+ sizeLayout->addWidget(m_sizeListWidget);
- m_vBoxLayout->addLayout(fontStyleSizeHBoxLayout);
+ m_vBoxLayout->addLayout(fontStyleSizeHBoxLayout);
}
-void CFontChooser::createLayout()
-{
- m_vBoxLayout = new QVBoxLayout(this);
- createFontAreaLayout();
- createTextAreaLayout();
+void CFontChooser::createLayout() {
+ m_vBoxLayout = new QVBoxLayout(this);
+ createFontAreaLayout();
+ createTextAreaLayout();
}
-void CFontChooser::createTextAreaLayout()
-{
- QWidget* webViewWidget = new WebViewerWidget(this);
- QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
+void CFontChooser::createTextAreaLayout() {
+ QWidget* webViewWidget = new WebViewerWidget(this);
+ QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
- webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-
- m_webView = new QWebView(webViewWidget);
- webViewLayout->addWidget(m_webView);
- m_vBoxLayout->addWidget(webViewWidget);
+ webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
+ m_webView = new QWebView(webViewWidget);
+ webViewLayout->addWidget(m_webView);
+ m_vBoxLayout->addWidget(webViewWidget);
}
-void CFontChooser::connectListWidgets()
-{
-
- bool ok = connect(
- m_fontListWidget,
- SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
- this,
- SLOT(fontChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
-
- ok = connect(
- m_styleListWidget,
- SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
- this,
- SLOT(styleChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
-
- ok = connect(
- m_sizeListWidget,
- SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
- this,
- SLOT(sizeChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
+void CFontChooser::connectListWidgets() {
+
+ bool ok = connect(
+ m_fontListWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this,
+ SLOT(fontChanged(QListWidgetItem *, QListWidgetItem *)));
+ Q_ASSERT(ok);
+
+ ok = connect(
+ m_styleListWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this,
+ SLOT(styleChanged(QListWidgetItem *, QListWidgetItem *)));
+ Q_ASSERT(ok);
+
+ ok = connect(
+ m_sizeListWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this,
+ SLOT(sizeChanged(QListWidgetItem *, QListWidgetItem *)));
+ Q_ASSERT(ok);
}
-void CFontChooser::fontChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/)
-{
- if (current == 0)
- return;
- QString fontFamily = current->text();
- m_font.setFamily(fontFamily);
- loadStyles(fontFamily);
- outputHtmlText();
- emit fontSelected(m_font);
+void CFontChooser::fontChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
+ if (current == 0)
+ return;
+ QString fontFamily = current->text();
+ m_font.setFamily(fontFamily);
+ loadStyles(fontFamily);
+ outputHtmlText();
+ emit fontSelected(m_font);
}
-QString CFontChooser::formatAsHtml(const QString& text)
-{
+QString CFontChooser::formatAsHtml(const QString& text) {
- QString htmlText;
+ QString htmlText;
htmlText.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
htmlText.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
htmlText.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
@@ -185,180 +173,164 @@ QString CFontChooser::formatAsHtml(const QString& text)
htmlText.append("<body>\n");
htmlText.append(" <div>\n");
htmlText.append(" <div style=\"display: inline;\" lang=\"en\">\n");
- htmlText.append(text);
+ htmlText.append(text);
htmlText.append(" </div>\n");
htmlText.append("</body>\n");
htmlText.append("</html>\n");
- return htmlText;
+ return htmlText;
}
-void CFontChooser::loadFonts()
-{
- m_fontListWidget->clear();
- QFontDatabase database;
- foreach (QString font, database.families()) {
- m_fontListWidget->addItem(font);
- }
- // This triggers loading the styles for the first font
- m_fontListWidget->setCurrentRow(0);
+void CFontChooser::loadFonts() {
+ m_fontListWidget->clear();
+ QFontDatabase database;
+ foreach (QString font, database.families()) {
+ m_fontListWidget->addItem(font);
+ }
+ // This triggers loading the styles for the first font
+ m_fontListWidget->setCurrentRow(0);
}
-void CFontChooser::loadStyles(const QString& font)
-{
- m_styleListWidget->clear();
- QFontDatabase database;
- foreach (QString style, database.styles(font))
- {
- m_styleListWidget->addItem(style);
- // This triggers loading the sizes for the first style
- restoreListWidgetValue(m_styleListWidget,m_choosenStyle);
- }
+void CFontChooser::loadStyles(const QString& font) {
+ m_styleListWidget->clear();
+ QFontDatabase database;
+ foreach (QString style, database.styles(font)) {
+ m_styleListWidget->addItem(style);
+ // This triggers loading the sizes for the first style
+ restoreListWidgetValue(m_styleListWidget, m_choosenStyle);
+ }
}
-void CFontChooser::loadSizes(const QString& font, const QString& style)
-{
+void CFontChooser::loadSizes(const QString& font, const QString& style) {
- QString saveText = saveListWidgetValue(m_sizeListWidget);
+ QString saveText = saveListWidgetValue(m_sizeListWidget);
- // Put new values into listWidget
- m_sizeListWidget->clear();
- QFontDatabase database;
- foreach (int size, database.pointSizes(font, style))
- {
- m_sizeListWidget->addItem(QString::number(size));
- }
+ // Put new values into listWidget
+ m_sizeListWidget->clear();
+ QFontDatabase database;
+ foreach (int size, database.pointSizes(font, style)) {
+ m_sizeListWidget->addItem(QString::number(size));
+ }
- restoreListWidgetValue(m_sizeListWidget, saveText);
+ restoreListWidgetValue(m_sizeListWidget, saveText);
}
-void CFontChooser::outputHtmlText()
-{
- QString text = formatAsHtml(m_htmlText);
- text.replace("#FONT-FAMILY#", m_font.family());
- text.replace("#FONT-SIZE#", QString::number(m_font.pointSize()));
- text.replace("#FONT-WEIGHT#", (m_font.bold() ? "bold" : "normal") );
- text.replace("#FONT-STYLE#", m_font.italic() ? "italic" : "normal");
- m_webView->setHtml(text);
+void CFontChooser::outputHtmlText() {
+ QString text = formatAsHtml(m_htmlText);
+ text.replace("#FONT-FAMILY#", m_font.family());
+ text.replace("#FONT-SIZE#", QString::number(m_font.pointSize()));
+ text.replace("#FONT-WEIGHT#", (m_font.bold() ? "bold" : "normal") );
+ text.replace("#FONT-STYLE#", m_font.italic() ? "italic" : "normal");
+ m_webView->setHtml(text);
}
-void CFontChooser::restoreListWidgetValue(QListWidget* listWidget, const QString& value)
-{
- if (value == "") {
- listWidget->setCurrentRow(0);
- return;
- }
-
- for (int i=0; i< listWidget->count(); i++)
- {
- if (listWidget->item(i)->text() == value)
- {
- listWidget->setCurrentRow(i);
- return;
- }
- }
- listWidget->setCurrentRow(0);
+void CFontChooser::restoreListWidgetValue(QListWidget* listWidget, const QString& value) {
+ if (value == "") {
+ listWidget->setCurrentRow(0);
+ return;
+ }
+
+ for (int i = 0; i < listWidget->count(); i++) {
+ if (listWidget->item(i)->text() == value) {
+ listWidget->setCurrentRow(i);
+ return;
+ }
+ }
+ listWidget->setCurrentRow(0);
}
-QString CFontChooser::saveListWidgetValue(QListWidget* listWidget)
-{
- QString saveText;
- int row = listWidget->currentRow();
- if (row >= 0) {
- saveText = listWidget->item(row)->text();
- }
- return saveText;
+QString CFontChooser::saveListWidgetValue(QListWidget* listWidget) {
+ QString saveText;
+ int row = listWidget->currentRow();
+ if (row >= 0) {
+ saveText = listWidget->item(row)->text();
+ }
+ return saveText;
}
-void CFontChooser::setFont(const QFont& font)
-{
- disconnect(m_fontListWidget, 0, 0, 0);
- disconnect(m_styleListWidget, 0, 0, 0);
- disconnect(m_sizeListWidget, 0, 0, 0);
+void CFontChooser::setFont(const QFont& font) {
+ disconnect(m_fontListWidget, 0, 0, 0);
+ disconnect(m_styleListWidget, 0, 0, 0);
+ disconnect(m_sizeListWidget, 0, 0, 0);
- // set the font
- m_font = font;
- restoreListWidgetValue(m_fontListWidget, m_font.family());
+ // set the font
+ m_font = font;
+ restoreListWidgetValue(m_fontListWidget, m_font.family());
- // set the style
- loadStyles( m_font.family());
- QFontDatabase database;
- QString styleString = database.styleString(m_font);
- m_choosenStyle = styleString;
- restoreListWidgetValue(m_styleListWidget, styleString);
+ // set the style
+ loadStyles( m_font.family());
+ QFontDatabase database;
+ QString styleString = database.styleString(m_font);
+ m_choosenStyle = styleString;
+ restoreListWidgetValue(m_styleListWidget, styleString);
- // set the size
- loadSizes(m_font.family(), styleString);
- restoreListWidgetValue(m_sizeListWidget, QString::number(m_font.pointSize()) );
+ // set the size
+ loadSizes(m_font.family(), styleString);
+ restoreListWidgetValue(m_sizeListWidget, QString::number(m_font.pointSize()) );
- outputHtmlText();
- connectListWidgets();
+ outputHtmlText();
+ connectListWidgets();
}
-void CFontChooser::setFontStyle(const QString& styleString, QFont* font)
-{
- if (styleString.contains("bold",Qt::CaseInsensitive))
- font->setBold(true);
- else
- font->setBold(false);
+void CFontChooser::setFontStyle(const QString& styleString, QFont* font) {
+ if (styleString.contains("bold", Qt::CaseInsensitive))
+ font->setBold(true);
+ else
+ font->setBold(false);
- if (styleString.contains("italic",Qt::CaseInsensitive) || styleString.contains("oblique",Qt::CaseInsensitive) )
- font->setItalic(true);
- else
- font->setItalic(false);
+ if (styleString.contains("italic", Qt::CaseInsensitive) || styleString.contains("oblique", Qt::CaseInsensitive) )
+ font->setItalic(true);
+ else
+ font->setItalic(false);
}
-void CFontChooser::setSampleText(const QString& htmlText)
-{
- m_htmlText = htmlText;
- outputHtmlText();
+void CFontChooser::setSampleText(const QString& htmlText) {
+ m_htmlText = htmlText;
+ outputHtmlText();
}
-void CFontChooser::sizeChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/)
-{
- if (current == 0)
- return;
+void CFontChooser::sizeChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
+ if (current == 0)
+ return;
- QString size = m_sizeListWidget->currentItem()->text();
- m_font.setPointSize(size.toInt());
+ QString size = m_sizeListWidget->currentItem()->text();
+ m_font.setPointSize(size.toInt());
- outputHtmlText();
- emit fontSelected(m_font);
+ outputHtmlText();
+ emit fontSelected(m_font);
}
-QSize CFontChooser::sizeHint() const
-{
- return QSize(170,100);
+QSize CFontChooser::sizeHint() const {
+ return QSize(170, 100);
}
-void CFontChooser::styleChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/)
-{
- if (current == 0)
- return;
+void CFontChooser::styleChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
+ if (current == 0)
+ return;
- QString styleString = current->text();
- setFontStyle(styleString, &m_font);
+ QString styleString = current->text();
+ setFontStyle(styleString, &m_font);
- // Save style if the user choose it
- bool focus = m_styleListWidget->hasFocus();
- if (focus)
- m_choosenStyle = styleString;
+ // Save style if the user choose it
+ bool focus = m_styleListWidget->hasFocus();
+ if (focus)
+ m_choosenStyle = styleString;
- QString font = m_fontListWidget->currentItem()->text();
- loadSizes(font, styleString);
+ QString font = m_fontListWidget->currentItem()->text();
+ loadSizes(font, styleString);
- outputHtmlText();
- emit fontSelected(m_font);
+ outputHtmlText();
+ emit fontSelected(m_font);
}
diff --git a/src/frontend/settingsdialogs/cfontchooser.h b/src/frontend/settingsdialogs/cfontchooser.h
index 028fda9..7dcefda 100644
--- a/src/frontend/settingsdialogs/cfontchooser.h
+++ b/src/frontend/settingsdialogs/cfontchooser.h
@@ -13,7 +13,7 @@
#ifndef CFONTCHOOSER_H
#define CFONTCHOOSER_H
-// These following two defines allow chosing between using KDE and
+// These following two defines allow chosing between using KDE and
// Qt only for rendering the preview text
@@ -29,46 +29,46 @@ class QWebView;
class CListWidget;
class CFontChooser : public QFrame {
- Q_OBJECT
+ Q_OBJECT
-public:
- CFontChooser(QWidget* parent = 0);
- ~CFontChooser();
- void setFont(const QFont& font);
- void setSampleText(const QString& text);
- QSize sizeHint() const;
+ public:
+ CFontChooser(QWidget* parent = 0);
+ ~CFontChooser();
+ void setFont(const QFont& font);
+ void setSampleText(const QString& text);
+ QSize sizeHint() const;
-private:
- void createFontAreaLayout();
- void createLayout();
- void createTextAreaLayout();
- void connectListWidgets();
- QString formatAsHtml(const QString& text);
- void loadFonts();
- void loadSizes(const QString& font, const QString& style);
- void loadStyles(const QString& font);
- void outputHtmlText();
- void restoreListWidgetValue(QListWidget* listWidget, const QString& value);
- QString saveListWidgetValue(QListWidget* listWidget);
-
- QFrame* m_fontWidget;
- QWebView* m_webView;
- CListWidget* m_fontListWidget;
- CListWidget* m_styleListWidget;
- CListWidget* m_sizeListWidget;
- QString m_htmlText;
- QFont m_font;
- QVBoxLayout* m_vBoxLayout;
- QString m_choosenStyle;
+ private:
+ void createFontAreaLayout();
+ void createLayout();
+ void createTextAreaLayout();
+ void connectListWidgets();
+ QString formatAsHtml(const QString& text);
+ void loadFonts();
+ void loadSizes(const QString& font, const QString& style);
+ void loadStyles(const QString& font);
+ void outputHtmlText();
+ void restoreListWidgetValue(QListWidget* listWidget, const QString& value);
+ QString saveListWidgetValue(QListWidget* listWidget);
-private slots:
- void fontChanged(QListWidgetItem* current, QListWidgetItem* previous);
- void setFontStyle(const QString& styleString, QFont* font);
- void sizeChanged(QListWidgetItem* current, QListWidgetItem* previous);
- void styleChanged(QListWidgetItem* current, QListWidgetItem* previous);
+ QFrame* m_fontWidget;
+ QWebView* m_webView;
+ CListWidget* m_fontListWidget;
+ CListWidget* m_styleListWidget;
+ CListWidget* m_sizeListWidget;
+ QString m_htmlText;
+ QFont m_font;
+ QVBoxLayout* m_vBoxLayout;
+ QString m_choosenStyle;
-signals:
- void fontSelected(const QFont&);
+ private slots:
+ void fontChanged(QListWidgetItem* current, QListWidgetItem* previous);
+ void setFontStyle(const QString& styleString, QFont* font);
+ void sizeChanged(QListWidgetItem* current, QListWidgetItem* previous);
+ void styleChanged(QListWidgetItem* current, QListWidgetItem* previous);
+
+ signals:
+ void fontSelected(const QFont&);
};
#endif
diff --git a/src/frontend/settingsdialogs/clanguagesettings.cpp b/src/frontend/settingsdialogs/clanguagesettings.cpp
index 30d6e6b..152de40 100644
--- a/src/frontend/settingsdialogs/clanguagesettings.cpp
+++ b/src/frontend/settingsdialogs/clanguagesettings.cpp
@@ -1,7 +1,7 @@
//
// C++ Implementation: clanguagesettings
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
@@ -33,270 +33,237 @@
#include <swlocale.h>
CLanguageSettingsPage::CLanguageSettingsPage(QWidget* /*parent*/)
- : BtConfigPage()
-{
-
- QVBoxLayout* layout = new QVBoxLayout(this);
-
- //Sword locales
- layout->addWidget(
- CToolClass::explanationLabel(
- this,
- tr(""),
- tr("Select the language in which the Biblical book names are displayed.")
- ));
-
- m_swordLocaleCombo = new QComboBox(this);
- QLabel* label = new QLabel( tr("Language for names of Bible books:"), this);
- label->setBuddy(m_swordLocaleCombo);
- m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
-
-
- QHBoxLayout* hBoxLayout = new QHBoxLayout();
- hBoxLayout->addWidget(label);
- hBoxLayout->addWidget(m_swordLocaleCombo);
- hBoxLayout->addStretch();
- layout->addLayout(hBoxLayout);
-
- QStringList languageNames;
- languageNames.append( languageMgr()->languageForAbbrev("en_US")->translatedName() );
-
- std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- for (std::list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++)
- {
- // qWarning("working on %s", (*it).c_str());
- const CLanguageMgr::Language* const l =
- CPointers::languageMgr()->languageForAbbrev( sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName() );
-
- if (l->isValid())
- {
- languageNames.append( l->translatedName() );
- }
- else
- {
- languageNames.append(
- sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
- );
- }
- } //for
-
- languageNames.sort();
- m_swordLocaleCombo->addItems( languageNames );
-
- const CLanguageMgr::Language* const l =
- CPointers::languageMgr()->languageForAbbrev( CBTConfig::get(CBTConfig::language) );
-
- QString currentLanguageName;
- if ( l->isValid() && languageNames.contains(l->translatedName()) )
- { //tranlated language name is in the box
- currentLanguageName = l->translatedName();
- }
- else
- { //a language like "German Abbrevs" might be the language to set
- sword::SWLocale* locale =
- sword::LocaleMgr::getSystemLocaleMgr()->getLocale( CBTConfig::get(CBTConfig::language).toLocal8Bit() );
- if (locale)
- {
- currentLanguageName = QString::fromLatin1(locale->getDescription());
- }
- }
-
- if (currentLanguageName.isEmpty())
- { // set english as default if nothing was chosen
- Q_ASSERT(languageMgr()->languageForAbbrev("en_US"));
- currentLanguageName = languageMgr()->languageForAbbrev("en_US")->translatedName();
- }
-
- //now set the item with the right name as current item
- for (int i = 0; i < m_swordLocaleCombo->count(); ++i)
- {
- if (currentLanguageName == m_swordLocaleCombo->itemText(i))
- {
- m_swordLocaleCombo->setCurrentIndex(i);
- break; //item found, finish the loop
- }
- }
-
- layout->addSpacing(20);
-
- //Font settings
-
- layout->addWidget(
- CToolClass::explanationLabel(
- this,
- tr("Fonts"),
- tr("You can specify a custom font for each language.")
- )
- );
- QHBoxLayout* hLayout = new QHBoxLayout();
-
- m_usageCombo = new QComboBox(this);
- m_usageCombo->setToolTip(tr("The font selection below will apply to all texts in this language"));
-
- hLayout->addWidget(m_usageCombo);
-
- CLanguageMgr::LangMap langMap = languageMgr()->availableLanguages();
-
- for (CLanguageMgr::LangMapIterator it = langMap.constBegin() ; it != langMap.constEnd(); ++it )
- {
- const QString name =
- (*it)->translatedName().isEmpty()
- ? (*it)->abbrev()
- : (*it)->translatedName();
-
- m_fontMap.insert(name, CBTConfig::get(*it) );
- }
-
- for( QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it )
- {
- if ( m_fontMap[it.key()].first )
- { //show font icon
- m_usageCombo->addItem(util::filesystem::DirectoryUtil::getIcon("fonts.svg"), it.key() );
- }
- else
- { //don't show icon for font
- m_usageCombo->addItem(it.key());
- }
- }
-
- m_useOwnFontCheck = new QCheckBox(tr("Use custom font"), this);
- m_useOwnFontCheck->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- connect(m_useOwnFontCheck, SIGNAL(toggled(bool)), SLOT(useOwnFontClicked(bool)) );
- hLayout->addWidget(m_useOwnFontCheck);
-
- layout->addLayout(hLayout);
- hLayout->setContentsMargins(0,0,0,0);
- //#warning TODO: remember the last selected font and jump there.
-
- m_fontChooser = new CFontChooser(this);
-
- //TODO: Eeli's wishlist: why not show something relevant here, like a Bible verse in chosen (not tr()'ed!) language?
- QString sampleText;
- sampleText.append("1 In the beginning God created the heaven and the earth. ");
+ : BtConfigPage() {
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+
+ //Sword locales
+ layout->addWidget(
+ CToolClass::explanationLabel(
+ this,
+ tr(""),
+ tr("Select the language in which the Biblical book names are displayed.")
+ ));
+
+ m_swordLocaleCombo = new QComboBox(this);
+ QLabel* label = new QLabel( tr("Language for names of Bible books:"), this);
+ label->setBuddy(m_swordLocaleCombo);
+ m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
+
+
+ QHBoxLayout* hBoxLayout = new QHBoxLayout();
+ hBoxLayout->addWidget(label);
+ hBoxLayout->addWidget(m_swordLocaleCombo);
+ hBoxLayout->addStretch();
+ layout->addLayout(hBoxLayout);
+
+ QStringList languageNames;
+ languageNames.append( languageMgr()->languageForAbbrev("en_US")->translatedName() );
+
+ std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ for (std::list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++) {
+ // qWarning("working on %s", (*it).c_str());
+ const CLanguageMgr::Language* const l =
+ CPointers::languageMgr()->languageForAbbrev( sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName() );
+
+ if (l->isValid()) {
+ languageNames.append( l->translatedName() );
+ }
+ else {
+ languageNames.append(
+ sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
+ );
+ }
+ } //for
+
+ languageNames.sort();
+ m_swordLocaleCombo->addItems( languageNames );
+
+ const CLanguageMgr::Language* const l =
+ CPointers::languageMgr()->languageForAbbrev( CBTConfig::get(CBTConfig::language) );
+
+ QString currentLanguageName;
+ if ( l->isValid() && languageNames.contains(l->translatedName()) ) { //tranlated language name is in the box
+ currentLanguageName = l->translatedName();
+ }
+ else { //a language like "German Abbrevs" might be the language to set
+ sword::SWLocale* locale =
+ sword::LocaleMgr::getSystemLocaleMgr()->getLocale( CBTConfig::get(CBTConfig::language).toLocal8Bit() );
+ if (locale) {
+ currentLanguageName = QString::fromLatin1(locale->getDescription());
+ }
+ }
+
+ if (currentLanguageName.isEmpty()) { // set english as default if nothing was chosen
+ Q_ASSERT(languageMgr()->languageForAbbrev("en_US"));
+ currentLanguageName = languageMgr()->languageForAbbrev("en_US")->translatedName();
+ }
+
+ //now set the item with the right name as current item
+ for (int i = 0; i < m_swordLocaleCombo->count(); ++i) {
+ if (currentLanguageName == m_swordLocaleCombo->itemText(i)) {
+ m_swordLocaleCombo->setCurrentIndex(i);
+ break; //item found, finish the loop
+ }
+ }
+
+ layout->addSpacing(20);
+
+ //Font settings
+
+ layout->addWidget(
+ CToolClass::explanationLabel(
+ this,
+ tr("Fonts"),
+ tr("You can specify a custom font for each language.")
+ )
+ );
+ QHBoxLayout* hLayout = new QHBoxLayout();
+
+ m_usageCombo = new QComboBox(this);
+ m_usageCombo->setToolTip(tr("The font selection below will apply to all texts in this language"));
+
+ hLayout->addWidget(m_usageCombo);
+
+ CLanguageMgr::LangMap langMap = languageMgr()->availableLanguages();
+
+ for (CLanguageMgr::LangMapIterator it = langMap.constBegin() ; it != langMap.constEnd(); ++it ) {
+ const QString name =
+ (*it)->translatedName().isEmpty()
+ ? (*it)->abbrev()
+ : (*it)->translatedName();
+
+ m_fontMap.insert(name, CBTConfig::get(*it) );
+ }
+
+ for ( QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
+ if ( m_fontMap[it.key()].first ) { //show font icon
+ m_usageCombo->addItem(util::filesystem::DirectoryUtil::getIcon("fonts.svg"), it.key() );
+ }
+ else { //don't show icon for font
+ m_usageCombo->addItem(it.key());
+ }
+ }
+
+ m_useOwnFontCheck = new QCheckBox(tr("Use custom font"), this);
+ m_useOwnFontCheck->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ connect(m_useOwnFontCheck, SIGNAL(toggled(bool)), SLOT(useOwnFontClicked(bool)) );
+ hLayout->addWidget(m_useOwnFontCheck);
+
+ layout->addLayout(hLayout);
+ hLayout->setContentsMargins(0, 0, 0, 0);
+ //#warning TODO: remember the last selected font and jump there.
+
+ m_fontChooser = new CFontChooser(this);
+
+ //TODO: Eeli's wishlist: why not show something relevant here, like a Bible verse in chosen (not tr()'ed!) language?
+ QString sampleText;
+ sampleText.append("1 In the beginning God created the heaven and the earth. ");
sampleText.append("2 And the earth was without form, and void; and darkness was on the face of the deep.");
- sampleText.append(" And the Spirit of God moved on the face of the waters.");
+ sampleText.append(" And the Spirit of God moved on the face of the waters.");
- m_fontChooser->setSampleText(sampleText);
- layout->addWidget(m_fontChooser);
+ m_fontChooser->setSampleText(sampleText);
+ layout->addWidget(m_fontChooser);
- connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)), SLOT(newDisplayWindowFontSelected(const QFont&)));
- connect(m_usageCombo, SIGNAL(activated(const QString&)), SLOT(newDisplayWindowFontAreaSelected(const QString&)));
+ connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)), SLOT(newDisplayWindowFontSelected(const QFont&)));
+ connect(m_usageCombo, SIGNAL(activated(const QString&)), SLOT(newDisplayWindowFontAreaSelected(const QString&)));
- m_fontChooser->setFont( m_fontMap[m_usageCombo->currentText()].second );
- useOwnFontClicked( m_fontMap[m_usageCombo->currentText()].first );
- m_useOwnFontCheck->setChecked( m_fontMap[m_usageCombo->currentText()].first );
- m_fontChooser->setMinimumSize(m_fontChooser->sizeHint());
+ m_fontChooser->setFont( m_fontMap[m_usageCombo->currentText()].second );
+ useOwnFontClicked( m_fontMap[m_usageCombo->currentText()].first );
+ m_useOwnFontCheck->setChecked( m_fontMap[m_usageCombo->currentText()].first );
+ m_fontChooser->setMinimumSize(m_fontChooser->sizeHint());
}
-CLanguageSettingsPage::~CLanguageSettingsPage()
-{
+CLanguageSettingsPage::~CLanguageSettingsPage() {
}
-void CLanguageSettingsPage::save()
-{
- for(QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it )
- {
- const CLanguageMgr::Language* const lang = languageMgr()->languageForTranslatedName(it.key());
- if (!lang->isValid())
- { //we possibly use a language, for which we have only the abbrev
- if (!lang->abbrev().isEmpty()) {
- CLanguageMgr::Language l(it.key(), it.key(), it.key()); //create a temp language
- CBTConfig::set(&l, it.value());
- }
- }
- else
- {
- CBTConfig::set(lang, it.value());
- }
- }
-
-
- QString languageAbbrev;
-
- const QString currentLanguageName = m_swordLocaleCombo->currentText();
- const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForTranslatedName( currentLanguageName );
-
- if (l && l->isValid())
- {
- languageAbbrev = l->abbrev();
- }
- else
- { //it can be the lang abbrev like de_abbrev or the Sword description
- std::list <sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
-
- for (std::list <sword::SWBuf>::iterator it = locales.begin(); it != locales.end(); it++)
- {
- sword::SWLocale* locale = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str());
- Q_ASSERT(locale);
-
- if ( locale && (QString::fromLatin1(locale->getDescription()) == currentLanguageName) )
- {
- languageAbbrev = QString::fromLatin1(locale->getName()); //we found the abbrevation for the current language
- break;
- }
- }
-
- if (languageAbbrev.isEmpty())
- {
- languageAbbrev = currentLanguageName; //probably a non-standard locale name like de_abbrev
- }
- }
-
- if (!languageAbbrev.isEmpty())
- {
- CBTConfig::set(CBTConfig::language, languageAbbrev);
- }
+void CLanguageSettingsPage::save() {
+ for (QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
+ const CLanguageMgr::Language* const lang = languageMgr()->languageForTranslatedName(it.key());
+ if (!lang->isValid()) { //we possibly use a language, for which we have only the abbrev
+ if (!lang->abbrev().isEmpty()) {
+ CLanguageMgr::Language l(it.key(), it.key(), it.key()); //create a temp language
+ CBTConfig::set(&l, it.value());
+ }
+ }
+ else {
+ CBTConfig::set(lang, it.value());
+ }
+ }
+
+
+ QString languageAbbrev;
+
+ const QString currentLanguageName = m_swordLocaleCombo->currentText();
+ const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForTranslatedName( currentLanguageName );
+
+ if (l && l->isValid()) {
+ languageAbbrev = l->abbrev();
+ }
+ else { //it can be the lang abbrev like de_abbrev or the Sword description
+ std::list <sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+
+ for (std::list <sword::SWBuf>::iterator it = locales.begin(); it != locales.end(); it++) {
+ sword::SWLocale* locale = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str());
+ Q_ASSERT(locale);
+
+ if ( locale && (QString::fromLatin1(locale->getDescription()) == currentLanguageName) ) {
+ languageAbbrev = QString::fromLatin1(locale->getName()); //we found the abbrevation for the current language
+ break;
+ }
+ }
+
+ if (languageAbbrev.isEmpty()) {
+ languageAbbrev = currentLanguageName; //probably a non-standard locale name like de_abbrev
+ }
+ }
+
+ if (!languageAbbrev.isEmpty()) {
+ CBTConfig::set(CBTConfig::language, languageAbbrev);
+ }
}
/** */
-void CLanguageSettingsPage::newDisplayWindowFontSelected(const QFont &newFont)
-{
- //belongs to the languages/fonts page
- CBTConfig::FontSettingsPair oldSettings = m_fontMap[ m_usageCombo->currentText() ];
- m_fontMap.insert( m_usageCombo->currentText(), CBTConfig::FontSettingsPair(oldSettings.first, newFont) );
+void CLanguageSettingsPage::newDisplayWindowFontSelected(const QFont &newFont) {
+ //belongs to the languages/fonts page
+ CBTConfig::FontSettingsPair oldSettings = m_fontMap[ m_usageCombo->currentText() ];
+ m_fontMap.insert( m_usageCombo->currentText(), CBTConfig::FontSettingsPair(oldSettings.first, newFont) );
}
/** Called when the combobox contents is changed */
-void CLanguageSettingsPage::newDisplayWindowFontAreaSelected(const QString& usage)
-{
- //belongs to fonts/languages
- useOwnFontClicked( m_fontMap[usage].first );
- m_useOwnFontCheck->setChecked( m_fontMap[usage].first );
+void CLanguageSettingsPage::newDisplayWindowFontAreaSelected(const QString& usage) {
+ //belongs to fonts/languages
+ useOwnFontClicked( m_fontMap[usage].first );
+ m_useOwnFontCheck->setChecked( m_fontMap[usage].first );
- m_fontChooser->setFont( m_fontMap[usage].second );
+ m_fontChooser->setFont( m_fontMap[usage].second );
}
/** This slot is called when the "Use own font for language" bo was clicked. */
-void CLanguageSettingsPage::useOwnFontClicked( bool isOn )
-{
- //belongs to fonts/languages
-
- m_fontChooser->setEnabled(isOn);
- m_fontMap[ m_usageCombo->currentText() ].first = isOn;
-
- if (isOn)
- { //show font icon
- m_usageCombo->setItemIcon(m_usageCombo->currentIndex(), util::filesystem::DirectoryUtil::getIcon("fonts.svg") );
- }
- else
- { //don't show
- m_usageCombo->setItemText(m_usageCombo->currentIndex(), m_usageCombo->currentText() ); //TODO: should this change icon to empty?
- }
+void CLanguageSettingsPage::useOwnFontClicked( bool isOn ) {
+ //belongs to fonts/languages
+
+ m_fontChooser->setEnabled(isOn);
+ m_fontMap[ m_usageCombo->currentText() ].first = isOn;
+
+ if (isOn) { //show font icon
+ m_usageCombo->setItemIcon(m_usageCombo->currentIndex(), util::filesystem::DirectoryUtil::getIcon("fonts.svg") );
+ }
+ else { //don't show
+ m_usageCombo->setItemText(m_usageCombo->currentIndex(), m_usageCombo->currentText() ); //TODO: should this change icon to empty?
+ }
}
-QString CLanguageSettingsPage::iconName()
-{
- return CResMgr::settings::fonts::icon;
+QString CLanguageSettingsPage::iconName() {
+ return CResMgr::settings::fonts::icon;
}
-QString CLanguageSettingsPage::label()
-{
- //: Empty string, don't translate
- return tr("");
+QString CLanguageSettingsPage::label() {
+ //: Empty string, don't translate
+ return tr("");
}
-QString CLanguageSettingsPage::header()
-{
- return tr("Languages");
+QString CLanguageSettingsPage::header() {
+ return tr("Languages");
}
diff --git a/src/frontend/settingsdialogs/clanguagesettings.h b/src/frontend/settingsdialogs/clanguagesettings.h
index 9dccc85..d4f588b 100644
--- a/src/frontend/settingsdialogs/clanguagesettings.h
+++ b/src/frontend/settingsdialogs/clanguagesettings.h
@@ -1,7 +1,7 @@
//
// C++ Interface: clanguagesettings
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
@@ -28,35 +28,34 @@ class CFontChooser;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CLanguageSettingsPage : public BtConfigPage, CPointers
-{
-Q_OBJECT
-public:
- CLanguageSettingsPage(QWidget *parent);
- ~CLanguageSettingsPage();
- void save();
- QString iconName();
- QString label();
- QString header();
-
-protected slots:
-
- // This slot is called when the "Use own font for language" button was clicked.
- void useOwnFontClicked(bool);
-
- // Called when a new font in the fonts page was selected.
- void newDisplayWindowFontSelected(const QFont &);
-
- // Called when the combobox contents is changed
- void newDisplayWindowFontAreaSelected(const QString&);
-
-private:
- QComboBox* m_swordLocaleCombo;
- QComboBox* m_usageCombo;
- QCheckBox* m_useOwnFontCheck;
- CFontChooser* m_fontChooser;
-
- QMap<QString,CBTConfig::FontSettingsPair> m_fontMap;
+class CLanguageSettingsPage : public BtConfigPage, CPointers {
+ Q_OBJECT
+ public:
+ CLanguageSettingsPage(QWidget *parent);
+ ~CLanguageSettingsPage();
+ void save();
+ QString iconName();
+ QString label();
+ QString header();
+
+ protected slots:
+
+ // This slot is called when the "Use own font for language" button was clicked.
+ void useOwnFontClicked(bool);
+
+ // Called when a new font in the fonts page was selected.
+ void newDisplayWindowFontSelected(const QFont &);
+
+ // Called when the combobox contents is changed
+ void newDisplayWindowFontAreaSelected(const QString&);
+
+ private:
+ QComboBox* m_swordLocaleCombo;
+ QComboBox* m_usageCombo;
+ QCheckBox* m_useOwnFontCheck;
+ CFontChooser* m_fontChooser;
+
+ QMap<QString, CBTConfig::FontSettingsPair> m_fontMap;
};
#endif
diff --git a/src/frontend/settingsdialogs/clistwidget.cpp b/src/frontend/settingsdialogs/clistwidget.cpp
index 8fdc130..61be4b5 100644
--- a/src/frontend/settingsdialogs/clistwidget.cpp
+++ b/src/frontend/settingsdialogs/clistwidget.cpp
@@ -11,20 +11,16 @@
#include "clistwidget.h"
CListWidget::CListWidget(QWidget* parent)
- : QListWidget(parent)
-{
+ : QListWidget(parent) {
}
-CListWidget::~CListWidget()
-{
+CListWidget::~CListWidget() {
}
-QSize CListWidget::sizeHint () const
-{
- return QSize(100,120);
+QSize CListWidget::sizeHint () const {
+ return QSize(100, 120);
}
-void CListWidget::setCharWidth(int width)
-{
- setMaximumWidth(CToolClass::mWidth(this, width));
+void CListWidget::setCharWidth(int width) {
+ setMaximumWidth(CToolClass::mWidth(this, width));
}
diff --git a/src/frontend/settingsdialogs/clistwidget.h b/src/frontend/settingsdialogs/clistwidget.h
index 6afd232..ae93db6 100644
--- a/src/frontend/settingsdialogs/clistwidget.h
+++ b/src/frontend/settingsdialogs/clistwidget.h
@@ -16,13 +16,13 @@
#include <QListWidget>
class CListWidget : public QListWidget {
- Q_OBJECT
+ Q_OBJECT
-public:
- CListWidget(QWidget* parent = 0);
- ~CListWidget();
- virtual QSize sizeHint () const;
- void setCharWidth(int width);
+ public:
+ CListWidget(QWidget* parent = 0);
+ ~CListWidget();
+ virtual QSize sizeHint () const;
+ void setCharWidth(int width);
};
#endif
diff --git a/src/frontend/settingsdialogs/cswordsettings.cpp b/src/frontend/settingsdialogs/cswordsettings.cpp
index 29afd17..3b5b89e 100644
--- a/src/frontend/settingsdialogs/cswordsettings.cpp
+++ b/src/frontend/settingsdialogs/cswordsettings.cpp
@@ -1,7 +1,7 @@
//
// C++ Implementation: cswordsettings
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
@@ -32,392 +32,366 @@
CSwordSettingsPage::CSwordSettingsPage(QWidget* /*parent*/)
- : BtConfigPage()
-{
- QVBoxLayout* vbox = new QVBoxLayout(this);
- QTabWidget* tabWidget = new QTabWidget();
- vbox->addWidget(tabWidget);
- setLayout(vbox);
-
- m_worksTab = new StandardWorksTab();
- m_filtersTab = new TextFiltersTab();
- tabWidget->addTab(m_worksTab, tr("Standard works"));
- tabWidget->addTab(m_filtersTab, tr("Text filters"));
+ : BtConfigPage() {
+ QVBoxLayout* vbox = new QVBoxLayout(this);
+ QTabWidget* tabWidget = new QTabWidget();
+ vbox->addWidget(tabWidget);
+ setLayout(vbox);
+
+ m_worksTab = new StandardWorksTab();
+ m_filtersTab = new TextFiltersTab();
+ tabWidget->addTab(m_worksTab, tr("Standard works"));
+ tabWidget->addTab(m_filtersTab, tr("Text filters"));
}
//Standard works tab
StandardWorksTab::StandardWorksTab()
- : QWidget(0)
-{
-
- // move: tabCtl->addTab(currentTab, tr("Standard works"));
- QGridLayout* gridLayout = new QGridLayout(this); //the last row is for stretching available space
- gridLayout->setSizeConstraint(QLayout::SetMinimumSize);
-
- gridLayout->addWidget(
- CToolClass::explanationLabel(
- this,
- tr(""),
- tr("Standard works are used when no particular work is specified, \
+ : QWidget(0) {
+ typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
+
+ // move: tabCtl->addTab(currentTab, tr("Standard works"));
+ QGridLayout* gridLayout = new QGridLayout(this); //the last row is for stretching available space
+ gridLayout->setSizeConstraint(QLayout::SetMinimumSize);
+
+ gridLayout->addWidget(
+ CToolClass::explanationLabel(
+ this,
+ tr(""),
+ tr("Standard works are used when no particular work is specified, \
for example when a hyperlink into a Bible or lexicon was clicked .")),
- 0,0,1,2 /*fill the horizontal space*/
- );
-
- //Create selection boxes
-
- m_standardBibleCombo = new QComboBox(this);
- QLabel* label = new QLabel( tr("Bible:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardBibleCombo);
- ////label->setAutoResize(true); //? not found in docs
- m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
-
- gridLayout->addWidget(label,1,0);
- gridLayout->addWidget(m_standardBibleCombo, 1, 1);
-
- m_standardCommentaryCombo = new QComboBox(this);
- label = new QLabel( tr("Commentary:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardCommentaryCombo);
- //label->setAutoResize(true);
- m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
-
- gridLayout->addWidget(label, 2, 0);
- gridLayout->addWidget(m_standardCommentaryCombo, 2, 1);
-
- m_standardLexiconCombo = new QComboBox(this);
- label = new QLabel(tr("Lexicon:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardLexiconCombo);
- //label->setAutoResize(true);
- m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
-
- gridLayout->addWidget(label,3,0);
- gridLayout->addWidget(m_standardLexiconCombo, 3, 1);
-
- m_standardDailyDevotionalCombo = new QComboBox(this);
- label = new QLabel(tr("Daily devotional:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardDailyDevotionalCombo);
- //label->setAutoResize(true);
- m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
-
- gridLayout->addWidget(label,4,0);
- gridLayout->addWidget(m_standardDailyDevotionalCombo, 4, 1);
-
- m_standardHebrewStrongCombo = new QComboBox(this);
- label = new QLabel(tr("Hebrew Strong's lexicon:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardHebrewStrongCombo);
- //label->setAutoResize(true);
- m_standardHebrewStrongCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
-
- gridLayout->addWidget(label, 5, 0);
- gridLayout->addWidget(m_standardHebrewStrongCombo, 5, 1);
-
- m_standardGreekStrongCombo = new QComboBox(this);
- label = new QLabel(tr("Greek Strong's lexicon:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardGreekStrongCombo);
- //label->setAutoResize(true);
- m_standardGreekStrongCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
-
- gridLayout->addWidget(label, 6, 0);
- gridLayout->addWidget(m_standardGreekStrongCombo, 6, 1);
-
- m_standardHebrewMorphCombo = new QComboBox(this);
- label = new QLabel( tr("Hebrew morphological lexicon:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardHebrewMorphCombo);
- //label->setAutoResize(true);
- m_standardHebrewMorphCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
-
- gridLayout->addWidget(label, 7, 0);
- gridLayout->addWidget(m_standardHebrewMorphCombo, 7, 1);
-
- m_standardGreekMorphCombo = new QComboBox(this);
- label = new QLabel(tr("Greek morphological lexicon:"), this);
- label->setAlignment(Qt::AlignRight);
- label->setBuddy(m_standardGreekMorphCombo);
- //label->setAutoResize(true);
- m_standardGreekMorphCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
-
- gridLayout->addWidget(label, 8, 0);
- gridLayout->addWidget(m_standardGreekMorphCombo, 8, 1);
-
- gridLayout->setRowStretch(9,5);
-
- //fill the comboboxes with the right modules
-
- QList<CSwordModuleInfo*>& modules = backend()->moduleList();
- QString modDescript;
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it)
- {
- modDescript = (*it)->config(CSwordModuleInfo::Description);
-
- switch ((*it)->type())
- {
- case CSwordModuleInfo::Bible:
- m_standardBibleCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Commentary:
- m_standardCommentaryCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Lexicon:
- {
- bool inserted = false;
- if ((*it)->has(CSwordModuleInfo::HebrewDef))
- {
- m_standardHebrewStrongCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekDef))
- {
- m_standardGreekStrongCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::HebrewParse))
- {
- m_standardHebrewMorphCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekParse))
- {
- m_standardGreekMorphCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->category() == CSwordModuleInfo::DailyDevotional)
- {
- m_standardDailyDevotionalCombo->addItem(modDescript);
- inserted = true;
- }
-
- if (!inserted)
- { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
- m_standardLexiconCombo->addItem(modDescript);
- }
- break;
- }
- default://unknown type
- break;
- } //switch
- } //for
-
- //using two lists and one loop is better than six loops with almost the same code :)
- QList<QComboBox*> comboList;
- QStringList moduleList;
-
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i)
- {
- //fill the combobox list in the right order (i.e. same order as the CBTConfig::module enum list)
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType)
- {
- case CBTConfig::standardBible:
- comboList.append(m_standardBibleCombo);
- break;
- case CBTConfig::standardCommentary:
- comboList.append(m_standardCommentaryCombo);
- break;
- case CBTConfig::standardLexicon:
- comboList.append(m_standardLexiconCombo);
- break;
- case CBTConfig::standardDailyDevotional:
- comboList.append(m_standardDailyDevotionalCombo);
- break;
- case CBTConfig::standardHebrewStrongsLexicon:
- comboList.append(m_standardHebrewStrongCombo);
- break;
- case CBTConfig::standardGreekStrongsLexicon:
- comboList.append(m_standardGreekStrongCombo);
- break;
- case CBTConfig::standardHebrewMorphLexicon:
- comboList.append(m_standardHebrewMorphCombo);
- break;
- case CBTConfig::standardGreekMorphLexicon:
- comboList.append(m_standardGreekMorphCombo);
- break;
- }; //switch
-
- //fill the module list
- CSwordModuleInfo* const m = CBTConfig::get( (CBTConfig::modules)(i) );
- if (m)
- {
- moduleList << m->config(CSwordModuleInfo::Description);
- }
- else
- {
- moduleList << QString::null;
- }
- } //for
-
- QString module = QString::null;
- int item = 0;
- int count = 0;
- QListIterator<QComboBox*> it(comboList);
- while (it.hasNext())
- {
- //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
- QComboBox* combo = it.next();
- module = moduleList[comboList.indexOf(combo)];
- count = combo->count();
- combo->setMaximumWidth(300);
-
- for (item = 0; item < count; item++)
- {
- if (combo->itemText(item) == module )
- {
- combo->setCurrentIndex(item);
- break;
- }
- }
- }
+ 0, 0, 1, 2 /*fill the horizontal space*/
+ );
+
+ //Create selection boxes
+
+ m_standardBibleCombo = new QComboBox(this);
+ QLabel* label = new QLabel( tr("Bible:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardBibleCombo);
+ ////label->setAutoResize(true); //? not found in docs
+ m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
+
+ gridLayout->addWidget(label, 1, 0);
+ gridLayout->addWidget(m_standardBibleCombo, 1, 1);
+
+ m_standardCommentaryCombo = new QComboBox(this);
+ label = new QLabel( tr("Commentary:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardCommentaryCombo);
+ //label->setAutoResize(true);
+ m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
+
+ gridLayout->addWidget(label, 2, 0);
+ gridLayout->addWidget(m_standardCommentaryCombo, 2, 1);
+
+ m_standardLexiconCombo = new QComboBox(this);
+ label = new QLabel(tr("Lexicon:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardLexiconCombo);
+ //label->setAutoResize(true);
+ m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
+
+ gridLayout->addWidget(label, 3, 0);
+ gridLayout->addWidget(m_standardLexiconCombo, 3, 1);
+
+ m_standardDailyDevotionalCombo = new QComboBox(this);
+ label = new QLabel(tr("Daily devotional:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardDailyDevotionalCombo);
+ //label->setAutoResize(true);
+ m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
+
+ gridLayout->addWidget(label, 4, 0);
+ gridLayout->addWidget(m_standardDailyDevotionalCombo, 4, 1);
+
+ m_standardHebrewStrongCombo = new QComboBox(this);
+ label = new QLabel(tr("Hebrew Strong's lexicon:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardHebrewStrongCombo);
+ //label->setAutoResize(true);
+ m_standardHebrewStrongCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
+
+ gridLayout->addWidget(label, 5, 0);
+ gridLayout->addWidget(m_standardHebrewStrongCombo, 5, 1);
+
+ m_standardGreekStrongCombo = new QComboBox(this);
+ label = new QLabel(tr("Greek Strong's lexicon:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardGreekStrongCombo);
+ //label->setAutoResize(true);
+ m_standardGreekStrongCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
+
+ gridLayout->addWidget(label, 6, 0);
+ gridLayout->addWidget(m_standardGreekStrongCombo, 6, 1);
+
+ m_standardHebrewMorphCombo = new QComboBox(this);
+ label = new QLabel( tr("Hebrew morphological lexicon:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardHebrewMorphCombo);
+ //label->setAutoResize(true);
+ m_standardHebrewMorphCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
+
+ gridLayout->addWidget(label, 7, 0);
+ gridLayout->addWidget(m_standardHebrewMorphCombo, 7, 1);
+
+ m_standardGreekMorphCombo = new QComboBox(this);
+ label = new QLabel(tr("Greek morphological lexicon:"), this);
+ label->setAlignment(Qt::AlignRight);
+ label->setBuddy(m_standardGreekMorphCombo);
+ //label->setAutoResize(true);
+ m_standardGreekMorphCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
+
+ gridLayout->addWidget(label, 8, 0);
+ gridLayout->addWidget(m_standardGreekMorphCombo, 8, 1);
+
+ gridLayout->setRowStretch(9, 5);
+
+ //fill the comboboxes with the right modules
+
+ const QList<CSwordModuleInfo*> &modules(backend()->moduleList());
+ QString modDescript;
+ for (MLCI it(modules.begin()); it != modules.end(); it++) {
+ modDescript = (*it)->config(CSwordModuleInfo::Description);
+
+ switch ((*it)->type()) {
+ case CSwordModuleInfo::Bible:
+ m_standardBibleCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Commentary:
+ m_standardCommentaryCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Lexicon: {
+ bool inserted = false;
+ if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
+ m_standardHebrewStrongCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekDef)) {
+ m_standardGreekStrongCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
+ m_standardHebrewMorphCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekParse)) {
+ m_standardGreekMorphCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
+ m_standardDailyDevotionalCombo->addItem(modDescript);
+ inserted = true;
+ }
+
+ if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
+ m_standardLexiconCombo->addItem(modDescript);
+ }
+ break;
+ }
+ default://unknown type
+ break;
+ } //switch
+ } //for
+
+ //using two lists and one loop is better than six loops with almost the same code :)
+ QList<QComboBox*> comboList;
+ QStringList moduleList;
+
+ for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
+ //fill the combobox list in the right order (i.e. same order as the CBTConfig::module enum list)
+ CBTConfig::modules moduleType = (CBTConfig::modules)(i);
+ switch (moduleType) {
+ case CBTConfig::standardBible:
+ comboList.append(m_standardBibleCombo);
+ break;
+ case CBTConfig::standardCommentary:
+ comboList.append(m_standardCommentaryCombo);
+ break;
+ case CBTConfig::standardLexicon:
+ comboList.append(m_standardLexiconCombo);
+ break;
+ case CBTConfig::standardDailyDevotional:
+ comboList.append(m_standardDailyDevotionalCombo);
+ break;
+ case CBTConfig::standardHebrewStrongsLexicon:
+ comboList.append(m_standardHebrewStrongCombo);
+ break;
+ case CBTConfig::standardGreekStrongsLexicon:
+ comboList.append(m_standardGreekStrongCombo);
+ break;
+ case CBTConfig::standardHebrewMorphLexicon:
+ comboList.append(m_standardHebrewMorphCombo);
+ break;
+ case CBTConfig::standardGreekMorphLexicon:
+ comboList.append(m_standardGreekMorphCombo);
+ break;
+ }
+ ; //switch
+
+ //fill the module list
+ CSwordModuleInfo* const m = CBTConfig::get( (CBTConfig::modules)(i) );
+ if (m) {
+ moduleList << m->config(CSwordModuleInfo::Description);
+ }
+ else {
+ moduleList << QString::null;
+ }
+ } //for
+
+ QString module = QString::null;
+ int item = 0;
+ int count = 0;
+ QListIterator<QComboBox*> it(comboList);
+ while (it.hasNext()) {
+ //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
+ QComboBox* combo = it.next();
+ module = moduleList[comboList.indexOf(combo)];
+ count = combo->count();
+ combo->setMaximumWidth(300);
+
+ for (item = 0; item < count; item++) {
+ if (combo->itemText(item) == module ) {
+ combo->setCurrentIndex(item);
+ break;
+ }
+ }
+ }
}
-TextFiltersTab::TextFiltersTab()
-{
- QVBoxLayout* layout = new QVBoxLayout(this);
- layout->setMargin(5);
- QWidget* eLabel = CToolClass::explanationLabel(
- this,
- tr(""),
- tr("Filters control the appearance of text. \
+TextFiltersTab::TextFiltersTab() {
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->setMargin(5);
+ QWidget* eLabel = CToolClass::explanationLabel(
+ this,
+ tr(""),
+ tr("Filters control the appearance of text. \
Here you can specify default settings for all filters. \
You can override these settings in each display window.")
- );
- eLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- eLabel->setMaximumHeight(50);
- eLabel->setMinimumWidth(300);
- layout->setSpacing(2);
- layout->addWidget(eLabel);
-
- m_lineBreaksCheck = new QCheckBox(this);
- m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
- m_lineBreaksCheck->setChecked(CBTConfig::get(CBTConfig::lineBreaks));
- layout->addWidget(m_lineBreaksCheck);
-
- m_verseNumbersCheck = new QCheckBox(this);
- m_verseNumbersCheck->setText(tr("Show verse numbers"));
- m_verseNumbersCheck->setChecked(CBTConfig::get(CBTConfig::verseNumbers));
- layout->addWidget(m_verseNumbersCheck);
-
- m_headingsCheck = new QCheckBox(this);
- m_headingsCheck->setText(tr("Show section headings"));
- m_headingsCheck->setChecked(CBTConfig::get(CBTConfig::headings));
- layout->addWidget(m_headingsCheck);
-
-
- m_scriptureReferencesCheck = new QCheckBox(this);
- m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
- m_scriptureReferencesCheck->setChecked(CBTConfig::get(CBTConfig::scriptureReferences));
- layout->addWidget(m_scriptureReferencesCheck);
-
- m_greekAccentsCheck = new QCheckBox(this);
- m_greekAccentsCheck->setText(tr("Show Greek accents"));
- m_greekAccentsCheck->setChecked(CBTConfig::get(CBTConfig::greekAccents));
- layout->addWidget(m_greekAccentsCheck);
-
- m_hebrewPointsCheck = new QCheckBox(this);
- m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
- m_hebrewPointsCheck->setChecked(CBTConfig::get(CBTConfig::hebrewPoints));
- layout->addWidget(m_hebrewPointsCheck);
-
- m_hebrewCantillationCheck = new QCheckBox(this);
- m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
- m_hebrewCantillationCheck->setChecked(CBTConfig::get(CBTConfig::hebrewCantillation));
- layout->addWidget(m_hebrewCantillationCheck);
-
- m_morphSegmentationCheck = new QCheckBox(this);
- m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
- m_morphSegmentationCheck->setChecked(CBTConfig::get(CBTConfig::morphSegmentation));
- layout->addWidget(m_morphSegmentationCheck);
-
- m_textualVariantsCheck = new QCheckBox(this);
- m_textualVariantsCheck->setText(tr("Use textual variants"));
- m_textualVariantsCheck->setChecked(CBTConfig::get(CBTConfig::textualVariants));
- layout->addWidget(m_textualVariantsCheck);
-
- layout->addStretch(4);
+ );
+ eLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ eLabel->setMaximumHeight(50);
+ eLabel->setMinimumWidth(300);
+ layout->setSpacing(2);
+ layout->addWidget(eLabel);
+
+ m_lineBreaksCheck = new QCheckBox(this);
+ m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
+ m_lineBreaksCheck->setChecked(CBTConfig::get(CBTConfig::lineBreaks));
+ layout->addWidget(m_lineBreaksCheck);
+
+ m_verseNumbersCheck = new QCheckBox(this);
+ m_verseNumbersCheck->setText(tr("Show verse numbers"));
+ m_verseNumbersCheck->setChecked(CBTConfig::get(CBTConfig::verseNumbers));
+ layout->addWidget(m_verseNumbersCheck);
+
+ m_headingsCheck = new QCheckBox(this);
+ m_headingsCheck->setText(tr("Show section headings"));
+ m_headingsCheck->setChecked(CBTConfig::get(CBTConfig::headings));
+ layout->addWidget(m_headingsCheck);
+
+
+ m_scriptureReferencesCheck = new QCheckBox(this);
+ m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
+ m_scriptureReferencesCheck->setChecked(CBTConfig::get(CBTConfig::scriptureReferences));
+ layout->addWidget(m_scriptureReferencesCheck);
+
+ m_greekAccentsCheck = new QCheckBox(this);
+ m_greekAccentsCheck->setText(tr("Show Greek accents"));
+ m_greekAccentsCheck->setChecked(CBTConfig::get(CBTConfig::greekAccents));
+ layout->addWidget(m_greekAccentsCheck);
+
+ m_hebrewPointsCheck = new QCheckBox(this);
+ m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
+ m_hebrewPointsCheck->setChecked(CBTConfig::get(CBTConfig::hebrewPoints));
+ layout->addWidget(m_hebrewPointsCheck);
+
+ m_hebrewCantillationCheck = new QCheckBox(this);
+ m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
+ m_hebrewCantillationCheck->setChecked(CBTConfig::get(CBTConfig::hebrewCantillation));
+ layout->addWidget(m_hebrewCantillationCheck);
+
+ m_morphSegmentationCheck = new QCheckBox(this);
+ m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
+ m_morphSegmentationCheck->setChecked(CBTConfig::get(CBTConfig::morphSegmentation));
+ layout->addWidget(m_morphSegmentationCheck);
+
+ m_textualVariantsCheck = new QCheckBox(this);
+ m_textualVariantsCheck->setText(tr("Use textual variants"));
+ m_textualVariantsCheck->setChecked(CBTConfig::get(CBTConfig::textualVariants));
+ layout->addWidget(m_textualVariantsCheck);
+
+ layout->addStretch(4);
}
-void CSwordSettingsPage::save()
-{
- m_worksTab->save();
- m_filtersTab->save();
+void CSwordSettingsPage::save() {
+ m_worksTab->save();
+ m_filtersTab->save();
}
-QString CSwordSettingsPage::iconName()
-{
- return CResMgr::settings::sword::icon;
+QString CSwordSettingsPage::iconName() {
+ return CResMgr::settings::sword::icon;
}
-QString CSwordSettingsPage::label()
-{
- //: Empty string, don't translate
- return tr("");
+QString CSwordSettingsPage::label() {
+ //: Empty string, don't translate
+ return tr("");
}
-QString CSwordSettingsPage::header()
-{
- return tr("Desk");
+QString CSwordSettingsPage::header() {
+ return tr("Desk");
}
-void StandardWorksTab::save()
-{
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i)
- {
- QString moduleDescription = QString::null;
-
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType)
- {
- case CBTConfig::standardBible:
- moduleDescription = m_standardBibleCombo->currentText();
- break;
- case CBTConfig::standardCommentary:
- moduleDescription = m_standardCommentaryCombo->currentText();
- break;
- case CBTConfig::standardLexicon:
- moduleDescription = m_standardLexiconCombo->currentText();
- break;
- case CBTConfig::standardDailyDevotional:
- moduleDescription = m_standardDailyDevotionalCombo->currentText();
- break;
- case CBTConfig::standardHebrewStrongsLexicon:
- moduleDescription = m_standardHebrewStrongCombo->currentText();
- break;
- case CBTConfig::standardGreekStrongsLexicon:
- moduleDescription = m_standardGreekStrongCombo->currentText();
- break;
- case CBTConfig::standardHebrewMorphLexicon:
- moduleDescription = m_standardHebrewMorphCombo->currentText();
- break;
- case CBTConfig::standardGreekMorphLexicon:
- moduleDescription = m_standardGreekMorphCombo->currentText();
- break;
- default:
- qWarning("Unhandled module type.");
- };
-
- CSwordModuleInfo* const module = backend()->findModuleByDescription(moduleDescription);
- CBTConfig::set
- (moduleType, module);
- }
+void StandardWorksTab::save() {
+ for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
+ QString moduleDescription = QString::null;
+
+ CBTConfig::modules moduleType = (CBTConfig::modules)(i);
+ switch (moduleType) {
+ case CBTConfig::standardBible:
+ moduleDescription = m_standardBibleCombo->currentText();
+ break;
+ case CBTConfig::standardCommentary:
+ moduleDescription = m_standardCommentaryCombo->currentText();
+ break;
+ case CBTConfig::standardLexicon:
+ moduleDescription = m_standardLexiconCombo->currentText();
+ break;
+ case CBTConfig::standardDailyDevotional:
+ moduleDescription = m_standardDailyDevotionalCombo->currentText();
+ break;
+ case CBTConfig::standardHebrewStrongsLexicon:
+ moduleDescription = m_standardHebrewStrongCombo->currentText();
+ break;
+ case CBTConfig::standardGreekStrongsLexicon:
+ moduleDescription = m_standardGreekStrongCombo->currentText();
+ break;
+ case CBTConfig::standardHebrewMorphLexicon:
+ moduleDescription = m_standardHebrewMorphCombo->currentText();
+ break;
+ case CBTConfig::standardGreekMorphLexicon:
+ moduleDescription = m_standardGreekMorphCombo->currentText();
+ break;
+ default:
+ qWarning("Unhandled module type.");
+ };
+
+ CSwordModuleInfo* const module = backend()->findModuleByDescription(moduleDescription);
+ CBTConfig::set
+ (moduleType, module);
+ }
}
-void TextFiltersTab::save()
-{
- CBTConfig::set(CBTConfig::lineBreaks, m_lineBreaksCheck->isChecked());
- CBTConfig::set(CBTConfig::verseNumbers, m_verseNumbersCheck->isChecked());
- CBTConfig::set(CBTConfig::headings, m_headingsCheck->isChecked());
- CBTConfig::set(CBTConfig::scriptureReferences, m_scriptureReferencesCheck->isChecked());
- CBTConfig::set(CBTConfig::hebrewPoints, m_hebrewPointsCheck->isChecked());
- CBTConfig::set(CBTConfig::hebrewCantillation, m_hebrewCantillationCheck->isChecked());
- CBTConfig::set(CBTConfig::morphSegmentation, m_morphSegmentationCheck->isChecked());
- CBTConfig::set(CBTConfig::greekAccents, m_greekAccentsCheck->isChecked());
- CBTConfig::set(CBTConfig::textualVariants, m_textualVariantsCheck->isChecked());
+void TextFiltersTab::save() {
+ CBTConfig::set(CBTConfig::lineBreaks, m_lineBreaksCheck->isChecked());
+ CBTConfig::set(CBTConfig::verseNumbers, m_verseNumbersCheck->isChecked());
+ CBTConfig::set(CBTConfig::headings, m_headingsCheck->isChecked());
+ CBTConfig::set(CBTConfig::scriptureReferences, m_scriptureReferencesCheck->isChecked());
+ CBTConfig::set(CBTConfig::hebrewPoints, m_hebrewPointsCheck->isChecked());
+ CBTConfig::set(CBTConfig::hebrewCantillation, m_hebrewCantillationCheck->isChecked());
+ CBTConfig::set(CBTConfig::morphSegmentation, m_morphSegmentationCheck->isChecked());
+ CBTConfig::set(CBTConfig::greekAccents, m_greekAccentsCheck->isChecked());
+ CBTConfig::set(CBTConfig::textualVariants, m_textualVariantsCheck->isChecked());
}
diff --git a/src/frontend/settingsdialogs/cswordsettings.h b/src/frontend/settingsdialogs/cswordsettings.h
index 19db47b..032471c 100644
--- a/src/frontend/settingsdialogs/cswordsettings.h
+++ b/src/frontend/settingsdialogs/cswordsettings.h
@@ -26,61 +26,58 @@ class QCheckBox;
class StandardWorksTab;
class TextFiltersTab;
-class CSwordSettingsPage : public BtConfigPage
-{
- Q_OBJECT
-
-public:
- CSwordSettingsPage(QWidget* parent);
- void save();
- QString iconName();
- QString label();
- QString header();
-
-private:
- StandardWorksTab* m_worksTab;
- TextFiltersTab* m_filtersTab;
+class CSwordSettingsPage : public BtConfigPage {
+ Q_OBJECT
+
+ public:
+ CSwordSettingsPage(QWidget* parent);
+ void save();
+ QString iconName();
+ QString label();
+ QString header();
+
+ private:
+ StandardWorksTab* m_worksTab;
+ TextFiltersTab* m_filtersTab;
};
//Tab pages. To be used only in Sword settings page.
-class StandardWorksTab : public QWidget, CPointers
-{
- Q_OBJECT
-
-public:
- StandardWorksTab();
- void save();
-
-private:
- QComboBox* m_standardBibleCombo;
- QComboBox* m_standardCommentaryCombo;
- QComboBox* m_standardLexiconCombo;
- QComboBox* m_standardDailyDevotionalCombo;
- QComboBox* m_standardHebrewStrongCombo;
- QComboBox* m_standardGreekStrongCombo;
- QComboBox* m_standardHebrewMorphCombo;
- QComboBox* m_standardGreekMorphCombo;
+class StandardWorksTab : public QWidget, CPointers {
+ Q_OBJECT
+
+ public:
+ StandardWorksTab();
+ void save();
+
+ private:
+ QComboBox* m_standardBibleCombo;
+ QComboBox* m_standardCommentaryCombo;
+ QComboBox* m_standardLexiconCombo;
+ QComboBox* m_standardDailyDevotionalCombo;
+ QComboBox* m_standardHebrewStrongCombo;
+ QComboBox* m_standardGreekStrongCombo;
+ QComboBox* m_standardHebrewMorphCombo;
+ QComboBox* m_standardGreekMorphCombo;
};
-class TextFiltersTab : public QWidget
-{
- Q_OBJECT
-
-public:
- TextFiltersTab();
- void save();
-
-private:
- QCheckBox* m_lineBreaksCheck;
- QCheckBox* m_verseNumbersCheck;
- QCheckBox* m_headingsCheck;
- QCheckBox* m_hebrewPointsCheck;
- QCheckBox* m_hebrewCantillationCheck;
- QCheckBox* m_morphSegmentationCheck;
- QCheckBox* m_greekAccentsCheck;
- QCheckBox* m_textualVariantsCheck;
- QCheckBox* m_scriptureReferencesCheck;
+class TextFiltersTab : public QWidget {
+ Q_OBJECT
+
+ public:
+ TextFiltersTab();
+ void save();
+
+ private:
+ QCheckBox* m_lineBreaksCheck;
+ QCheckBox* m_verseNumbersCheck;
+ QCheckBox* m_headingsCheck;
+ QCheckBox* m_hebrewPointsCheck;
+ QCheckBox* m_hebrewCantillationCheck;
+ QCheckBox* m_morphSegmentationCheck;
+ QCheckBox* m_greekAccentsCheck;
+ QCheckBox* m_textualVariantsCheck;
+ QCheckBox* m_scriptureReferencesCheck;
};
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 785cc1c..0eab2ca 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -16,6 +16,7 @@
#include "util/directoryutil.h"
#include "util/migrationutil.h"
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/config/cbtconfig.h"
#include <stdlib.h>
@@ -42,150 +43,75 @@ using namespace util::filesystem;
bool showDebugMessages;
void myMessageOutput( QtMsgType type, const char *msg ) {
- //we use this messagehandler to switch debugging off in final releases
- switch (type) {
- case QtDebugMsg:
- if (showDebugMessages) { //only show messages if they are enabled!
- fprintf( stderr,"(BibleTime %s) Debug: %s\n", BT_VERSION, msg );
- }
- break;
- case QtWarningMsg:
- //if (showDebugMessages) //comment out for releases so users don't get our debug warnings
- fprintf( stderr,"(BibleTime %s) WARNING: %s\n", BT_VERSION, msg );
- break;
- case QtFatalMsg:
- case QtCriticalMsg:
- fprintf( stderr,"(BibleTime %s) _FATAL_: %s\nPlease report this bug! (http://www.bibletime.info/development_help.html)", BT_VERSION, msg );
- abort(); // dump core on purpose
- }
+ //we use this messagehandler to switch debugging off in final releases
+ switch (type) {
+ case QtDebugMsg:
+ if (showDebugMessages) { //only show messages if they are enabled!
+ fprintf( stderr, "(BibleTime %s) Debug: %s\n", BT_VERSION, msg );
+ }
+ break;
+ case QtWarningMsg:
+ //if (showDebugMessages) //comment out for releases so users don't get our debug warnings
+ fprintf( stderr, "(BibleTime %s) WARNING: %s\n", BT_VERSION, msg );
+ break;
+ case QtFatalMsg:
+ case QtCriticalMsg:
+ fprintf( stderr, "(BibleTime %s) _FATAL_: %s\nPlease report this bug! (http://www.bibletime.info/development_help.html)", BT_VERSION, msg );
+ abort(); // dump core on purpose
+ }
}
-// TODO - redo signal handler
-#if 0
-extern "C" {
- static void setSignalHandler(void (*handler)(int));
-
- // Crash recovery signal handler
- static void signalHandler(int sigId) {
- setSignalHandler(SIG_DFL);
- fprintf(stderr, "*** BibleTime got signal %d (Exiting)\n", sigId);
- // try to cleanup all windows
- if (CBTConfig::get(CBTConfig::crashedLastTime)) {
- //crashed this time and the execution before this one, probably a bug which occurs every time
- CBTConfig::set(CBTConfig::crashedTwoTimes, true);
- }
- else {
- //try to restore next time.
- CBTConfig::set(CBTConfig::crashedLastTime, true);
- }
- if (bibletime_ptr) {
- bibletime_ptr->saveSettings();
- fprintf(stderr, "*** Saving seemed to be successful. If restoring does not work on next startup please use the option --ignore-session\n");
- }
- ::exit(-1); //exit BibleTime
- }
-
- // Crash recovery signal handler
- static void crashHandler(int sigId) {
- setSignalHandler(SIG_DFL);
- fprintf(stderr, "*** BibleTime got signal %d (Crashing). Trying to save settings.\n", sigId);
- if (CBTConfig::get(CBTConfig::crashedLastTime)) {
- // crashed this time and the execution before this one,
- // probably a bug which occurs every time
- CBTConfig::set(CBTConfig::crashedTwoTimes, true);
- }
- else {
- //try to restore next time.
- CBTConfig::set(CBTConfig::crashedLastTime, true);
- }
- if (bibletime_ptr) {
- bibletime_ptr->saveSettings();
- fprintf(stderr, "*** Saving seemed to be successful. If restoring does not work on next startup please use the option --ignore-session\n");
- }
- // Return to DrKonqi.
- }
-
- static void setSignalHandler(void (*handler)(int)) {
- signal(SIGKILL, handler);
- signal(SIGTERM, handler);
- signal(SIGHUP, handler);
- KCrash::setEmergencySaveFunction(crashHandler);
- }
+void registerMetaTypes() {
+ qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>("BtBookshelfTreeModel::Grouping");
}
-#endif
-
int main(int argc, char* argv[]) {
- qInstallMsgHandler( myMessageOutput );
+ qInstallMsgHandler( myMessageOutput );
#ifdef BT_ENABLE_TESTING
- if (QString(argv[1]) == QString("--run-tests"))
- {
- BibleTimeTest testClass;
- return QTest::qExec(&testClass);
- }
-#endif
-
-#if 0
- //TODO: port to QT
- static KCmdLineOptions options;
- options.add("debug", ki18n("Enable debug messages"),0);
- options.add("ignore-session", ki18n("Ignore the startup session that was saved when BibleTime was closed the last time."),0);
- options.add("open-default-bible <key>", ki18n("Open the standard Bible with the given key. Use <random> to open at a random position."),0);
-#endif
-
-
- BibleTimeApp app(argc, argv); //for QApplication
- app.setApplicationName("bibletime");
- app.setApplicationVersion(BT_VERSION);
-
- // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
- QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
- //first install QT's own translations
- QTranslator qtTranslator;
- qtTranslator.load("qt_" + QLocale::system().name());
- app.installTranslator(&qtTranslator);
- //then our own
- QTranslator BibleTimeTranslator;
- BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DirectoryUtil::getLocaleDir().canonicalPath());
- app.installTranslator(&BibleTimeTranslator);
-
-#if 0
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- // A binary option (on / off)
- if (args->isSet("debug")) {
- showDebugMessages = true;
- app.setProperty("--debug", true);
- }
- if (!args->getOptionList("test").isEmpty()) {
- QStringList testingFeatures = args->getOptionList("test");
- foreach (QString feature, testingFeatures) {
- app.setProperty(feature.toLatin1().data(), true);
- }
- }
+ if (QString(argv[1]) == QString("--run-tests")) {
+ BibleTimeTest testClass;
+ return QTest::qExec(&testClass);
+ }
#endif
- // This is the QT4 version, will only work if main App is QApplication
- // A binary option (on / off)
+ BibleTimeApp app(argc, argv); //for QApplication
+ app.setApplicationName("bibletime");
+ app.setApplicationVersion(BT_VERSION);
+
+ registerMetaTypes();
+
+ // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ //first install QT's own translations
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + QLocale::system().name());
+ app.installTranslator(&qtTranslator);
+ //then our own
+ QTranslator BibleTimeTranslator;
+ BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DirectoryUtil::getLocaleDir().canonicalPath());
+ app.installTranslator(&BibleTimeTranslator);
+
+ // This is the QT4 version, will only work if main App is QApplication
+ // A binary option (on / off)
showDebugMessages = QCoreApplication::arguments().contains("--debug");
app.setProperty("--debug", showDebugMessages);
- //Migrate configuration data, if neccessary
- util::MigrationUtil::checkMigration();
+ //Migrate configuration data, if neccessary
+ util::MigrationUtil::checkMigration();
// setSignalHandler(signalHandler);
BibleTime bibleTime;
- // a new BibleTime version was installed (maybe a completely new installation)
- if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION)
- {
- CBTConfig::set(CBTConfig::bibletimeVersion, BT_VERSION);
+ // a new BibleTime version was installed (maybe a completely new installation)
+ if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION) {
+ CBTConfig::set(CBTConfig::bibletimeVersion, BT_VERSION);
bibleTime.saveConfigSettings();
- }
+ }
- // restore the workspace and process command line options
- //app.setMainWidget(bibletime_ptr); //no longer used in qt4 (QApplication)
+ // restore the workspace and process command line options
+ //app.setMainWidget(bibletime_ptr); //no longer used in qt4 (QApplication)
bibleTime.show();
bibleTime.processCommandline(); //must be done after the bibletime window is visible
diff --git a/src/tests/backend/config/cbtconfig_test.cpp b/src/tests/backend/config/cbtconfig_test.cpp
index 8fe76d5..81a63b6 100644
--- a/src/tests/backend/config/cbtconfig_test.cpp
+++ b/src/tests/backend/config/cbtconfig_test.cpp
@@ -14,23 +14,22 @@
#include <QtTest/QtTest>
-void BibleTimeTest::frontend_cbtconfig_test()
-{
- QList<int> value1;
- value1 << -1 << 0 << 1 << 993738;
- QString value1String("-1,0,1,993738");
- QList<int> emptyValue;
- QString emptyValueString("");
-
- //conversion checks int-string
- QCOMPARE(CBTConfig::IntListToString(value1), value1String);
- QCOMPARE(CBTConfig::IntListToString(emptyValue), emptyValueString);
-
- //conversion checks string-int
- QCOMPARE(CBTConfig::StringToIntList(value1String), value1);
- QCOMPARE(CBTConfig::StringToIntList(emptyValueString), emptyValue);
-
- //roundtrip checks
- QCOMPARE(CBTConfig::StringToIntList(CBTConfig::IntListToString(value1)), value1);
- QCOMPARE(CBTConfig::StringToIntList(CBTConfig::IntListToString(emptyValue)), emptyValue);
+void BibleTimeTest::frontend_cbtconfig_test() {
+ QList<int> value1;
+ value1 << -1 << 0 << 1 << 993738;
+ QString value1String("-1,0,1,993738");
+ QList<int> emptyValue;
+ QString emptyValueString("");
+
+ //conversion checks int-string
+ QCOMPARE(CBTConfig::IntListToString(value1), value1String);
+ QCOMPARE(CBTConfig::IntListToString(emptyValue), emptyValueString);
+
+ //conversion checks string-int
+ QCOMPARE(CBTConfig::StringToIntList(value1String), value1);
+ QCOMPARE(CBTConfig::StringToIntList(emptyValueString), emptyValue);
+
+ //roundtrip checks
+ QCOMPARE(CBTConfig::StringToIntList(CBTConfig::IntListToString(value1)), value1);
+ QCOMPARE(CBTConfig::StringToIntList(CBTConfig::IntListToString(emptyValue)), emptyValue);
}
diff --git a/src/tests/bibletime_test.cpp b/src/tests/bibletime_test.cpp
index e27a817..f084592 100644
--- a/src/tests/bibletime_test.cpp
+++ b/src/tests/bibletime_test.cpp
@@ -11,9 +11,8 @@
#include <QtTest/QtTest>
-void BibleTimeTest::dummyTest()
-{
- QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
+void BibleTimeTest::dummyTest() {
+ QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
}
diff --git a/src/tests/bibletime_test.h b/src/tests/bibletime_test.h
index a115553..ed347ad 100644
--- a/src/tests/bibletime_test.h
+++ b/src/tests/bibletime_test.h
@@ -12,16 +12,15 @@
#include <QObject>
-class BibleTimeTest: public QObject
-{
- Q_OBJECT
+class BibleTimeTest: public QObject {
+ Q_OBJECT
-private slots:
- //frontend
- void frontend_cbtconfig_test();
-
- //dummy test
- void dummyTest();
+ private slots:
+ //frontend
+ void frontend_cbtconfig_test();
+
+ //dummy test
+ void dummyTest();
};
diff --git a/src/util/cpointers.cpp b/src/util/cpointers.cpp
index 73c36d4..dd3d0d5 100644
--- a/src/util/cpointers.cpp
+++ b/src/util/cpointers.cpp
@@ -19,37 +19,37 @@
CPointers::PointerCache m_pointerCache;
void CPointers::setBackend(CSwordBackend* const backend) {
- Q_ASSERT( m_pointerCache.backend == 0);
- CPointers::deleteBackend();
- m_pointerCache.backend = backend;
+ Q_ASSERT( m_pointerCache.backend == 0);
+ CPointers::deleteBackend();
+ m_pointerCache.backend = backend;
}
void CPointers::setInfoDisplay(InfoDisplay::CInfoDisplay* const infoDisplay) {
- Q_ASSERT( m_pointerCache.infoDisplay == 0);
- m_pointerCache.infoDisplay = infoDisplay;
+ Q_ASSERT( m_pointerCache.infoDisplay == 0);
+ m_pointerCache.infoDisplay = infoDisplay;
}
void CPointers::deleteBackend() {
- delete m_pointerCache.backend;
- m_pointerCache.backend = 0;
+ delete m_pointerCache.backend;
+ m_pointerCache.backend = 0;
}
void CPointers::deleteLanguageMgr() {
- delete m_pointerCache.langMgr;
- m_pointerCache.langMgr = 0;
+ delete m_pointerCache.langMgr;
+ m_pointerCache.langMgr = 0;
}
void CPointers::deleteDisplayTemplateMgr() {
- delete m_pointerCache.displayTemplateMgr;
- m_pointerCache.displayTemplateMgr = 0;
+ delete m_pointerCache.displayTemplateMgr;
+ m_pointerCache.displayTemplateMgr = 0;
}
/** Returns a pointer to the printer object. */
CDisplayTemplateMgr* CPointers::displayTemplateManager() {
- if (!m_pointerCache.displayTemplateMgr) {
- m_pointerCache.displayTemplateMgr = new CDisplayTemplateMgr();
- }
+ if (!m_pointerCache.displayTemplateMgr) {
+ m_pointerCache.displayTemplateMgr = new CDisplayTemplateMgr();
+ }
- return m_pointerCache.displayTemplateMgr;
+ return m_pointerCache.displayTemplateMgr;
}
diff --git a/src/util/cpointers.h b/src/util/cpointers.h
index 48ceea0..99b9ea4 100644
--- a/src/util/cpointers.h
+++ b/src/util/cpointers.h
@@ -19,97 +19,97 @@ class CLanguageMgr;
class CDisplayTemplateMgr;
namespace InfoDisplay {
- class CInfoDisplay;
+class CInfoDisplay;
}
/** Holds the pointers to important classes like modules, backend etc.
*/
class CPointers {
-protected:
- friend class BibleTime; //BibleTime may initialize this object
- friend class BibleTimeApp; //BibleTimeApp may initialize this object
- friend int main(int argc, char* argv[]); //main may set the printer
-
- //Empty virtuaual destructor
- virtual ~CPointers() {}
-
- /** Set the backend.
- * @param backend Pointer to the new application-wide Sword backend
- */
- static void setBackend(CSwordBackend* const backend);
- /** Set the info display.
- * @param iDisplay The pointer to the new info display.
- */
- static void setInfoDisplay(InfoDisplay::CInfoDisplay* const iDisplay);
-
- /** Delete the backend. Should be called by BibleTimeApp,
- * because the backend should be deleted as late as possible.
- */
- static void deleteBackend();
- /** Delete the printer. Should be called by BibleTimeApp,
- * because the printer should be deleted as late as possible.
- */
- static void deletePrinter();
- /** Delete the language manager. Should be called by BibleTimeApp,
- * because the language manager should be deleted as late as possible.
- */
- static void deleteLanguageMgr();
- /** Delete the display template manager. Should be called by BibleTimeApp,
- * because the template manager should be deleted as late as possible.
- */
- static void deleteDisplayTemplateMgr();
-
-public: // Public methods
- /** Returns a pointer to the backend
- * @return The backend pointer.
- */
- inline static CSwordBackend* backend();
- /** Returns a pointer to the language manager
- * @return The language manager
- */
- inline static CLanguageMgr* languageMgr();
- /** Returns a pointer to the info display.
- * @return The backend pointer.
- */
- inline static InfoDisplay::CInfoDisplay* infoDisplay();
- /** Returns a pointer to the application's display template manager
- * @return The backend pointer.
- */
- static CDisplayTemplateMgr* displayTemplateManager();
-
- struct PointerCache {
- PointerCache() {
- backend = 0;
- langMgr = 0;
- infoDisplay = 0;
- displayTemplateMgr = 0;
- };
-
- CSwordBackend* backend;
- CLanguageMgr* langMgr;
- InfoDisplay::CInfoDisplay* infoDisplay;
- CDisplayTemplateMgr* displayTemplateMgr;
- };
+ protected:
+ friend class BibleTime; //BibleTime may initialize this object
+ friend class BibleTimeApp; //BibleTimeApp may initialize this object
+ friend int main(int argc, char* argv[]); //main may set the printer
+
+ //Empty virtuaual destructor
+ virtual ~CPointers() {}
+
+ /** Set the backend.
+ * @param backend Pointer to the new application-wide Sword backend
+ */
+ static void setBackend(CSwordBackend* const backend);
+ /** Set the info display.
+ * @param iDisplay The pointer to the new info display.
+ */
+ static void setInfoDisplay(InfoDisplay::CInfoDisplay* const iDisplay);
+
+ /** Delete the backend. Should be called by BibleTimeApp,
+ * because the backend should be deleted as late as possible.
+ */
+ static void deleteBackend();
+ /** Delete the printer. Should be called by BibleTimeApp,
+ * because the printer should be deleted as late as possible.
+ */
+ static void deletePrinter();
+ /** Delete the language manager. Should be called by BibleTimeApp,
+ * because the language manager should be deleted as late as possible.
+ */
+ static void deleteLanguageMgr();
+ /** Delete the display template manager. Should be called by BibleTimeApp,
+ * because the template manager should be deleted as late as possible.
+ */
+ static void deleteDisplayTemplateMgr();
+
+ public: // Public methods
+ /** Returns a pointer to the backend
+ * @return The backend pointer.
+ */
+ inline static CSwordBackend* backend();
+ /** Returns a pointer to the language manager
+ * @return The language manager
+ */
+ inline static CLanguageMgr* languageMgr();
+ /** Returns a pointer to the info display.
+ * @return The backend pointer.
+ */
+ inline static InfoDisplay::CInfoDisplay* infoDisplay();
+ /** Returns a pointer to the application's display template manager
+ * @return The backend pointer.
+ */
+ static CDisplayTemplateMgr* displayTemplateManager();
+
+ struct PointerCache {
+ PointerCache() {
+ backend = 0;
+ langMgr = 0;
+ infoDisplay = 0;
+ displayTemplateMgr = 0;
+ };
+
+ CSwordBackend* backend;
+ CLanguageMgr* langMgr;
+ InfoDisplay::CInfoDisplay* infoDisplay;
+ CDisplayTemplateMgr* displayTemplateMgr;
+ };
};
extern CPointers::PointerCache m_pointerCache;
/** Returns a pointer to the backend ... */
inline CSwordBackend* CPointers::backend() {
- return m_pointerCache.backend;
+ return m_pointerCache.backend;
}
/** Returns a pointer to the backend ... */
inline CLanguageMgr* CPointers::languageMgr() {
- if (!m_pointerCache.langMgr) {
- m_pointerCache.langMgr = new CLanguageMgr();
- }
- return m_pointerCache.langMgr;
+ if (!m_pointerCache.langMgr) {
+ m_pointerCache.langMgr = new CLanguageMgr();
+ }
+ return m_pointerCache.langMgr;
}
/** Returns a pointer to the printer object. */
inline InfoDisplay::CInfoDisplay* CPointers::infoDisplay() {
- return m_pointerCache.infoDisplay;
+ return m_pointerCache.infoDisplay;
}
diff --git a/src/util/cresmgr.cpp b/src/util/cresmgr.cpp
index e0c7573..97f0c78 100644
--- a/src/util/cresmgr.cpp
+++ b/src/util/cresmgr.cpp
@@ -13,487 +13,487 @@
namespace CResMgr {
- namespace mainWindow {
- const QString icon = "bibletime.svg";
- } // mainWindow
- namespace modules {
- namespace bible {
- const QString icon_unlocked = "bible.svg";
- const QString icon_locked = "bible_locked.svg";
- const QString icon_add = "bible_add.svg";
- } //bible
- namespace commentary {
- const QString icon_unlocked = "commentary.svg";
- const QString icon_locked = "commentary_locked.svg";
- const QString icon_add = "commentary_add.svg";
- } //commentary
- namespace lexicon {
- const QString icon_unlocked = "lexicon.svg";
- const QString icon_locked = "lexicon_locked.svg";
- const QString icon_add = "lexicon_add.svg";
- }//lexicon
- namespace book {
- const QString icon_unlocked = "book.svg";
- const QString icon_locked = "book_locked.svg";
- const QString icon_add = "book_add.svg";
- }//book
- }//modules
-
- namespace categories {
- namespace bibles {
- const QString icon = "bible.svg";
- }
- namespace commentaries {
- const QString icon = "commentary.svg";
- }
- namespace lexicons {
- const QString icon = "dictionary.svg";
- }
- namespace dailydevotional {
- const QString icon = "calendar.svg";
- }
- namespace books {
- const QString icon = "books.svg";
- }
- namespace glossary {
- const QString icon = "dictionary.svg";
- }
- namespace images {
- const QString icon = "map.svg";
- }
- namespace cults {
- const QString icon = "questionable.svg";
- }
- }//categories
- namespace mainMenu { //Main menu
-
- namespace view { //Main menu->View
- namespace showMainIndex {
- const QString icon = "view_index.svg";
- const QKeySequence accel(Qt::Key_F9);
- const char* actionName = "viewMainIndex_action";
- }
- namespace showInfoDisplay {
- const QString icon = "view_mag.svg";
- const QKeySequence accel(Qt::Key_F8);
- const char* actionName = "viewInfoDisplay_action";
- }
- }//mainMenu::view
-
- namespace mainIndex {
- namespace search {
- const QString icon = "find.svg";
- const QKeySequence accel(Qt::CTRL + Qt::Key_O);
- const char* actionName = "mainindex_search_action";
- }
- namespace searchdefaultbible {
- const QString icon = "find.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_F);
- const char* actionName = "mainindex_searchdefaultbible_action";
- }
- }//mainMenu::mainIndex
-
- namespace window { //mainMenu::window
- namespace loadProfile {
- const QString icon = "view_profile.svg";
- const char* actionName = "windowLoadProfile_action";
- }
- namespace saveProfile {
- const QString icon = "view_profile.svg";
- const char* actionName = "windowSaveProfile_action";
- }
- namespace saveToNewProfile {
- const QString icon = "view_profile.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_S);
- const char* actionName = "windowSaveToNewProfile_action";
- }
- namespace deleteProfile {
- const QString icon = "view_profile.svg";
- const char* actionName = "windowDeleteProfile_action";
- }
- namespace showFullscreen {
- const QString icon = "window_fullscreen.svg";
- const QKeySequence accel(Qt::Key_F5);
- const char* actionName = "windowFullscreen_action";
- }
- namespace arrangementMode {
- const QString icon = "cascade_auto.svg";
- const QKeySequence accel;
- const char* actionName = "windowArrangementMode_action";
-
- namespace manual {
- const QString icon = "tile.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_M);
- const char* actionName = "windowArrangementManual_action";
- }
- namespace autoTileHorizontal {
- const QString icon = "tile_horiz.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_H);
- const char* actionName = "windowAutoTileHorizontal_action";
- }
- namespace autoTileVertical {
- const QString icon = "tile_vert.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_G);
- const char* actionName = "windowAutoTileVertical_action";
- }
- namespace autoCascade {
- const QString icon = "cascade_auto.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_J);
- const char* actionName = "windowAutoCascade_action";
- }
- }
- namespace tileHorizontal {
- const QString icon = "tile_horiz.svg";
- const QKeySequence accel(Qt::CTRL + Qt::Key_H);
- const char* actionName = "windowTileHorizontal_action";
- }
- namespace tileVertical {
- const QString icon = "tile_vert.svg";
- const QKeySequence accel(Qt::CTRL + Qt::Key_G);
- const char* actionName = "windowTileVertical_action";
- }
- namespace cascade {
- const QString icon = "cascade.svg";
- const QKeySequence accel(Qt::CTRL + Qt::Key_J);
- const char* actionName = "windowCascade_action";
- }
- namespace closeAll {
- const QString icon = "fileclose.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_W);
- const char* actionName = "windowCloseAll_action";
- }
- }//mainMenu::window
-
- namespace settings { //Main menu->Settings
- namespace swordSetupDialog {
- const QString icon = "swordconfig.svg";
- const QKeySequence accel(Qt::Key_F4);
- const char* actionName = "options_sword_setup";
- }
-
- }//mainMenu::settings
-
- namespace help { //Main menu->Help
- namespace handbook {
- const QString icon = "contents2.svg";
- const QKeySequence accel(Qt::Key_F1);
- const char* actionName = "helpHandbook_action";
- }
- namespace bibleStudyHowTo {
- const QString icon = "contents2.svg";
- const QKeySequence accel(Qt::Key_F2);
- const char* actionName = "helpHowTo_action";
- }
- }//mainMenu::help
- } //end of mainMenu
-
- namespace searchdialog {
- const QString icon = "find.svg";
- const QString close_icon = "stop.svg";
- const QString help_icon = "questionmark";
- const QString chooseworks_icon = "checkbox";
- const QString setupscope_icon = "configure";
-
- namespace result {
- namespace moduleList {
-
- namespace copyMenu {
- const QString icon = "edit_copy.svg";
- }
- namespace saveMenu {
- const QString icon = "file_save.svg";
- }
- namespace printMenu {
- const QString icon = "print.svg";
- }
- }
- namespace foundItems {
-
- namespace copyMenu {
- const QString icon = "edit_copy.svg";
- }
- namespace saveMenu {
- const QString icon = "file_save.svg";
- }
- namespace printMenu {
- const QString icon = "print.svg";
- }
- }
- }
- } //searchDialog
-
- namespace displaywindows {
+namespace mainWindow {
+const QString icon = "bibletime.svg";
+} // mainWindow
+namespace modules {
+namespace bible {
+const QString icon_unlocked = "bible.svg";
+const QString icon_locked = "bible_locked.svg";
+const QString icon_add = "bible_add.svg";
+} //bible
+namespace commentary {
+const QString icon_unlocked = "commentary.svg";
+const QString icon_locked = "commentary_locked.svg";
+const QString icon_add = "commentary_add.svg";
+} //commentary
+namespace lexicon {
+const QString icon_unlocked = "lexicon.svg";
+const QString icon_locked = "lexicon_locked.svg";
+const QString icon_add = "lexicon_add.svg";
+}//lexicon
+namespace book {
+const QString icon_unlocked = "book.svg";
+const QString icon_locked = "book_locked.svg";
+const QString icon_add = "book_add.svg";
+}//book
+}//modules
+
+namespace categories {
+namespace bibles {
+const QString icon = "bible.svg";
+}
+namespace commentaries {
+const QString icon = "commentary.svg";
+}
+namespace lexicons {
+const QString icon = "lexicon.svg";
+}
+namespace dailydevotional {
+const QString icon = "calendar.svg";
+}
+namespace books {
+const QString icon = "books.svg";
+}
+namespace glossary {
+const QString icon = "dictionary.svg";
+}
+namespace images {
+const QString icon = "map.svg";
+}
+namespace cults {
+const QString icon = "questionable.svg";
+}
+}//categories
+namespace mainMenu { //Main menu
+
+namespace view { //Main menu->View
+namespace showMainIndex {
+const QString icon = "view_index.svg";
+const QKeySequence accel(Qt::Key_F9);
+const char* actionName = "viewMainIndex_action";
+}
+namespace showInfoDisplay {
+const QString icon = "view_mag.svg";
+const QKeySequence accel(Qt::Key_F8);
+const char* actionName = "viewInfoDisplay_action";
+}
+}//mainMenu::view
+
+namespace mainIndex {
+namespace search {
+const QString icon = "find.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_O);
+const char* actionName = "mainindex_search_action";
+}
+namespace searchdefaultbible {
+const QString icon = "find.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_F);
+const char* actionName = "mainindex_searchdefaultbible_action";
+}
+}//mainMenu::mainIndex
+
+namespace window { //mainMenu::window
+namespace loadProfile {
+const QString icon = "view_profile.svg";
+const char* actionName = "windowLoadProfile_action";
+}
+namespace saveProfile {
+const QString icon = "view_profile.svg";
+const char* actionName = "windowSaveProfile_action";
+}
+namespace saveToNewProfile {
+const QString icon = "view_profile.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_S);
+const char* actionName = "windowSaveToNewProfile_action";
+}
+namespace deleteProfile {
+const QString icon = "view_profile.svg";
+const char* actionName = "windowDeleteProfile_action";
+}
+namespace showFullscreen {
+const QString icon = "window_fullscreen.svg";
+const QKeySequence accel(Qt::Key_F5);
+const char* actionName = "windowFullscreen_action";
+}
+namespace arrangementMode {
+const QString icon = "cascade_auto.svg";
+const QKeySequence accel;
+const char* actionName = "windowArrangementMode_action";
+
+namespace manual {
+const QString icon = "tile.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_M);
+const char* actionName = "windowArrangementManual_action";
+}
+namespace autoTileHorizontal {
+const QString icon = "tile_horiz.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_H);
+const char* actionName = "windowAutoTileHorizontal_action";
+}
+namespace autoTileVertical {
+const QString icon = "tile_vert.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_G);
+const char* actionName = "windowAutoTileVertical_action";
+}
+namespace autoCascade {
+const QString icon = "cascade_auto.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_J);
+const char* actionName = "windowAutoCascade_action";
+}
+}
+namespace tileHorizontal {
+const QString icon = "tile_horiz.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_H);
+const char* actionName = "windowTileHorizontal_action";
+}
+namespace tileVertical {
+const QString icon = "tile_vert.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_G);
+const char* actionName = "windowTileVertical_action";
+}
+namespace cascade {
+const QString icon = "cascade.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_J);
+const char* actionName = "windowCascade_action";
+}
+namespace closeAll {
+const QString icon = "fileclose.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_W);
+const char* actionName = "windowCloseAll_action";
+}
+}//mainMenu::window
+
+namespace settings { //Main menu->Settings
+namespace swordSetupDialog {
+const QString icon = "swordconfig.svg";
+const QKeySequence accel(Qt::Key_F4);
+const char* actionName = "options_sword_setup";
+}
+
+}//mainMenu::settings
+
+namespace help { //Main menu->Help
+namespace handbook {
+const QString icon = "contents2.svg";
+const QKeySequence accel(Qt::Key_F1);
+const char* actionName = "helpHandbook_action";
+}
+namespace bibleStudyHowTo {
+const QString icon = "contents2.svg";
+const QKeySequence accel(Qt::Key_F2);
+const char* actionName = "helpHowTo_action";
+}
+}//mainMenu::help
+} //end of mainMenu
+
+namespace searchdialog {
+const QString icon = "find.svg";
+const QString close_icon = "stop.svg";
+const QString help_icon = "questionmark";
+const QString chooseworks_icon = "checkbox";
+const QString setupscope_icon = "configure";
+
+namespace result {
+namespace moduleList {
+
+namespace copyMenu {
+const QString icon = "edit_copy.svg";
+}
+namespace saveMenu {
+const QString icon = "file_save.svg";
+}
+namespace printMenu {
+const QString icon = "print.svg";
+}
+}
+namespace foundItems {
+
+namespace copyMenu {
+const QString icon = "edit_copy.svg";
+}
+namespace saveMenu {
+const QString icon = "file_save.svg";
+}
+namespace printMenu {
+const QString icon = "print.svg";
+}
+}
+}
+} //searchDialog
+
+namespace displaywindows {
/* namespace transliteration {
const QString icon = "bt_displaytranslit";
}*/
- namespace displaySettings {
- const QString icon = "displayconfig.svg";
- }
-
- namespace general {
- namespace search {
- const QString icon = "find.svg";
- const QKeySequence accel(Qt::CTRL + Qt::Key_N);
- const char* actionName = "window_search_action";
- }
-
- namespace backInHistory {
- const QString icon = "back.svg";
- const QKeySequence accel(Qt::ALT + Qt::Key_Left);
- const char* actionName = "window_history_back_action";
- }
- namespace forwardInHistory {
- const QString icon = "forward.svg";
- const QKeySequence accel(Qt::ALT + Qt::Key_Right);
- const char* actionName = "window_history_forward_action";
- }
- namespace findStrongs {
- const QString icon = "bt_findstrongs.svg";
- const QKeySequence accel;
- const char* actionName = "window_find_strongs_action";
- }
-
- }
- namespace bibleWindow {
- namespace nextBook {
- const QKeySequence accel(Qt::CTRL + Qt::Key_Y);
- }
- namespace previousBook {
- const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_Y);
- }
-
- namespace nextChapter {
- const QKeySequence accel(Qt::CTRL + Qt::Key_X);
- }
- namespace previousChapter {
- const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_X);
- }
- namespace nextVerse {
- const QKeySequence accel(Qt::CTRL + Qt::Key_V);
- }
- namespace previousVerse {
- const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_V);
- }
-
- namespace copyMenu {
- const QString icon = "edit_copy.svg";
- }
- namespace saveMenu {
- const QString icon = "file_save.svg";
- }
- namespace printMenu {
- const QString icon = "print.svg";
- }
- }
- namespace commentaryWindow {
- namespace syncWindow {
- const QString icon = "sync.svg";
- const QKeySequence accel;
- const char* actionName = "commentary_syncWindow";
- }
- }
- namespace lexiconWindow {
- namespace entryList {
- QString tooltip;
- }
- namespace nextEntry {
- const QKeySequence accel(Qt::CTRL + Qt::Key_V);
- }
- namespace previousEntry {
- const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_V);
- }
-
- namespace copyMenu {
- const QString icon = "edit_copy.svg";
- }
- namespace saveMenu {
- const QString icon = "file_save.svg";
- }
- namespace printMenu {
- const QString icon = "print.svg";
- }
- }
- namespace bookWindow {
- namespace toggleTree {
- const QString icon = "view_sidetree.svg";
- const QKeySequence accel;
- }
- }
-
- namespace writeWindow {
- namespace saveText {
- const QString icon = "file_save";
- const QKeySequence accel;
- const char* actionName = "writeWindow_saveText";
- }
- namespace restoreText {
- const QString icon = "import.svg";
- const QKeySequence accel;
- const char* actionName = "writeWindow_restoreText";
- }
- namespace deleteEntry {
- const QString icon = "edit_delete.svg";
- const QKeySequence accel;
- const char* actionName = "writeWindow_deleteEntry";
- }
-
- //formatting buttons
- namespace boldText {
- const QString icon = "text_bold.svg";
- const QKeySequence accel;
- const char* actionName = "writeWindow_boldText";
- }
- namespace italicText {
- const QString icon = "text_italic.svg";
- const QKeySequence accel;
- const char* actionName = "writeWindow_italicText";
- }
- namespace underlinedText {
- const QString icon = "text_under.svg";
- const QKeySequence accel;
- const char* actionName = "writeWindow_underlineText";
- }
-
- namespace alignLeft {
- const QString icon = "text_leftalign";
- const QKeySequence accel;
- const char* actionName = "writeWindow_alignLeft";
- }
- namespace alignCenter {
- const QString icon = "text_center";
- const QKeySequence accel;
- const char* actionName = "writeWindow_alignCenter";
- }
- namespace alignRight {
- const QString icon = "text_rightalign";
- const QKeySequence accel;
- const char* actionName = "writeWindow_alignRight";
- }
- namespace alignJustify {
- const QString icon = "text_justify";
- const QKeySequence accel;
- const char* actionName = "writeWindow_alignJustify";
- }
-
- namespace fontFamily {
- const QKeySequence accel;
- const char* actionName = "writeWindow_fontFamily";
- }
- namespace fontSize {
- const QKeySequence accel;
- const char* actionName = "writeWindow_fontSize";
- }
- }
- }//displayWindows
-
- namespace settings {
- namespace startup {
- const QString icon = "startconfig.svg";
- }
- namespace fonts {
- const QString icon = "fonts.svg";
- }
- namespace profiles {
- const QString icon = "view_profile.svg";
- }
- namespace sword {
- const QString icon = "swordconfig.svg";
-
- }
- namespace keys {
- const QString icon = "key_bindings.svg";
- }
- }//settings
-
- namespace mainIndex { // Bookshelf view
- namespace search {
- const QString icon = "find.svg";
- const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_M);
- const char* actionName = "GMsearch_action";
- }
- namespace newFolder {
- const QString icon = "folder_new.svg";
- }
- namespace changeFolder {
- const QString icon = "folder.svg";
- }
- namespace openedFolder {
- const QString icon = "folder_open.svg";
- }
- namespace closedFolder {
- const QString icon = "folder.svg";
- }
-
- namespace bookmark {
- const QString icon = "bookmark.svg";
- }
- namespace changeBookmark {
- const QString icon = "bookmark.svg";
- }
- namespace importBookmarks {
- const QString icon = "import.svg";
- }
- namespace exportBookmarks {
- const QString icon = "export.svg";
- }
- namespace printBookmarks {
- const QString icon = "print.svg";
- }
- namespace deleteItems {
- const QString icon = "edit_delete.svg";
- }
-
- namespace editModuleMenu {
- const QString icon = "pencil.svg";
- }
- namespace editModulePlain {
- const QString icon = "pencil.svg";
- }
- namespace editModuleHTML {
- const QString icon = "pencil.svg";
- }
-
- namespace unlockModule {
- const QString icon = "unlock.svg";
- }
- namespace aboutModule {
- const QString icon = "info.svg";
- }
- namespace grouping {
- const QString icon = "view-tree.svg";
- }
- }//mainIndex
-
- namespace bookshelfmgr {
- namespace installpage {
- const QString icon = "bible_add";
- const QString refresh_icon = "refresh";
- const QString delete_icon = "trash";
- const QString add_icon = "plus";
- const QString install_icon = "bible_add";
- const QString path_icon = "configure";
- }
- namespace removepage {
- const QString icon = "bible_remove";
- const QString remove_icon = "trash";
- }
- namespace indexpage {
- const QString icon = "document_magnifier";
- const QString create_icon = "folder_new";
- const QString delete_icon = "trash";
- }
- namespace paths {
- const QString add_icon = "plus";
- const QString edit_icon = "pencil";
- const QString remove_icon = "trash";
- }
- }
-
+namespace displaySettings {
+const QString icon = "displayconfig.svg";
+}
+
+namespace general {
+namespace search {
+const QString icon = "find.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_N);
+const char* actionName = "window_search_action";
+}
+
+namespace backInHistory {
+const QString icon = "back.svg";
+const QKeySequence accel(Qt::ALT + Qt::Key_Left);
+const char* actionName = "window_history_back_action";
+}
+namespace forwardInHistory {
+const QString icon = "forward.svg";
+const QKeySequence accel(Qt::ALT + Qt::Key_Right);
+const char* actionName = "window_history_forward_action";
+}
+namespace findStrongs {
+const QString icon = "bt_findstrongs.svg";
+const QKeySequence accel;
+const char* actionName = "window_find_strongs_action";
+}
+
+}
+namespace bibleWindow {
+namespace nextBook {
+const QKeySequence accel(Qt::CTRL + Qt::Key_Y);
+}
+namespace previousBook {
+const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_Y);
+}
+
+namespace nextChapter {
+const QKeySequence accel(Qt::CTRL + Qt::Key_X);
+}
+namespace previousChapter {
+const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_X);
+}
+namespace nextVerse {
+const QKeySequence accel(Qt::CTRL + Qt::Key_V);
+}
+namespace previousVerse {
+const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_V);
+}
+
+namespace copyMenu {
+const QString icon = "edit_copy.svg";
+}
+namespace saveMenu {
+const QString icon = "file_save.svg";
+}
+namespace printMenu {
+const QString icon = "print.svg";
+}
+}
+namespace commentaryWindow {
+namespace syncWindow {
+const QString icon = "sync.svg";
+const QKeySequence accel;
+const char* actionName = "commentary_syncWindow";
+}
+}
+namespace lexiconWindow {
+namespace entryList {
+QString tooltip;
+}
+namespace nextEntry {
+const QKeySequence accel(Qt::CTRL + Qt::Key_V);
+}
+namespace previousEntry {
+const QKeySequence accel(Qt::CTRL + Qt::SHIFT + Qt::Key_V);
+}
+
+namespace copyMenu {
+const QString icon = "edit_copy.svg";
+}
+namespace saveMenu {
+const QString icon = "file_save.svg";
+}
+namespace printMenu {
+const QString icon = "print.svg";
+}
+}
+namespace bookWindow {
+namespace toggleTree {
+const QString icon = "view_sidetree.svg";
+const QKeySequence accel;
+}
+}
+
+namespace writeWindow {
+namespace saveText {
+const QString icon = "file_save";
+const QKeySequence accel;
+const char* actionName = "writeWindow_saveText";
+}
+namespace restoreText {
+const QString icon = "import.svg";
+const QKeySequence accel;
+const char* actionName = "writeWindow_restoreText";
+}
+namespace deleteEntry {
+const QString icon = "edit_delete.svg";
+const QKeySequence accel;
+const char* actionName = "writeWindow_deleteEntry";
+}
+
+//formatting buttons
+namespace boldText {
+const QString icon = "text_bold.svg";
+const QKeySequence accel;
+const char* actionName = "writeWindow_boldText";
+}
+namespace italicText {
+const QString icon = "text_italic.svg";
+const QKeySequence accel;
+const char* actionName = "writeWindow_italicText";
+}
+namespace underlinedText {
+const QString icon = "text_under.svg";
+const QKeySequence accel;
+const char* actionName = "writeWindow_underlineText";
+}
+
+namespace alignLeft {
+const QString icon = "text_leftalign";
+const QKeySequence accel;
+const char* actionName = "writeWindow_alignLeft";
+}
+namespace alignCenter {
+const QString icon = "text_center";
+const QKeySequence accel;
+const char* actionName = "writeWindow_alignCenter";
+}
+namespace alignRight {
+const QString icon = "text_rightalign";
+const QKeySequence accel;
+const char* actionName = "writeWindow_alignRight";
+}
+namespace alignJustify {
+const QString icon = "text_justify";
+const QKeySequence accel;
+const char* actionName = "writeWindow_alignJustify";
+}
+
+namespace fontFamily {
+const QKeySequence accel;
+const char* actionName = "writeWindow_fontFamily";
+}
+namespace fontSize {
+const QKeySequence accel;
+const char* actionName = "writeWindow_fontSize";
+}
+}
+}//displayWindows
+
+namespace settings {
+namespace startup {
+const QString icon = "startconfig.svg";
+}
+namespace fonts {
+const QString icon = "fonts.svg";
+}
+namespace profiles {
+const QString icon = "view_profile.svg";
+}
+namespace sword {
+const QString icon = "swordconfig.svg";
+
+}
+namespace keys {
+const QString icon = "key_bindings.svg";
+}
+}//settings
+
+namespace mainIndex { // Bookshelf view
+namespace search {
+const QString icon = "find.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_M);
+const char* actionName = "GMsearch_action";
+}
+namespace newFolder {
+const QString icon = "folder_new.svg";
+}
+namespace changeFolder {
+const QString icon = "folder.svg";
+}
+namespace openedFolder {
+const QString icon = "folder_open.svg";
+}
+namespace closedFolder {
+const QString icon = "folder.svg";
+}
+
+namespace bookmark {
+const QString icon = "bookmark.svg";
+}
+namespace changeBookmark {
+const QString icon = "bookmark.svg";
+}
+namespace importBookmarks {
+const QString icon = "import.svg";
+}
+namespace exportBookmarks {
+const QString icon = "export.svg";
+}
+namespace printBookmarks {
+const QString icon = "print.svg";
+}
+namespace deleteItems {
+const QString icon = "edit_delete.svg";
+}
+
+namespace editModuleMenu {
+const QString icon = "pencil.svg";
+}
+namespace editModulePlain {
+const QString icon = "pencil.svg";
+}
+namespace editModuleHTML {
+const QString icon = "pencil.svg";
+}
+
+namespace unlockModule {
+const QString icon = "unlock.svg";
+}
+namespace aboutModule {
+const QString icon = "info.svg";
+}
+namespace grouping {
+const QString icon = "view-tree.svg";
+}
+}//mainIndex
+
+namespace bookshelfmgr {
+namespace installpage {
+const QString icon = "bible_add";
+const QString refresh_icon = "refresh";
+const QString delete_icon = "trash";
+const QString add_icon = "plus";
+const QString install_icon = "bible_add";
+const QString path_icon = "configure";
+}
+namespace removepage {
+const QString icon = "bible_remove";
+const QString remove_icon = "trash";
+}
+namespace indexpage {
+const QString icon = "document_magnifier";
+const QString create_icon = "folder_new";
+const QString delete_icon = "trash";
+}
+namespace paths {
+const QString add_icon = "plus";
+const QString edit_icon = "pencil";
+const QString remove_icon = "trash";
+}
+}
+
}
namespace CResMgr {
- void init_tr() {
- } //init_tr()
+void init_tr() {
+} //init_tr()
} //CResMgr
diff --git a/src/util/cresmgr.h b/src/util/cresmgr.h
index 95d931e..fcd602b 100644
--- a/src/util/cresmgr.h
+++ b/src/util/cresmgr.h
@@ -18,495 +18,495 @@
* @author The BibleTime team
*/
namespace CResMgr {
- void init_tr();
-
- namespace mainWindow {
- extern const QString icon;
- }
- namespace modules {
- namespace bible {
- extern const QString icon_unlocked;
- extern const QString icon_locked;
- extern const QString icon_add;
- }
- namespace commentary {
- extern const QString icon_unlocked;
- extern const QString icon_locked;
- extern const QString icon_add;
- }
- namespace lexicon {
- extern const QString icon_unlocked;
- extern const QString icon_locked;
- extern const QString icon_add;
- }
- namespace book {
- extern const QString icon_unlocked;
- extern const QString icon_locked;
- extern const QString icon_add;
- }
- }
-
- namespace categories {
- namespace bibles {
- extern const QString icon;
- }
- namespace commentaries {
- extern const QString icon;
- }
- namespace lexicons {
- extern const QString icon;
- }
- namespace dailydevotional {
- extern const QString icon;
- }
- namespace books {
- extern const QString icon;
- }
- namespace glossary {
- extern const QString icon;
- }
- namespace images {
- extern const QString icon;
- }
- namespace cults {
- extern const QString icon;
- }
- }
-
- namespace mainMenu { //Main menu
-
- namespace view { //Main menu->View
- namespace showMainIndex {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace showInfoDisplay {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
-
- namespace mainIndex { //configuration for the main index and the view->search menu
- namespace search {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace searchdefaultbible {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
-
- namespace window { //Main menu->Window
- namespace loadProfile {
- extern const QString icon;
- extern const char* actionName;
- }
- namespace saveProfile {
- extern const QString icon;
- extern const char* actionName;
- }
- namespace saveToNewProfile {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace deleteProfile {
- extern const QString icon;
- extern const char* actionName;
- }
- namespace showFullscreen {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace arrangementMode {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
-
- namespace manual {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace autoTileVertical {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace autoTileHorizontal {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace autoCascade {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
- namespace tileVertical {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace tileHorizontal {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace cascade {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace closeAll {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
-
- namespace settings { //Main menu->Settings
- namespace editToolBar { // available as KStdAction
- }
- namespace optionsDialog { // available as KStdAction
- }
- namespace swordSetupDialog {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
-
- namespace help { //Main menu->Help
- namespace handbook {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace bibleStudyHowTo {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
- } //end of main menu
-
- namespace searchdialog {
- extern const QString icon;
- extern const QString close_icon;
- extern const QString help_icon;
- extern const QString chooseworks_icon;
- extern const QString setupscope_icon;
-
- namespace result {
- namespace moduleList {
-
- namespace copyMenu {
- extern const QString icon;
- }
- namespace saveMenu {
- extern const QString icon;
- }
- namespace printMenu {
- extern const QString icon;
- }
- }
- namespace foundItems {
-
- namespace copyMenu {
- extern const QString icon;
- }
- namespace saveMenu {
- extern const QString icon;
- }
- namespace printMenu {
- extern const QString icon;
- }
-
- }
- }
- }
+void init_tr();
+
+namespace mainWindow {
+extern const QString icon;
+}
+namespace modules {
+namespace bible {
+extern const QString icon_unlocked;
+extern const QString icon_locked;
+extern const QString icon_add;
+}
+namespace commentary {
+extern const QString icon_unlocked;
+extern const QString icon_locked;
+extern const QString icon_add;
+}
+namespace lexicon {
+extern const QString icon_unlocked;
+extern const QString icon_locked;
+extern const QString icon_add;
+}
+namespace book {
+extern const QString icon_unlocked;
+extern const QString icon_locked;
+extern const QString icon_add;
+}
+}
+
+namespace categories {
+namespace bibles {
+extern const QString icon;
+}
+namespace commentaries {
+extern const QString icon;
+}
+namespace lexicons {
+extern const QString icon;
+}
+namespace dailydevotional {
+extern const QString icon;
+}
+namespace books {
+extern const QString icon;
+}
+namespace glossary {
+extern const QString icon;
+}
+namespace images {
+extern const QString icon;
+}
+namespace cults {
+extern const QString icon;
+}
+}
+
+namespace mainMenu { //Main menu
+
+namespace view { //Main menu->View
+namespace showMainIndex {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace showInfoDisplay {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+
+namespace mainIndex { //configuration for the main index and the view->search menu
+namespace search {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace searchdefaultbible {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+
+namespace window { //Main menu->Window
+namespace loadProfile {
+extern const QString icon;
+extern const char* actionName;
+}
+namespace saveProfile {
+extern const QString icon;
+extern const char* actionName;
+}
+namespace saveToNewProfile {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace deleteProfile {
+extern const QString icon;
+extern const char* actionName;
+}
+namespace showFullscreen {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace arrangementMode {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+
+namespace manual {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace autoTileVertical {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace autoTileHorizontal {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace autoCascade {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+namespace tileVertical {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace tileHorizontal {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace cascade {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace closeAll {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+
+namespace settings { //Main menu->Settings
+namespace editToolBar { // available as KStdAction
+}
+namespace optionsDialog { // available as KStdAction
+}
+namespace swordSetupDialog {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+
+namespace help { //Main menu->Help
+namespace handbook {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace bibleStudyHowTo {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+} //end of main menu
+
+namespace searchdialog {
+extern const QString icon;
+extern const QString close_icon;
+extern const QString help_icon;
+extern const QString chooseworks_icon;
+extern const QString setupscope_icon;
+
+namespace result {
+namespace moduleList {
+
+namespace copyMenu {
+extern const QString icon;
+}
+namespace saveMenu {
+extern const QString icon;
+}
+namespace printMenu {
+extern const QString icon;
+}
+}
+namespace foundItems {
+
+namespace copyMenu {
+extern const QString icon;
+}
+namespace saveMenu {
+extern const QString icon;
+}
+namespace printMenu {
+extern const QString icon;
+}
+
+}
+}
+}
namespace workspace {}
- namespace displaywindows {
- namespace transliteration {
- extern const QString icon;
- }
- namespace displaySettings {
- extern const QString icon;
- }
-
- namespace general {
- namespace search {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- namespace backInHistory {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace forwardInHistory {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- namespace findStrongs {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- }
-
- namespace bibleWindow {
- namespace nextBook {
- extern const QKeySequence accel;
- }
- namespace previousBook {
- extern const QKeySequence accel;
- }
-
- namespace nextChapter {
- extern const QKeySequence accel;
- }
- namespace previousChapter {
- extern const QKeySequence accel;
- }
-
- namespace nextVerse {
- extern const QKeySequence accel;
- }
- namespace previousVerse {
- extern const QKeySequence accel;
- }
-
- namespace copyMenu {
- extern const QString icon;
- }
- namespace saveMenu {
- extern const QString icon;
- }
- namespace printMenu {
- extern const QString icon;
- }
- }
- namespace commentaryWindow {
- namespace syncWindow {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- }
-
- namespace lexiconWindow {
- namespace nextEntry {
- extern const QKeySequence accel;
- }
- namespace previousEntry {
- extern const QKeySequence accel;
- }
-
- namespace copyMenu {
- extern const QString icon;
- }
- namespace saveMenu {
- extern const QString icon;
- }
- namespace printMenu {
- extern const QString icon;
- }
- }
- namespace bookWindow {
- namespace toggleTree {
- extern const QString icon;
- extern const QKeySequence accel;
- }
- }
-
-
- namespace writeWindow {
- namespace saveText {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace restoreText {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace deleteEntry {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- //formatting buttons
- namespace boldText {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace italicText {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace underlinedText {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- namespace alignLeft {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace alignCenter {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace alignRight {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace alignJustify {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
-
- namespace fontFamily {
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace fontSize {
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace fontColor {
- }
-
- }
- }
-
- namespace settings {
- namespace startup {
- extern const QString icon;
- }
- namespace fonts {
- extern const QString icon;
- }
- namespace profiles {
- extern const QString icon;
- }
- namespace sword {
- extern const QString icon;
-
- }
- namespace keys {
- extern const QString icon;
- }
- }
-
- namespace mainIndex { //configuration for the main index and the view->search menu
- namespace search {
- extern const QString icon;
- extern const QKeySequence accel;
- extern const char* actionName;
- }
- namespace newFolder {
- extern const QString icon;
- }
- namespace changeFolder {
- extern const QString icon;
- }
- namespace openedFolder {
- extern const QString icon;
- }
- namespace closedFolder {
- extern const QString icon;
- }
-
- namespace bookmark {
- extern const QString icon;
- }
- namespace changeBookmark {
- extern const QString icon;
- }
- namespace importBookmarks {
- extern const QString icon;
- }
- namespace exportBookmarks {
- extern const QString icon;
- }
- namespace printBookmarks {
- extern const QString icon;
- }
- namespace deleteItems {
- extern const QString icon;
- }
-
- namespace editModuleMenu {
- extern const QString icon;
- }
- namespace editModulePlain {
- extern const QString icon;
- }
- namespace editModuleHTML {
- extern const QString icon;
- }
-
- namespace unlockModule {
- extern const QString icon;
- }
- namespace aboutModule {
- extern const QString icon;
- }
- namespace grouping {
- extern const QString icon;
- }
- }
-
- namespace bookshelfmgr {
- namespace installpage {
- extern const QString icon;
- extern const QString refresh_icon;
- extern const QString delete_icon;
- extern const QString add_icon;
- extern const QString install_icon;
- extern const QString path_icon;
- }
- namespace removepage {
- extern const QString icon;
- extern const QString remove_icon;
- }
- namespace indexpage {
- extern const QString icon;
- extern const QString create_icon;
- extern const QString delete_icon;
- }
- namespace paths {
- extern const QString add_icon;
- extern const QString edit_icon;
- extern const QString remove_icon;
- }
- }
+namespace displaywindows {
+namespace transliteration {
+extern const QString icon;
+}
+namespace displaySettings {
+extern const QString icon;
+}
+
+namespace general {
+namespace search {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+namespace backInHistory {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace forwardInHistory {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+namespace findStrongs {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+}
+
+namespace bibleWindow {
+namespace nextBook {
+extern const QKeySequence accel;
+}
+namespace previousBook {
+extern const QKeySequence accel;
+}
+
+namespace nextChapter {
+extern const QKeySequence accel;
+}
+namespace previousChapter {
+extern const QKeySequence accel;
+}
+
+namespace nextVerse {
+extern const QKeySequence accel;
+}
+namespace previousVerse {
+extern const QKeySequence accel;
+}
+
+namespace copyMenu {
+extern const QString icon;
+}
+namespace saveMenu {
+extern const QString icon;
+}
+namespace printMenu {
+extern const QString icon;
+}
+}
+namespace commentaryWindow {
+namespace syncWindow {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+}
+
+namespace lexiconWindow {
+namespace nextEntry {
+extern const QKeySequence accel;
+}
+namespace previousEntry {
+extern const QKeySequence accel;
+}
+
+namespace copyMenu {
+extern const QString icon;
+}
+namespace saveMenu {
+extern const QString icon;
+}
+namespace printMenu {
+extern const QString icon;
+}
+}
+namespace bookWindow {
+namespace toggleTree {
+extern const QString icon;
+extern const QKeySequence accel;
+}
+}
+
+
+namespace writeWindow {
+namespace saveText {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace restoreText {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace deleteEntry {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+//formatting buttons
+namespace boldText {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace italicText {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace underlinedText {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+namespace alignLeft {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace alignCenter {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace alignRight {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace alignJustify {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+
+namespace fontFamily {
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace fontSize {
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace fontColor {
+}
+
+}
+}
+
+namespace settings {
+namespace startup {
+extern const QString icon;
+}
+namespace fonts {
+extern const QString icon;
+}
+namespace profiles {
+extern const QString icon;
+}
+namespace sword {
+extern const QString icon;
+
+}
+namespace keys {
+extern const QString icon;
+}
+}
+
+namespace mainIndex { //configuration for the main index and the view->search menu
+namespace search {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
+namespace newFolder {
+extern const QString icon;
+}
+namespace changeFolder {
+extern const QString icon;
+}
+namespace openedFolder {
+extern const QString icon;
+}
+namespace closedFolder {
+extern const QString icon;
+}
+
+namespace bookmark {
+extern const QString icon;
+}
+namespace changeBookmark {
+extern const QString icon;
+}
+namespace importBookmarks {
+extern const QString icon;
+}
+namespace exportBookmarks {
+extern const QString icon;
+}
+namespace printBookmarks {
+extern const QString icon;
+}
+namespace deleteItems {
+extern const QString icon;
+}
+
+namespace editModuleMenu {
+extern const QString icon;
+}
+namespace editModulePlain {
+extern const QString icon;
+}
+namespace editModuleHTML {
+extern const QString icon;
+}
+
+namespace unlockModule {
+extern const QString icon;
+}
+namespace aboutModule {
+extern const QString icon;
+}
+namespace grouping {
+extern const QString icon;
+}
+}
+
+namespace bookshelfmgr {
+namespace installpage {
+extern const QString icon;
+extern const QString refresh_icon;
+extern const QString delete_icon;
+extern const QString add_icon;
+extern const QString install_icon;
+extern const QString path_icon;
+}
+namespace removepage {
+extern const QString icon;
+extern const QString remove_icon;
+}
+namespace indexpage {
+extern const QString icon;
+extern const QString create_icon;
+extern const QString delete_icon;
+}
+namespace paths {
+extern const QString add_icon;
+extern const QString edit_icon;
+extern const QString remove_icon;
+}
+}
}
#endif
diff --git a/src/util/ctoolclass.cpp b/src/util/ctoolclass.cpp
index c21bfe3..5d4ab51 100644
--- a/src/util/ctoolclass.cpp
+++ b/src/util/ctoolclass.cpp
@@ -29,251 +29,249 @@
/** Converts HTML text to plain text */
QString CToolClass::htmlToText(const QString& html) {
- QString newText = html;
- // convert some tags we need in code
- newText.replace( QRegExp(" "),"#SPACE#" );
- newText.replace( QRegExp("<br/?>\\s*"), "<br/>\n" );
- newText.replace( QRegExp("#SPACE#")," " );
-
- QRegExp re("<.+>");
- re.setMinimal(true);
- newText.replace( re,"" );
- return newText;
+ QString newText = html;
+ // convert some tags we need in code
+ newText.replace( QRegExp(" "), "#SPACE#" );
+ newText.replace( QRegExp("<br/?>\\s*"), "<br/>\n" );
+ newText.replace( QRegExp("#SPACE#"), " " );
+
+ QRegExp re("<.+>");
+ re.setMinimal(true);
+ newText.replace( re, "" );
+ return newText;
}
/** Converts text to HTML (\n to <BR>) */
QString CToolClass::textToHTML(const QString& text) {
- QString newText = text;
- newText.replace( QRegExp("<BR>\n"),"#NEWLINE#" );
- newText.replace( QRegExp("\n"),"<BR>\n" );
- newText.replace( QRegExp("#NEWLINE#"),"<BR>\n");
- return newText;
+ QString newText = text;
+ newText.replace( QRegExp("<BR>\n"), "#NEWLINE#" );
+ newText.replace( QRegExp("\n"), "<BR>\n" );
+ newText.replace( QRegExp("#NEWLINE#"), "<BR>\n");
+ return newText;
}
/** Creates the file filename and put text into the file.
*/
bool CToolClass::savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite, QTextCodec* fileCodec) {
- QFile saveFile(filename);
- bool ret;
-
- if (saveFile.exists()) {
- if (!forceOverwrite && QMessageBox::question(0, QObject::tr("Overwrite File?"),
- QString::fromLatin1("<qt><B>%1</B><BR>%2</qt>")
- .arg( QObject::tr("The file already exists.") )
- .arg( QObject::tr("Do you want to overwrite it?")),
- QMessageBox::Yes|QMessageBox::No,
- QMessageBox::No) == QMessageBox::No
- )
- {
- return false;
- }
- else { //either the user chose yes or forceOverwrite is set
- saveFile.remove();
- }
- }
-
- if ( saveFile.open(QIODevice::ReadWrite) ) {
- QTextStream textstream( &saveFile );
- textstream.setCodec(fileCodec);
- textstream << text;
- saveFile.close();
- ret = true;
- }
- else {
- QMessageBox::critical(0, QObject::tr("Error"),
- QString::fromLatin1("<qt>%1<BR><B>%2</B></qt>")
- .arg( QObject::tr("The file couldn't be saved.") )
- .arg( QObject::tr("Please check permissions etc.")));
- saveFile.close();
- ret = false;
- }
- return ret;
+ QFile saveFile(filename);
+ bool ret;
+
+ if (saveFile.exists()) {
+ if (!forceOverwrite && QMessageBox::question(0, QObject::tr("Overwrite File?"),
+ QString::fromLatin1("<qt><B>%1</B><BR>%2</qt>")
+ .arg( QObject::tr("The file already exists.") )
+ .arg( QObject::tr("Do you want to overwrite it?")),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No) == QMessageBox::No
+ ) {
+ return false;
+ }
+ else { //either the user chose yes or forceOverwrite is set
+ saveFile.remove();
+ }
+ }
+
+ if ( saveFile.open(QIODevice::ReadWrite) ) {
+ QTextStream textstream( &saveFile );
+ textstream.setCodec(fileCodec);
+ textstream << text;
+ saveFile.close();
+ ret = true;
+ }
+ else {
+ QMessageBox::critical(0, QObject::tr("Error"),
+ QString::fromLatin1("<qt>%1<BR><B>%2</B></qt>")
+ .arg( QObject::tr("The file couldn't be saved.") )
+ .arg( QObject::tr("Please check permissions etc.")));
+ saveFile.close();
+ ret = false;
+ }
+ return ret;
}
/** Returns the icon used for the module given as aparameter. */
QIcon CToolClass::getIconForModule( CSwordModuleInfo* module_info ) {
- return util::filesystem::DirectoryUtil::getIcon(getIconNameForModule(module_info));
+ return util::filesystem::DirectoryUtil::getIcon(getIconNameForModule(module_info));
}
/** Returns the name for the icon used for the module given as aparameter. */
QString CToolClass::getIconNameForModule( CSwordModuleInfo* module_info ) {
- //qDebug("CToolClass::getIconNameForModule");
- if (!module_info) return CResMgr::modules::book::icon_locked;
-
- if (module_info->category() == CSwordModuleInfo::Cult) {
- return "stop.svg";
- }
-
- switch (module_info->type()) {
- case CSwordModuleInfo::Bible:
- if (module_info->isLocked())
- return CResMgr::modules::bible::icon_locked;
- else
- return CResMgr::modules::bible::icon_unlocked;
- break;
-
- case CSwordModuleInfo::Lexicon:
- if (module_info->isLocked())
- return CResMgr::modules::lexicon::icon_locked;
- else
- return CResMgr::modules::lexicon::icon_unlocked;
- break;
-
- case CSwordModuleInfo::Commentary:
- if (module_info->isLocked())
- return CResMgr::modules::commentary::icon_locked;
- else
- return CResMgr::modules::commentary::icon_unlocked;
- break;
-
- case CSwordModuleInfo::GenericBook:
- if (module_info->isLocked())
- return CResMgr::modules::book::icon_locked;
- else
- return CResMgr::modules::book::icon_unlocked;
- break;
-
- case CSwordModuleInfo::Unknown: //fallback
- default:
- if (module_info->isLocked())
- return CResMgr::modules::book::icon_locked;
- else
- return CResMgr::modules::book::icon_unlocked;
- break;
- }
- return CResMgr::modules::book::icon_unlocked;
+ //qDebug("CToolClass::getIconNameForModule");
+ if (!module_info) return CResMgr::modules::book::icon_locked;
+
+ if (module_info->category() == CSwordModuleInfo::Cult) {
+ return "stop.svg";
+ }
+
+ switch (module_info->type()) {
+ case CSwordModuleInfo::Bible:
+ if (module_info->isLocked())
+ return CResMgr::modules::bible::icon_locked;
+ else
+ return CResMgr::modules::bible::icon_unlocked;
+ break;
+
+ case CSwordModuleInfo::Lexicon:
+ if (module_info->isLocked())
+ return CResMgr::modules::lexicon::icon_locked;
+ else
+ return CResMgr::modules::lexicon::icon_unlocked;
+ break;
+
+ case CSwordModuleInfo::Commentary:
+ if (module_info->isLocked())
+ return CResMgr::modules::commentary::icon_locked;
+ else
+ return CResMgr::modules::commentary::icon_unlocked;
+ break;
+
+ case CSwordModuleInfo::GenericBook:
+ if (module_info->isLocked())
+ return CResMgr::modules::book::icon_locked;
+ else
+ return CResMgr::modules::book::icon_unlocked;
+ break;
+
+ case CSwordModuleInfo::Unknown: //fallback
+ default:
+ if (module_info->isLocked())
+ return CResMgr::modules::book::icon_locked;
+ else
+ return CResMgr::modules::book::icon_unlocked;
+ break;
+ }
+ return CResMgr::modules::book::icon_unlocked;
}
QLabel* CToolClass::explanationLabel(QWidget* parent, const QString& heading, const QString& text ) {
- QString br;
- if (!heading.isEmpty() && !text.isEmpty()) {
- br = QString::fromLatin1("<span style='white-space:pre'> - </span>");
- }
- QLabel* label = new QLabel( QString::fromLatin1("<B>%1</B>%2<small>%3</small>").arg(heading).arg(br).arg(text),parent );
-
- label->setWordWrap(true);
- label->setMargin(1);
- label->setFrameStyle(QFrame::Box | QFrame::Sunken);
- return label;
+ QString br;
+ if (!heading.isEmpty() && !text.isEmpty()) {
+ br = QString::fromLatin1("<span style='white-space:pre'> - </span>");
+ }
+ QLabel* label = new QLabel( QString::fromLatin1("<B>%1</B>%2<small>%3</small>").arg(heading).arg(br).arg(text), parent );
+
+ label->setWordWrap(true);
+ label->setMargin(1);
+ label->setFrameStyle(QFrame::Box | QFrame::Sunken);
+ return label;
}
/** No descriptions */
bool CToolClass::inHTMLTag(int pos, QString & text) {
- int i1=text.lastIndexOf("<",pos);
- int i2=text.lastIndexOf(">",pos);
- int i3=text.indexOf(">",pos);
- int i4=text.indexOf("<",pos);
+ int i1 = text.lastIndexOf("<", pos);
+ int i2 = text.lastIndexOf(">", pos);
+ int i3 = text.indexOf(">", pos);
+ int i4 = text.indexOf("<", pos);
- // if ((i1>0) && (i2==-1)) //we're in th first html tag
- // i2=i1; // not ncessary, just for explanation
+ // if ((i1>0) && (i2==-1)) //we're in th first html tag
+ // i2=i1; // not ncessary, just for explanation
- if ((i3>0) && (i4==-1)) //we're in the last html tag
- i4=i3+1;
+ if ((i3 > 0) && (i4 == -1)) //we're in the last html tag
+ i4 = i3 + 1;
- // qWarning("%d > %d && %d < %d",i1,i2,i3,i4);
+ // qWarning("%d > %d && %d < %d",i1,i2,i3,i4);
- if ( (i1>i2) && (i3<i4) )
- return true; //yes, we're in a tag
+ if ( (i1 > i2) && (i3 < i4) )
+ return true; //yes, we're in a tag
- return false;
+ return false;
}
QString CToolClass::moduleToolTip(CSwordModuleInfo* module) {
- Q_ASSERT(module);
- if (!module) {
- return QString::null;
- }
+ Q_ASSERT(module);
+ if (!module) {
+ return QString::null;
+ }
- QString text;
+ QString text;
- text = QString("<b>%1</b> ").arg( module->name() )
- + ((module->category() == CSwordModuleInfo::Cult) ? QString::fromLatin1("<small><b>%1</b></small><br>").arg(QObject::tr("Take care, this work contains cult / questionable material!")) : QString::null);
+ text = QString("<b>%1</b> ").arg( module->name() )
+ + ((module->category() == CSwordModuleInfo::Cult) ? QString::fromLatin1("<small><b>%1</b></small><br>").arg(QObject::tr("Take care, this work contains cult / questionable material!")) : QString::null);
- text += QString("<small>(") + module->config(CSwordModuleInfo::Description) + QString(")</small><hr>");
+ text += QString("<small>(") + module->config(CSwordModuleInfo::Description) + QString(")</small><hr>");
- text += QObject::tr("Language") + QString(": %1<br>").arg( module->language()->translatedName() );
+ text += QObject::tr("Language") + QString(": %1<br>").arg( module->language()->translatedName() );
- if (module->isEncrypted()) {
- text += QObject::tr("Unlock key") + QString(": %1<br>")
- .arg(!module->config(CSwordModuleInfo::CipherKey).isEmpty() ? module->config(CSwordModuleInfo::CipherKey) : QString("<font COLOR=\"red\">%1</font>").arg(QObject::tr("not set")));
- }
+ if (module->isEncrypted()) {
+ text += QObject::tr("Unlock key") + QString(": %1<br>")
+ .arg(!module->config(CSwordModuleInfo::CipherKey).isEmpty() ? module->config(CSwordModuleInfo::CipherKey) : QString("<font COLOR=\"red\">%1</font>").arg(QObject::tr("not set")));
+ }
- if (module->hasVersion()) {
- text += QObject::tr("Version") + QString(": %1<br>").arg( module->config(CSwordModuleInfo::ModuleVersion) );
- }
+ if (module->hasVersion()) {
+ text += QObject::tr("Version") + QString(": %1<br>").arg( module->config(CSwordModuleInfo::ModuleVersion) );
+ }
- QString options;
- unsigned int opts;
- for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
- if (module->has( static_cast<CSwordModuleInfo::FilterTypes>(opts) )) {
- if (!options.isEmpty()) {
- options += QString::fromLatin1(", ");
- }
+ QString options;
+ unsigned int opts;
+ for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
+ if (module->has( static_cast<CSwordModuleInfo::FilterTypes>(opts) )) {
+ if (!options.isEmpty()) {
+ options += QString::fromLatin1(", ");
+ }
- options += CSwordBackend::translatedOptionName(
- static_cast<CSwordModuleInfo::FilterTypes>(opts)
- );
- }
- }
+ options += CSwordBackend::translatedOptionName(
+ static_cast<CSwordModuleInfo::FilterTypes>(opts)
+ );
+ }
+ }
- if (!options.isEmpty()) {
- text += QObject::tr("Options") + QString::fromLatin1(": <small>") + options + QString("</small>");
- }
+ if (!options.isEmpty()) {
+ text += QObject::tr("Options") + QString::fromLatin1(": <small>") + options + QString("</small>");
+ }
- if (text.right(4) == QString::fromLatin1("<br>")) {
- text = text.left(text.length()-4);
- }
+ if (text.right(4) == QString::fromLatin1("<br>")) {
+ text = text.left(text.length() - 4);
+ }
- return text;
+ return text;
}
QString CToolClass::remoteModuleToolTip(CSwordModuleInfo* module, QString localVer) {
- Q_ASSERT(module);
- if (!module) {
- return QString::null;
- }
+ Q_ASSERT(module);
+ if (!module) {
+ return QString::null;
+ }
- QString text;
+ QString text;
- text = QString("<p style='white-space:pre'><b>%1</b> ").arg( module->name() )
- + ((module->category() == CSwordModuleInfo::Cult) ? QString::fromLatin1("<small><b>%1</b></small><br>").arg(QObject::tr("Take care, this work contains cult / questionable material!")) : QString::null);
+ text = QString("<p style='white-space:pre'><b>%1</b> ").arg( module->name() )
+ + ((module->category() == CSwordModuleInfo::Cult) ? QString::fromLatin1("<small><b>%1</b></small><br>").arg(QObject::tr("Take care, this work contains cult / questionable material!")) : QString::null);
- text += QString("<small>(") + module->config(CSwordModuleInfo::Description) + QString(")</small><hr/>");
+ text += QString("<small>(") + module->config(CSwordModuleInfo::Description) + QString(")</small><hr/>");
- if (module->isEncrypted()) {
- text += QObject::tr("Encrypted - needs unlock key") + QString("<br>");
- }
+ if (module->isEncrypted()) {
+ text += QObject::tr("Encrypted - needs unlock key") + QString("<br>");
+ }
- if (!localVer.isEmpty()) {
- text += QString("<b>") + QObject::tr("Updated version available!") + QString("</b><br>");
- }
+ if (!localVer.isEmpty()) {
+ text += QString("<b>") + QObject::tr("Updated version available!") + QString("</b><br>");
+ }
- if (module->hasVersion()) {
- text += QObject::tr("Version") + QString(": %1").arg( module->config(CSwordModuleInfo::ModuleVersion) );
- }
- // if installed already
- if (!localVer.isEmpty()) {
- text += QString(" ") + QObject::tr("Installed version") + QString(": %1").arg(localVer);
- }
- text += QString("<br>");
+ if (module->hasVersion()) {
+ text += QObject::tr("Version") + QString(": %1").arg( module->config(CSwordModuleInfo::ModuleVersion) );
+ }
+ // if installed already
+ if (!localVer.isEmpty()) {
+ text += QString(" ") + QObject::tr("Installed version") + QString(": %1").arg(localVer);
+ }
+ text += QString("<br>");
- text += QString("<small>(") + QObject::tr("Double click for more information") + QString(")</small></p>");
-
+ text += QString("<small>(") + QObject::tr("Double click for more information") + QString(")</small></p>");
- if (text.right(4) == QString::fromLatin1("<br>")) {
- text = text.left(text.length()-4);
- }
- return text;
+ if (text.right(4) == QString::fromLatin1("<br>")) {
+ text = text.left(text.length() - 4);
+ }
+
+ return text;
}
-int CToolClass::mWidth(const QWidget* widget, int m)
-{
- if (widget) {
- return widget->fontMetrics().width(QString().fill('M', m));
- }
- return QApplication::fontMetrics().width(QString().fill('M', m));
+int CToolClass::mWidth(const QWidget* widget, int m) {
+ if (widget) {
+ return widget->fontMetrics().width(QString().fill('M', m));
+ }
+ return QApplication::fontMetrics().width(QString().fill('M', m));
}
diff --git a/src/util/ctoolclass.h b/src/util/ctoolclass.h
index 47ba228..0e48dfd 100644
--- a/src/util/ctoolclass.h
+++ b/src/util/ctoolclass.h
@@ -30,65 +30,65 @@ class QWidget;
* #include "util/util.h"
* util::function();
* (comment by Eeli)
- *
+ *
*/
class CToolClass {
-public:
- /**
- * Converts HTML text to plain text.
- * This function converts some HTML tags in text (e.g. <BR> to \n)
- * @return The text withput HTML tags and with converted <BR> to \n
- * @author Joachim Ansorg
- */
- static QString htmlToText(const QString&);
- /**
- * Converts text to HTML converting some text commands into HTML tags (e.g. \n to <BR>)
- * @return The HTML formatted text we got after changing \n to <BR>
- * @author Joachim Ansorg
- */
- static QString textToHTML(const QString&);
- /**
- * Creates the file filename and put the text of parameter "text" into the file.
- * @return True if saving was sucessful, otherwise false
- * @author Joachim Ansorg
- */
- static bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, QTextCodec* fileCodec = QTextCodec::codecForLocale());
- /**
- * Returns the icon used for the module given as aparameter.
- */
- static QIcon getIconForModule( CSwordModuleInfo* );
- /**
- * Returns the name for the icon used for the module given as aparameter.
- */
- static QString getIconNameForModule( CSwordModuleInfo* );
-
- /** Returns a label to explain difficult things of dialogs.
- * This function returns a label with heading "heading" and explanation "text". This label should be used to
- * explain difficult things of the GUI, e.g. in the optionsdialog.
- */
- static QLabel* explanationLabel(QWidget* parent, const QString& heading, const QString& text );
- /**
- * Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag.
- */
- static bool inHTMLTag(int pos, QString & text);
+ public:
+ /**
+ * Converts HTML text to plain text.
+ * This function converts some HTML tags in text (e.g. <BR> to \n)
+ * @return The text withput HTML tags and with converted <BR> to \n
+ * @author Joachim Ansorg
+ */
+ static QString htmlToText(const QString&);
+ /**
+ * Converts text to HTML converting some text commands into HTML tags (e.g. \n to <BR>)
+ * @return The HTML formatted text we got after changing \n to <BR>
+ * @author Joachim Ansorg
+ */
+ static QString textToHTML(const QString&);
+ /**
+ * Creates the file filename and put the text of parameter "text" into the file.
+ * @return True if saving was sucessful, otherwise false
+ * @author Joachim Ansorg
+ */
+ static bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, QTextCodec* fileCodec = QTextCodec::codecForLocale());
+ /**
+ * Returns the icon used for the module given as aparameter.
+ */
+ static QIcon getIconForModule( CSwordModuleInfo* );
+ /**
+ * Returns the name for the icon used for the module given as aparameter.
+ */
+ static QString getIconNameForModule( CSwordModuleInfo* );
+
+ /** Returns a label to explain difficult things of dialogs.
+ * This function returns a label with heading "heading" and explanation "text". This label should be used to
+ * explain difficult things of the GUI, e.g. in the optionsdialog.
+ */
+ static QLabel* explanationLabel(QWidget* parent, const QString& heading, const QString& text );
+ /**
+ * Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag.
+ */
+ static bool inHTMLTag(int pos, QString & text);
+
+ /** Return the module's tooltip text
+ * @param module The module required for the tooltip
+ * @return The tooltip text for the passed module
+ */
+ static QString moduleToolTip(CSwordModuleInfo* module);
- /** Return the module's tooltip text
- * @param module The module required for the tooltip
- * @return The tooltip text for the passed module
- */
- static QString moduleToolTip(CSwordModuleInfo* module);
+ /** Return the module's tooltip text for a remote module
+ * @param module The module required for the tooltip
+ * @return The tooltip text for the passed module
+ */
+ static QString remoteModuleToolTip(CSwordModuleInfo* module, QString localVer);
- /** Return the module's tooltip text for a remote module
- * @param module The module required for the tooltip
- * @return The tooltip text for the passed module
- */
- static QString remoteModuleToolTip(CSwordModuleInfo* module, QString localVer);
-
- /**
- * Returns the width in pixels for a string which has mCount 'M' letters, using the specified widget's font.
- * This can be used when setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use pixels directly.
- */
- static int mWidth(const QWidget* widget, int mCount);
+ /**
+ * Returns the width in pixels for a string which has mCount 'M' letters, using the specified widget's font.
+ * This can be used when setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use pixels directly.
+ */
+ static int mWidth(const QWidget* widget, int mCount);
};
#endif
diff --git a/src/util/dialogutil.cpp b/src/util/dialogutil.cpp
index e89f881..b2169c4 100644
--- a/src/util/dialogutil.cpp
+++ b/src/util/dialogutil.cpp
@@ -1,7 +1,7 @@
//
// C++ Interface: dialogutil
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2009
@@ -13,49 +13,46 @@
#include <QtGui/QDialogButtonBox>
#include <QtGui/QPushButton>
-namespace util
-{
+namespace util {
- static void replaceText(QDialogButtonBox* box, QDialogButtonBox::StandardButton flag, const QString& text)
- {
- QPushButton* button = box->button(flag);
- if (button != 0)
- button->setText(text);
- }
+static void replaceText(QDialogButtonBox* box, QDialogButtonBox::StandardButton flag, const QString& text) {
+ QPushButton* button = box->button(flag);
+ if (button != 0)
+ button->setText(text);
+}
- void prepareDialogBox(QDialogButtonBox* box)
- {
- //: Standard button
- replaceText(box, QDialogButtonBox::Ok , QPushButton::tr("OK" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Open , QPushButton::tr("Open" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Save , QPushButton::tr("Save" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Cancel , QPushButton::tr("Cancel" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Close , QPushButton::tr("Close" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Discard , QPushButton::tr("Discard" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Apply , QPushButton::tr("Apply" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Reset , QPushButton::tr("Reset" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::RestoreDefaults, QPushButton::tr("Restore defaults", "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Help , QPushButton::tr("Help" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::SaveAll , QPushButton::tr("Save All" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::Yes , QPushButton::tr("Yes" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::YesToAll, QPushButton::tr("Yes to all", "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::No , QPushButton::tr("No" , "Dialog Button"));
- //: Standard button
- replaceText(box, QDialogButtonBox::NoToAll , QPushButton::tr("No to all" , "Dialog Button"));
- }
+void prepareDialogBox(QDialogButtonBox* box) {
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Ok , QPushButton::tr("OK" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Open , QPushButton::tr("Open" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Save , QPushButton::tr("Save" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Cancel , QPushButton::tr("Cancel" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Close , QPushButton::tr("Close" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Discard , QPushButton::tr("Discard" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Apply , QPushButton::tr("Apply" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Reset , QPushButton::tr("Reset" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::RestoreDefaults, QPushButton::tr("Restore defaults", "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Help , QPushButton::tr("Help" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::SaveAll , QPushButton::tr("Save All" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::Yes , QPushButton::tr("Yes" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::YesToAll, QPushButton::tr("Yes to all", "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::No , QPushButton::tr("No" , "Dialog Button"));
+ //: Standard button
+ replaceText(box, QDialogButtonBox::NoToAll , QPushButton::tr("No to all" , "Dialog Button"));
+}
}
diff --git a/src/util/dialogutil.h b/src/util/dialogutil.h
index e25c931..2a7958b 100644
--- a/src/util/dialogutil.h
+++ b/src/util/dialogutil.h
@@ -1,7 +1,7 @@
//
// C++ Interface: dialogutil
//
-// Description:
+// Description:
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 2009
@@ -14,9 +14,8 @@
class QDialogButtonBox;
-namespace util
-{
- void prepareDialogBox(QDialogButtonBox* box);
+namespace util {
+void prepareDialogBox(QDialogButtonBox* box);
}
#endif
diff --git a/src/util/directoryutil.cpp b/src/util/directoryutil.cpp
index 6a1076d..0403d7b 100644
--- a/src/util/directoryutil.cpp
+++ b/src/util/directoryutil.cpp
@@ -23,83 +23,79 @@ namespace util {
namespace filesystem {
void DirectoryUtil::removeRecursive(const QString dir) {
- //Check for validity of argument
- if (dir.isEmpty()) return;
- QDir d(dir);
- if (!d.exists()) return;
-
- //remove all files in this dir
- d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
- const QFileInfoList fileList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_file = fileList.begin(); it_file != fileList.end(); it_file++)
- {
- d.remove( it_file->fileName() );
- }
-
- //remove all subdirs recursively
- d.setFilter( QDir::Dirs | QDir::NoSymLinks );
- const QFileInfoList dirList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_dir = dirList.begin(); it_dir != dirList.end(); it_dir++)
- {
- if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
- continue;
- }
- removeRecursive( it_dir->absoluteFilePath() );
- }
- d.rmdir(dir);
+ //Check for validity of argument
+ if (dir.isEmpty()) return;
+ QDir d(dir);
+ if (!d.exists()) return;
+
+ //remove all files in this dir
+ d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
+ const QFileInfoList fileList = d.entryInfoList();
+ for (QFileInfoList::const_iterator it_file = fileList.begin(); it_file != fileList.end(); it_file++) {
+ d.remove( it_file->fileName() );
+ }
+
+ //remove all subdirs recursively
+ d.setFilter( QDir::Dirs | QDir::NoSymLinks );
+ const QFileInfoList dirList = d.entryInfoList();
+ for (QFileInfoList::const_iterator it_dir = dirList.begin(); it_dir != dirList.end(); it_dir++) {
+ if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
+ continue;
+ }
+ removeRecursive( it_dir->absoluteFilePath() );
+ }
+ d.rmdir(dir);
}
/** Returns the size of the directory including the size of all it's files and it's subdirs.
*/
unsigned long DirectoryUtil::getDirSizeRecursive(const QString dir) {
- //Check for validity of argument
- QDir d(dir);
- if (!d.exists()) return 0;
-
- unsigned long size = 0;
-
- //First get the size of all files int this folder
- d.setFilter(QDir::Files);
- const QFileInfoList infoList = d.entryInfoList();
- for (QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); it++)
- {
- size += it->size();
- }
-
- //Then add the sizes of all subdirectories
- d.setFilter(QDir::Dirs);
- const QFileInfoList dirInfoList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_dir = dirInfoList.begin(); it_dir != dirInfoList.end(); it_dir++)
- {
- if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
- continue;
- }
- size += getDirSizeRecursive( it_dir->absoluteFilePath() );
- }
- return size;
+ //Check for validity of argument
+ QDir d(dir);
+ if (!d.exists()) return 0;
+
+ unsigned long size = 0;
+
+ //First get the size of all files int this folder
+ d.setFilter(QDir::Files);
+ const QFileInfoList infoList = d.entryInfoList();
+ for (QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); it++) {
+ size += it->size();
+ }
+
+ //Then add the sizes of all subdirectories
+ d.setFilter(QDir::Dirs);
+ const QFileInfoList dirInfoList = d.entryInfoList();
+ for (QFileInfoList::const_iterator it_dir = dirInfoList.begin(); it_dir != dirInfoList.end(); it_dir++) {
+ if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
+ continue;
+ }
+ size += getDirSizeRecursive( it_dir->absoluteFilePath() );
+ }
+ return size;
}
/**Recursively copies a directory, overwriting existing files*/
-void DirectoryUtil::copyRecursive(QString src, QString dest){
- QDir srcDir(src);
- QDir destDir(dest);
- //Copy files
- QStringList files = srcDir.entryList(QDir::Files);
- for (QStringList::iterator it = files.begin(); it != files.end(); ++it){
- QFile currFile(src + "/" + *it);
- QString newFileLoc = dest + "/" + *it;
- QFile newFile(newFileLoc);
- newFile.remove();
- currFile.copy(newFileLoc);
- }
- QStringList dirs = srcDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
- for (QStringList::iterator it = dirs.begin(); it != dirs.end(); ++it){
- QString temp = *it;
- if (!destDir.cd(*it)){
- destDir.mkdir(*it);
- }
- copyRecursive(src + "/" + *it, dest + "/" + *it);
- }
+void DirectoryUtil::copyRecursive(QString src, QString dest) {
+ QDir srcDir(src);
+ QDir destDir(dest);
+ //Copy files
+ QStringList files = srcDir.entryList(QDir::Files);
+ for (QStringList::iterator it = files.begin(); it != files.end(); ++it) {
+ QFile currFile(src + "/" + *it);
+ QString newFileLoc = dest + "/" + *it;
+ QFile newFile(newFileLoc);
+ newFile.remove();
+ currFile.copy(newFileLoc);
+ }
+ QStringList dirs = srcDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (QStringList::iterator it = dirs.begin(); it != dirs.end(); ++it) {
+ QString temp = *it;
+ if (!destDir.cd(*it)) {
+ destDir.mkdir(*it);
+ }
+ copyRecursive(src + "/" + *it, dest + "/" + *it);
+ }
}
static QDir cachedIconDir;
@@ -119,246 +115,226 @@ static QDir cachedUserIndexDir;
static bool dirCacheInitialized = false;
-void DirectoryUtil::initDirectoryCache(void)
-{
- QDir wDir( QCoreApplication::applicationDirPath() );
- wDir.makeAbsolute();
-
- if (!wDir.cdUp()) //installation prefix
- {
- qWarning() << "Cannot cd up from directory " << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedIconDir = wDir; //icon dir
- if (!cachedIconDir.cd("share/bibletime/icons") || !cachedIconDir.isReadable())
- {
- qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedJavascriptDir = wDir;
- if (!cachedJavascriptDir.cd("share/bibletime/javascript") || !cachedJavascriptDir.isReadable())
- {
- qWarning() << "Cannot find javascript directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedLicenseDir = wDir;
- if (!cachedLicenseDir.cd("share/bibletime/license") || !cachedLicenseDir.isReadable())
- {
- qWarning() << "Cannot find license directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedPicsDir = wDir; //icon dir
- if (!cachedPicsDir.cd("share/bibletime/pics") || !cachedPicsDir.isReadable())
- {
- qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedLocaleDir = wDir;
- if (!cachedLocaleDir.cd("share/bibletime/locale")) {
- qWarning() << "Cannot find locale directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- QString localeName = QLocale::system().name();
- QString langCode = localeName.section('_', 0, 0);
-
- cachedHandbookDir = wDir;
- if (!cachedHandbookDir.cd(QString("share/bibletime/docs/handbook/") + localeName)) {
- if (!cachedHandbookDir.cd(QString("share/bibletime/docs/handbook/") + langCode)) {
- if (!cachedHandbookDir.cd("share/bibletime/docs/handbook/en/")) {
- qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
- }
- }
-
- cachedHowtoDir = wDir;
- if (!cachedHowtoDir.cd(QString("share/bibletime/docs/howto/") + localeName)) {
- if (!cachedHowtoDir.cd(QString("share/bibletime/docs/howto/") + langCode)) {
- if (!cachedHowtoDir.cd("share/bibletime/docs/howto/en/")) {
- qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
- }
- }
-
- cachedDisplayTemplatesDir = wDir; //display templates dir
- if (!cachedDisplayTemplatesDir.cd("share/bibletime/display-templates/")) {
- qWarning() << "Cannot find display template directory relative to" << QCoreApplication::applicationDirPath();
- throw;
- }
-
- cachedUserHomeDir = QDir::home();
-
- cachedUserBaseDir = QDir::home();
- if (!cachedUserBaseDir.cd(".bibletime")){
- bool success = cachedUserBaseDir.mkdir(".bibletime") && cachedUserBaseDir.cd(".bibletime");
- if (!success){
- qWarning() << "Could not create user setting directory.";
- throw;
- }
- }
-
- cachedUserSessionsDir = cachedUserBaseDir;
- if (!cachedUserSessionsDir.cd("sessions")){
- bool success = cachedUserSessionsDir.mkdir("sessions") && cachedUserSessionsDir.cd("sessions");
- if (!success){
- qWarning() << "Could not create user sessions directory.";
- throw;
- }
- }
-
- cachedUserCacheDir = cachedUserBaseDir;
- if (!cachedUserCacheDir.cd("cache")){
- bool success = cachedUserCacheDir.mkdir("cache") && cachedUserCacheDir.cd("cache");
- if (!success){
- qWarning() << "Could not create user cache directory.";
- throw;
- }
- }
-
- cachedUserIndexDir = cachedUserBaseDir;
- if (!cachedUserIndexDir.cd("indices")){
- bool success = cachedUserIndexDir.mkdir("indices") && cachedUserIndexDir.cd("indices");
- if (!success){
- qWarning() << "Could not create user indices directory.";
- }
- }
-
- cachedUserDisplayTemplatesDir = cachedUserBaseDir;
- if (!cachedUserDisplayTemplatesDir.cd("display-templates")){
- bool success = cachedUserDisplayTemplatesDir.mkdir("display-templates") && cachedUserDisplayTemplatesDir.cd("display-templates");
- if (!success){
- qWarning() << "Could not create user display templates directory.";
- }
- }
-
- dirCacheInitialized = true;
+void DirectoryUtil::initDirectoryCache(void) {
+ QDir wDir( QCoreApplication::applicationDirPath() );
+ wDir.makeAbsolute();
+
+ if (!wDir.cdUp()) { //installation prefix
+ qWarning() << "Cannot cd up from directory " << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedIconDir = wDir; //icon dir
+ if (!cachedIconDir.cd("share/bibletime/icons") || !cachedIconDir.isReadable()) {
+ qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedJavascriptDir = wDir;
+ if (!cachedJavascriptDir.cd("share/bibletime/javascript") || !cachedJavascriptDir.isReadable()) {
+ qWarning() << "Cannot find javascript directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedLicenseDir = wDir;
+ if (!cachedLicenseDir.cd("share/bibletime/license") || !cachedLicenseDir.isReadable()) {
+ qWarning() << "Cannot find license directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedPicsDir = wDir; //icon dir
+ if (!cachedPicsDir.cd("share/bibletime/pics") || !cachedPicsDir.isReadable()) {
+ qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedLocaleDir = wDir;
+ if (!cachedLocaleDir.cd("share/bibletime/locale")) {
+ qWarning() << "Cannot find locale directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ QString localeName = QLocale::system().name();
+ QString langCode = localeName.section('_', 0, 0);
+
+ cachedHandbookDir = wDir;
+ if (!cachedHandbookDir.cd(QString("share/bibletime/docs/handbook/") + localeName)) {
+ if (!cachedHandbookDir.cd(QString("share/bibletime/docs/handbook/") + langCode)) {
+ if (!cachedHandbookDir.cd("share/bibletime/docs/handbook/en/")) {
+ qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+ }
+ }
+
+ cachedHowtoDir = wDir;
+ if (!cachedHowtoDir.cd(QString("share/bibletime/docs/howto/") + localeName)) {
+ if (!cachedHowtoDir.cd(QString("share/bibletime/docs/howto/") + langCode)) {
+ if (!cachedHowtoDir.cd("share/bibletime/docs/howto/en/")) {
+ qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+ }
+ }
+
+ cachedDisplayTemplatesDir = wDir; //display templates dir
+ if (!cachedDisplayTemplatesDir.cd("share/bibletime/display-templates/")) {
+ qWarning() << "Cannot find display template directory relative to" << QCoreApplication::applicationDirPath();
+ throw;
+ }
+
+ cachedUserHomeDir = QDir::home();
+
+ cachedUserBaseDir = QDir::home();
+ if (!cachedUserBaseDir.cd(".bibletime")) {
+ bool success = cachedUserBaseDir.mkdir(".bibletime") && cachedUserBaseDir.cd(".bibletime");
+ if (!success) {
+ qWarning() << "Could not create user setting directory.";
+ throw;
+ }
+ }
+
+ cachedUserSessionsDir = cachedUserBaseDir;
+ if (!cachedUserSessionsDir.cd("sessions")) {
+ bool success = cachedUserSessionsDir.mkdir("sessions") && cachedUserSessionsDir.cd("sessions");
+ if (!success) {
+ qWarning() << "Could not create user sessions directory.";
+ throw;
+ }
+ }
+
+ cachedUserCacheDir = cachedUserBaseDir;
+ if (!cachedUserCacheDir.cd("cache")) {
+ bool success = cachedUserCacheDir.mkdir("cache") && cachedUserCacheDir.cd("cache");
+ if (!success) {
+ qWarning() << "Could not create user cache directory.";
+ throw;
+ }
+ }
+
+ cachedUserIndexDir = cachedUserBaseDir;
+ if (!cachedUserIndexDir.cd("indices")) {
+ bool success = cachedUserIndexDir.mkdir("indices") && cachedUserIndexDir.cd("indices");
+ if (!success) {
+ qWarning() << "Could not create user indices directory.";
+ }
+ }
+
+ cachedUserDisplayTemplatesDir = cachedUserBaseDir;
+ if (!cachedUserDisplayTemplatesDir.cd("display-templates")) {
+ bool success = cachedUserDisplayTemplatesDir.mkdir("display-templates") && cachedUserDisplayTemplatesDir.cd("display-templates");
+ if (!success) {
+ qWarning() << "Could not create user display templates directory.";
+ }
+ }
+
+ dirCacheInitialized = true;
}
-QDir DirectoryUtil::getIconDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedIconDir;
+QDir DirectoryUtil::getIconDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedIconDir;
}
-QDir DirectoryUtil::getJavascriptDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedJavascriptDir;
+QDir DirectoryUtil::getJavascriptDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedJavascriptDir;
}
-QDir DirectoryUtil::getLicenseDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedLicenseDir;
+QDir DirectoryUtil::getLicenseDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedLicenseDir;
}
-QIcon DirectoryUtil::getIcon(const QString& name)
-{
- static QMap<QString, QIcon> iconCache;
- //error if trying to use name directly...
- QString name2(name);
- QString plainName = name2.remove(".svg", Qt::CaseInsensitive);
- if (iconCache.contains(plainName)) {
- return iconCache.value(plainName);
- }
-
- QString iconDir = getIconDir().canonicalPath();
- QString iconFileName = iconDir + "/" + plainName + ".svg";
- if (QFile(iconFileName).exists())
- {
- QIcon ic = QIcon(iconFileName);
- iconCache.insert(plainName, ic);
- return ic;
- }
- else {
- iconFileName = iconDir + "/" + plainName + ".png";
- if (QFile(iconFileName).exists()) {
- QIcon ic = QIcon(iconFileName);
- iconCache.insert(plainName, ic);
- return ic;
- } else {
- qWarning() << "Cannot find icon file" << iconFileName << ", using default icon.";
- iconFileName = iconDir + "/" + "/default.svg";
- if (QFile(iconFileName).exists()) {
- return QIcon(iconDir + "/default.svg");
- } else {
- return QIcon(iconDir + "default.png");
- }
- }
- }
+QIcon DirectoryUtil::getIcon(const QString& name) {
+ static QMap<QString, QIcon> iconCache;
+ //error if trying to use name directly...
+ QString name2(name);
+ QString plainName = name2.remove(".svg", Qt::CaseInsensitive);
+ if (iconCache.contains(plainName)) {
+ return iconCache.value(plainName);
+ }
+
+ QString iconDir = getIconDir().canonicalPath();
+ QString iconFileName = iconDir + "/" + plainName + ".svg";
+ if (QFile(iconFileName).exists()) {
+ QIcon ic = QIcon(iconFileName);
+ iconCache.insert(plainName, ic);
+ return ic;
+ }
+ else {
+ iconFileName = iconDir + "/" + plainName + ".png";
+ if (QFile(iconFileName).exists()) {
+ QIcon ic = QIcon(iconFileName);
+ iconCache.insert(plainName, ic);
+ return ic;
+ }
+ else {
+ qWarning() << "Cannot find icon file" << iconFileName << ", using default icon.";
+ iconFileName = iconDir + "/" + "/default.svg";
+ if (QFile(iconFileName).exists()) {
+ return QIcon(iconDir + "/default.svg");
+ }
+ else {
+ return QIcon(iconDir + "default.png");
+ }
+ }
+ }
}
-QDir DirectoryUtil::getPicsDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedPicsDir;
+QDir DirectoryUtil::getPicsDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedPicsDir;
}
-QDir DirectoryUtil::getLocaleDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedLocaleDir;
+QDir DirectoryUtil::getLocaleDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedLocaleDir;
}
-QDir DirectoryUtil::getHandbookDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedHandbookDir;
+QDir DirectoryUtil::getHandbookDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedHandbookDir;
}
-QDir DirectoryUtil::getHowtoDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedHowtoDir;
+QDir DirectoryUtil::getHowtoDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedHowtoDir;
}
-QDir DirectoryUtil::getDisplayTemplatesDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedDisplayTemplatesDir;
+QDir DirectoryUtil::getDisplayTemplatesDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedDisplayTemplatesDir;
}
-QDir DirectoryUtil::getUserBaseDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserBaseDir;
+QDir DirectoryUtil::getUserBaseDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserBaseDir;
}
-QDir DirectoryUtil::getUserHomeDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserHomeDir;
+QDir DirectoryUtil::getUserHomeDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserHomeDir;
}
-QDir DirectoryUtil::getUserSessionsDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserSessionsDir;
+QDir DirectoryUtil::getUserSessionsDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserSessionsDir;
}
-QDir DirectoryUtil::getUserCacheDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserCacheDir;
+QDir DirectoryUtil::getUserCacheDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserCacheDir;
}
-QDir DirectoryUtil::getUserIndexDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserIndexDir;
+QDir DirectoryUtil::getUserIndexDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserIndexDir;
}
-QDir DirectoryUtil::getUserDisplayTemplatesDir(void)
-{
- if (!dirCacheInitialized) initDirectoryCache();
- return cachedUserDisplayTemplatesDir;
+QDir DirectoryUtil::getUserDisplayTemplatesDir(void) {
+ if (!dirCacheInitialized) initDirectoryCache();
+ return cachedUserDisplayTemplatesDir;
}
diff --git a/src/util/directoryutil.h b/src/util/directoryutil.h
index be13c79..2ed5be9 100644
--- a/src/util/directoryutil.h
+++ b/src/util/directoryutil.h
@@ -23,88 +23,88 @@ namespace filesystem {
* @author The BibleTime team <info@bibletime.info>
*/
class DirectoryUtil {
-private:
- DirectoryUtil() {};
- ~DirectoryUtil() {};
-
-public:
- /** Removes the given dir with all it's files and subdirs.
- *
- * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object
- * for each of it at the same time in the deepest recursion.
- * For really deep dir tree this may lead to a stack overflow.
- */
- static void removeRecursive(const QString dir);
-
- /** Returns the size of the directory including the size of all its files
- * and its subdirs.
- *
- * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object
- * for each of it at the same time in the deepest recursion.
- * For really deep dir tree this may lead to a stack overflow.
- *
- * @return The size of the dir in bytes
- */
- static unsigned long getDirSizeRecursive(const QString dir);
-
- /** Recursively copies one directory into another. This WILL OVERWRITE
- * any existing files of the same name, and WILL NOT handle symlinks.
- *
- * This probably won't need to be used for large directory structures.
- */
- static void copyRecursive(const QString src, const QString dest);
-
- /** Return the path to the icons. */
- static QDir getIconDir(void);
-
- /** Return the path to the javascript. */
- static QDir getJavascriptDir(void);
-
- /** Return the path to the license. */
- static QDir getLicenseDir(void);
-
- /** Returns an icon with the given name */
- static QIcon getIcon(const QString& name);
-
- /** Return the path to the pictures. */
- static QDir getPicsDir(void);
-
- /** Return the path to the translation files. */
- static QDir getLocaleDir(void);
-
- /** Return the path to the handbook files, either of the current locale or en as fallback. */
- static QDir getHandbookDir(void);
-
- /** Return the path to the bible study howto files, either of the current locale or en as fallback. */
- static QDir getHowtoDir(void);
-
- /** Return the path to the default display template files. */
- static QDir getDisplayTemplatesDir(void);
-
- /** Return the path to the user's home directory.*/
- static QDir getUserHomeDir(void);
-
- /** Return the path to the user's settings directory.*/
- static QDir getUserBaseDir(void);
-
- /** Return the path to the user's sessions directory.*/
- static QDir getUserSessionsDir(void);
-
- /** Return the path to the user's cache directory.*/
- static QDir getUserCacheDir(void);
-
- /** Return the path to the user's indices directory.*/
- static QDir getUserIndexDir(void);
-
- /** Return the path to the user's custom display templates directory.*/
- static QDir getUserDisplayTemplatesDir(void);
-
-private:
- /** Will cache a few directories like icon directory */
- static void initDirectoryCache(void);
+ private:
+ DirectoryUtil() {};
+ ~DirectoryUtil() {};
+
+ public:
+ /** Removes the given dir with all it's files and subdirs.
+ *
+ * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object
+ * for each of it at the same time in the deepest recursion.
+ * For really deep dir tree this may lead to a stack overflow.
+ */
+ static void removeRecursive(const QString dir);
+
+ /** Returns the size of the directory including the size of all its files
+ * and its subdirs.
+ *
+ * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object
+ * for each of it at the same time in the deepest recursion.
+ * For really deep dir tree this may lead to a stack overflow.
+ *
+ * @return The size of the dir in bytes
+ */
+ static unsigned long getDirSizeRecursive(const QString dir);
+
+ /** Recursively copies one directory into another. This WILL OVERWRITE
+ * any existing files of the same name, and WILL NOT handle symlinks.
+ *
+ * This probably won't need to be used for large directory structures.
+ */
+ static void copyRecursive(const QString src, const QString dest);
+
+ /** Return the path to the icons. */
+ static QDir getIconDir(void);
+
+ /** Return the path to the javascript. */
+ static QDir getJavascriptDir(void);
+
+ /** Return the path to the license. */
+ static QDir getLicenseDir(void);
+
+ /** Returns an icon with the given name */
+ static QIcon getIcon(const QString& name);
+
+ /** Return the path to the pictures. */
+ static QDir getPicsDir(void);
+
+ /** Return the path to the translation files. */
+ static QDir getLocaleDir(void);
+
+ /** Return the path to the handbook files, either of the current locale or en as fallback. */
+ static QDir getHandbookDir(void);
+
+ /** Return the path to the bible study howto files, either of the current locale or en as fallback. */
+ static QDir getHowtoDir(void);
+
+ /** Return the path to the default display template files. */
+ static QDir getDisplayTemplatesDir(void);
+
+ /** Return the path to the user's home directory.*/
+ static QDir getUserHomeDir(void);
+
+ /** Return the path to the user's settings directory.*/
+ static QDir getUserBaseDir(void);
+
+ /** Return the path to the user's sessions directory.*/
+ static QDir getUserSessionsDir(void);
+
+ /** Return the path to the user's cache directory.*/
+ static QDir getUserCacheDir(void);
+
+ /** Return the path to the user's indices directory.*/
+ static QDir getUserIndexDir(void);
+
+ /** Return the path to the user's custom display templates directory.*/
+ static QDir getUserDisplayTemplatesDir(void);
+
+ private:
+ /** Will cache a few directories like icon directory */
+ static void initDirectoryCache(void);
};
-
+
} //namespace filesystem
} //namespace directoryutil
diff --git a/src/util/migrationutil.cpp b/src/util/migrationutil.cpp
index 072b750..af4efca 100644
--- a/src/util/migrationutil.cpp
+++ b/src/util/migrationutil.cpp
@@ -19,73 +19,71 @@
using namespace util::filesystem;
-namespace util{
+namespace util {
-void MigrationUtil::checkMigration(){
- if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION)
- {
- sword::SWVersion lastVersion(CBTConfig::get(CBTConfig::bibletimeVersion).toUtf8());
- //lastVersion will be 0.0, if it was an old KDE install,
- //because the config could not be found yet
- if (lastVersion < sword::SWVersion("1.7.0") )
- {
- tryMigrationFromKDE3(); //
- }
- }
+void MigrationUtil::checkMigration() {
+ if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION) {
+ sword::SWVersion lastVersion(CBTConfig::get(CBTConfig::bibletimeVersion).toUtf8());
+ //lastVersion will be 0.0, if it was an old KDE install,
+ //because the config could not be found yet
+ if (lastVersion < sword::SWVersion("1.7.0") ) {
+ tryMigrationFromKDE3(); //
+ }
+ }
}
//Migration code for KDE 4 port, moves from old config dir to ~/.bibletime/
-void MigrationUtil::tryMigrationFromKDE3(){
- //List of potential old KDE directories to load data from.
- QStringList searchDirs;
- searchDirs << "/.kde" << "/.kde3" << "/.kde3.5";
- searchDirs << "/.kde3.4" << "/.kde3.3" << "/.kde3.2";
- searchDirs << "/.kde3.1" << "/.kde3.0";
-
- foreach (QString searchDir, searchDirs){
- QString currSearch = QDir::homePath() + searchDir;
- QDir searchHome(currSearch);
- QFile oldRc(currSearch + "/share/config/bibletimerc");
- //Copy our old bibletimerc into the new KDE4 directory.
- QString newRcLoc = DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc";
- QFile newRc(newRcLoc);
-
- //Migrate only if the old config exists and the new doesn't
- if (oldRc.exists() && !newRc.exists()){
- QMessageBox msg (QMessageBox::Question, QObject::tr("Settings Migration"),
- QObject::tr("It appears you have a BibleTime configuration from KDE 3 stored in %1, and you have not migrated it to this version. Would you like to import it?").arg(currSearch), QMessageBox::Yes | QMessageBox::No);
- int result = msg.exec();
- if (result != QMessageBox::Yes){
- break;
- }
- oldRc.copy(newRcLoc);
- QFile oldBookmarks(currSearch + "/share/apps/bibletime/bookmarks.xml");
- if (oldBookmarks.exists()){
- QString newBookmarksLoc = DirectoryUtil::getUserBaseDir().absolutePath() + "/" + "bookmarks.xml";
- QFile newBookmarks(newBookmarksLoc);
- newBookmarks.remove();
- oldBookmarks.copy(newBookmarksLoc);
- }
- QDir sessionDir(currSearch + "/share/apps/bibletime/sessions");
- if (sessionDir.exists()){
- DirectoryUtil::copyRecursive(
- sessionDir.absolutePath(),
- DirectoryUtil::getUserSessionsDir().absolutePath());
- }
- else{
- QDir oldSessionDir(currSearch + "/share/apps/bibletime/profiles");
- if (oldSessionDir.exists()){
- DirectoryUtil::copyRecursive(
- oldSessionDir.absolutePath(),
- DirectoryUtil::getUserSessionsDir().absolutePath());
- }
- }
- //We found at least a config file, so we are done
- //searching for migration data.
- break;
- }
- }
- CBTConfig::syncConfig();
+void MigrationUtil::tryMigrationFromKDE3() {
+ //List of potential old KDE directories to load data from.
+ QStringList searchDirs;
+ searchDirs << "/.kde" << "/.kde3" << "/.kde3.5";
+ searchDirs << "/.kde3.4" << "/.kde3.3" << "/.kde3.2";
+ searchDirs << "/.kde3.1" << "/.kde3.0";
+
+ foreach (QString searchDir, searchDirs) {
+ QString currSearch = QDir::homePath() + searchDir;
+ QDir searchHome(currSearch);
+ QFile oldRc(currSearch + "/share/config/bibletimerc");
+ //Copy our old bibletimerc into the new KDE4 directory.
+ QString newRcLoc = DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc";
+ QFile newRc(newRcLoc);
+
+ //Migrate only if the old config exists and the new doesn't
+ if (oldRc.exists() && !newRc.exists()) {
+ QMessageBox msg (QMessageBox::Question, QObject::tr("Settings Migration"),
+ QObject::tr("It appears you have a BibleTime configuration from KDE 3 stored in %1, and you have not migrated it to this version. Would you like to import it?").arg(currSearch), QMessageBox::Yes | QMessageBox::No);
+ int result = msg.exec();
+ if (result != QMessageBox::Yes) {
+ break;
+ }
+ oldRc.copy(newRcLoc);
+ QFile oldBookmarks(currSearch + "/share/apps/bibletime/bookmarks.xml");
+ if (oldBookmarks.exists()) {
+ QString newBookmarksLoc = DirectoryUtil::getUserBaseDir().absolutePath() + "/" + "bookmarks.xml";
+ QFile newBookmarks(newBookmarksLoc);
+ newBookmarks.remove();
+ oldBookmarks.copy(newBookmarksLoc);
+ }
+ QDir sessionDir(currSearch + "/share/apps/bibletime/sessions");
+ if (sessionDir.exists()) {
+ DirectoryUtil::copyRecursive(
+ sessionDir.absolutePath(),
+ DirectoryUtil::getUserSessionsDir().absolutePath());
+ }
+ else {
+ QDir oldSessionDir(currSearch + "/share/apps/bibletime/profiles");
+ if (oldSessionDir.exists()) {
+ DirectoryUtil::copyRecursive(
+ oldSessionDir.absolutePath(),
+ DirectoryUtil::getUserSessionsDir().absolutePath());
+ }
+ }
+ //We found at least a config file, so we are done
+ //searching for migration data.
+ break;
+ }
+ }
+ CBTConfig::syncConfig();
}
}
diff --git a/src/util/migrationutil.h b/src/util/migrationutil.h
index 66571ff..38c0715 100644
--- a/src/util/migrationutil.h
+++ b/src/util/migrationutil.h
@@ -10,29 +10,29 @@
#ifndef UTIL_MIGRATIONUTIL_H
#define UTIL_MIGRATIONUTIL_H
-namespace util{
+namespace util {
/**
* Tools for handling settings migration automatically.
* @author The BibleTime team <info@bibletime.info>
*/
-class MigrationUtil{
-public:
- /**
- * Performs any and all applicable migration actions, if neccessary
- */
- static void checkMigration();
-private:
- MigrationUtil() {}; //hide
- ~MigrationUtil() {}; //hide
- /*
- * Performs a migration from a KDE 3 version of BibleTime. It supports all
- * KDE 3 versions of BibleTime, including versions older than 1.3. Its
- * only alteration is to move files to the new location, and to rename the
- * sessions directory from pre-1.3 versions if necessary. It does not
- * change any settings.
- */
- static void tryMigrationFromKDE3();
+class MigrationUtil {
+ public:
+ /**
+ * Performs any and all applicable migration actions, if neccessary
+ */
+ static void checkMigration();
+ private:
+ MigrationUtil() {}; //hide
+ ~MigrationUtil() {}; //hide
+ /*
+ * Performs a migration from a KDE 3 version of BibleTime. It supports all
+ * KDE 3 versions of BibleTime, including versions older than 1.3. Its
+ * only alteration is to move files to the new location, and to rename the
+ * sessions directory from pre-1.3 versions if necessary. It does not
+ * change any settings.
+ */
+ static void tryMigrationFromKDE3();
};
} //namespace util