summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.cpp14
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.cpp16
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.cpp2
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.h4
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.cpp13
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.h4
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.cpp17
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.h4
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp76
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h62
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp16
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp56
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h7
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp19
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp17
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp6
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp42
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h8
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp18
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp250
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h88
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp185
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h99
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h6
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp23
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h2
-rw-r--r--src/frontend/btaboutdialog.cpp16
-rw-r--r--src/frontend/btaboutdialog.h5
-rw-r--r--src/frontend/btaboutmoduledialog.cpp6
-rw-r--r--src/frontend/btaboutmoduledialog.h4
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp22
-rw-r--r--src/frontend/btbookshelfdockwidget.h2
-rw-r--r--src/frontend/btbookshelfgroupingmenu.cpp7
-rw-r--r--src/frontend/btbookshelfgroupingmenu.h2
-rw-r--r--src/frontend/btbookshelfview.cpp13
-rw-r--r--src/frontend/btbookshelfview.h3
-rw-r--r--src/frontend/btbookshelfwidget.cpp11
-rw-r--r--src/frontend/btbookshelfwidget.h3
-rw-r--r--src/frontend/btcentralwidget.cpp51
-rw-r--r--src/frontend/btcentralwidget.h33
-rw-r--r--src/frontend/btmenuview.cpp2
-rw-r--r--src/frontend/btmenuview.h2
-rw-r--r--src/frontend/btmodulechooserdialog.cpp10
-rw-r--r--src/frontend/btmodulechooserdialog.h4
-rw-r--r--src/frontend/btmoduleindexdialog.cpp2
-rw-r--r--src/frontend/btmoduleindexdialog.h4
-rw-r--r--src/frontend/btopenworkaction.cpp11
-rw-r--r--src/frontend/btopenworkaction.h3
-rw-r--r--src/frontend/cdragdrop.h4
-rw-r--r--src/frontend/cexportmanager.cpp39
-rw-r--r--src/frontend/cexportmanager.h10
-rw-r--r--src/frontend/cinfodisplay.cpp304
-rw-r--r--src/frontend/cinfodisplay.h102
-rw-r--r--src/frontend/cmdiarea.cpp86
-rw-r--r--src/frontend/cmdiarea.h23
-rw-r--r--src/frontend/cprinter.cpp3
-rw-r--r--src/frontend/cprinter.h4
-rw-r--r--src/frontend/crossrefrendering.cpp2
-rw-r--r--src/frontend/crossrefrendering.h9
-rw-r--r--src/frontend/display/btcolorwidget.cpp2
-rw-r--r--src/frontend/display/btcolorwidget.h4
-rw-r--r--src/frontend/display/btfindwidget.cpp118
-rw-r--r--src/frontend/display/btfindwidget.h56
-rw-r--r--src/frontend/display/btfontsizewidget.cpp2
-rw-r--r--src/frontend/display/btfontsizewidget.h4
-rw-r--r--src/frontend/display/bthtml.js156
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp95
-rw-r--r--src/frontend/display/bthtmlfindtext.h36
-rw-r--r--src/frontend/display/bthtmlfindtext.ui145
-rw-r--r--src/frontend/display/bthtmljsobject.cpp42
-rw-r--r--src/frontend/display/bthtmljsobject.h4
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp10
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h17
-rw-r--r--src/frontend/display/cdisplay.cpp16
-rw-r--r--src/frontend/display/cdisplay.h17
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp183
-rw-r--r--src/frontend/display/chtmlwritedisplay.h52
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp9
-rw-r--r--src/frontend/display/cplainwritedisplay.h31
-rw-r--r--src/frontend/display/creaddisplay.cpp2
-rw-r--r--src/frontend/display/creaddisplay.h6
-rw-r--r--src/frontend/display/cwritedisplay.cpp21
-rw-r--r--src/frontend/display/cwritedisplay.h47
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp67
-rw-r--r--src/frontend/displaywindow/btactioncollection.h35
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp9
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h4
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp2
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h4
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp14
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h4
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp2
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h4
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp23
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h4
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp2
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h4
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h4
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp91
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h44
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp36
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h46
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp38
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h18
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp122
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h19
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp11
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h14
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp70
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h36
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp13
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h6
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp159
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h56
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp56
-rw-r--r--src/frontend/displaywindow/creadwindow.h28
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp158
-rw-r--r--src/frontend/displaywindow/cwritewindow.h92
-rw-r--r--src/frontend/keychooser/bthistory.cpp5
-rw-r--r--src/frontend/keychooser/bthistory.h6
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp163
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h142
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp20
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h6
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp56
-rw-r--r--src/frontend/keychooser/ckeychooser.h161
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp214
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h274
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp25
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h6
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp6
-rw-r--r--src/frontend/keychooser/cscrollbutton.h5
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp79
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h96
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp18
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp2
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp8
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp15
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h10
-rw-r--r--src/frontend/messagedialog.cpp91
-rw-r--r--src/frontend/messagedialog.h49
-rw-r--r--src/frontend/profile/cprofile.cpp380
-rw-r--r--src/frontend/profile/cprofile.h113
-rw-r--r--src/frontend/profile/cprofilemgr.cpp118
-rw-r--r--src/frontend/profile/cprofilemgr.h67
-rw-r--r--src/frontend/profile/cprofilewindow.cpp30
-rw-r--r--src/frontend/profile/cprofilewindow.h45
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp6
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp57
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h18
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp136
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h4
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp6
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h3
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h6
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp332
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h14
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp11
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h5
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h4
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp81
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h4
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp26
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp32
-rw-r--r--src/frontend/searchdialog/csearchdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp22
-rw-r--r--src/frontend/searchdialog/csearchresultview.h4
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.cpp2
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.h4
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.cpp30
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.h8
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.cpp19
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.h4
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp6
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h4
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h4
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.cpp203
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.h55
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.cpp87
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.h54
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp58
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h4
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp19
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h4
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp19
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h4
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp6
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h6
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp306
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h97
-rw-r--r--src/frontend/tips/bttipdialog.cpp32
-rw-r--r--src/frontend/tips/bttipdialog.h4
221 files changed, 3464 insertions, 5001 deletions
diff --git a/src/frontend/bookmarks/btbookmarkfolder.cpp b/src/frontend/bookmarks/btbookmarkfolder.cpp
index af027a9..3088e99 100644
--- a/src/frontend/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/bookmarks/btbookmarkfolder.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,11 +10,12 @@
#include "frontend/bookmarks/btbookmarkfolder.h"
#include <QFileDialog>
+#include "bibletimeapp.h"
#include "frontend/bookmarks/btbookmarkitembase.h"
#include "frontend/bookmarks/btbookmarkitem.h"
#include "frontend/bookmarks/btbookmarkloader.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtBookmarkFolder::BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent)
@@ -77,12 +78,9 @@ void BtBookmarkFolder::rename() {
}
void BtBookmarkFolder::update() {
- namespace DU = util::directory;
-
- if (isExpanded() && childCount())
- setIcon(0, DU::getIcon(CResMgr::mainIndex::openedFolder::icon));
- else
- setIcon(0, DU::getIcon(CResMgr::mainIndex::closedFolder::icon));
+ setIcon(0, util::getIcon(isExpanded() && childCount()
+ ? CResMgr::mainIndex::openedFolder::icon
+ : CResMgr::mainIndex::closedFolder::icon));
}
bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
diff --git a/src/frontend/bookmarks/btbookmarkfolder.h b/src/frontend/bookmarks/btbookmarkfolder.h
index 20388df..4f7c80c 100644
--- a/src/frontend/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/bookmarks/btbookmarkfolder.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/btbookmarkitem.cpp b/src/frontend/bookmarks/btbookmarkitem.cpp
index 639d33e..952be22 100644
--- a/src/frontend/bookmarks/btbookmarkitem.cpp
+++ b/src/frontend/bookmarks/btbookmarkitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,14 +10,16 @@
#include "frontend/bookmarks/btbookmarkitem.h"
#include <QSharedPointer>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "btglobal.h"
#include "frontend/bookmarks/btbookmarkfolder.h"
#include "frontend/bookmarks/bteditbookmarkdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtBookmarkItem::BtBookmarkItem(const CSwordModuleInfo *module,
@@ -81,7 +83,7 @@ QString BtBookmarkItem::toolTip() const {
return QString::null;
}
- FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
+ FilterOptions filterOptions = btConfig().getFilterOptions();
filterOptions.footnotes = false;
filterOptions.scriptureReferences = false;
CSwordBackend::instance()->setFilterOptions(filterOptions);
@@ -91,7 +93,7 @@ QString BtBookmarkItem::toolTip() const {
k->setKey(key());
// const CLanguageMgr::Language* lang = module()->language();
- // CBTConfig::FontSettingsPair fontPair = CBTConfig::get(lang);
+ // BtConfig::FontSettingsPair fontPair = getBtConfig().getFontForLanguage(lang);
Q_ASSERT(k.data());
QString header = QString::fromLatin1("%1 (%2)")
@@ -134,9 +136,7 @@ void BtBookmarkItem::rename() {
}
void BtBookmarkItem::update() {
- namespace DU = util::directory;
-
- setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+ setIcon(0, util::getIcon(CResMgr::mainIndex::bookmark::icon));
if (m_title.isEmpty()) {
m_title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
diff --git a/src/frontend/bookmarks/btbookmarkitem.h b/src/frontend/bookmarks/btbookmarkitem.h
index 89fd412..932d4e0 100644
--- a/src/frontend/bookmarks/btbookmarkitem.h
+++ b/src/frontend/bookmarks/btbookmarkitem.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/btbookmarkitembase.h b/src/frontend/bookmarks/btbookmarkitembase.h
index 2ae1430..630d018 100644
--- a/src/frontend/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/bookmarks/btbookmarkitembase.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/btbookmarkloader.cpp b/src/frontend/bookmarks/btbookmarkloader.cpp
index daebfe1..63e0797 100644
--- a/src/frontend/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/bookmarks/btbookmarkloader.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/btbookmarkloader.h b/src/frontend/bookmarks/btbookmarkloader.h
index 8b819ce..25b56b8 100644
--- a/src/frontend/bookmarks/btbookmarkloader.h
+++ b/src/frontend/bookmarks/btbookmarkloader.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.cpp b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
index 614498f..1291f56 100644
--- a/src/frontend/bookmarks/bteditbookmarkdialog.cpp
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,9 +16,10 @@
#include <QLineEdit>
#include <QTextEdit>
#include <QWidget>
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
-#include "util/directory.h"
+#include "frontend/messagedialog.h"
+#include "util/geticon.h"
BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
@@ -28,12 +29,10 @@ BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- namespace DU = util::directory;
-
QVBoxLayout *mainLayout = new QVBoxLayout(this);
resize(400, 300);
- setWindowIcon(DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+ setWindowIcon(util::getIcon(CResMgr::mainIndex::bookmark::icon));
m_layout = new QFormLayout;
@@ -57,7 +56,7 @@ BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
| QDialogButtonBox::Ok,
Qt::Horizontal,
this);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
mainLayout->addWidget(m_buttonBox);
QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.h b/src/frontend/bookmarks/bteditbookmarkdialog.h
index c3455e2..674ccdf 100644
--- a/src/frontend/bookmarks/bteditbookmarkdialog.h
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/cbookmarkindex.cpp b/src/frontend/bookmarks/cbookmarkindex.cpp
index 15f272c..1b697d0 100644
--- a/src/frontend/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/bookmarks/cbookmarkindex.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,9 +28,10 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QToolTip>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/referencemanager.h"
+#include "bibletimeapp.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cprinter.h"
@@ -38,11 +39,12 @@
#include "frontend/bookmarks/btbookmarkitem.h"
#include "frontend/bookmarks/btbookmarkfolder.h"
#include "frontend/bookmarks/btbookmarkloader.h"
+#include "frontend/messagedialog.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
#include "bibletime.h"
@@ -52,7 +54,7 @@ CBookmarkIndex::CBookmarkIndex(QWidget *parent)
m_previousEventItem(0) {
setMouseTracking(true);
m_magTimer.setSingleShot(true);
- m_magTimer.setInterval(CBTConfig::get(CBTConfig::magDelay));
+ m_magTimer.setInterval(btConfig().value<int>("GUI/magDelay", 400));
setContextMenuPolicy(Qt::CustomContextMenu);
initView();
initConnections();
@@ -126,12 +128,11 @@ void CBookmarkIndex::initView() {
* than to modify all QAction constructors.
*/
QAction* CBookmarkIndex::newQAction(const QString& text, const QString& pix, const int /*shortcut*/, const QObject* receiver, const char* slot, QObject* parent) {
- namespace DU = util::directory;
QAction *action;
if (pix.isEmpty()) {
action = new QAction(text, parent);
} else {
- action = new QAction(DU::getIcon(pix), text, parent);
+ action = new QAction(util::getIcon(pix), text, parent);
}
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
return action;
@@ -681,7 +682,7 @@ void CBookmarkIndex::printBookmarks() {
return;
}
QSharedPointer<Printing::CPrinter> printer(
- new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
+ new Printing::CPrinter( this, btConfig().getDisplayOptions(), btConfig().getFilterOptions() )
);
printer->printKeyTree(tree);
}
@@ -699,7 +700,7 @@ void CBookmarkIndex::deleteEntries(bool confirm) {
}
}
- if (util::showQuestion(this, tr("Delete Items"),
+ if (message::showQuestion(this, tr("Delete Items"),
tr("Do you really want to delete the selected items and child-items?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No )
!= QMessageBox::Yes) {
diff --git a/src/frontend/bookmarks/cbookmarkindex.h b/src/frontend/bookmarks/cbookmarkindex.h
index 2875a5d..df4a1c6 100644
--- a/src/frontend/bookmarks/cbookmarkindex.h
+++ b/src/frontend/bookmarks/cbookmarkindex.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 3b82560..e5d0fd1 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index e90c3ed..2525bd8 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
deleted file mode 100644
index 652ff04..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "backend/btinstallbackend.h"
-#include <QList>
-#include <QObject>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-using namespace sword;
-
-BtInstallMgr::BtInstallMgr()
- : InstallMgr(BtInstallBackend::configPath().toLatin1(), this),
- m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true)
-{ //use this class also as status reporter
- this->setFTPPassive(true);
-}
-
-BtInstallMgr::~BtInstallMgr() {
- //doesn't really help because it only sets a flag
- terminate(); //make sure to close the connection
-}
-
-bool BtInstallMgr::isUserDisclaimerConfirmed() const {
- // \todo Check from config if it's been confirmed with "don't show this anymore" checked.
- // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
- return true;
-}
-
-void BtInstallMgr::statusUpdate(double dltotal, double dlnow) {
- if (dlnow > dltotal)
- dlnow = dltotal;
-
- int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0);
-
- if (totalPercent > 100) {
- totalPercent = 100;
- }
- else if (totalPercent < 0) {
- totalPercent = 0;
- }
-
- int filePercent = (int)((float)(dlnow) / (float)(dltotal + 1) * 100.0);
- if (filePercent > 100) {
- filePercent = 100;
- }
- else if (filePercent < 0) {
- filePercent = 0;
- }
- //qApp->processEvents();
- emit percentCompleted(totalPercent, filePercent);
-}
-
-
-void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* message) {
- if (m_firstCallOfPreStatus) {
- m_firstCallOfPreStatus = false;
- emit downloadStarted();
- }
- m_completedBytes = completedBytes;
- m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero
-}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
deleted file mode 100644
index 7d39440..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef NEWBTINSTALLMGR_H
-#define NEWBTINSTALLMGR_H
-
-#include <QObject>
-
-#include <QList>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-/**
-* Our own reimplementation to provide installation and status bar updates.
-*/
-class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
- Q_OBJECT
- public:
- BtInstallMgr();
- ~BtInstallMgr();
-
- /** Re-implemented from sword::InstallMgr. */
- bool isUserDisclaimerConfirmed() const;
-
- signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted(const int total, const int file);
- void downloadStarted();
-
- protected:
- /**
- Reimplementation of sword::StatusReporter::statusUpdate().
- */
- void statusUpdate(double dltotal, double dlnow);
-
- /**
- * Reimplementation of sword::StatusReporter::preStatus().
- * \warning This method is not always called before statusUpdate().
- * Called before starting to download each file of the module package.
- * The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
- * This function is not utilized in the UI ATM.
- */
- void preStatus(long totalBytes, long completedBytes, const char *message);
-
- private:
- long m_totalBytes;
- long m_completedBytes;
- bool m_firstCallOfPreStatus;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index 42febaa..8eebde6 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -2,20 +2,24 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
+namespace {
+const QString GeometryKey = "GUI/BookshelfManager/ModuleManagerDialog/geometry";
+} // anonymous namespace
+
static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget *parent,
@@ -59,13 +63,9 @@ BtModuleManagerDialog::~BtModuleManagerDialog() {
}
void BtModuleManagerDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
- move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void BtModuleManagerDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
- CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
- CBTConfig::set(CBTConfig::bookshelfPosX, x());
- CBTConfig::set(CBTConfig::bookshelfPosY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index 01ef594..4d94026 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index f40d8c3..646efab 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,10 +25,13 @@
#include <QProgressDialog>
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
-const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
+const QString PROTO_FTP( QObject::tr("Remote FTP") ); //Remote path
+const QString PROTO_SFTP( QObject::tr("Remote SFTP") );
+const QString PROTO_HTTP( QObject::tr("Remote HTTP") );
+const QString PROTO_HTTPS( QObject::tr("Remote HTTPS") );
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
: QDialog(),
@@ -39,7 +42,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->setMargin( 10 );
mainLayout->setSpacing( 5 );
- QHBoxLayout *captionLayout = new QHBoxLayout( this );
+ QHBoxLayout *captionLayout = new QHBoxLayout;
mainLayout->addLayout(captionLayout);
QLabel *label = new QLabel( tr("Caption"), this );
captionLayout->addWidget( label );
@@ -50,7 +53,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QGridLayout* layout = new QGridLayout( this );
+ QGridLayout* layout = new QGridLayout;
layout->setSpacing(3);
layout->setMargin(3);
mainLayout->addLayout(layout);
@@ -68,6 +71,9 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
m_protocolCombo = new QComboBox( this );
layout->addWidget(m_protocolCombo, 1, 0);
m_protocolCombo->addItem( PROTO_FTP );
+ m_protocolCombo->addItem( PROTO_SFTP );
+ m_protocolCombo->addItem( PROTO_HTTP );
+ m_protocolCombo->addItem( PROTO_HTTPS);
m_protocolCombo->addItem( PROTO_FILE );
m_serverEdit = new QLineEdit( this );
@@ -81,7 +87,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
buttonBox->addButton(getListButton, QDialogButtonBox::ActionRole);
@@ -95,7 +101,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
void CSwordSetupInstallSourcesDialog::slotOk() {
//run a few tests to validate the input first
if ( m_captionEdit->text().trimmed().isEmpty() ) { //no caption
- util::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
return;
}
@@ -103,25 +109,25 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
sword::InstallSource is = BtInstallBackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
- util::showInformation( this, tr( "Error" ),
+ message::showInformation( this, tr( "Error" ),
tr("A source with this caption already exists. Please provide a different caption."));
return;
}
- if ( m_protocolCombo->currentText() == PROTO_FTP &&
+ if ( this->isRemote(m_protocolCombo->currentText()) &&
m_serverEdit->text().trimmed().isEmpty() ) { //no server name
- util::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
return;
}
if ( m_protocolCombo->currentText() == PROTO_FILE) {
const QFileInfo fi( m_pathEdit->text() );
if (!fi.exists() || !fi.isReadable()) { //no valid and readable path
- util::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
return;
}
else if ( m_pathEdit->text().isEmpty() ) {
- util::showInformation( this, tr( "Error" ), tr("Please provide a path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a path."));
}
}
@@ -130,7 +136,7 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
}
void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
- if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
+ if (this->isRemote(m_protocolCombo->currentText())) { //REMOTE
m_serverLabel->setEnabled(true);
m_serverEdit->setEnabled(true);
}
@@ -152,7 +158,7 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
QString message(tr("List of sources will be downloaded from a remote server. Sources will be added to the current list. New source will replace an old one if it has the same label. You can later remove the sources you don't want to keep.\n\nDo you want to continue?"));
- QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::StandardButton answer = message::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -206,9 +212,20 @@ void CSwordSetupInstallSourcesDialog::slotRefreshCanceled() {
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
sword::InstallSource newSource(""); //empty, invalid Source
- if (m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = m_serverEdit->text().toUtf8();
+ if (this->isRemote(m_protocolCombo->currentText())) {
+ if (m_protocolCombo->currentText() == PROTO_FTP) {
+ newSource.type = "FTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_SFTP) {
+ newSource.type = "SFTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTP) {
+ newSource.type = "HTTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTPS) {
+ newSource.type = "HTTPS";
+ }
+ newSource.source = m_serverEdit->text().toUtf8();
//a message to the user would be nice, but we're in message freeze right now (1.5.1)
if (m_serverEdit->text().right(1) == "/") { //remove a trailing slash
newSource.source = m_serverEdit->text().mid(0, m_serverEdit->text().length() - 1).toUtf8();
@@ -225,4 +242,7 @@ sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
return newSource;
}
-
+bool CSwordSetupInstallSourcesDialog::isRemote(const QString& sourceType) {
+ return sourceType == PROTO_FTP || sourceType == PROTO_SFTP ||
+ sourceType == PROTO_HTTP || sourceType == PROTO_HTTPS;
+}
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index e69e9a9..20bf461 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
// Sword includes:
#include <installmgr.h>
@@ -41,6 +43,7 @@ class CSwordSetupInstallSourcesDialog : public QDialog {
void slotRefreshProgress(const int, const int current);
private:
+ bool isRemote(const QString&);
QLabel *m_serverLabel;
QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
QComboBox *m_protocolCombo;
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 960f5c8..b117f80 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,21 +16,20 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btmoduleindexdialog.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
{
- namespace DU = util::directory;
-
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout;
@@ -60,11 +59,11 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
//m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc...
m_moduleList->setSortingEnabled(false);
- m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );
+ m_autoDeleteOrphanedIndicesBox->setChecked( btConfig().value<bool>("settings/behaviour/autoDeleteOrphanedIndices", true) );
// icons for our buttons
- m_createButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
- m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
+ m_createButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
+ m_deleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()),
@@ -78,7 +77,7 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
}
BtIndexPage::~BtIndexPage() {
- CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
+ btConfig().setValue("settings/behaviour/autoDeleteOrphanedIndices", m_autoDeleteOrphanedIndicesBox->isChecked() );
}
/** Populates the module list with installed modules and orphaned indices */
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 303c6ab..100de17 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 01ca55b..a689c05 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 070df6f..49f1978 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
index 880ea6a..6f0fc9b 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -32,10 +32,6 @@ BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
Qt::DirectConnection);
}
-BtInstallModuleChooserDialogModel::~BtInstallModuleChooserDialogModel() {
- // Intentionally empty
-}
-
QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::BackgroundRole:
@@ -111,14 +107,11 @@ void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &top
m_dataChangedFired = false;
}
-bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo *m1) const {
- if (m1 != 0 && checkedModules().contains(m1)) {
- Q_FOREACH(CSwordModuleInfo *m2, m_modules.keys()) {
- if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name()) {
+bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo * m1) const {
+ if (m1 != 0 && checkedModules().contains(m1))
+ Q_FOREACH (CSwordModuleInfo * m2, modules())
+ if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name())
return true;
- }
- }
- }
return false;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
index 6120fa8..406b89c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ class BtInstallModuleChooserDialogModel: public BtBookshelfTreeModel {
Q_OBJECT
public:
BtInstallModuleChooserDialogModel(const Grouping &grouping, QObject *parent = 0);
- ~BtInstallModuleChooserDialogModel();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index 9c7955a..5f8bfb8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,12 +16,12 @@
#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
-#include <QSettings>
#include <QSharedPointer>
#include <QStackedLayout>
#include <QToolButton>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/btinstallbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
@@ -29,9 +29,10 @@
#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
#include "frontend/btbookshelfview.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -39,6 +40,7 @@ namespace {
const QString groupingOrderKey ("GUI/BookshelfManager/InstallPage/grouping");
const QString headerStateKey ("GUI/BookshelfManager/InstallPage/headerState");
const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule");
+const QString installPathKey ("GUI/BookshelfManager/InstallPage/installPathIndex");
} // anonymous namespace
@@ -47,13 +49,13 @@ const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule
// *********************************************************
BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
, m_groupingOrder(groupingOrderKey)
, m_modulesSelected(0)
, m_modulesSelectedSources(0)
{
// Read settings:
- m_headerState = CBTConfig::getConfig()->value(headerStateKey).toByteArray();
+ m_headerState = btConfig().value<QByteArray>(headerStateKey, QByteArray());
// Initialize widgets:
initView();
@@ -71,8 +73,6 @@ QString BtInstallPage::selectedInstallPath() {
}
void BtInstallPage::initView() {
- namespace DU = util::directory;
-
// Warning label:
m_warningLabel = new QLabel(this);
@@ -85,10 +85,10 @@ void BtInstallPage::initView() {
initSourcesCombo();
m_sourceAddButton = new QPushButton(this);
- m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+ m_sourceAddButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
m_sourceDeleteButton = new QPushButton(this);
- m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+ m_sourceDeleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
sourceChooserLayout->setContentsMargins(0, 8, 0, 0);
@@ -119,10 +119,10 @@ void BtInstallPage::initView() {
initPathCombo();
m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
+ m_configurePathButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
m_installButton = new QPushButton(this);
- m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
+ m_installButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
QHBoxLayout *pathLayout = new QHBoxLayout();
@@ -175,7 +175,7 @@ void BtInstallPage::initPathCombo() {
}
// choose the current value from config but check whether we have so many items
- int configValue = CBTConfig::get(CBTConfig::installPathIndex);
+ int configValue = btConfig().value<int>(installPathKey, 0);
int index = configValue > (m_pathCombo->count() - 1) ? m_pathCombo->count() - 1 : configValue;
m_pathCombo->setCurrentIndex(index);
}
@@ -202,7 +202,7 @@ void BtInstallPage::initSourcesCombo() {
}
// Read selected module from config:
- QString selected = CBTConfig::getConfig()->value(selectedModuleKey).toString();
+ const QString selected = btConfig().value<QString>(selectedModuleKey, QString());
// Populate combo box
bool selectionOk = false;
@@ -219,7 +219,7 @@ void BtInstallPage::initSourcesCombo() {
// Set selection, if it wasn't properly configured:
if (!selectionOk) {
m_sourceComboBox->setCurrentIndex(0);
- CBTConfig::getConfig()->setValue(selectedModuleKey, sourceList.at(0));
+ btConfig().setValue(selectedModuleKey, sourceList.at(0));
}
}
@@ -268,7 +268,7 @@ void BtInstallPage::retranslateUi() {
m_sourceGroupBox->setTitle(tr("Select installation &source:"));
m_sourceAddButton->setText(tr("&Add..."));
- m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton->setToolTip(tr("Add new source"));
m_sourceDeleteButton->setText(tr("&Delete..."));
m_sourceDeleteButton->setToolTip(tr("Delete this source"));
@@ -293,7 +293,7 @@ void BtInstallPage::slotHeaderChanged() {
Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()) != 0);
IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
m_headerState = w->treeView()->header()->saveState();
- CBTConfig::getConfig()->setValue(headerStateKey, m_headerState);
+ btConfig().setValue(headerStateKey, m_headerState);
}
void BtInstallPage::slotInstall() {
@@ -310,7 +310,7 @@ void BtInstallPage::slotInstall() {
canWrite = false;
}
if (!canWrite) {
- const int result = util::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
+ const int result = message::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
if (result != QMessageBox::Ignore) {
return;
}
@@ -327,22 +327,17 @@ void BtInstallPage::slotInstall() {
}
if (dlg->exec() == QDialog::Accepted) {
- QSet<const CSwordModuleInfo*> cm;
- Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
- cm.insert(m);
- }
-
- if (cm.empty())
+ QList<CSwordModuleInfo *> modules(dlg->checkedModules().toList());
+ if (modules.empty())
return;
/// \todo first remove all modules which will be updated from the module list
// but what modules? all with the same real name? (there may be _n modules...)
// progressDialog is WA_DeleteOnClose
- BtInstallProgressDialog *progressDialog = new BtInstallProgressDialog(cm, selectedInstallPath(), this);
-
+ typedef BtInstallProgressDialog BIPD;
+ BIPD * const progressDialog = new BIPD(modules, selectedInstallPath(), this);
m_installButton->setEnabled(false);
-
// the progress dialog is now modal, it can be made modeless later.
progressDialog->exec();
@@ -351,7 +346,7 @@ void BtInstallPage::slotInstall() {
}
void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
- CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
+ btConfig().setValue(installPathKey, m_pathCombo->currentIndex());
}
void BtInstallPage::slotEditPaths() {
@@ -390,26 +385,35 @@ void BtInstallPage::slotSourceAdd() {
void BtInstallPage::slotSourceDelete() {
typedef BtInstallPageWorksWidget IPWW;
- int ret = util::showWarning(this, tr("Delete Source?"),
+ int ret = message::showWarning(this, tr("Delete Source?"),
tr("Do you really want to delete this source?"),
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ window()->setEnabled(false);
Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()));
IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ m_sourceMap.remove(QString(w->installSource().caption));
w->deleteSource();
initSourcesCombo();
slotSourceIndexChanged(m_sourceComboBox->currentIndex());
delete w;
+ window()->setEnabled(true);
+ qApp->restoreOverrideCursor();
}
}
void BtInstallPage::slotSourceIndexChanged(int index) {
- if (index < 0) index = 0;
+ if (index < 0) {
+ if(!m_sourceComboBox->count())
+ return;
+ index = 0;
+ }
/// \todo use pointers instead of text
QString moduleName = m_sourceComboBox->itemText(index);
- CBTConfig::getConfig()->setValue(selectedModuleKey, moduleName);
+ btConfig().setValue(selectedModuleKey, moduleName);
activateSource(BtInstallBackend::source(moduleName));
}
@@ -431,9 +435,10 @@ void BtInstallPage::slotSelectedModulesChanged() {
void BtInstallPage::slotSwordSetupChanged() {
QString moduleName = m_sourceComboBox->currentText();
- initSourcesCombo();
+ // clean m_sourceMap before initSourcesCombo() make too much work
qDeleteAll(m_sourceMap.values());
m_sourceMap.clear();
+ initSourcesCombo();
m_sourceComboBox->setCurrentIndex(m_sourceComboBox->findText(moduleName));
initPathCombo();
m_modulesSelected = 0;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index 0cb6724..fe791cf 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
index 9aa6743..06e97f8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -27,10 +27,6 @@ BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent
setCheckable(true);
}
-BtInstallPageModel::~BtInstallPageModel() {
- // Intentionally empty
-}
-
QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::DisplayRole:
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
index 8a02409..009aa15 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ class BtInstallPageModel: public BtBookshelfTreeModel {
Q_OBJECT
public:
BtInstallPageModel(const Grouping &grouping, QObject *parent = 0);
- ~BtInstallPageModel();
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
index 0bb8829..629a69c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,12 +16,13 @@
#include <QToolButton>
#include "backend/btinstallbackend.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
#include "frontend/btbookshelfview.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
namespace {
@@ -55,7 +56,6 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
, m_backend(0)
, m_myModel(0)
{
- namespace DU = util::directory;
setTreeModel(new BtInstallPageModel(g, this));
@@ -65,15 +65,20 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
m_sourceRefreshButton = new QToolButton(this);
m_sourceRefreshButton->setAutoRaise(true);
- m_sourceRefreshButton ->setToolTip(tr("Refresh the list of works from this source"));
- m_sourceRefreshButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
+ m_sourceRefreshButton->setToolTip(tr("Refresh the list of works from this source"));
+ m_sourceRefreshButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
setRightCornerWidget(m_sourceRefreshButton);
connect(m_sourceRefreshButton, SIGNAL(clicked()),
this, SLOT(slotSourceRefresh()));
- // Delayed init, part 1 - disable parent:
- parent->setEnabled(false);
+ m_backend = BtInstallBackend::backend(m_source);
+ Q_ASSERT(m_backend != 0);
+ m_myModel = new BtBookshelfModel(this);
+ Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
+ if (filter(module)) m_myModel->addModule(module);
+ }
+ setSourceModel(m_myModel);
}
BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
@@ -83,7 +88,6 @@ BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
void BtInstallPageWorksWidget::deleteSource() {
qDebug() << "Deleting source" << m_source.caption;
- setEnabled(false);
m_myModel->clear();
BtInstallBackend::deleteSource(QString(m_source.caption));
}
@@ -103,28 +107,6 @@ void BtInstallPageWorksWidget::updateTree() {
}
}
-void BtInstallPageWorksWidget::paintEvent(QPaintEvent *e) {
- // Delayed init, part 2 - queue init when painted:
- if (m_myModel == 0) {
- QTimer::singleShot(0, this, SLOT(slotDelayedInit()));
- }
- BtBookshelfWidget::paintEvent(e);
-}
-
-void BtInstallPageWorksWidget::slotDelayedInit() {
- // Delayed init, part 3 - initialize + reenable parent
- qApp->setOverrideCursor(Qt::WaitCursor);
- m_backend = BtInstallBackend::backend(m_source);
- Q_ASSERT(m_backend != 0);
- m_myModel = new BtBookshelfModel(this);
- Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
- if (filter(module)) m_myModel->addModule(module);
- }
- setSourceModel(m_myModel);
- m_parent->setEnabled(true);
- qApp->restoreOverrideCursor();
-}
-
void BtInstallPageWorksWidget::slotSourceRefresh() {
qDebug() << "Refreshing source" << m_source.caption;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
index 1a9bd8f..d02e99e 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -39,12 +41,8 @@ class BtInstallPageWorksWidget: public BtBookshelfWidget {
void updateTree();
- /** Reimplemented from QWidget. */
- virtual void paintEvent(QPaintEvent *e);
-
private slots:
- void slotDelayedInit();
void slotSourceRefresh();
private: /* Fields: */
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index b4deb51..109bbd9 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,9 +21,11 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "bibletimeapp.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -77,19 +79,19 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_addButton = new QPushButton(tr("&Add..."), this);
m_addButton->setToolTip(tr("Add new folder"));
- m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
+ m_addButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
buttonLayout->addWidget(m_addButton);
m_editButton = new QPushButton(tr("&Edit..."), this);
m_editButton->setToolTip(tr("Edit the selected folder"));
- m_editButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
+ m_editButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
buttonLayout->addWidget(m_editButton);
m_removeButton = new QPushButton(tr("&Remove"), this);
m_removeButton->setToolTip(tr("Remove the selected folder"));
- m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
buttonLayout->addWidget(m_removeButton);
@@ -102,7 +104,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
mainLayout->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
@@ -177,7 +179,7 @@ void BtInstallPathDialog::slotEditClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you want to use this folder instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you want to use this folder instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (result != QMessageBox::Yes) return;
}
//i->setText(0, dir.absolutePath()); // absolute, not canonical
@@ -197,7 +199,7 @@ void BtInstallPathDialog::slotAddClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index 9adf6bc..de4c69a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index cc862fa..53fd274 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,21 +21,24 @@
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
+#include "backend/btinstallthread.h"
-BtInstallProgressDialog::BtInstallProgressDialog(
- const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent, Qt::WindowFlags flags)
+BtInstallProgressDialog::BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
+ const QString & destination,
+ QWidget * parent,
+ Qt::WindowFlags flags)
: QDialog(parent, flags)
+ , m_nextInstallIndex(0)
{
// we want this dialog to be deleted when user closes it or the downloads are completed
setAttribute(Qt::WA_DeleteOnClose, true);
+
setWindowTitle(tr("Install Progress"));
- //create the dialog which shows the status and lets the user stop installation
+
m_statusWidget = new QTreeWidget();
m_statusWidget->setRootIsDecorated(false);
- m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress") << QString::null);
+ m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress"));
m_statusWidget->header()->setStretchLastSection(false);
#if QT_VERSION < 0x050000
m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
@@ -44,190 +47,117 @@ BtInstallProgressDialog::BtInstallProgressDialog(
m_statusWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
m_statusWidget->header()->setSectionsMovable(false);
#endif
- //m_statusWidget->setColumnWidth(1, util::tool::mWidth(m_statusWidget, 2));
-
- Q_FOREACH(const CSwordModuleInfo *module, modules) {
- const QString sourceName(module->property("installSourceName").toString());
- // create a thread for this module
- BtInstallThread* thread = new BtInstallThread(module->name(), sourceName, destination);
- m_waitingThreads.insert(sourceName, thread);
- m_threadsByModule.insert(module->name(), thread);
- // progress widget/item
- QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
- stopButton->setFixedSize(stopButton->sizeHint());
-
- // the item
- QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
- m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
- progressItem->setSizeHint(2, stopButton->sizeHint());
+
+ Q_FOREACH(const CSwordModuleInfo * module, modules) {
+ QTreeWidgetItem * progressItem = new QTreeWidgetItem(m_statusWidget);
progressItem->setText(0, module->name());
- progressItem->setFlags(Qt::ItemIsEnabled);
- m_statusWidget->setItemWidget(progressItem, 2, stopButton);
+ progressItem->setIcon(0, module->moduleIcon());
progressItem->setText(1, tr("Waiting for turn..."));
-
- //connect the signals between the dialog, items and threads
- QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
- //is this needed or is statusUpdated enough?
- QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
-
- QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
+ progressItem->setFlags(Qt::ItemIsEnabled);
}
m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
- QPushButton* stopAllButton = new QPushButton(tr("Stop All"), this);
+ m_stopAllButton = new QPushButton(tr("Stop All"), this);
- QVBoxLayout* layout = new QVBoxLayout(this);
+ QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(m_statusWidget);
- layout->addWidget(stopAllButton);
-
- connect(stopAllButton, SIGNAL(clicked()), SLOT(slotStopInstall()) );
-
- qApp->processEvents();
-
- startThreads();
-
+ layout->addWidget(m_stopAllButton);
+
+ connect(m_stopAllButton, SIGNAL(clicked()),
+ this, SLOT(slotStopInstall()));
+
+ m_thread = new BtInstallThread(modules, destination, this);
+ // Connect the signals between the dialog, items and threads
+ connect(m_thread, SIGNAL(preparingInstall(int)),
+ this, SLOT(slotInstallStarted(int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(downloadStarted(int)),
+ this, SLOT(slotDownloadStarted(int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(statusUpdated(int, int)),
+ this, SLOT(slotStatusUpdated(int, int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(installCompleted(int, bool)),
+ this, SLOT(slotOneItemCompleted(int, bool)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(finished()),
+ this, SLOT(slotThreadFinished()),
+ Qt::QueuedConnection);
+ #if QT_VERSION < 0x050000
+ connect(m_thread, SIGNAL(terminated()),
+ this, SLOT(slotThreadFinished()),
+ Qt::QueuedConnection);
+ #endif
+ m_thread->start();
}
-void BtInstallProgressDialog::startThreads() {
- // remove all the updated modules from the backend module list at once
- //foreach (QString mName, m_threadsByModule.keys()) {
- //}
- //QList<CSwordModuleInfo*> CSwordBackend::instance()()->takeModulesFromList(m_threadsByModule.keys());
- //loop through the multimap of the waiting threads, start at most 3 threads for each source
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
-// concurrency is disabled for now
-// while (threadIterator != m_waitingThreads.end()) {
-// QString sourceName = threadIterator.key();
-// if (m_runningThreads.values(sourceName).count() < 3) {
-// BtInstallThread* t = threadIterator.value();
-// m_runningThreads.insert(sourceName, t);
-// threadIterator = m_waitingThreads.erase(threadIterator);
-// t->start();
-// }
-// else ++threadIterator;
-// }
- //non-concurrent
- if (threadIterator != m_waitingThreads.begin()) {
- // go to the last item which is actually the first in the visible list
- // because the iterator is reversed compared to insert order
- threadIterator--;
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
+BtInstallProgressDialog::~BtInstallProgressDialog() {
+ m_thread->wait();
+ delete m_thread;
}
-void BtInstallProgressDialog::slotOneItemCompleted(QString module, QString source, int status) {
- QString message;
- //status comes from the sword installer.
- /// \todo Additionally we should check that there are files really installed.
- if (status != 0) {
- message = tr("Failed");
- }
- else {
- message = tr("Completed");
+void BtInstallProgressDialog::slotStopInstall() {
+ m_stopAllButton->setDisabled(true);
+ m_thread->stopInstall();
+ for (int i = m_nextInstallIndex; i < m_statusWidget->topLevelItemCount(); i++) {
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(i);
+ item->setText(1, QString::null);
+ item->setDisabled(true);
}
- oneItemStoppedOrCompleted(module, source, message);
-}
-
-void BtInstallProgressDialog::slotOneItemStopped(QString module, QString source) {
- oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
}
-void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage) {
- qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
- // update the list item
- m_statusWidget->setItemWidget(getItem(module), 1, 0);
- getItem(module)->setText(1, statusMessage);
- m_statusWidget->itemWidget(getItem(module), 2)->setEnabled(false);
- getItem(module)->setDisabled(true);
-
- qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
- m_runningThreads.remove(source, m_threadsByModule.value(module));
- m_waitingThreads.remove(source, m_threadsByModule.value(module));
-
-//concurrency is disabled for now
-// //start a waiting thread if there are any
-// QList<BtInstallThread*> threadsForSource = m_waitingThreads.values(source);
-// if (!threadsForSource.isEmpty()) {
-// BtInstallThread* thread = threadsForSource.at(0);
-// m_waitingThreads.remove(source, thread);
-// m_runningThreads.insert(source, thread);
-// thread->start();
-// }
-
- //non-concurrent
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
- if (m_runningThreads.isEmpty() && threadIterator != m_waitingThreads.begin()) {
- threadIterator--; // the last item
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
-
- if (threadsDone()) {
- qDebug() << "close the dialog";
- close();
- }
+void BtInstallProgressDialog::slotInstallStarted(int moduleIndex) {
+ Q_ASSERT(moduleIndex == m_nextInstallIndex);
+ m_nextInstallIndex++;
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ item->setText(1, tr("Preparing install..."));
+ m_statusWidget->scrollToItem(item);
}
-void BtInstallProgressDialog::slotStopInstall() {
- qDebug() << "BtInstallProgressDialog::slotStopInstall";
-
- // Clear the waiting threads map, stop all running threads.
-
- m_waitingThreads.clear();
- if (m_runningThreads.count() > 0) {
- foreach(BtInstallThread* thread, m_runningThreads) {
- thread->slotStopInstall();
- }
- }
- else {
- close();
- }
+void BtInstallProgressDialog::slotDownloadStarted(int moduleIndex) {
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ item->setText(1, QString::null);
+ getOrCreateProgressBar(item)->setValue(0);
}
-void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) {
+void BtInstallProgressDialog::slotStatusUpdated(int moduleIndex, int status) {
// find the progress bar for this module and update the value
- QWidget* itemWidget = m_statusWidget->itemWidget(getItem(module) , 1);
- QProgressBar* bar = dynamic_cast<QProgressBar*>(itemWidget);
- if (bar) bar->setValue(status);
-}
-
-void BtInstallProgressDialog::slotInstallStarted(QString module, QString) {
- getItem(module)->setText(1, tr("Preparing install..."));
+ getOrCreateProgressBar(moduleIndex)->setValue(status);
}
-void BtInstallProgressDialog::slotDownloadStarted(QString module) {
- getItem(module)->setText(1, QString::null);
- //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true);
-
- QProgressBar* bar = new QProgressBar(m_statusWidget);
- bar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- bar->setValue(0);
- m_statusWidget->setItemWidget(getItem(module), 1, bar);
+void BtInstallProgressDialog::slotOneItemCompleted(int moduleIndex, bool successful) {
+QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ // update the list item
+ m_statusWidget->setItemWidget(item, 1, NULL);
+ item->setText(1, successful ? tr("Completed") : tr("Failed"));
+ item->setDisabled(true);
}
-QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) {
- return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0);
+void BtInstallProgressDialog::slotThreadFinished() {
+ close();
}
-void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
+void BtInstallProgressDialog::closeEvent(QCloseEvent * event) {
if (event->spontaneous()) {
event->ignore();
+ slotStopInstall();
return;
}
// other parts of the UI/engine must be updated
CSwordBackend::instance()->reloadModules(CSwordBackend::AddedModules);
}
-bool BtInstallProgressDialog::threadsDone() {
- return (m_waitingThreads.isEmpty() && m_runningThreads.isEmpty());
+QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(int moduleIndex) {
+ return getOrCreateProgressBar(m_statusWidget->topLevelItem(moduleIndex));
+}
+
+QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(QTreeWidgetItem * item) {
+ QWidget * const itemWidget = m_statusWidget->itemWidget(item, 1);
+ QProgressBar * progressBar = dynamic_cast<QProgressBar *>(itemWidget);
+ if (!progressBar) {
+ progressBar = new QProgressBar(m_statusWidget);
+ progressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_statusWidget->setItemWidget(item, 1, progressBar);
+ }
+ return progressBar;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
index a72b280..e6add1c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,56 +14,56 @@
#include <QDialog>
-#include <QMultiMap>
#include <QString>
class BtInstallThread;
class CSwordModuleInfo;
+class QProgressBar;
class QTreeWidget;
class QTreeWidgetItem;
-class BtInstallProgressDialog : public QDialog {
- Q_OBJECT
- public:
- BtInstallProgressDialog(const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent = 0,
- Qt::WindowFlags flags = 0);
-
- public slots:
- void slotOneItemCompleted(QString module, QString source, int status);
- void slotOneItemStopped(QString module, QString source);
- void slotStopInstall();
- void slotStatusUpdated(QString module, int status);
- void slotDownloadStarted(QString module);
- void slotInstallStarted(QString module, QString);
-
- protected:
- /**
- * Handles closing by the window close button, Cancel (Stop) All button, or completing
- * the downloads.
- */
- virtual void closeEvent(QCloseEvent* event);
-
-//signals:
-// void swordSetupChanged();
-
- private:
-
- /// \todo using maps is tedious and error prone. Find better solution for handling the modules
- // and their states.
- QMultiMap<QString, BtInstallThread*> m_waitingThreads;
- QMultiMap<QString, BtInstallThread*> m_runningThreads;
- QMap<QString, BtInstallThread*> m_threadsByModule;
- //QList<BtInstallThread*> m_doneThreads;
-
- QTreeWidget* m_statusWidget;
-
- private:
- QTreeWidgetItem* getItem(QString moduleName);
- bool threadsDone();
- void startThreads();
- void oneItemStoppedOrCompleted(QString module, QString source, QString message);
+class BtInstallProgressDialog: public QDialog {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
+ const QString & destination,
+ QWidget * parent = 0,
+ Qt::WindowFlags flags = 0);
+ ~BtInstallProgressDialog();
+
+public slots:
+
+ void slotStopInstall();
+ void slotInstallStarted(int moduleIndex);
+ void slotDownloadStarted(int moduleIndex);
+ void slotStatusUpdated(int moduleIndex, int status);
+ void slotOneItemCompleted(int moduleIndex, bool status);
+ void slotThreadFinished();
+
+protected: /* Methods: */
+
+ /**
+ Handles closing by the window close button, Cancel (Stop) All button, or
+ completing the downloads.
+ */
+ virtual void closeEvent(QCloseEvent * event);
+
+private: /* Methods: */
+
+ QProgressBar * getOrCreateProgressBar(int moduleIndex);
+ QProgressBar * getOrCreateProgressBar(QTreeWidgetItem * item);
+
+private: /* Fields: */
+
+ QTreeWidget * m_statusWidget;
+ QPushButton * m_stopAllButton;
+ BtInstallThread * m_thread;
+ int m_nextInstallIndex;
+
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
deleted file mode 100644
index 3b25f02..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QDir>
-#include <QString>
-#include <QThread>
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "backend/btinstallbackend.h"
-
-// Sword includes:
-#include <filemgr.h>
-
-
-BtInstallThread::BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent)
- : QThread(parent),
- done(false),
- m_module(moduleName),
- m_destination(destinationName),
- m_source(sourceName),
- m_cancelled(false) {
- m_iMgr = new BtInstallMgr();
-}
-
-
-BtInstallThread::~BtInstallThread() {
- delete m_iMgr;
-}
-
-void BtInstallThread::run() {
- qDebug() << "****************************************\nBtInstallThread::run, mod:" << m_module << "\n************************************";
-
-
- emit preparingInstall(m_module, m_source);
- //This is 0 before set here - remember when using the value when cancelling
- // the installation before this has been run
- m_installSource = QSharedPointer<sword::InstallSource>(new sword::InstallSource(BtInstallBackend::source(m_source)));
- m_backendForSource = QSharedPointer<CSwordBackend>(BtInstallBackend::backend(*m_installSource));
-
- //make sure target/mods.d and target/modules exist
- /// \todo move this to some common precondition
- QDir dir(m_destination);
- if (!dir.exists()) {
- dir.mkdir(m_destination);
- qDebug() << "made directory" << m_destination;
- }
- if (!dir.exists("modules")) {
- dir.mkdir("modules");
- qDebug() << "made directory" << m_destination << "/modules";
- }
- if (!dir.exists("mods.d")) {
- dir.mkdir("mods.d");
- qDebug() << "made directory" << m_destination << "/mods.d";
- }
-
- QObject::connect(m_iMgr, SIGNAL(percentCompleted(int, int)), this, SLOT(slotManagerStatusUpdated(int, int)), Qt::QueuedConnection);
- QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection);
-
- //check whether it's an update. If yes, remove existing module first
- /// \todo silently removing without undo if the user cancels the update is WRONG!!!
- removeModule();
-
- // manager for the destination path
- sword::SWMgr lMgr( m_destination.toLatin1() );
-
- if (BtInstallBackend::isRemote(*m_installSource)) {
- int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.data());
- if (status != 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else {
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
- else { //local source
- emit statusUpdated(m_module, 0);
- int status = m_iMgr->installModule(&lMgr, m_installSource->directory.c_str(), m_module.toLatin1());
- if (status > 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else if (status == -1) {
- // it was terminated, do nothing
- }
- else {
- emit statusUpdated(m_module, 100);
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
-}
-
-void BtInstallThread::slotStopInstall() {
- qDebug() << "*************************************\nBtInstallThread::slotStopInstall" << m_module << "\n********************************";
- if (!done) {
- done = true;
- qDebug() << "*********************************\nBtInstallThread::slotStopInstall, installing" << m_module << "was cancelled\n**************************************";
- m_iMgr->terminate();
- //this->terminate(); // It's dangerous to forcibly stop, but we will clean up the files
- //qApp->processEvents();
- // wait to terminate for some secs. We rather let the execution go on and cleaning up to fail than the app to freeze
- int notRun = this->wait(25000);
- if (notRun) {
- this->terminate();
- this->wait(10000);
- qDebug() << "installthread (" << m_module << ") terminated, delete m_iMgr";
- delete m_iMgr; // this makes sure the ftp library will be cleaned up in the destroyer
- m_iMgr = 0;
- }
- // cleanup: remove the module, remove the temp files
- // if installation has already started
- if (m_installSource.data() != 0) {
- // remove the installed module, just to be sure because mgr may
- // have been terminated when copying files
- removeModule();
- removeTempFiles();
- qDebug() << "BtInstallThread::slotStopInstall will emit installStopped...";
- }
- emit installStopped(m_module, m_source);
- }
-}
-
-void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
- emit statusUpdated(m_module, totalProgress);
-}
-
-void BtInstallThread::slotDownloadStarted() {
- emit downloadStarted(m_module);
-}
-
-void BtInstallThread::removeModule() {
- CSwordModuleInfo* m;
- m = CSwordBackend::instance()->findModuleByName(m_module);
- if (!m) {
- m = BtInstallBackend::backend(BtInstallBackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
- }
- if (m) { //module found?
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
- QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
- QString dataPath = m->config(CSwordModuleInfo::DataPath);
- if (dataPath.left(2) == "./") {
- dataPath = dataPath.mid(2);
- }
-
- if (prefixPath.contains(dataPath)) {
- prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
- }
- else {
- prefixPath = QString::fromLatin1(CSwordBackend::instance()->prefixPath);
- }
-
- sword::SWMgr mgr(prefixPath.toLatin1());
- BtInstallMgr iMgr;
- iMgr.removeModule(&mgr, m->name().toLatin1());
- }
- else {
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "not found";
- }
-}
-
-void BtInstallThread::removeTempFiles() {
- // (take the remote conf file for this module, take DataPath,
- // take the absolute path of the InstallMgr)
-
- //sword::InstallSource is = BtInstallBackend::source(m_source);
- if (BtInstallBackend::isRemote(*m_installSource)) {
- // get the path for the module temp files
- CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
- QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
- qDebug() << "Delete path:" << dataPath;
- // it's easier to use sword than qt
- sword::FileMgr::removeDir(dataPath.toLatin1().data());
- }
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
deleted file mode 100644
index 8bb660d..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINSTALLTHREAD_H
-#define BTINSTALLTHREAD_H
-
-#include <QThread>
-
-#include <QSharedPointer>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
-
-class BtInstallProgressDialog;
-class CSwordBackend;
-
-/**
-* Thread for installing a module.
-*
-* See the Qt thread documents. We have to be careful with signals and slots,
-* with other things.
-
-The main thread creates and owns the BtInstallThread object.
-When the install thread (the run() method) has been started
-the install thread object receives status update signals
-from the installmgr object. This works because these signals are sent
-from the running install thread but received in the thread object which
-lives in the main thread (note the difference between a thread object and a
-running thread). The slot of the thread object is executed in the main thread
-event loop, not in the install thread.
-
-The running thread sends update signals to the progress dialog.
-(This works because the signals are queued, i.e. the dialog is running
-in the main app event loop which queues the signals. ???)
-
-When the user cancels installing the main thread sends signal to a slot
-in the thread object. The slot is then run in the main thread, not
-in the install thread (note again the difference between a thread object and a
-running thread). That slot terminates the running install thread immediately.
-That is not the cleanest way to do it, but the Sword library has no good
-support for threads. Terminating a Sword InstallMgr takes time and leads to
-slow response. Therefore we stop installing by force and clean up the
-temporary files manually.
-
-* Terminating a thread forcibly is "dangerous and discouraged" but we have to do it,
-* I couldn't get cancelling work reliably otherwise. The Sword library is bad for threads.
-* We use ftp connection and file resources; the connection can be ignored but the files
-* have to be cleaned up after termination.
-*/
-class BtInstallThread : public QThread {
- Q_OBJECT
- public:
- BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent = 0);
-
- ~BtInstallThread();
-
- public slots:
- void slotStopInstall();
- void slotManagerStatusUpdated(int totalProgress, int fileProgress);
- void slotDownloadStarted();
-
- public: // data member
- bool done;
-
- protected:
- virtual void run();
- void removeModule();
- void removeTempFiles();
-
- QString m_module;
- QString m_destination;
- QString m_source;
- bool m_cancelled;
- BtInstallMgr* m_iMgr;
- //BtInstallMgr m_iMgr;
- QSharedPointer<sword::InstallSource> m_installSource;
- /// \todo it would be best to get the backend from the bookshelf manager install page
- // where it has already been created. Could fasten the progress dialog startup.
- QSharedPointer<CSwordBackend> m_backendForSource;
-
- signals:
- /** Emitted when the install progress status is updated. */
- void statusUpdated(QString module, int progressPercent);
- /** Emitted when installing has been stopped/cancelled. */
- void installStopped(QString module, QString source);
- /** Emitted when installing is complete. */
- void installCompleted(QString module, QString source, int errorStatus);
- /** Emitted when the first file download has been started. */
- void downloadStarted(QString module);
- void preparingInstall(QString module, QString source);
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
index 949c82e..856f58b 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
@@ -2,7 +2,7 @@
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source,
@@ -44,7 +44,7 @@ bool BtRefreshProgressDialog::runAndDelete() {
setValue(100);
qApp->processEvents();
} else {
- util::showWarning(this, tr("Warning"),
+ message::showWarning(this, tr("Warning"),
tr("Failed to refresh source %1")
.arg(QString(m_source.caption)));
}
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
index dfabcf6..03f82c9 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QProgressDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
class BtRefreshProgressDialog: public QProgressDialog {
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 8b9dd3c..57879ea 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -17,18 +17,19 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
-#include <QMessageBox>
#include <QPushButton>
#include <QToolButton>
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
// Sword includes:
#include <swmgr.h>
@@ -40,10 +41,8 @@ const QString groupingOrderKey("GUI/BookshelfManager/RemovePage/grouping");
}
BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
{
- namespace DU = util::directory;
-
m_worksGroupBox = new QGroupBox(this);
m_worksGroupBox->setFlat(true);
QVBoxLayout *wLayout = new QVBoxLayout;
@@ -77,7 +76,7 @@ BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
uLayout->addStretch(1);
m_removeButton = new QPushButton(this);
- m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
m_removeButton->setEnabled(false);
uLayout->addWidget(m_removeButton, 0, Qt::AlignRight);
@@ -131,13 +130,13 @@ void BtRemovePage::slotRemoveModules() {
/// \bug <nobr> is not working, Qt bug
const QString moduleString("<nobr><img src=\"%1\" width=\"%2\" height=\"%3\"/>&nbsp;%4</nobr>");
const QString iconDir = util::directory::getIconDir().canonicalPath() + '/';
- Q_FOREACH(const CSwordModuleInfo *m,
+ Q_FOREACH(const CSwordModuleInfo * m,
m_bookshelfWidget->treeModel()->checkedModules())
{
- const QIcon icon = CSwordModuleInfo::moduleIcon(m);
+ const QIcon icon = CSwordModuleInfo::moduleIcon(*m);
const QSize iconSize = icon.actualSize(QSize(textHeight, textHeight));
prettyModuleNames.append(moduleString
- .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m))
+ .arg(iconDir + CSwordModuleInfo::moduleIconFilename(*m))
.arg(iconSize.width())
.arg(iconSize.height())
.arg(m->name()));
@@ -149,7 +148,7 @@ void BtRemovePage::slotRemoveModules() {
.append("<br/><br/>")
.append(tr("Do you really want to remove them from your system?"));
- if ((util::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
+ if ((message::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
// Update the module list before really removing. Remember deleting the pointers later.
QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames);
@@ -180,7 +179,7 @@ void BtRemovePage::slotRemoveModules() {
mgr = mgrDict[ prefixPath ];
}
qDebug() << "Removing the module" << mInfo->name() << "...";
- installMgr.removeModule(mgr, mInfo->module()->Name());
+ installMgr.removeModule(mgr, mInfo->module()->getName());
}
//delete the removed moduleinfo pointers
qDeleteAll(toBeDeleted);
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 02ff88e..a9600d8 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
index a0955b2..9fce7ab 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
index 14e0a67..50da32b 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btaboutdialog.cpp b/src/frontend/btaboutdialog.cpp
index 1bfe708..fd0a3c9 100644
--- a/src/frontend/btaboutdialog.cpp
+++ b/src/frontend/btaboutdialog.cpp
@@ -2,13 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/btaboutdialog.h"
+#include "frontend/messagedialog.h"
#include <QApplication>
#include <QDesktopServices>
#include <QDialogButtonBox>
@@ -18,7 +19,6 @@
#include <QTextStream>
#include <QVBoxLayout>
#include <QWebView>
-#include "util/dialogutil.h"
#include "util/directory.h"
// Sword includes:
@@ -88,11 +88,8 @@ BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags)
retranslateUi();
}
-BtAboutDialog::~BtAboutDialog() {
- // Intentionally empty
-}
-
void BtAboutDialog::resizeEvent(QResizeEvent* event) {
+ Q_UNUSED(event);
QString version = "BibleTime " BT_VERSION;
QFontMetrics fm(m_versionLabel->font());
int w = width() - m_iconLabel->width() - 80;
@@ -117,7 +114,7 @@ void BtAboutDialog::retranslateUi() {
retranslateQtTab();
retranslateLicenceTab();
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
}
void BtAboutDialog::retranslateBtTab() {
@@ -130,7 +127,7 @@ void BtAboutDialog::retranslateBtTab() {
"our team, please send an email to %1.")
.arg(MAKE_LINK_STATIC("mailto:info@bibletime.info", "info@bibletime.info"));
content += "</p><p>";
- content += tr("(c)1999-2011, The BibleTime Team");
+ content += tr("(c)1999-2014, The BibleTime Team");
content += "</p><p>" MAKE_LINK_STATIC("http://www.bibletime.info", "www.bibletime.info")
"</p>";
m_bibletimeTab->setHtml(MAKE_HTML(m_bibletimeTab, content));
@@ -168,6 +165,7 @@ void BtAboutDialog::retranslateContributorsTab() {
MAKE_CONTR(content, "Eeli Kaikkonnen", developer)
MAKE_CONTR(content, "Chris Kujawa", developer)
MAKE_CONTR(content, "Mark Lybarger", developer)
+ MAKE_CONTR(content, "Konstantin Maslyuk", developer)
MAKE_CONTR(content, "Luke Mauldin", developer)
MAKE_CONTR(content, "James Ots", designer)
MAKE_CONTR(content, "Andrus Raag", artist)
@@ -177,6 +175,7 @@ void BtAboutDialog::retranslateContributorsTab() {
MAKE_CONTR2(content, "Wolfgang Stradner", tr("tester"), tr("usability expert"))
MAKE_CONTR(content, "Kang Sun", developer)
MAKE_CONTR(content, "Thorsten Uhlmann", developer)
+ MAKE_CONTR(content, "John Turpish", developer)
MAKE_CONTR(content, "David White", developer)
MAKE_CONTR(content, "Mark Zealey", developer)
MAKE_CONTR(content, "Patrick Sebastian Zimmermann", developer)
@@ -210,6 +209,7 @@ void BtAboutDialog::retranslateContributorsTab() {
"<li>Vlad Savitsky</li>"
"<li>Henrik Sonesson</li>"
"<li>Johan van der Lingen</li>"
+ "<li>Damian Wrzalski</li>"
"<li>Konstantin Maslyuk</li>"
"<li>Jean Van Schaftingen</li>"
"<li>Roland Teschner</li>"
diff --git a/src/frontend/btaboutdialog.h b/src/frontend/btaboutdialog.h
index 2ad6607..132074a 100644
--- a/src/frontend/btaboutdialog.h
+++ b/src/frontend/btaboutdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +24,6 @@ class BtAboutDialog: public QDialog {
Q_OBJECT
public:
BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtAboutDialog();
protected:
virtual void resizeEvent(QResizeEvent* event);
diff --git a/src/frontend/btaboutmoduledialog.cpp b/src/frontend/btaboutmoduledialog.cpp
index ab15fb9..b8603b5 100644
--- a/src/frontend/btaboutmoduledialog.cpp
+++ b/src/frontend/btaboutmoduledialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +14,7 @@
#include <QWidget>
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/btaboutmoduledialog.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
BTAboutModuleDialog::BTAboutModuleDialog(const CSwordModuleInfo *moduleInfo,
@@ -44,5 +44,5 @@ BTAboutModuleDialog::BTAboutModuleDialog(const CSwordModuleInfo *moduleInfo,
void BTAboutModuleDialog::retranslateUi() {
setWindowTitle(tr("Information About %1").arg(m_moduleInfo->name()));
m_textEdit->setHtml(m_moduleInfo->aboutText());
- util::prepareDialogBox(m_buttons);
+ message::prepareDialogBox(m_buttons);
}
diff --git a/src/frontend/btaboutmoduledialog.h b/src/frontend/btaboutmoduledialog.h
index fda51ea..05f78d1 100644
--- a/src/frontend/btaboutmoduledialog.h
+++ b/src/frontend/btaboutmoduledialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index 2d85930..46ee023 100644
--- a/src/frontend/btbookshelfdockwidget.cpp
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -16,16 +16,17 @@
#include <QActionGroup>
#include <QLabel>
#include <QMenu>
-#include <QMessageBox>
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
namespace {
@@ -102,7 +103,6 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
}
void BtBookshelfDockWidget::initMenus() {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
m_itemContextMenu = new QMenu(this);
@@ -115,30 +115,30 @@ void BtBookshelfDockWidget::initMenus() {
m_itemContextMenu->addAction(m_itemOpenAction);
m_itemSearchAction = new QAction(this);
- m_itemSearchAction->setIcon(DU::getIcon(RM::search::icon));
+ m_itemSearchAction->setIcon(util::getIcon(RM::search::icon));
m_itemActionGroup->addAction(m_itemSearchAction);
m_itemContextMenu->addAction(m_itemSearchAction);
m_itemEditMenu = new QMenu(this);
- m_itemEditMenu->setIcon(DU::getIcon(RM::editModuleMenu::icon));
+ m_itemEditMenu->setIcon(util::getIcon(RM::editModuleMenu::icon));
m_itemContextMenu->addMenu(m_itemEditMenu);
m_itemEditPlainAction = new QAction(this);
- m_itemEditPlainAction->setIcon(DU::getIcon(RM::editModulePlain::icon));
+ m_itemEditPlainAction->setIcon(util::getIcon(RM::editModulePlain::icon));
m_itemActionGroup->addAction(m_itemEditPlainAction);
m_itemEditMenu->addAction(m_itemEditPlainAction);
m_itemEditHtmlAction = new QAction(this);
- m_itemEditHtmlAction->setIcon(DU::getIcon(RM::editModuleHTML::icon));
+ m_itemEditHtmlAction->setIcon(util::getIcon(RM::editModuleHTML::icon));
m_itemActionGroup->addAction(m_itemEditHtmlAction);
m_itemEditMenu->addAction(m_itemEditHtmlAction);
m_itemUnlockAction = new QAction(this);
- m_itemUnlockAction->setIcon(DU::getIcon(RM::unlockModule::icon));
+ m_itemUnlockAction->setIcon(util::getIcon(RM::unlockModule::icon));
m_itemActionGroup->addAction(m_itemUnlockAction);
m_itemContextMenu->addAction(m_itemUnlockAction);
m_itemAboutAction = new QAction(this);
- m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
+ m_itemAboutAction->setIcon(util::getIcon(RM::aboutModule::icon));
m_itemActionGroup->addAction(m_itemAboutAction);
m_itemContextMenu->addAction(m_itemAboutAction);
@@ -170,7 +170,7 @@ void BtBookshelfDockWidget::slotModuleActivated(CSwordModuleInfo *module) {
warning message. Actually the whole case when the user tries to open a locked
module needs to be rethought and refactored.
*/
- QMessageBox::warning(this, tr("Warning: Module locked!"),
+ message::showWarning(this, tr("Warning: Module locked!"),
tr("You are trying to access an encrypted module. Please "
"provide an unlock key in the following dialog to open the "
"module."));
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index 87508f4..fe415d7 100644
--- a/src/frontend/btbookshelfdockwidget.h
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btbookshelfgroupingmenu.cpp b/src/frontend/btbookshelfgroupingmenu.cpp
index de2bcf6..c456f80 100644
--- a/src/frontend/btbookshelfgroupingmenu.cpp
+++ b/src/frontend/btbookshelfgroupingmenu.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -12,8 +12,10 @@
#include "frontend/btbookshelfgroupingmenu.h"
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
namespace {
@@ -48,12 +50,11 @@ inline const BtBookshelfTreeModel::Grouping &getActionRef(const QAction *a) {
void BtBookshelfGroupingMenu::initMenu(bool showNoGrouping) {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
if (!groupsInitialized) initializeGroups();
- setIcon(DU::getIcon(RM::grouping::icon));
+ setIcon(util::getIcon(RM::grouping::icon));
m_groupingActionGroup = new QActionGroup(this);
m_groupingActionGroup->setExclusive(true);
diff --git a/src/frontend/btbookshelfgroupingmenu.h b/src/frontend/btbookshelfgroupingmenu.h
index 83605a7..f49c3c0 100644
--- a/src/frontend/btbookshelfgroupingmenu.h
+++ b/src/frontend/btbookshelfgroupingmenu.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btbookshelfview.cpp b/src/frontend/btbookshelfview.cpp
index cb0dcd9..1a04eff 100644
--- a/src/frontend/btbookshelfview.cpp
+++ b/src/frontend/btbookshelfview.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -37,13 +37,10 @@ BtBookshelfView::BtBookshelfView(QWidget *parent)
this, SLOT(slotItemHovered(QModelIndex)));
}
-BtBookshelfView::~BtBookshelfView() {
- // Intentionally empty
-}
-
-CSwordModuleInfo *BtBookshelfView::getModule(const QModelIndex &index) const {
- return (CSwordModuleInfo *) model()
- ->data(index, BtBookshelfModel::ModulePointerRole).value<void*>();
+CSwordModuleInfo * BtBookshelfView::getModule(const QModelIndex & index) const {
+ void * const module = model()->data(index,
+ BtBookshelfModel::ModulePointerRole).value<void *>();
+ return static_cast<CSwordModuleInfo *>(module);
}
void BtBookshelfView::keyPressEvent(QKeyEvent *event) {
diff --git a/src/frontend/btbookshelfview.h b/src/frontend/btbookshelfview.h
index 940c084..f957785 100644
--- a/src/frontend/btbookshelfview.h
+++ b/src/frontend/btbookshelfview.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ class BtBookshelfView: public QTreeView {
Q_OBJECT
public:
BtBookshelfView(QWidget *parent = 0);
- virtual ~BtBookshelfView();
CSwordModuleInfo *getModule(const QModelIndex &index) const;
diff --git a/src/frontend/btbookshelfwidget.cpp b/src/frontend/btbookshelfwidget.cpp
index c4b0d54..2ce812e 100644
--- a/src/frontend/btbookshelfwidget.cpp
+++ b/src/frontend/btbookshelfwidget.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -24,6 +24,7 @@
#include <QToolButton>
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
#include "frontend/btbookshelfdockwidget.h"
@@ -31,6 +32,7 @@
#include "frontend/btbookshelfview.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
@@ -61,10 +63,6 @@ BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
this, SLOT(slotShowItemContextMenu(CSwordModuleInfo*, QPoint)));
}
-BtBookshelfWidget::~BtBookshelfWidget() {
- // Intentionally empty
-}
-
void BtBookshelfWidget::setSourceModel(QAbstractItemModel *model) {
Q_ASSERT(model != 0);
m_sourceModel = model;
@@ -96,11 +94,10 @@ void BtBookshelfWidget::setRightCornerWidget(QWidget *w) {
}
void BtBookshelfWidget::initActions() {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
m_showHideAction = new QAction(this);
- m_showHideAction->setIcon(DU::getIcon("layer-visible-on.svg"));
+ m_showHideAction->setIcon(util::getIcon("layer-visible-on.svg"));
m_showHideAction->setCheckable(true);
connect(m_showHideAction, SIGNAL(toggled(bool)),
m_postFilterModel, SLOT(setShowHidden(bool)));
diff --git a/src/frontend/btbookshelfwidget.h b/src/frontend/btbookshelfwidget.h
index 3f1e605..7811b5c 100644
--- a/src/frontend/btbookshelfwidget.h
+++ b/src/frontend/btbookshelfwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -35,7 +35,6 @@ class BtBookshelfWidget: public QWidget {
Q_OBJECT
public:
explicit BtBookshelfWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~BtBookshelfWidget();
void setSourceModel(QAbstractItemModel *model);
diff --git a/src/frontend/btcentralwidget.cpp b/src/frontend/btcentralwidget.cpp
new file mode 100644
index 0000000..04615c3
--- /dev/null
+++ b/src/frontend/btcentralwidget.cpp
@@ -0,0 +1,51 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/btcentralwidget.h"
+
+#include "frontend/cmdiarea.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include <QAction>
+#include <QKeyEvent>
+#include <QKeySequence>
+
+
+ BtCentralWidget::BtCentralWidget(CMDIArea* mdiArea, BtFindWidget* findWidget, QWidget* parent)
+ : QWidget(parent), m_mdiArea(mdiArea), m_findWidget(findWidget) {
+ }
+
+void BtCentralWidget::keyPressEvent(QKeyEvent *e) {
+
+// const QString text = e->text();
+// if (text.isEmpty()) {
+ QWidget::keyPressEvent(e);
+// return;
+// }
+// CDisplayWindow* activeDisplayWindow = m_mdiArea->getActiveDisplayWindow();
+// if (activeDisplayWindow != 0) {
+
+// BtActionCollection* actionCollection = activeDisplayWindow->actionCollection();
+// QAction* findAction = actionCollection->action("findText");
+// QKeySequence keySequence = findAction->shortcut();
+// QString key = keySequence.toString();
+// if (key == text)
+// return;
+// }
+
+// if (text.startsWith(QLatin1Char('/'))) {
+// if (!m_findWidget->isVisible()) {
+// m_findWidget->showAndClear();
+// } else {
+// m_findWidget->show();
+// }
+// } else {
+// QWidget::keyPressEvent(e);
+// }
+}
diff --git a/src/frontend/btcentralwidget.h b/src/frontend/btcentralwidget.h
new file mode 100644
index 0000000..3ef9002
--- /dev/null
+++ b/src/frontend/btcentralwidget.h
@@ -0,0 +1,33 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTCENTRALWIDGET_H
+#define BTCENTRALWIDGET_H
+
+#include <QWidget>
+class QKeyEvent;
+class CMDIArea;
+class BtFindWidget;
+
+class BtCentralWidget: public QWidget {
+
+public:
+ BtCentralWidget(CMDIArea* mdiArea, BtFindWidget* findWidget, QWidget* parent=0);
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+
+private:
+ CMDIArea* m_mdiArea;
+ BtFindWidget* m_findWidget;
+};
+
+#endif
diff --git a/src/frontend/btmenuview.cpp b/src/frontend/btmenuview.cpp
index 71998b7..919602b 100644
--- a/src/frontend/btmenuview.cpp
+++ b/src/frontend/btmenuview.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btmenuview.h b/src/frontend/btmenuview.h
index 98ec729..39b56f6 100644
--- a/src/frontend/btmenuview.h
+++ b/src/frontend/btmenuview.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btmodulechooserdialog.cpp b/src/frontend/btmodulechooserdialog.cpp
index e8f3dd0..e6ed79f 100644
--- a/src/frontend/btmodulechooserdialog.cpp
+++ b/src/frontend/btmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -19,7 +19,7 @@
#include "frontend/btaboutmoduledialog.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include "util/tool.h"
@@ -49,12 +49,8 @@ BtModuleChooserDialog::BtModuleChooserDialog(QWidget *parent, Qt::WindowFlags fl
retranslateUi();
}
-BtModuleChooserDialog::~BtModuleChooserDialog() {
- // Intentionally empty
-}
-
void BtModuleChooserDialog::retranslateUi() {
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
}
void BtModuleChooserDialog::slotModuleAbout(CSwordModuleInfo *module) {
diff --git a/src/frontend/btmodulechooserdialog.h b/src/frontend/btmodulechooserdialog.h
index 706088c..685ac48 100644
--- a/src/frontend/btmodulechooserdialog.h
+++ b/src/frontend/btmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -24,8 +24,6 @@ class QLabel;
class BtModuleChooserDialog : public QDialog {
Q_OBJECT
- public:
- virtual ~BtModuleChooserDialog();
protected:
explicit BtModuleChooserDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
diff --git a/src/frontend/btmoduleindexdialog.cpp b/src/frontend/btmoduleindexdialog.cpp
index 2dac498..2714ea7 100644
--- a/src/frontend/btmoduleindexdialog.cpp
+++ b/src/frontend/btmoduleindexdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btmoduleindexdialog.h b/src/frontend/btmoduleindexdialog.h
index 29a13c4..8b794f9 100644
--- a/src/frontend/btmoduleindexdialog.h
+++ b/src/frontend/btmoduleindexdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btopenworkaction.cpp b/src/frontend/btopenworkaction.cpp
index 50d0d5f..a398412 100644
--- a/src/frontend/btopenworkaction.cpp
+++ b/src/frontend/btopenworkaction.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -14,8 +14,9 @@
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/btbookshelfgroupingmenu.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey,
@@ -33,10 +34,6 @@ BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey,
this, SLOT(slotIndexTriggered(QModelIndex)));
}
-BtOpenWorkActionMenu::~BtOpenWorkActionMenu() {
- // Intentionally empty
-}
-
void BtOpenWorkActionMenu::setSourceModel(QAbstractItemModel *model) {
m_treeModel->setSourceModel(model);
}
@@ -81,7 +78,7 @@ BtOpenWorkAction::BtOpenWorkAction(const QString &groupingConfigKey,
m_menu->setSourceModel(CSwordBackend::instance()->model());
setMenu(m_menu);
- setIcon(util::directory::getIcon("folder-open.svg"));
+ setIcon(util::getIcon("folder-open.svg"));
retranslateUi();
slotModelChanged();
diff --git a/src/frontend/btopenworkaction.h b/src/frontend/btopenworkaction.h
index 6b28908..1ca8379 100644
--- a/src/frontend/btopenworkaction.h
+++ b/src/frontend/btopenworkaction.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -29,7 +29,6 @@ class BtOpenWorkActionMenu: public BtMenuView {
public:
BtOpenWorkActionMenu(const QString &groupingConfigKey,
QWidget *parent = 0);
- ~BtOpenWorkActionMenu();
void setSourceModel(QAbstractItemModel *model);
inline QAbstractItemModel *sourceModel() const { return m_treeModel->sourceModel(); }
diff --git a/src/frontend/cdragdrop.h b/src/frontend/cdragdrop.h
index 8fa270f..869d2fb 100644
--- a/src/frontend/cdragdrop.h
+++ b/src/frontend/cdragdrop.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/cexportmanager.cpp b/src/frontend/cexportmanager.cpp
index 640eae7..e7546ba 100644
--- a/src/frontend/cexportmanager.cpp
+++ b/src/frontend/cexportmanager.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -76,7 +76,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
if (vk && vk->isBoundSet()) {
- text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules );
+ text = render->renderKeyRange( QString::fromUtf8(vk->getLowerBound()), QString::fromUtf8(vk->getUpperBound()), modules );
}
else { //no range supported
text = render->renderSingleKey(key->key(), modules);
@@ -90,14 +90,12 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
return true;
}
-bool CExportManager::saveKeyList(const sword::ListKey &l,
+bool CExportManager::saveKeyList(const sword::ListKey & l,
const CSwordModuleInfo *module,
Format format,
bool addText)
{
- /// \warning This is a workaround for Sword constness
- sword::ListKey list = l;
- if (!list.Count())
+ if (!l.getCount())
return false;
const QString filename = getSaveFileName(format);
@@ -107,12 +105,13 @@ bool CExportManager::saveKeyList(const sword::ListKey &l,
CTextRendering::KeyTree tree; /// \todo Verify that items in tree are properly freed.
- setProgressRange(list.Count());
+ setProgressRange(l.getCount());
CTextRendering::KeyTreeItem::Settings itemSettings;
itemSettings.highlight = false;
+ sword::ListKey list(l);
list.setPosition(sword::TOP);
- while (!list.Error() && !progressWasCancelled()) {
+ while (!list.popError() && !progressWasCancelled()) {
tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
incProgress();
@@ -180,8 +179,8 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
CSwordVerseKey * vk = dynamic_cast<CSwordVerseKey*>(key);
if (vk && vk->isBoundSet()) {
text = render->renderKeyRange(
- QString::fromUtf8(vk->LowerBound()),
- QString::fromUtf8(vk->UpperBound()),
+ QString::fromUtf8(vk->getLowerBound()),
+ QString::fromUtf8(vk->getUpperBound()),
modules
);
}
@@ -201,7 +200,7 @@ bool CExportManager::copyKeyList(const sword::ListKey &l,
bool addText)
{
sword::ListKey list = l;
- if (!list.Count())
+ if (!list.getCount())
return false;
CTextRendering::KeyTree tree; /// \todo Verify that items in tree are properly freed.
@@ -209,7 +208,7 @@ bool CExportManager::copyKeyList(const sword::ListKey &l,
itemSettings.highlight = false;
list.setPosition(sword::TOP);
- while (!list.Error() && !progressWasCancelled()) {
+ while (!list.popError() && !progressWasCancelled()) {
tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
list.increment();
@@ -254,18 +253,16 @@ bool CExportManager::copyKeyList(const QList<CSwordKey*> &list,
return true;
}
-bool CExportManager::printKeyList(const sword::ListKey &l,
+bool CExportManager::printKeyList(const sword::ListKey & list,
const CSwordModuleInfo *module,
const DisplayOptions &displayOptions,
const FilterOptions &filterOptions)
{
- /// \warning This is a workaround for Sword constness
- sword::ListKey list = l;
CPrinter::KeyTreeItem::Settings settings;
CPrinter::KeyTree tree; /// \todo Verify that items in tree are properly freed.
- setProgressRange(list.Count());
- for (int i=0; i< list.Count(); i++) {
+ setProgressRange(list.getCount());
+ for (int i=0; i< list.getCount(); i++) {
const sword::SWKey* swKey = list.getElement(i);
const sword::VerseKey* vKey = dynamic_cast<const sword::VerseKey*>(swKey);
if (vKey != 0) {
@@ -370,13 +367,13 @@ bool CExportManager::printByHyperlink(const QString &hyperlink,
if (module) {
//check if we have a range of entries or a single one
if ((module->type() == CSwordModuleInfo::Bible) || (module->type() == CSwordModuleInfo::Commentary)) {
- sword::ListKey verses = sword::VerseKey().ParseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
+ sword::ListKey verses = sword::VerseKey().parseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
+ for (int i = 0; i < verses.getCount(); i++) {
sword::VerseKey* element = dynamic_cast<sword::VerseKey*>(verses.getElement(i));
if (element) {
- const QString startKey = QString::fromUtf8(element->LowerBound().getText());
- const QString stopKey = QString::fromUtf8(element->UpperBound().getText());
+ const QString startKey = QString::fromUtf8(element->getLowerBound().getText());
+ const QString stopKey = QString::fromUtf8(element->getUpperBound().getText());
tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
}
diff --git a/src/frontend/cexportmanager.h b/src/frontend/cexportmanager.h
index 0d882e0..a222ac8 100644
--- a/src/frontend/cexportmanager.h
+++ b/src/frontend/cexportmanager.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QList>
#include <QString>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "btglobal.h"
class CSwordKey;
@@ -37,8 +39,8 @@ class CExportManager {
CExportManager(const bool showProgress = true,
const QString &progressLabel = QString::null,
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults(),
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults());
+ const FilterOptions &filterOptions = btConfig().getFilterOptions(),
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions());
~CExportManager();
bool saveKey(CSwordKey* key, const Format format, const bool addText);
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index 8165b8b..202eb48 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,15 +20,16 @@
#include <QtAlgorithms>
#include <QMenu>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
#include "backend/managers/referencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
+#include "bibletime.h"
#include "frontend/crossrefrendering.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+#include "util/htmlescape.h"
// Sword includes:
#include <listkey.h>
@@ -39,33 +40,36 @@ using namespace sword;
namespace InfoDisplay {
-CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
- QVBoxLayout* layout = new QVBoxLayout(this);
+CInfoDisplay::CInfoDisplay(BibleTime * parent)
+ : QWidget(parent)
+ , m_mainWindow(parent)
+{
+ QVBoxLayout * const layout = new QVBoxLayout(this);
layout->setContentsMargins(2, 2, 2, 2); // Leave small border
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- m_htmlPart = CDisplay::createReadInstance(0, this);
- m_htmlPart->setMouseTracking(false); //we don't want strong/lemma/note mouse infos
+ m_htmlPart = new BtHtmlReadDisplay(0, this);
+ m_htmlPart->setMouseTracking(false); // We don't want strong/lemma/note mouse infos
m_htmlPart->view()->setAcceptDrops(false);
- QAction* selectAllAction = new QAction(QIcon(), tr("Select all"), this);
+ QAction * const selectAllAction = new QAction(QIcon(), tr("Select all"), this);
selectAllAction->setShortcut(QKeySequence::SelectAll);
- QObject::connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()) );
+ QObject::connect(selectAllAction, SIGNAL(triggered()),
+ this, SLOT(selectAll()));
- QAction* copyAction = new QAction(tr("Copy"), this);
- copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
- QObject::connect(copyAction, SIGNAL(triggered()), m_htmlPart->connectionsProxy(), SLOT(copySelection()) );
+ QAction * const copyAction = new QAction(tr("Copy"), this);
+ copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
+ QObject::connect(copyAction, SIGNAL(triggered()),
+ m_htmlPart->connectionsProxy(), SLOT(copySelection()));
- QMenu* menu = new QMenu(this);
+ QMenu * const menu = new QMenu(this);
menu->addAction(selectAllAction);
menu->addAction(copyAction);
m_htmlPart->installPopup(menu);
- connect(
- m_htmlPart->connectionsProxy(),
- SIGNAL(referenceClicked(const QString&, const QString&)),
- SLOT(lookupInfo(const QString&, const QString&))
- );
+ QObject::connect(m_htmlPart->connectionsProxy(),
+ SIGNAL(referenceClicked(const QString &, const QString &)),
+ SLOT(lookupInfo(const QString &, const QString &)));
layout->addWidget(m_htmlPart->view());
@@ -80,102 +84,101 @@ void CInfoDisplay::unsetInfo() {
"moving the mouse.</small>"));
}
-void CInfoDisplay::setInfo(const QString &data, const QString &lang) {
- CDisplayTemplateMgr *mgr = CDisplayTemplateMgr::instance();
+void CInfoDisplay::setInfo(const QString & renderedData, const QString & lang) {
+ CDisplayTemplateMgr * const mgr = CDisplayTemplateMgr::instance();
Q_ASSERT(mgr != 0);
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
QString div = "<div class=\"infodisplay\"";
- if (!lang.isEmpty()) {
- div.append(" lang=\"");
- div.append(lang);
- div.append("\"");
- }
+ if (!lang.isEmpty())
+ div.append(" lang=\"").append(lang).append("\"");
+
div.append(">");
QString content(mgr->fillTemplate(CDisplayTemplateMgr::activeTemplateName(),
- div + data + "</div>",
+ div + renderedData + "</div>",
settings));
m_htmlPart->setText(content);
}
-void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) {
+void CInfoDisplay::lookupInfo(const QString & mod_name,
+ const QString & key_text)
+{
qDebug() << "CInfoDisplay::lookup";
qDebug() << mod_name << key_text;
- CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName(mod_name);
+ CSwordModuleInfo * const m = CSwordBackend::instance()->findModuleByName(mod_name);
Q_ASSERT(m);
if (!m)
return;
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(m) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(m));
key->setKey(key_text);
setInfo(key->renderedText(), m->language()->abbrev());
}
-void CInfoDisplay::setInfo(const InfoType type, const QString& data) {
+void CInfoDisplay::setInfo(const InfoType type, const QString & data) {
ListInfoData list;
- list.append( qMakePair(type, data) );
-
+ list.append(qMakePair(type, data));
setInfo(list);
}
-void CInfoDisplay::setInfo(const ListInfoData& list) {
- //if the widget is hidden it would be inefficient to render and display the data
- if (!isVisible()) {
+void CInfoDisplay::setInfo(const ListInfoData & list) {
+ // If the widget is hidden it would be inefficient to render and display the data
+ if (!isVisible())
return;
- }
if (list.isEmpty()) {
m_htmlPart->setText("<html></html>");
return;
}
- QString text;
+ QString renderedText;
ListInfoData::const_iterator end = list.end();
for (ListInfoData::const_iterator it = list.begin(); it != end; ++it) {
- switch ( (*it).first ) {
+ switch ((*it).first) {
case Lemma:
- text.append( decodeStrongs( (*it).second ) );
+ renderedText.append(decodeStrongs((*it).second));
continue;
case Morph:
- text.append( decodeMorph( (*it).second ) );
+ renderedText.append(decodeMorph((*it).second));
continue;
case CrossReference:
- text.append( decodeCrossReference( (*it).second ) );
+ renderedText.append(decodeCrossReference((*it).second));
continue;
case Footnote:
- text.append( decodeFootnote( (*it).second ) );
+ renderedText.append(decodeFootnote((*it).second));
continue;
case WordTranslation:
- text.append( getWordTranslation( (*it).second ) );
+ renderedText.append(getWordTranslation((*it).second));
continue;
case WordGloss:
- //text.append( getWordTranslation( (*it).second ) );
+ //text.append(getWordTranslation((*it).second));
continue;
case Abbreviation:
- text.append( decodeAbbreviation( (*it).second ) );
+ renderedText.append(decodeAbbreviation((*it).second));
continue;
case Text:
- text.append( (*it).second );
+ renderedText.append((*it).second);
continue;
default:
continue;
};
}
-
- setInfo(text);
+ setInfo(renderedText);
}
-void CInfoDisplay::setInfo(CSwordModuleInfo *module) {
+void CInfoDisplay::setInfo(CSwordModuleInfo * const module) {
+ using util::htmlEscape;
+
if (module) {
setInfo(tr("<div class=\"moduleinfo\"><h3>%1</h3><p>%2</p><p>Version: %3</p></div>")
- .arg(module->name())
- .arg(module->config(CSwordModuleInfo::Description))
- .arg(module->config(CSwordModuleInfo::ModuleVersion)));
+ .arg(htmlEscape(module->name()))
+ .arg(htmlEscape(module->config(CSwordModuleInfo::Description)))
+ .arg(htmlEscape(module->config(CSwordModuleInfo::ModuleVersion))));
} else {
unsetInfo();
}
@@ -185,28 +188,21 @@ void CInfoDisplay::selectAll() {
m_htmlPart->selectAll();
}
-const QString CInfoDisplay::decodeAbbreviation( const QString& data ) {
- // QStringList strongs = QStringList::split("|", data);
- QString ret;
- QString text = data;
-
- ret.append(
- QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
+const QString CInfoDisplay::decodeAbbreviation(const QString & data) {
+ // QStringList strongs = QStringList::split("|", data);
+ return QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
.arg(tr("Abbreviation"))
.arg("text")
- .arg(text));
-
- return ret;
+ .arg(data);
}
-const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
+const QString CInfoDisplay::decodeCrossReference(const QString & data) {
Q_ASSERT(!data.isEmpty());
- if (data.isEmpty()) {
+ if (data.isEmpty())
return QString("<div class=\"crossrefinfo\"><h3>%1</h3></div>")
.arg(tr("Cross references"));
- }
- // qWarning("setting crossref %s", data.latin1());
+ // qWarning("setting crossref %s", data.latin1());
DisplayOptions dispOpts;
dispOpts.lineBreaks = false;
@@ -223,99 +219,87 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
CrossRefRendering renderer(dispOpts, filterOpts);
CTextRendering::KeyTree tree;
- // const bool isBible = true;
- CSwordModuleInfo* module = CBTConfig::get(CBTConfig::standardBible);
+ // const bool isBible = true;
+ const CSwordModuleInfo * module = btConfig().getDefaultSwordModuleByType("standardBible");
+ if (!module)
+ module = m_mainWindow->getCurrentModule();
- //a prefixed module gives the module to look into
+ // a prefixed module gives the module to look into
QRegExp re("^[^ ]+:");
- // re.setMinimal(true);
+ // re.setMinimal(true);
int pos = re.indexIn(data);
- if (pos != -1) {
+ if (pos != -1)
pos += re.matchedLength() - 1;
- }
if (pos > 0) {
const QString moduleName = data.left(pos);
- // qWarning("found module %s", moduleName.latin1());
+ // qWarning("found module %s", moduleName.latin1());
module = CSwordBackend::instance()->findModuleByName(moduleName);
- if (!module) {
- module = CBTConfig::get(CBTConfig::standardBible);
- }
- // Q_ASSERT(module);
+ if (!module)
+ module = btConfig().getDefaultSwordModuleByType("standardBible");
+ // Q_ASSERT(module);
}
- //Q_ASSERT(module); //why? the existense of the module is tested later
- CTextRendering::KeyTreeItem::Settings settings (
+ // Q_ASSERT(module); // why? the existense of the module is tested later
+ CTextRendering::KeyTreeItem::Settings settings(
false,
CTextRendering::KeyTreeItem::Settings::CompleteShort
);
if (module && (module->type() == CSwordModuleInfo::Bible)) {
VerseKey vk;
- sword::ListKey refs = vk.ParseVerseList((const char*)data.mid((pos == -1) ? 0 : pos + 1).toUtf8(), "Gen 1:1", true);
+ sword::ListKey refs = vk.parseVerseList((const char*) data.mid((pos == -1) ? 0 : pos + 1).toUtf8(), "Gen 1:1", true);
- for (int i = 0; i < refs.Count(); ++i) {
- SWKey* key = refs.getElement(i);
+ for (int i = 0; i < refs.getCount(); i++) {
+ SWKey * const key = refs.getElement(i);
Q_ASSERT(key);
- VerseKey* vk = dynamic_cast<VerseKey*>(key);
+ VerseKey * const vk = dynamic_cast<VerseKey*>(key);
- CTextRendering::KeyTreeItem* itm = (CTextRendering::KeyTreeItem*)0; //explicit conversion for MS VS
- if (vk && vk->isBoundSet()) { //render a range of keys
- itm = new CTextRendering::KeyTreeItem(
- QString::fromUtf8(vk->LowerBound().getText()),
- QString::fromUtf8(vk->UpperBound().getText()),
+ if (vk && vk->isBoundSet()) { // render a range of keys
+ tree.append(new CTextRendering::KeyTreeItem(
+ QString::fromUtf8(vk->getLowerBound().getText()),
+ QString::fromUtf8(vk->getUpperBound().getText()),
module,
settings
- );
- }
- else {
- itm = new CTextRendering::KeyTreeItem(
+ ));
+ } else {
+ tree.append(new CTextRendering::KeyTreeItem(
QString::fromUtf8(key->getText()),
QString::fromUtf8(key->getText()),
module,
settings
- );
+ ));
}
-
- Q_ASSERT(itm);
-
- tree.append( itm );
}
- }
- else if (module) {
- CTextRendering::KeyTreeItem* itm = new CTextRendering::KeyTreeItem(
- data.mid((pos == -1) ? 0 : pos + 1),
- module,
- settings
- );
- tree.append( itm );
+ } else if (module) {
+ tree.append(new CTextRendering::KeyTreeItem(data.mid((pos == -1)
+ ? 0
+ : pos + 1),
+ module,
+ settings));
}
- // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
- //spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
+ // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
+ // spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
QString lang = "en"; // default english
- if (module) {
+ if (module)
lang = module->language()->abbrev();
- }
-
- const QString RenderedText = renderer.renderKeyTree(tree);
return QString("<div class=\"crossrefinfo\" lang=\"%1\"><h3>%2</h3><div class=\"para\" dir=\"%3\">%4</div></div>")
.arg(lang)
.arg(tr("Cross references"))
.arg(module ? ((module->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") : "")
- .arg(RenderedText);
+ .arg(renderer.renderKeyTree(tree));
}
/*!
- \fn CInfoDisplay::decodeFootnote( const QString& data )
+ \fn CInfoDisplay::decodeFootnote(const QString & data)
*/
-const QString CInfoDisplay::decodeFootnote( const QString& data ) {
+const QString CInfoDisplay::decodeFootnote(const QString & data) {
QStringList list = data.split("/");
Q_ASSERT(list.count() >= 3);
- if (!list.count()) {
+ if (!list.count())
return QString::null;
- }
FilterOptions filterOpts;
filterOpts.headings = false;
@@ -336,25 +320,23 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
list.pop_front();
const QString keyname = list.join("/");
- CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(modulename);
- if (!module) {
+ CSwordModuleInfo * const module = CSwordBackend::instance()->findModuleByName(modulename);
+ if (!module)
return QString::null;
- }
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey(keyname);
- key->renderedText(CSwordKey::ProcessEntryAttributesOnly); //force entryAttributes
+ key->renderedText(CSwordKey::ProcessEntryAttributesOnly); // force entryAttributes
- const char* note =
+ const char * const note =
module->module()->getEntryAttributes()
["Footnote"][swordFootnote.toLatin1().data()]["body"].c_str();
QString text = module->isUnicode() ? QString::fromUtf8(note) : QString(note);
- text = QString::fromUtf8(module->module()->RenderText(
+ text = QString::fromUtf8(module->module()->renderText(
module->isUnicode()
- ? (const char*)text.toUtf8()
- : (const char*)text.toLatin1()
- ));
+ ? static_cast<const char *>(text.toUtf8())
+ : static_cast<const char *>(text.toLatin1())));
return QString("<div class=\"footnoteinfo\" lang=\"%1\"><h3>%2</h3><p>%3</p></div>")
.arg(module->language()->abbrev())
@@ -362,22 +344,22 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
.arg(text);
}
-const QString CInfoDisplay::decodeStrongs( const QString& data ) {
+const QString CInfoDisplay::decodeStrongs(const QString & data) {
QStringList strongs = data.split("|");
QString ret;
QStringList::const_iterator end = strongs.end();
for (QStringList::const_iterator it = strongs.begin(); it != end; ++it) {
- CSwordModuleInfo* const module = CBTConfig::get
+ CSwordModuleInfo * const module = btConfig().getDefaultSwordModuleByType
(
((*it).left(1) == QString("H")) ?
- CBTConfig::standardHebrewStrongsLexicon :
- CBTConfig::standardGreekStrongsLexicon
+ "standardHebrewStrongsLexicon" :
+ "standardGreekStrongsLexicon"
);
QString text;
if (module) {
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey((*it).mid(1)); // skip H or G (language sign), will have to change later if we have better modules
text = key->renderedText();
}
@@ -398,13 +380,13 @@ const QString CInfoDisplay::decodeStrongs( const QString& data ) {
return ret;
}
-const QString CInfoDisplay::decodeMorph( const QString& data ) {
+const QString CInfoDisplay::decodeMorph(const QString & data) {
QStringList morphs = data.split("|");
QString ret;
- foreach(QString morph, morphs) {
+ Q_FOREACH (QString morph, morphs) {
//qDebug() << "CInfoDisplay::decodeMorph, morph: " << morph;
- CSwordModuleInfo* module = 0;
+ CSwordModuleInfo * module = 0;
bool skipFirstChar = false;
QString value = "";
QString valueClass = "";
@@ -412,8 +394,8 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
int valStart = morph.indexOf(':');
if (valStart > -1) {
valueClass = morph.mid(0, valStart);
- //qDebug() << "valueClass: " << valueClass;
- module = CSwordBackend::instance()->findModuleByName( valueClass );
+ // qDebug() << "valueClass: " << valueClass;
+ module = CSwordBackend::instance()->findModuleByName(valueClass);
}
value = morph.mid(valStart + 1); //works for prepended module and without (-1 +1 == 0).
@@ -425,51 +407,46 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
if (value.size() > 1 && value.at(1).isDigit()) {
switch (value.at(0).toLatin1()) {
case 'G':
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
skipFirstChar = true;
break;
case 'H':
- module = CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType("standardHebrewMorphLexicon");
skipFirstChar = true;
break;
default:
skipFirstChar = false;
/// \todo we can't tell here if it's a greek or hebrew moprh code, that's a problem we have to solve
- // module = CBTConfig::get(CBTConfig::standardGreekMorphLexicon);
+ // module = getBtConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
break;
}
}
//if it is still not set use the default
- if (!module) {
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
- }
+ if (!module)
+ module = btConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
}
QString text;
- //Q_ASSERT(module);
+ // Q_ASSERT(module);
if (module) {
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
- //skip H or G (language sign) if we have to skip it
+ // skip H or G (language sign) if we have to skip it
const bool isOk = key->setKey(skipFirstChar ? value.mid(1) : value);
- //Q_ASSERT(isOk);
- if (!isOk) { //try to use the other morph lexicon, because this one failed with the current morph code
- key->setModule(CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon));
+ // Q_ASSERT(isOk);
+ if (!isOk) { // try to use the other morph lexicon, because this one failed with the current morph code
+ key->setModule(btConfig().getDefaultSwordModuleByType("standardHebrewMorphLexicon")); /// \todo: what if the module doesn't exist?
key->setKey(skipFirstChar ? value.mid(1) : value);
}
text = key->renderedText();
}
- //if the module wasn't found just display an empty morph info
+ // if the module wasn't found just display an empty morph info
QString lang = "en"; // default to english
if (module)
lang = module->language()->abbrev();
- ret.append( QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ ret.append(QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(lang)
.arg(tr("Morphology"))
.arg(value)
@@ -480,26 +457,21 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
return ret;
}
-const QString CInfoDisplay::getWordTranslation( const QString& data ) {
- CSwordModuleInfo* const module = CBTConfig::get
- (CBTConfig::standardLexicon);
- if (!module) {
+const QString CInfoDisplay::getWordTranslation(const QString & data) {
+ CSwordModuleInfo * const module = btConfig().getDefaultSwordModuleByType("standardLexicon");
+ if (!module)
return QString::null;
- }
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey(data);
- if (key->key().toUpper() != data.toUpper()) { //key not present in the lexicon
+ if (key->key().toUpper() != data.toUpper()) //key not present in the lexicon
return QString::null;
- }
- QString ret = QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ return QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(module->language()->abbrev())
.arg(tr("Word lookup"))
.arg(data)
.arg(key->renderedText());
-
- return ret;
}
QSize CInfoDisplay::sizeHint() const {
diff --git a/src/frontend/cinfodisplay.h b/src/frontend/cinfodisplay.h
index 7bc15e7..46623ba 100644
--- a/src/frontend/cinfodisplay.h
+++ b/src/frontend/cinfodisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,51 +22,65 @@
class CReadDisplay;
class QAction;
class QSize;
+class BibleTime;
+
namespace InfoDisplay {
-class CInfoDisplay : public QWidget {
- Q_OBJECT
- public:
- enum InfoType {
- Abbreviation,
- CrossReference,
- Footnote,
- Lemma,
- Morph,
- WordTranslation,
- WordGloss,
- Text
- };
-
- typedef QPair<InfoType, QString> InfoData;
- typedef QList<InfoData> ListInfoData;
-
- CInfoDisplay(QWidget *parent = 0);
-
- void unsetInfo();
- void setInfo(const QString &data, const QString &lang = QString());
- void setInfo(const InfoType, const QString& data);
- void setInfo(const ListInfoData&);
- QSize sizeHint() const;
-
- public slots:
- void setInfo(CSwordModuleInfo *module);
-
- protected:
- const QString decodeAbbreviation( const QString& data );
- const QString decodeCrossReference( const QString& data );
- const QString decodeFootnote( const QString& data );
- const QString decodeStrongs( const QString& data );
- const QString decodeMorph( const QString& data );
- const QString getWordTranslation( const QString& data );
-
- protected slots:
- void lookupInfo(const QString &, const QString &);
- void selectAll();
-
- private:
- CReadDisplay* m_htmlPart;
+class CInfoDisplay: public QWidget {
+
+ Q_OBJECT
+
+public: /* Types: */
+
+ enum InfoType {
+ Abbreviation,
+ CrossReference,
+ Footnote,
+ Lemma,
+ Morph,
+ WordTranslation,
+ WordGloss,
+ Text
+ };
+
+ typedef QPair<InfoType, QString> InfoData;
+ typedef QList<InfoData> ListInfoData;
+
+public: /* Methods: */
+
+ CInfoDisplay(BibleTime * parent = NULL);
+
+ void unsetInfo();
+ void setInfo(const QString & renderedData,
+ const QString & lang = QString());
+ void setInfo(const InfoType, const QString & data);
+ void setInfo(const ListInfoData &);
+ QSize sizeHint() const;
+
+public slots:
+
+ void setInfo(CSwordModuleInfo * module);
+
+private: /* Methods: */
+
+ const QString decodeAbbreviation(const QString & data);
+ const QString decodeCrossReference(const QString & data);
+ const QString decodeFootnote(const QString & data);
+ const QString decodeStrongs(const QString & data);
+ const QString decodeMorph(const QString & data);
+ const QString getWordTranslation(const QString & data);
+
+private slots:
+
+ void lookupInfo(const QString &, const QString &);
+ void selectAll();
+
+private: /* Fields: */
+
+ CReadDisplay * m_htmlPart;
+ BibleTime * m_mainWindow;
+
};
} //end of InfoDisplay namespace
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index fb116af..d879dfa 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#include "bibletime.h"
#include "frontend/cmdiarea.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
-
+#include "frontend/display/cdisplay.h"
#include <QEvent>
#include <QMdiSubWindow>
#include <QMenu>
@@ -18,9 +18,26 @@
#include <QTabBar>
#include <QTimer>
#include <QToolBar>
+#include <QWebView>
#include <QWindowStateChangeEvent>
-#define MOVESIZE 30
+
+namespace {
+
+inline CDisplayWindow * getDisplayWindow(const QMdiSubWindow * const mdiWindow) {
+ return qobject_cast<CDisplayWindow *>(mdiWindow->widget());
+}
+
+inline QWebView * getWebViewFromDisplayWindow(const CDisplayWindow * const displayWindow) {
+ if (!displayWindow)
+ return NULL;
+ CDisplay * const display = displayWindow->displayWidget();
+ if (!display)
+ return NULL;
+ return qobject_cast<QWebView *>(display->view());
+}
+
+} // anonymous namespace
CMDIArea::CMDIArea(BibleTime *parent)
@@ -61,8 +78,10 @@ void CMDIArea::fixSystemMenu(QMdiSubWindow* subWindow) {
}
}
-QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
- QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
+QMdiSubWindow * CMDIArea::addSubWindow(QWidget * widget,
+ Qt::WindowFlags windowFlags)
+{
+ QMdiSubWindow * const subWindow = QMdiArea::addSubWindow(widget, windowFlags);
subWindow->installEventFilter(this);
fixSystemMenu(subWindow);
@@ -73,28 +92,24 @@ QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFl
// If we already have an active window, make the new one simular to it
if (activeSubWindow()) {
if (activeSubWindow()->isMaximized()) {
- // Maximize the new window
- subWindow->showMaximized();
- }
- else {
+ subWindow->showMaximized(); // Maximize the new window
+ } else {
// Make new window the same size as the active window and move it slightly.
subWindow->resize(activeSubWindow()->size());
QRect subWinGeom = activeSubWindow()->geometry();
+ static const int MOVESIZE = 30;
subWinGeom.translate(MOVESIZE, MOVESIZE);
// If it goes off screen, move it almost to the top left
- if ( ! frameRect().contains(subWinGeom)) {
+ if (!frameRect().contains(subWinGeom))
subWinGeom.moveTo(MOVESIZE, MOVESIZE);
- }
subWindow->setGeometry(subWinGeom);
}
- }
- else {
+ } else {
//set the window to be big enough
subWindow->resize(400, 400);
}
subWindow->raise();
- }
- else {
+ } else {
// Automatic arrangement modes
enableWindowMinMaxFlags(false);
triggerWindowUpdate();
@@ -285,6 +300,14 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() const {
return ret;
}
+QWebView* CMDIArea::getActiveWebView()
+{
+ QMdiSubWindow* activeMdiWindow = activeSubWindow();
+ CDisplayWindow* const activeWindow = getDisplayWindow(activeMdiWindow);
+ QWebView* webView = getWebViewFromDisplayWindow(activeWindow);
+ return webView;
+}
+
void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
if (subWindowList().isEmpty())
m_bibleTime->clearMdiToolBars();
@@ -295,13 +318,44 @@ void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
emit sigSetToplevelCaption( client->windowTitle().trimmed() );
// Notify child window it is active
- CDisplayWindow * const activeWindow = qobject_cast<CDisplayWindow*>(client->widget());
+ CDisplayWindow* const activeWindow = getDisplayWindow(client);
if (activeWindow != 0 && activeWindow != m_activeWindow) {
m_activeWindow = activeWindow;
activeWindow->windowActivated();
}
}
+void CMDIArea::findNextTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::findPreviousTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::highlightTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText("", options); // clear old highlight
+ activeWebView->findText(text, options);
+}
+
void CMDIArea::resizeEvent(QResizeEvent* e) {
/*
Do not call QMdiArea::resizeEvent(e) if we are in manual arrangement
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 4b9d70e..6245d94 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,6 +20,7 @@
class BibleTime;
class CSwordModuleInfo;
class CDisplayWindow;
+class QWebView;
/**
A custom MDI area widget.
@@ -51,7 +54,15 @@ class CMDIArea: public QMdiArea {
/**
Reimplementation of QMdiArea::addSubWindow().
*/
- QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags windowFlags = 0);
+ QMdiSubWindow * addSubWindow(QWidget * widget,
+ Qt::WindowFlags windowFlags = 0);
+
+ /**
+ Returns the BibleTime main window
+ */
+ BibleTime* bibleTimeWindow() {
+ return m_bibleTime;
+ }
/**
Resets the MDI arrangement mode and arranges the windows.
@@ -118,6 +129,12 @@ class CMDIArea: public QMdiArea {
*/
void myTileHorizontal();
+ void findNextTextInActiveWindow(const QString& text, bool caseSensitive);
+
+ void findPreviousTextInActiveWindow(const QString& text, bool caseSensitive);
+
+ void highlightTextInActiveWindow(const QString& text, bool caseSensitive);
+
signals:
/**
@@ -143,6 +160,8 @@ class CMDIArea: public QMdiArea {
void fixSystemMenu(QMdiSubWindow* subWindow);
+ QWebView* getActiveWebView();
+
protected slots:
/**
diff --git a/src/frontend/cprinter.cpp b/src/frontend/cprinter.cpp
index 50ff67d..b10d614 100644
--- a/src/frontend/cprinter.cpp
+++ b/src/frontend/cprinter.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,6 +15,7 @@
#include <QWebPage>
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/config/btconfig.h"
namespace Printing {
diff --git a/src/frontend/cprinter.h b/src/frontend/cprinter.h
index e702565..48001a1 100644
--- a/src/frontend/cprinter.h
+++ b/src/frontend/cprinter.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/crossrefrendering.cpp b/src/frontend/crossrefrendering.cpp
index ac538da..868b6ce 100644
--- a/src/frontend/crossrefrendering.cpp
+++ b/src/frontend/crossrefrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/crossrefrendering.h b/src/frontend/crossrefrendering.h
index d6f33a2..fb22aa2 100644
--- a/src/frontend/crossrefrendering.h
+++ b/src/frontend/crossrefrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +13,7 @@
#define INFODISPLAYCROSSREFRENDERING_H
#include "backend/rendering/chtmlexportrendering.h"
+#include "backend/config/btconfig.h"
namespace InfoDisplay {
@@ -20,8 +23,8 @@ class CrossRefRendering : public Rendering::CHTMLExportRendering {
friend class CInfoDisplay;
CrossRefRendering(
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions(),
+ const FilterOptions &filterOptions = btConfig().getFilterOptions()
);
virtual QString entryLink(const KeyTreeItem &item,
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index 0d09259..579e461 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 5cc0f56..9dd2e97 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfindwidget.cpp b/src/frontend/display/btfindwidget.cpp
new file mode 100644
index 0000000..1ada629
--- /dev/null
+++ b/src/frontend/display/btfindwidget.cpp
@@ -0,0 +1,118 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/display/btfindwidget.h"
+
+#include "QApplication"
+#include "QCheckBox"
+#include "QHBoxLayout"
+#include "QLineEdit"
+#include "QSpacerItem"
+#include "QToolButton"
+#include "bibletimeapp.h"
+#include "util/cresmgr.h"
+#include "util/geticon.h"
+
+
+BtFindWidget::BtFindWidget(QWidget* parent)
+ : QWidget(parent) {
+ createLayout();
+ createToolButton(CResMgr::findWidget::close_icon, "", SLOT(hide()));
+ createTextEditor();
+ createToolButton(CResMgr::findWidget::previous_icon, tr("Previous"), SLOT(findPrevious()));
+ createToolButton(CResMgr::findWidget::next_icon, tr("Next"), SLOT(findNext()));
+ createCaseCheckBox();
+ createSpacer();
+ setFocusProxy(m_textEditor);
+}
+
+BtFindWidget::~BtFindWidget() {
+}
+
+void BtFindWidget::createLayout() {
+ m_layout = new QHBoxLayout(this);
+ m_layout->setMargin(0);
+ m_layout->setSpacing(8);
+}
+
+void BtFindWidget::createToolButton(const QString& iconName, const QString& text, const char* slot) {
+ QToolButton* button = new QToolButton(this);
+ button->setIcon(util::getIcon(iconName));
+ button->setIconSize(QSize(16,16));
+ button->setText(text);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setAutoRaise(true);
+ m_layout->addWidget(button);
+ bool ok = connect(button, SIGNAL(released()), this, slot);
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createTextEditor() {
+ m_textEditor = new QLineEdit(this);
+#if QT_VERSION < 0x050000
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0, QApplication::UnicodeUTF8));
+#else
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0));
+#endif
+ m_layout->addWidget(m_textEditor);
+ bool ok = connect(m_textEditor, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
+ Q_ASSERT(ok);
+ ok = connect(m_textEditor,SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createCaseCheckBox() {
+ m_caseCheckBox = new QCheckBox(tr("Match case"), this);
+ m_layout->addWidget(m_caseCheckBox);
+}
+
+void BtFindWidget::createSpacer() {
+ QSpacerItem* spacer = new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum);
+ m_layout->addItem(spacer);
+}
+
+void BtFindWidget::highlightText(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+}
+
+void BtFindWidget::returnPressed() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::textChanged(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findNext() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findPrevious() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findPrevious(text, caseSensitive);
+}
+
+void BtFindWidget::showAndSelect(){
+ setVisible(true);
+ QWidget::show();
+ m_textEditor->selectAll();
+ m_textEditor->setFocus(Qt::ShortcutFocusReason);
+}
diff --git a/src/frontend/display/btfindwidget.h b/src/frontend/display/btfindwidget.h
new file mode 100644
index 0000000..52a879a
--- /dev/null
+++ b/src/frontend/display/btfindwidget.h
@@ -0,0 +1,56 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTFINDIDGET_H
+#define BTFINDIDGET_H
+
+#include <QWidget>
+#include <QWebPage>
+class QCheckBox;
+class QLineEdit;
+class QHBoxLayout;
+class QString;
+
+class BtFindWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ BtFindWidget(QWidget* parent = 0);
+ ~BtFindWidget();
+ void showAndSelect();
+
+ private slots:
+ void findNext();
+ void findPrevious();
+ void returnPressed();
+ void textChanged(const QString& text);
+
+ private:
+ void createCaseCheckBox();
+ void createLayout();
+ void createSpacer();
+ void createTextEditor();
+ void createToolButton(const QString& iconName, const QString& text, const char* slot);
+ void highlightText(const QString& searchText);
+
+ QHBoxLayout* m_layout;
+ QLineEdit* m_textEditor;
+ QCheckBox* m_caseCheckBox;
+
+ signals:
+ void findPrevious(const QString & text, bool caseSensitive);
+ void findNext(const QString & text, bool caseSensitive);
+ void highlightText(const QString & text, bool caseSensitive);
+};
+
+#endif
+
+
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index b302fed..82fdd08 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index c2d7198..40b94a1 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtml.js b/src/frontend/display/bthtml.js
index 689ba55..d56318f 100644
--- a/src/frontend/display/bthtml.js
+++ b/src/frontend/display/bthtml.js
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,119 +18,105 @@ var timeOutId = -1;
// Scroll window to html anchor
function gotoAnchor(anchor)
{
- document.location=document.location + "#" + anchor;
-}
-
-// Set body editable
-function setEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','true');
-}
-
-// Set body not editable
-function setNotEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','false');
+ document.location=document.location + "#" + anchor;
}
// Mouse button clicked handler
function mouseClickHandler (mEvent)
{
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var url = "";
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- btHtmlJsObject.mouseClick(url);
- }
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var url = "";
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ btHtmlJsObject.mouseClick(url);
+ }
}
// Mouse button pressed down handler
function mouseDownHandler (mEvent)
{
- var node;
- var url = "";
- var lemma = "";
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- var tmpLemma = mEvent.target.getAttribute("lemma");
- if (tmpLemma)
- lemma = tmpLemma;
- }
-
- if (mEvent.button === 2) // Right mouse button
- {
- btHtmlJsObject.mouseDownRight(url, lemma);
- }
- if (mEvent.button === 0) // Left mouse button
- {
- if (!(mEvent.target === undefined))
- {
- var X = mEvent.clientX;
- var Y = mEvent.clientY;
- btHtmlJsObject.mouseDownLeft(url, X, Y);
- }
- }
+ var node;
+ var url = "";
+ var lemma = "";
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ var tmpLemma = mEvent.target.getAttribute("lemma");
+ if (tmpLemma)
+ lemma = tmpLemma;
+ }
+
+ if (mEvent.button === 2) // Right mouse button
+ {
+ btHtmlJsObject.mouseDownRight(url, lemma);
+ }
+ if (mEvent.button === 0) // Left mouse button
+ {
+ if (!(mEvent.target === undefined))
+ {
+ var X = mEvent.clientX;
+ var Y = mEvent.clientY;
+ btHtmlJsObject.mouseDownLeft(url, X, Y);
+ }
+ }
}
// Mouse moved event handler
function mouseMoveHandler (mEvent)
{
- currentNode = mEvent.target;
- var shiftKey = mEvent.shiftKey;
- var x = mEvent.clientX;
- var y = mEvent.clientY;
- var node = mEvent.target;
- if ( node != undefined && node != prevNode )
- {
- prevNode = node;
-
- if (node.attributes.length > 0)
- {
- attribList = getNodeAttributes(node);
- btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
- }
- }
+ currentNode = mEvent.target;
+ var shiftKey = mEvent.shiftKey;
+ var x = mEvent.clientX;
+ var y = mEvent.clientY;
+ var node = mEvent.target;
+ if ( node != undefined && node != prevNode )
+ {
+ prevNode = node;
+
+ if (node.attributes.length > 0)
+ {
+ attribList = getNodeAttributes(node);
+ btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
+ }
+ }
}
// Get attributes of a DOM node and put into a single string
function getNodeAttributes(node)
{
- var attribList = '';
- if (node.attributes.length > 0)
- {
- for (i = 0; i < node.attributes.length; i++)
- {
- attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
- }
- }
- return attribList;
+ var attribList = '';
+ if (node.attributes.length > 0)
+ {
+ for (i = 0; i < node.attributes.length; i++)
+ {
+ attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
+ }
+ }
+ return attribList;
}
// Start a timer event
function startTimer(time)
{
- clearTimeout(timeOutId);
- timeOutId = setTimeout("timerEvent()",time);
+ clearTimeout(timeOutId);
+ timeOutId = setTimeout("timerEvent()",time);
}
// Handles a timer event
function timerEvent()
{
- timeOutId = -1;
- if (currentNode != 0 && currentNode == prevNode)
- {
- var attributes = getNodeAttributes(currentNode);
- btHtmlJsObject.timeOutEvent(attributes);
- }
+ timeOutId = -1;
+ if (currentNode != 0 && currentNode == prevNode)
+ {
+ var attributes = getNodeAttributes(currentNode);
+ btHtmlJsObject.timeOutEvent(attributes);
+ }
}
document.getElementsByTagName("body")[0].addEventListener ('mousedown', function (eve) { mouseDownHandler (eve); }, true);
@@ -139,8 +125,6 @@ document.getElementsByTagName("body")[0].addEventListener ('click', function
btHtmlJsObject.startTimer.connect(this, this.startTimer);
btHtmlJsObject.gotoAnchor.connect(this, this.gotoAnchor);
-btHtmlJsObject.setDocumentEditable.connect(this, this.setEditable);
-btHtmlJsObject.setDocumentNotEditable.connect(this, this.setNotEditable);
;
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
deleted file mode 100644
index 1b15b11..0000000
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/display/bthtmlfindtext.h"
-
-#include <QMdiSubWindow>
-#include "frontend/cmdiarea.h"
-#include "frontend/display/bthtmlreaddisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-
-static BtHtmlFindText* dialog = 0;
-
-void showBtHtmlFindText(CMDIArea* mdiArea) {
- if (dialog == 0)
- dialog = new BtHtmlFindText(mdiArea, mdiArea);
- dialog->show();
-}
-
-BtHtmlFindText::BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent, f), m_mdiArea(mdiArea) {
- ui.setupUi(this);
- bool ok;
- ok = connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
- Q_ASSERT(ok);
- ok = connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
- Q_ASSERT(ok);
-}
-
-BtHtmlFindText::~BtHtmlFindText() {
-}
-
-void BtHtmlFindText::findNext() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = 0;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-void BtHtmlFindText::findPrevious() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = QWebPage::FindBackward;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-
-QWebView* BtHtmlFindText::getActiveWindowWebView() {
- QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
- if (activeSubWindow == 0)
- return 0;
-
- QWidget* activeWindowWidget = activeSubWindow->widget();
- if (activeWindowWidget == 0)
- return 0;
-
- CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
- if (cDisplayWindow == 0)
- return 0;
-
- CDisplay* cDisplay = cDisplayWindow->displayWidget();
- if (cDisplay == 0)
- return 0;
-
- QWidget* textView = cDisplay->view();
- if (textView == 0)
- return 0;
-
- QWebView* webView = qobject_cast<QWebView*>(textView);
- return webView;
-}
-
-
-
-
-
-
-
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
deleted file mode 100644
index 1d941c1..0000000
--- a/src/frontend/display/bthtmlfindtext.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTHTMLFINDTEXT_H
-#define BTHTMLFINDTEXT_H
-
-/// \todo Qt Designer UI file!?
-#include "ui_bthtmlfindtext.h"
-
-
-class CMDIArea;
-class QWebView;
-
-class BtHtmlFindText : public QDialog {
- Q_OBJECT
-
- public:
- BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent = 0, Qt::WindowFlags f = 0);
- ~BtHtmlFindText();
- public slots:
- void findNext();
- void findPrevious();
- private:
- QWebView* getActiveWindowWebView();
- Ui_findTextDialog ui;
- CMDIArea* m_mdiArea;
-};
-
-
-#endif
diff --git a/src/frontend/display/bthtmlfindtext.ui b/src/frontend/display/bthtmlfindtext.ui
deleted file mode 100644
index c04de0c..0000000
--- a/src/frontend/display/bthtmlfindtext.ui
+++ /dev/null
@@ -1,145 +0,0 @@
-<ui version="4.0" >
- <class>findTextDialog</class>
- <widget class="QDialog" name="findTextDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>227</width>
- <height>115</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Find Text</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="QFrame" name="findFrame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2" >
- <item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QComboBox" name="findTextComboBox" >
- <property name="toolTip" >
- <string>The text you want to search for</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="caseBox" >
- <property name="toolTip" >
- <string>Search with case sensitivity</string>
- </property>
- <property name="text" >
- <string>Case &amp;sensitive</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_6" >
- <item>
- <spacer name="horizontalSpacer_6" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="previousButton" >
- <property name="toolTip" >
- <string>Find the previous location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Previous</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="nextButton" >
- <property name="toolTip" >
- <string>Find the next location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Next</string>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton" >
- <property name="toolTip" >
- <string>Close the dialog</string>
- </property>
- <property name="text" >
- <string>&amp;Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>closeButton</sender>
- <signal>clicked()</signal>
- <receiver>findTextDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>200</x>
- <y>124</y>
- </hint>
- <hint type="destinationlabel" >
- <x>224</x>
- <y>106</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index aa44865..cb395cc 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,7 @@
#include <QDrag>
#include <QSharedPointer>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
#include "backend/managers/cswordbackend.h"
@@ -105,7 +105,7 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
// no mouse button pressed and tracking enabled
// start timer that updates the mag window
// Sets timer in javascript. See bthtml.js startTimer()
- emit startTimer(CBTConfig::get(CBTConfig::magDelay));
+ emit startTimer(btConfig().value<int>("GUI/magDelay", 400));
m_prev_attributes = attributes;
// When the javascript timer interupts, the see timerEvent() in bthtml.js
// will call the timeOutEvent in this class
@@ -113,40 +113,32 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
}
// called from javascript timerEvent() in bthtml.js
-void BtHtmlJsObject::timeOutEvent(const QString& attributes) {
+void BtHtmlJsObject::timeOutEvent(const QString & attributes) {
if (m_prev_attributes != attributes)
return;
m_prev_attributes = "";
CInfoDisplay::ListInfoData infoList;
- QStringList attrList = attributes.split("||");
+ const QStringList attrList = attributes.split("||");
for (int i = 0; i < attrList.count(); i++) {
- QString attrPair = attrList[i];
- QStringList attr = attrPair.split("=");
+ const QStringList attr(attrList[i].split('='));
if (attr.count() == 2) {
- QString attrName = attr[0];
- QString attrValue = attr[1];
- if (attrName == "note") {
- infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
- }
- if (attrName == "lemma") {
- infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
- }
- if (attrName == "morph") {
- infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
- }
- if (attrName == "expansion") {
- infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
- }
- if (attrName == "crossrefs") {
- infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
+ if (attr[0] == "note") {
+ infoList.append(qMakePair(CInfoDisplay::Footnote, attr[1]));
+ } else if (attr[0] == "lemma") {
+ infoList.append(qMakePair(CInfoDisplay::Lemma, attr[1]));
+ } else if (attr[0] == "morph") {
+ infoList.append(qMakePair(CInfoDisplay::Morph, attr[1]));
+ } else if (attr[0] == "expansion") {
+ infoList.append(qMakePair(CInfoDisplay::Abbreviation, attr[1]));
+ } else if (attr[0] == "crossrefs") {
+ infoList.append(qMakePair(CInfoDisplay::CrossReference, attr[1]));
}
}
}
// Update the mag if valid attributes were found
- if (!(infoList.isEmpty())) {
+ if (!(infoList.isEmpty()))
BibleTime::instance()->infoDisplay()->setInfo(infoList);
- }
}
// clearing the previous attribute effectively stops any time out event
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index 109de5a..3bf37f5 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 1842178..7b303e7 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,8 +14,10 @@
#include <QString>
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
+#include "bibletime.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
+#include "frontend/cmdiarea.h"
#include "frontend/display/bthtmljsobject.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
@@ -25,8 +27,6 @@
using namespace InfoDisplay;
-void showBtHtmlFindText(CMDIArea*);
-
static QString javascript; // Initialized from file bthtml.js
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
@@ -266,8 +266,8 @@ void BtHtmlReadDisplay::setLemma(const QString& lemma) {
// Open the Find text dialog
void BtHtmlReadDisplay::openFindTextDialog() {
- CMDIArea* mdiArea = parentWindow()->mdi();
- showBtHtmlFindText(mdiArea);
+ BibleTime* bibleTime = parentWindow()->mdi()->bibleTimeWindow();
+ bibleTime->openFindWidget();
}
// Send "completed" signal when the text is finished loading into the viewer
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index f1e1f5c..0a703d3 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,11 +25,6 @@
class BtHtmlReadDisplayView;
-class QScrollArea;
-class QWidget;
-class QString;
-class BtHtmlReadDisplay;
-class QEvent;
/** The implementation for the HTML read display.
* @author The BibleTime team
@@ -38,6 +35,10 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
friend class BtHtmlReadDisplayView;
public:
+
+ BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
+ virtual ~BtHtmlReadDisplay();
+
//reimplemented functions from CDisplay
// Returns the right text part in the specified format.
virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
@@ -68,9 +69,7 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
void completed();
protected:
- friend class CDisplay;
- BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
- virtual ~BtHtmlReadDisplay();
+
void slotGoToAnchor(const QString& anchor);
struct DNDData {
bool mousePressed;
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 4def9f5..a5c5bc8 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -98,20 +98,6 @@ void CDisplayConnections::openFindTextDialog() {
/*----------------------*/
-CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
- return new BtHtmlReadDisplay(readWindow, parent);
-}
-
-CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
- // qWarning("CDisplay::createWriteInstance");
- if (type == PlainTextDisplay) {
- return new CPlainWriteDisplay(writeWindow, parent);
- }
- else {
- return new CHTMLWriteDisplay(writeWindow, parent);
- };
-}
-
CDisplay::CDisplay(CDisplayWindow* parent) :
m_parentWindow(parent),
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index a0a0020..de971d5 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +18,6 @@
class CDisplayConnections;
class CDisplayWindow;
-class CReadDisplay;
-class CReadWindow;
-class CWriteDisplay;
-class CWriteWindow;
class QMenu;
/** The base class for all display widgets.
@@ -27,15 +25,6 @@ class QMenu;
*/
class CDisplay {
public:
- enum WriteDisplayType {
- HTMLDisplay = 0,
- PlainTextDisplay
- };
-
- static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow,
- const WriteDisplayType& type = PlainTextDisplay,
- QWidget* parent = 0 );
enum TextType {
HTMLText, /* Used for HTML markup */
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index ce7b94c..829f607 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,90 +14,109 @@
#include <QTextEdit>
#include <QToolBar>
#include <QToolTip>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/display/btcolorwidget.h"
#include "frontend/display/btfontsizewidget.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/chtmlwritewindow.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtActionCollection;
-CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
-: CPlainWriteDisplay(parentWindow, parent) {
- m_actions.bold = 0;
- m_actions.italic = 0;
- m_actions.underline = 0;
- m_actions.selectAll = 0;
+namespace {
+const QString CHTMLWriteDisplayFontKey = "HtmlWriteDisplay/font";
+const QString CHTMLWriteDisplayFontColorKey = "HtmlWriteDisplay/fontColor";
+}
+
+CHTMLWriteDisplay::CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget* parent)
+ : CPlainWriteDisplay(parentWindow, parent)
+ , m_handingFormatChangeFromEditor(false)
+{
+
+ BtConfig & conf = btConfig();
+ setTextColor(conf.sessionValue(CHTMLWriteDisplayFontColorKey, textColor()));
+ QFont f = conf.sessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ setCurrentFont(f);
+
//--------------------bold toggle-------------------------
- namespace DU = util::directory;
m_actions.bold = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
tr("Bold"),
this);
m_actions.bold->setCheckable(true);
+ m_actions.bold->setChecked(f.bold());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
m_actions.bold->setToolTip( tr("Bold") );
- connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
+ connect(m_actions.bold, SIGNAL(toggled(bool)),
+ this, SLOT(toggleBold(bool)), Qt::DirectConnection);
//--------------------italic toggle-------------------------
m_actions.italic = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
tr("Italic"),
this );
m_actions.italic->setCheckable(true);
+ m_actions.italic->setChecked(f.italic());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
- connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
+ connect(m_actions.italic, SIGNAL(toggled(bool)),
+ this, SLOT(toggleItalic(bool)), Qt::DirectConnection);
m_actions.italic->setToolTip( tr("Italic") );
//--------------------underline toggle-------------------------
m_actions.underline = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
tr("Underline"),
this );
m_actions.underline->setCheckable(true);
+ m_actions.underline->setChecked(f.underline());
m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
- connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
+ connect(m_actions.underline, SIGNAL(toggled(bool)),
+ this, SLOT(toggleUnderline(bool)), Qt::DirectConnection);
m_actions.underline->setToolTip( tr("Underline") );
//--------------------align left toggle-------------------------
m_actions.alignLeft = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
tr("Left"), this);
m_actions.alignLeft->setCheckable(true);
m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
- connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
+ connect(m_actions.alignLeft, SIGNAL(toggled(bool)),
+ this, SLOT(alignLeft(bool)), Qt::DirectConnection);
m_actions.alignLeft->setToolTip( tr("Align left") );
//--------------------align center toggle-------------------------
m_actions.alignCenter = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
tr("Center"), this);
m_actions.alignCenter->setCheckable(true);
m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
- connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
+ connect(m_actions.alignCenter, SIGNAL(toggled(bool)),
+ this, SLOT(alignCenter(bool)), Qt::DirectConnection);
m_actions.alignCenter->setToolTip( tr("Center") );
//--------------------align right toggle-------------------------
m_actions.alignRight = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
tr("Right"), this);
m_actions.alignRight->setCheckable(true);
m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
- connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
+ connect(m_actions.alignRight, SIGNAL(toggled(bool)),
+ this, SLOT(alignRight(bool)), Qt::DirectConnection);
m_actions.alignRight->setToolTip( tr("Align right") );
setAcceptRichText(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
-}
-CHTMLWriteDisplay::~CHTMLWriteDisplay() {
+ connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
+ this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat)), Qt::DirectConnection);
}
-void CHTMLWriteDisplay::setText( const QString& newText ) {
+void CHTMLWriteDisplay::setText(const QString & newText) {
QTextEdit::setHtml(newText);
}
@@ -105,42 +124,45 @@ const QString CHTMLWriteDisplay::plainText() {
return QTextEdit::toPlainText();
}
-void CHTMLWriteDisplay::toggleBold(bool) {
- setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
+void CHTMLWriteDisplay::toggleBold(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontWeight(checked ? QFont::Bold : QFont::Normal);
}
-void CHTMLWriteDisplay::toggleItalic(bool) {
- setFontItalic( m_actions.italic->isChecked() );
+void CHTMLWriteDisplay::toggleItalic(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontItalic(checked);
}
-void CHTMLWriteDisplay::toggleUnderline(bool) {
- setFontUnderline( m_actions.underline->isChecked() );
+void CHTMLWriteDisplay::toggleUnderline(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontUnderline(checked);
}
-
void CHTMLWriteDisplay::alignLeft(bool set) {
- if (set && (alignment() != Qt::AlignLeft)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignLeft)) {
setAlignment(Qt::AlignLeft);
- slotAlignmentChanged(Qt::AlignLeft);
+ alignmentChanged(Qt::AlignLeft);
}
}
void CHTMLWriteDisplay::alignCenter(bool set) {
- if (set && (alignment() != Qt::AlignHCenter)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignHCenter)) {
setAlignment(Qt::AlignHCenter);
- slotAlignmentChanged(Qt::AlignHCenter);
+ alignmentChanged(Qt::AlignHCenter);
}
}
void CHTMLWriteDisplay::alignRight(bool set) {
- if (set && (alignment() != Qt::AlignRight)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignRight)) {
setAlignment(Qt::AlignRight);
- slotAlignmentChanged(Qt::AlignRight);
+ alignmentChanged(Qt::AlignRight);
}
}
/** The text's alignment changed. Enable the right buttons. */
-void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
+void CHTMLWriteDisplay::alignmentChanged( int a ) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
bool alignLeft = false;
bool alignCenter = false;
bool alignRight = false;
@@ -164,61 +186,79 @@ void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
m_actions.alignRight->setChecked( alignRight );
}
-void CHTMLWriteDisplay::changeFontSize(int newSize) {
- setFontPointSize((qreal)newSize);
-}
-
-/** Is called when a new color was selected. */
-void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
- setTextColor( c );
+void CHTMLWriteDisplay::slotCurrentCharFormatChanged(const QTextCharFormat &) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
+ m_handingFormatChangeFromEditor = true;
+ QFont f = currentFont();
+ emit signalFontChanged(f);
+ emit signalFontSizeChanged(f.pointSize());
+ emit signalFontColorChanged(textColor());
+
+ m_actions.bold->setChecked(f.bold());
+ m_actions.italic->setChecked(f.italic());
+ m_actions.underline->setChecked(f.underline());
+ m_handingFormatChangeFromEditor = false;
+
+ BtConfig & conf = btConfig();
+ conf.setSessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ conf.setSessionValue(CHTMLWriteDisplayFontColorKey, textColor());
}
-/** Is called when a text with another color was selected. */
-void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
- emit setColor(c);
+void CHTMLWriteDisplay::slotFontSizeChosen(int newSize) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontPointSize((qreal)newSize);
}
-void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
- emit fontChanged(font);
- emit fontSizeChanged(font.pointSize());
-
- m_actions.bold->setChecked( font.bold() );
- m_actions.italic->setChecked( font.italic() );
- m_actions.underline->setChecked( font.underline() );
+/** Is called when a new color was selected. */
+void CHTMLWriteDisplay::slotFontColorChosen( const QColor& c) {
+ if (!m_handingFormatChangeFromEditor)
+ setTextColor( c );
}
-void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
- setFontFamily(font.family());
+void CHTMLWriteDisplay::slotFontFamilyChosen(const QFont& font) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontFamily(font.family());
}
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ Q_UNUSED(actions);
+
+ QFont f = currentFont();
//--------------------font chooser-------------------------
QFontComboBox* fontFamilyCombo = new QFontComboBox(this);
+ fontFamilyCombo->setCurrentFont(f);
fontFamilyCombo->setToolTip( tr("Font") );
bar->addWidget(fontFamilyCombo);
bool ok = connect(fontFamilyCombo, SIGNAL(currentFontChanged(const QFont&)),
- this, SLOT(slotFontFamilyChoosen(const QFont&)));
+ this, SLOT(slotFontFamilyChosen(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontChanged(const QFont&)), fontFamilyCombo, SLOT(setCurrentFont(const QFont&)));
+ ok = connect(this, SIGNAL(signalFontChanged(const QFont&)),
+ fontFamilyCombo, SLOT(setCurrentFont(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------font size chooser-------------------------
BtFontSizeWidget* fontSizeChooser = new BtFontSizeWidget(this);
+ fontSizeChooser->setFontSize(f.pointSize());
fontSizeChooser->setToolTip( tr("Font size") );
bar->addWidget(fontSizeChooser);
- ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)),
+ this, SLOT(slotFontSizeChosen(int)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontSizeChanged(int)), fontSizeChooser, SLOT(setFontSize(int)));
+ ok = connect(this, SIGNAL(signalFontSizeChanged(int)),
+ fontSizeChooser, SLOT(setFontSize(int)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------color button-------------------------
- BtColorWidget* colorChooser = new BtColorWidget();
- colorChooser->setToolTip(tr("Font color"));
- bar->addWidget(colorChooser);
- ok = connect(colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ BtColorWidget* fontColorChooser = new BtColorWidget();
+ fontColorChooser->setColor(textColor());
+ fontColorChooser->setToolTip(tr("Font color"));
+ bar->addWidget(fontColorChooser);
+ ok = connect(fontColorChooser, SIGNAL(changed(const QColor&)),
+ this, SLOT(slotFontColorChosen(const QColor&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(setColor(const QColor&)), colorChooser, SLOT(setColor(const QColor&)));
+ ok = connect(this, SIGNAL(signalFontColorChanged(const QColor&)),
+ fontColorChooser, SLOT(setColor(QColor)), Qt::DirectConnection);
Q_ASSERT(ok);
bar->addSeparator();
@@ -233,13 +273,4 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
bar->addAction(m_actions.alignLeft);
bar->addAction(m_actions.alignCenter);
bar->addAction(m_actions.alignRight);
-
- connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
- connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
- connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
-
- //set initial values for toolbar items
- slotFontChanged( font() );
- slotAlignmentChanged( alignment() );
- slotColorChanged( textColor() );
}
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index e8e4e7c..1bc9dd0 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +18,7 @@
class BtActionCollection;
class BtColorWidget;
class BtFontSizeWidget;
-class CWriteWindow;
+class CHTMLWriteWindow;
class QAction;
class QFontComboBox;
class QMenu;
@@ -29,6 +31,9 @@ class QWidget;
class CHTMLWriteDisplay : public CPlainWriteDisplay {
Q_OBJECT
public:
+
+ CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Sets the new text for this display widget. (CPlainWriteDisplay).
*/
@@ -45,41 +50,29 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
protected:
- friend class CDisplay;
- CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- ~CHTMLWriteDisplay();
+
+ void alignmentChanged(int);
protected slots:
- void toggleBold(bool);
- void toggleItalic(bool);
- void toggleUnderline(bool);
+ void toggleBold(bool checked);
+ void toggleItalic(bool checked);
+ void toggleUnderline(bool checked);
void alignLeft(bool);
void alignCenter(bool);
void alignRight(bool);
- void changeFontSize(int);
+ void slotFontFamilyChosen(const QFont&);
+ void slotFontSizeChosen(int);
+ void slotFontColorChosen( const QColor& );
- void slotFontChanged( const QFont& );
- void slotFontFamilyChoosen(const QFont&);
-
- /**
- * The text's alignment changed. Enable the right buttons.
- */
- void slotAlignmentChanged( int );
- /**
- * Is called when a new color was selected.
- */
- void slotColorSelected( const QColor& );
- /**
- * Is called when a text with another color was selected.
- */
- void slotColorChanged( const QColor& );
+ void slotCurrentCharFormatChanged(const QTextCharFormat &);
signals:
- void fontChanged(const QFont& font);
- void fontSizeChanged(int);
- void setColor(const QColor&);
+
+ void signalFontChanged(const QFont &);
+ void signalFontSizeChanged(int);
+ void signalFontColorChanged(const QColor &);
private:
struct {
@@ -90,11 +83,10 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
QAction* alignLeft;
QAction* alignCenter;
QAction* alignRight;
-
- //popup menu
- QAction* selectAll;
}
m_actions;
+
+ bool m_handingFormatChangeFromEditor;
};
#endif
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index 07cecf3..e4b22d5 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,10 +19,13 @@
#include "frontend/cdragdrop.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
+CPlainWriteDisplay::CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent)
+ : QTextEdit(parentWindow ? parentWindow : parent)
+ , CDisplay(parentWindow)
+{
setAcceptRichText(false);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index 575789e..dad57a1 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,22 +13,21 @@
#define CPLAINWRITEDISPLAY_H
#include <QTextEdit>
-#include "frontend/display/cwritedisplay.h"
+#include "frontend/display/cdisplay.h"
class BtActionCollection;
-class CHTMLWriteDisplay;
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QDropEvent;
-class QMenu;
-class QWidget;
+class CPlainWriteWindow;
+class QToolBar;
/** The write display implementation for plain source code editing.
* @author The BibleTime team
*/
-class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
+class CPlainWriteDisplay : public QTextEdit, public CDisplay {
public:
+
+ CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Reimplementation.
*/
@@ -52,27 +53,21 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
const DisplayOptions &,
const FilterOptions &) {}
- /**
- * Reimplementation (CWriteDisplay).
- */
virtual bool isModified() const;
/**
- * Sets the current status of the edit widget (CWriteDisplay).
+ * Sets the current status of the edit widget.
*/
virtual void setModified( const bool modified );
/**
- * Returns the text of this edit widget (CWriteDisplay).
+ * Returns the text of this edit widget.
*/
virtual const QString plainText();
/**
- * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
+ * Creates the necessary action objects and puts them on the toolbar.
*/
virtual void setupToolbar(QToolBar*, BtActionCollection*);
protected:
- friend class CDisplay;
-
- CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
/**
* Reimplementation from QTextEdit to manage drops of our drag and drop objects.
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index f1b2f65..f5c3459 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index 4b6dbeb..dd25a76 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +18,8 @@
#include "backend/managers/cswordbackend.h"
+class CReadWindow;
+
/** The base class for all read-only widgets like KHTMLView.
*@author The BibleTime team
*/
diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp
deleted file mode 100644
index 47a3302..0000000
--- a/src/frontend/display/cwritedisplay.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/display/cwritedisplay.h"
-
-#include "frontend/displaywindow/cwritewindow.h"
-
-
-CWriteDisplay::CWriteDisplay( CWriteWindow* writeWindow ) : CDisplay(writeWindow) {
- // Intentionally empty
-}
-
-CWriteDisplay::~CWriteDisplay() {
- // Intentionally empty
-}
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
deleted file mode 100644
index 0010749..0000000
--- a/src/frontend/display/cwritedisplay.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CWRITEDISPLAY_H
-#define CWRITEDISPLAY_H
-
-#include "frontend/display/cdisplay.h"
-
-
-class BtActionCollection;
-class QToolBar;
-
-/** The base class for all read/write-display classes.
- *@author The BibleTime team
- */
-class CWriteDisplay : public CDisplay {
- protected:
-
- CWriteDisplay( CWriteWindow* writeWindow );
- ~CWriteDisplay();
-
- public: // Public methods
- /**
- * Sets the current modified status of the widget.
- */
- virtual void setModified( const bool modified ) = 0;
- /**
- * Returns true if the current text was modified.
- */
- virtual bool isModified() const = 0;
- /**
- * Returns the text of this edit widget.
- */
- virtual const QString plainText() = 0;
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- */
- virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
-};
-
-#endif
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index 55909b7..f25b972 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,10 +12,8 @@
#include <QAction>
#include <QDebug>
#include <QKeySequence>
-#include <QSettings>
#include <QString>
#include <QStringList>
-#include "backend/config/cbtconfig.h"
#include "util/directory.h"
@@ -40,7 +38,7 @@ QList<QAction*> BtActionCollection::actions() {
QList<QAction*> actionList;
for (ActionMap::const_iterator iter = m_actions.constBegin();
iter != m_actions.constEnd();
- iter++)
+ ++iter)
{
actionList.append(iter.value()->action);
}
@@ -79,7 +77,7 @@ QAction* BtActionCollection::addAction(const QString &name, const QObject *recei
QKeySequence BtActionCollection::getDefaultShortcut(QAction* action) {
for (ActionMap::const_iterator iter = m_actions.constBegin();
iter != m_actions.constEnd();
- iter++)
+ ++iter)
{
if (iter.value()->action == action) {
return iter.value()->defaultKeys;
@@ -88,57 +86,26 @@ QKeySequence BtActionCollection::getDefaultShortcut(QAction* action) {
return QKeySequence();
}
-void BtActionCollection::readSettings() {
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
-
- Q_FOREACH (const QString &key, settings->childKeys()) {
- QAction *a = action(key);
+void BtActionCollection::readShortcuts(const QString &group) {
+ QHash<QString, QList <QKeySequence > > shortcuts = btConfig().getShortcuts(group);
+ for(QHash<QString, QList <QKeySequence> >::const_iterator iter = shortcuts.begin();
+ iter != shortcuts.end();
+ ++iter)
+ {
+ QAction *a = action(iter.key());
if (a == 0)
continue;
-
- QVariant variant = settings->value(key);
- // qDebug() << variant << " | " << variant.typeName();
- if (variant.type() != QVariant::List
- && variant.type() != QVariant::StringList)
- {
- continue;
- }
-
- QList<QKeySequence> shortcuts;
- if (variant.type() == QVariant::List) { // For BibleTime before 2.9
- Q_FOREACH (const QVariant &shortcut, variant.toList()) {
- shortcuts.append(shortcut.toString());
- }
- } else {
- Q_ASSERT(variant.type() == QVariant::StringList);
- Q_FOREACH (const QString &shortcut, variant.toStringList()) {
- shortcuts.append(shortcut);
- }
- }
- a->setShortcuts(shortcuts);
+ action(iter.key())->setShortcuts(iter.value());
}
-
- settings->endGroup();
}
-void BtActionCollection::writeSettings() {
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
-
+void BtActionCollection::writeShortcuts(const QString &group) {
+ QHash< QString, QList<QKeySequence> > shortcuts;
for (ActionMap::const_iterator iter = m_actions.constBegin();
- iter != m_actions.constEnd();
- iter++)
+ iter != m_actions.constEnd();
+ ++iter)
{
- // Write beautiful string lists (since 2.9):
- QStringList varList;
- Q_FOREACH (const QKeySequence &shortcut, iter.value()->action->shortcuts()) {
- /// \note saving QKeySequences directly doesn't appear to work!
- varList.append(shortcut.toString());
- }
- settings->setValue(iter.key(), varList);
- // qDebug() << ">>" << settings->value(iter.key()).typeName();
+ shortcuts.insert(iter.key(), iter.value()->action->shortcuts());
}
-
- settings->endGroup();
+ btConfig().setShortcuts(group, shortcuts);
}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index e99522d..a4d062f 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,10 +17,12 @@
#include <QList>
#include <QMap>
+#include "backend/config/btconfig.h"
class BtActionItem;
class QAction;
class QKeySequence;
+class QString;
class BtActionCollection: public QObject {
@@ -40,20 +44,31 @@ class BtActionCollection: public QObject {
QAction *action(const QString &name) const;
- inline void setConfigGroup(const QString &group) {
- m_groupName = group;
- }
-
- void readSettings();
-
- void writeSettings();
-
+ /*!
+ * \brief Read shortcuts from config.
+ *
+ * Read the shortcuts for the given group
+ * from the configuration and add them to
+ * this action collection.
+ *
+ * \param[in] group Shortcut group to read actions from.
+ */
+ void readShortcuts(const QString &group);
+
+ /*!
+ * \brief Write shortcuts to config.
+ *
+ * Write the shortcuts of this action collection
+ * to the given group in the configuration.
+ *
+ * \param[in] group Shortcut group to write actions to.
+ */
+ void writeShortcuts(const QString& group);
QKeySequence getDefaultShortcut(QAction* action);
private: /* Fields: */
ActionMap m_actions;
- QString m_groupName;
};
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
index 597a965..bca9334 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,17 +14,16 @@
#include <QString>
#include <QToolTip>
#include <QToolButton>
-#include "util/directory.h"
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent)
: QToolButton(parent) {
- namespace DU = util::directory;
-
initMenu();
- setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));
+ setIcon(util::getIcon(CResMgr::displaywindows::displaySettings::icon));
setPopupMode(QToolButton::InstantPopup);
setEnabled(false);
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.h b/src/frontend/displaywindow/btdisplaysettingsbutton.h
index c7c8f09..f82f682 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.h
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbar.cpp b/src/frontend/displaywindow/btmodulechooserbar.cpp
index 22b5ca8..e8d80cb 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbar.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbar.h b/src/frontend/displaywindow/btmodulechooserbar.h
index 977d3c0..024bc08 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.h
+++ b/src/frontend/displaywindow/btmodulechooserbar.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.cpp b/src/frontend/displaywindow/btmodulechooserbutton.cpp
index 200da78..4e0a5fc 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,11 +15,12 @@
#include <QString>
#include <QToolButton>
#include <QToolTip>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtModuleChooserButton::BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype)
@@ -58,7 +59,6 @@ void BtModuleChooserButton::updateMenu(QStringList newModulesToUse, QString this
m_module = thisModule;
m_hasModule = thisModule.isEmpty() ? false : true;
- namespace DU = util::directory;
//All items are iterated and the state is changed properly
QListIterator<QMenu*> it(m_submenus);
@@ -70,7 +70,7 @@ void BtModuleChooserButton::updateMenu(QStringList newModulesToUse, QString this
}
}
m_noneAction->setChecked(m_hasModule ? false : true);
- setIcon(DU::getIcon(iconName()));
+ setIcon(util::getIcon(iconName()));
if (m_hasModule) {
setToolTip( QString(tr("Select a work [%1]")).arg(m_module) );
@@ -141,7 +141,7 @@ void BtModuleChooserButton::populateMenu() {
// Filters: add only non-hidden and right type
BTModuleTreeItem::HiddenOff hiddenFilter;
QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>("GUI/bookshelfShowHidden", false)) {
filters.append(&hiddenFilter);
}
TypeFilter typeFilter(m_moduleType);
@@ -150,7 +150,7 @@ void BtModuleChooserButton::populateMenu() {
if (m_moduleType == CSwordModuleInfo::Bible) {
BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
QList<BTModuleTreeItem::Filter*> filters2;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>("GUI/bookshelfShowHidden", false)) {
filters2.append(&hiddenFilter);
}
TypeFilter typeFilter2(CSwordModuleInfo::Commentary);
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.h b/src/frontend/displaywindow/btmodulechooserbutton.h
index ba7d89e..03c2b9b 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.h
+++ b/src/frontend/displaywindow/btmodulechooserbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.cpp b/src/frontend/displaywindow/bttextwindowheader.cpp
index 71e98f0..6f108d7 100644
--- a/src/frontend/displaywindow/bttextwindowheader.cpp
+++ b/src/frontend/displaywindow/bttextwindowheader.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.h b/src/frontend/displaywindow/bttextwindowheader.h
index 6dd4b0a..2673d78 100644
--- a/src/frontend/displaywindow/bttextwindowheader.h
+++ b/src/frontend/displaywindow/bttextwindowheader.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
index 600bf15..a974c2c 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,11 +17,17 @@
#include <QSizePolicy>
#include <QLabel>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/bttextwindowheader.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
+
+
+namespace {
+const QString BookshelfShowHiddenKey = "GUI/bookshelfShowHidden";
+} // anonymous namespace
const char* ActionType = "ActionType";
@@ -81,7 +87,6 @@ void BtTextWindowHeaderWidget::updateWidget(QStringList newModulesToUse, QString
populateMenu();
m_module = thisModule;
- namespace DU = util::directory;
//All items are iterated and the state is changed properly
QListIterator<QMenu*> it(m_submenus);
@@ -147,18 +152,18 @@ void BtTextWindowHeaderWidget::populateMenu() {
m_removeAction = new QAction(tr("Remove"), m_popup);
m_removeAction->setProperty(ActionType, RemoveAction);
- m_removeAction->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::removemoduleicon));
+ m_removeAction->setIcon(util::getIcon(CResMgr::displaywindows::general::removemoduleicon));
m_popup->addAction(m_removeAction);
// Add Replace and Add menus, both have all modules in them
QMenu* replaceItem = new QMenu(tr("Replace"), m_popup);
- replaceItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::replacemoduleicon));
+ replaceItem->setIcon(util::getIcon(CResMgr::displaywindows::general::replacemoduleicon));
replaceItem->setProperty(ActionType, ReplaceAction);
m_popup->addMenu(replaceItem);
QMenu* addItem = new QMenu(tr("Add"), m_popup);
addItem->setProperty(ActionType, AddAction);
- addItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::addmoduleicon));
+ addItem->setIcon(util::getIcon(CResMgr::displaywindows::general::addmoduleicon));
m_popup->addMenu(addItem);
QList<QMenu*> toplevelMenus;
@@ -170,7 +175,7 @@ void BtTextWindowHeaderWidget::populateMenu() {
// Filters: add only non-hidden, non-locked and correct type
BTModuleTreeItem::HiddenOff hiddenFilter;
QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>(BookshelfShowHiddenKey, false)) {
filters.append(&hiddenFilter);
}
TypeFilter typeFilter(m_moduleType);
@@ -179,7 +184,7 @@ void BtTextWindowHeaderWidget::populateMenu() {
if (m_moduleType == CSwordModuleInfo::Bible) {
BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
QList<BTModuleTreeItem::Filter*> filters2;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>(BookshelfShowHiddenKey, false)) {
filters2.append(&hiddenFilter);
}
if (menu == addItem || menu == replaceItem) {
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.h b/src/frontend/displaywindow/bttextwindowheaderwidget.h
index 02e0310..c69bf11 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.h
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 1a5593b..e443f8a 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index ebbc848..4999098 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btwindowmodulechooser.h b/src/frontend/displaywindow/btwindowmodulechooser.h
index a39e7a1..40ffcf0 100644
--- a/src/frontend/displaywindow/btwindowmodulechooser.h
+++ b/src/frontend/displaywindow/btwindowmodulechooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index aa6ae6b..4d88f13 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +16,6 @@
#include <QMenu>
#include <QTimer>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/keys/cswordversekey.h"
#include "frontend/cexportmanager.h"
@@ -26,44 +25,19 @@
#include "frontend/displaywindow/ccommentaryreadwindow.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
#include "util/directory.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-using namespace Profile;
+void CBibleReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
-CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
- : CLexiconReadWindow(moduleList, parent) {
-}
-
-CBibleReadWindow::~CBibleReadWindow() {
-}
-
-void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
- /**
- \todo Make CProfileWindow properly handle these things so we wouldn't have
- to mess around with bits.
- */
- CLexiconReadWindow::applyProfileSettings(settings);
-
- int result = settings->windowSettings;
-
- filterOptions().footnotes = (result & 0x0001) != 0;
- filterOptions().strongNumbers = (result & 0x0002) != 0;
- filterOptions().headings = (result & 0x0004) != 0;
- filterOptions().morphTags = (result & 0x0008) != 0;
- filterOptions().lemmas = (result & 0x0010) != 0;
- filterOptions().hebrewPoints = (result & 0x0020) != 0;
- filterOptions().hebrewCantillation = (result & 0x0040) != 0;
- filterOptions().greekAccents = (result & 0x0080) != 0;
- filterOptions().textualVariants = (result & 0x0100) != 0;
- filterOptions().redLetterWords = (result & 0x0200) != 0;
- filterOptions().scriptureReferences = (result & 0x0400) != 0;
- filterOptions().morphSegmentation = (result & 0x0800) != 0;
- displayOptions().lineBreaks = (result & 0x1000) != 0;
- displayOptions().verseNumbers = (result & 0x2000) != 0;
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ filterOptions() = conf.getFilterOptions();
+ displayOptions() = conf.getDisplayOptions();
+ conf.endGroup();
emit sigFilterOptionsChanged(filterOptions());
emit sigDisplayOptionsChanged(displayOptions());
@@ -72,31 +46,14 @@ void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
lookup();
}
-void CBibleReadWindow::storeProfileSettings( CProfileWindow * const settings) {
- /**
- \todo Make CProfileWindow properly handle these things so we wouldn't have
- to mess around with bits.
- */
-
- int result = 0x0000;
- if (filterOptions().footnotes) result |= 0x0001;
- if (filterOptions().strongNumbers) result |= 0x0002;
- if (filterOptions().headings) result |= 0x0004;
- if (filterOptions().morphTags) result |= 0x0008;
- if (filterOptions().lemmas) result |= 0x0010;
- if (filterOptions().hebrewPoints) result |= 0x0020;
- if (filterOptions().hebrewCantillation) result |= 0x0040;
- if (filterOptions().greekAccents) result |= 0x0080;
- if (filterOptions().textualVariants) result |= 0x0100;
- if (filterOptions().redLetterWords) result |= 0x0200;
- if (filterOptions().scriptureReferences) result |= 0x0400;
- if (filterOptions().morphSegmentation) result |= 0x0800;
- if (displayOptions().lineBreaks) result |= 0x1000;
- if (displayOptions().verseNumbers) result |= 0x2000;
-
- settings->windowSettings = result;
-
- CLexiconReadWindow::storeProfileSettings(settings);
+void CBibleReadWindow::storeProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ conf.setFilterOptions(filterOptions());
+ conf.setDisplayOptions(displayOptions());
+ conf.endGroup();
+
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
}
@@ -274,7 +231,7 @@ void CBibleReadWindow::initActions() {
this, SLOT(printAll()));
addAction(m_actions.print.chapter);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
+ ac->readShortcuts("Bible shortcuts");
}
void CBibleReadWindow::initConnections() {
@@ -405,11 +362,11 @@ void CBibleReadWindow::copyDisplayedText() {
dummy.setVerse(1);
CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(false, tr("Copying"), filterOptions(), displayOptions());
mgr.copyKey(&vk, CExportManager::Text, true);
@@ -425,10 +382,10 @@ void CBibleReadWindow::saveChapterHTML() {
dummy.setVerse(1);
CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(&vk, CExportManager::HTML, true);
@@ -442,11 +399,11 @@ void CBibleReadWindow::saveChapterPlain() {
CSwordVerseKey dummy(*verseKey());
dummy.setVerse(1);
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(&vk, CExportManager::Text, true);
@@ -464,7 +421,7 @@ void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
+ actionCollection()->readShortcuts("Bible shortcuts");
}
/** No descriptions */
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 198c4fd..99c98fb 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,28 +24,21 @@ class QEvent;
class QMenu;
class QObject;
-/** The read display window for Bibles.
- *@author The BibleTime team
- */
-class CBibleReadWindow : public CLexiconReadWindow {
+class CBibleReadWindow: public CLexiconReadWindow {
+
Q_OBJECT
- public:
- CBibleReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CBibleReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Reimplementation.
- */
+
+ public: /* Methods: */
+
+ inline CBibleReadWindow(const QList<CSwordModuleInfo*> & modules, CMDIArea* parent)
+ : CLexiconReadWindow(modules, parent) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
static void insertKeyboardActions( BtActionCollection* const a );
- protected:
+ protected: /* Methods: */
+
virtual void initActions();
virtual void initToolbars();
virtual void initConnections();
@@ -97,6 +92,7 @@ class CBibleReadWindow : public CLexiconReadWindow {
public slots:
+
void nextBook();
void previousBook();
void nextChapter();
@@ -108,7 +104,8 @@ class CBibleReadWindow : public CLexiconReadWindow {
*/
virtual void reload(CSwordBackend::SetupChangedReason reason);
- protected slots: // Protected slots
+ protected slots:
+
/**
* Copies the current chapter into the clipboard.
*/
@@ -124,14 +121,13 @@ class CBibleReadWindow : public CLexiconReadWindow {
virtual void lookupSwordKey( CSwordKey* newKey );
void syncWindows();
- private:
+ private: /* Methods: */
/**
* Wrapper around key() to return the right type of key.
*/
CSwordVerseKey* verseKey();
- // CTransliterationButton* m_transliterationButton;
};
-#endif
+#endif /* CBIBLEREADWINDOW_H */
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index ff2adf2..fade4d5 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,41 +14,31 @@
#include <QSplitter>
#include <QToolBar>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordtreekey.h"
-#include "frontend/display/cdisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/cbooktreechooser.h"
-#include "frontend/profile/cprofilewindow.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-using namespace Profile;
+void CBookReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
-CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CLexiconReadWindow(modules, parent), m_treeAction(0), m_treeChooser(0) {
-}
-
-CBookReadWindow::~CBookReadWindow() {
-}
-
-void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::applyProfileSettings(profileWindow);
-
- if (profileWindow->windowSettings) {
+ Q_ASSERT(m_treeAction);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ if (btConfig().sessionValue<bool>(windowGroup + "treeShown", true) != m_treeAction->isChecked())
m_treeAction->activate(QAction::Trigger);
- }
}
-void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::storeProfileSettings(profileWindow);
+void CBookReadWindow::storeProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
- //store information about our show tree structure button
- profileWindow->windowSettings = m_treeAction->isChecked();
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "treeShown", m_treeAction->isChecked());
}
void CBookReadWindow::initActions() {
@@ -70,7 +60,7 @@ void CBookReadWindow::initActions() {
this, SLOT(treeToggled()));
addAction(m_treeAction);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
+ ac->readShortcuts("Book shortcuts");
}
void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
@@ -96,7 +86,7 @@ void CBookReadWindow::initConnections() {
void CBookReadWindow::initView() {
QSplitter* splitter = new QSplitter(this);
m_treeChooser = new CBookTreeChooser(modules(), history(), key(), splitter);
- setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+ setDisplayWidget(new BtHtmlReadDisplay(this, splitter));
m_treeChooser->hide();
// Create Navigation toolbar
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index 8b85504..63f3922 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's BtActionCollection code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,33 +17,30 @@ class BtActionCollection;
class CBookTreeChooser;
class QAction;
-/**
- * @author The BibleTime team
- */
-class CBookReadWindow : public CLexiconReadWindow {
+class CBookReadWindow: public CLexiconReadWindow {
+
Q_OBJECT
- public:
- static void insertKeyboardActions( BtActionCollection* const a );
- CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ public: /* Methods: */
- virtual ~CBookReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ inline CBookReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
+ : CLexiconReadWindow(modules, parent)
+ , m_treeAction(0)
+ , m_treeChooser(0) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
+ static void insertKeyboardActions(BtActionCollection * const a);
public slots:
+
/**
* Refreshes the content of this display window and the content of the keychooser.
*/
virtual void reload(CSwordBackend::SetupChangedReason reason);
- protected:
+ protected: /* Methods: */
+
virtual void initActions();
virtual void initToolbars();
virtual void initConnections();
@@ -53,21 +50,24 @@ class CBookReadWindow : public CLexiconReadWindow {
virtual void setupPopupMenu();
- protected slots: // Protected slots
+ protected slots:
+
/**
* Reimplementation to take care of the tree chooser.
*/
virtual void modulesChanged();
- private:
- QAction* m_treeAction;
- CBookTreeChooser* m_treeChooser;
+ private slots:
- private slots: // Private slots
/**
* Is called when the action was executed to toggle the tree view.
*/
void treeToggled();
+
+ private: /* Fields: */
+
+ QAction * m_treeAction;
+ CBookTreeChooser * m_treeChooser;
};
#endif
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index f2c2c3d..1beb5c5 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,25 +13,19 @@
#include <QIcon>
#include <QMenu>
#include <QToolBar>
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {
-}
void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
- namespace DU = util::directory;
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -58,7 +52,7 @@ void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
- qaction = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ qaction = new QAction(QIcon(util::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
tr("Synchronize"), a);
qaction->setCheckable(true);
qaction->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
@@ -120,19 +114,23 @@ void CCommentaryReadWindow::initActions() {
m_syncButton = qaction;
addAction(qaction);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ actionCollection()->readShortcuts("Commentary shortcuts");
}
-void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- m_syncButton->setChecked(true);
- }
+void CCommentaryReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
+
+ Q_ASSERT(windowGroup.endsWith('/'));
+ Q_ASSERT(m_syncButton);
+ m_syncButton->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncEnabled", false));
}
-void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::storeProfileSettings(profileWindow);
- profileWindow->windowSettings = m_syncButton->isChecked();
+void CCommentaryReadWindow::storeProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
+
+ Q_ASSERT(windowGroup.endsWith('/'));
+ Q_ASSERT(m_syncButton);
+ btConfig().setSessionValue(windowGroup + "syncEnabled", m_syncButton->isChecked());
}
void CCommentaryReadWindow::initToolbars() {
@@ -153,7 +151,7 @@ void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ actionCollection()->readShortcuts("Commentary shortcuts");
}
/** rapper around key() to return the right type of key. */
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index 679906c..06cbd93 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,15 +30,11 @@ class CCommentaryReadWindow : public CLexiconReadWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
- CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ inline CCommentaryReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
+ : CLexiconReadWindow(modules, parent) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
virtual bool syncAllowed() const;
public slots: // Public slots
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 0b9bc61..a584d6e 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,12 +11,14 @@
#include <QCloseEvent>
#include <QDebug>
+#include <QMdiSubWindow>
#include <QMenu>
#include <QStringList>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordkey.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/cmdiarea.h"
#include "frontend/display/cdisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
@@ -25,15 +27,12 @@
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/keychooser/bthistory.h"
-#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
+CDisplayWindow::CDisplayWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
: QMainWindow(parent),
m_actionCollection(0),
m_mdi(parent),
@@ -69,8 +68,17 @@ CDisplayWindow::~CDisplayWindow() {
m_swordKey = 0;
}
+QWidget * CDisplayWindow::getProfileWindow() const {
+ for (QWidget * w = parentWidget(); w; w = w->parentWidget()) {
+ QMdiSubWindow * sw = qobject_cast<QMdiSubWindow *>(w);
+ if (sw)
+ return sw;
+ }
+ return const_cast<CDisplayWindow *>(this);
+}
+
BibleTime* CDisplayWindow::btMainWindow() {
- return dynamic_cast<BibleTime*>(m_mdi->parent());
+ return dynamic_cast<BibleTime*>(m_mdi->parent()->parent());
}
void CDisplayWindow::setToolBarsHidden() {
@@ -110,9 +118,77 @@ const QList<const CSwordModuleInfo*> CDisplayWindow::modules() const {
return CSwordBackend::instance()->getConstPointerList(m_modules);
}
-void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
- namespace DU = util::directory;
+/** Store the settings of this window in the given CProfileWindow object. */
+void CDisplayWindow::storeProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+
+ conf.beginGroup(windowGroup);
+
+ QWidget * w = getProfileWindow();
+
+ /**
+ \note We don't use saveGeometry/restoreGeometry for MDI subwindows,
+ because they give slightly incorrect results with some window
+ managers. Might be related to Qt bug QTBUG-7634.
+ */
+ const QRect rect(w->x(), w->y(), w->width(), w->height());
+ conf.setSessionValue<QRect>("windowRect", rect);
+
+ conf.setSessionValue("maximized", w->isMaximized());
+
+ bool hasFocus = (w == dynamic_cast<CDisplayWindow *>(mdi()->activeSubWindow()));
+ conf.setSessionValue("hasFocus", hasFocus);
+ // conf.setSessionValue("type", static_cast<int>(modules().first()->type()));
+
+ // Save current key:
+ if (key()) {
+ CSwordKey * k = key();
+ sword::VerseKey * vk = dynamic_cast<sword::VerseKey*>(k);
+ QString oldLang;
+ if (vk) {
+ // Save keys in english only:
+ const QString oldLang = QString::fromLatin1(vk->getLocale());
+ vk->setLocale("en");
+ conf.setSessionValue("key", k->key());
+ vk->setLocale(oldLang.toLatin1());
+ } else {
+ conf.setSessionValue("key", k->key());
+ }
+ }
+ // Save list of modules:
+ QStringList mods;
+ Q_FOREACH (const CSwordModuleInfo * module, modules())
+ mods.append(module->name());
+ conf.setSessionValue("modules", mods);
+
+ conf.endGroup();
+}
+
+void CDisplayWindow::applyProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ setUpdatesEnabled(false);
+
+ QWidget * w = getProfileWindow();
+
+ /**
+ \note We don't use restoreGeometry/saveGeometry for MDI subwindows,
+ because they give slightly incorrect results with some window
+ managers. Might be related to Qt bug QTBUG-7634.
+ */
+ const QRect rect = conf.sessionValue<QRect>("windowRect");
+ w->resize(rect.width(), rect.height());
+ w->move(rect.x(), rect.y());
+
+ if (conf.sessionValue<bool>("maximized"))
+ w->showMaximized();
+
+ setUpdatesEnabled(true);
+ conf.endGroup();
+}
+
+void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
QAction* actn = new QAction(QIcon(), tr("Select all"), a);
actn->setShortcut(QKeySequence::SelectAll);
a->addAction("selectAll", actn);
@@ -129,13 +205,13 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
actn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
a->addAction("openLocation", actn);
- actn = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::general::search::icon)),
+ actn = new QAction(QIcon(util::getIcon(CResMgr::displaywindows::general::search::icon)),
tr("Search with works of this window"), a);
actn->setShortcut(CResMgr::displaywindows::general::search::accel);
a->addAction(CResMgr::displaywindows::general::search::actionName, actn);
BtToolBarPopupAction* action = new BtToolBarPopupAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ QIcon(util::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
tr("Back in history"),
a
);
@@ -143,7 +219,7 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
action = new BtToolBarPopupAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ QIcon(util::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
tr("Forward in history"),
a
);
@@ -201,7 +277,7 @@ void CDisplayWindow::initActions() {
Q_ASSERT(ok);
addAction(actn);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, ac);
+ ac->readShortcuts("Displaywindow shortcuts");
}
/** Refresh the settings of this window. */
@@ -223,8 +299,8 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
lookup();
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, actionCollection());
- CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
+ actionCollection()->readShortcuts("DisplayWindow shortcuts");
+ actionCollection()->readShortcuts("Readwindow shortcuts");
emit sigModuleListSet(m_modules);
}
@@ -316,7 +392,7 @@ void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
m_moduleChooserBar = bar;
bar->setWindowTitle(tr("Work chooser buttons"));
bar->setLayoutDirection(Qt::LeftToRight);
- bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ bar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
}
}
@@ -325,7 +401,7 @@ void CDisplayWindow::setHeaderBar( QToolBar* header ) {
m_headerBar = header;
header->setMovable(false);
header->setWindowTitle(tr("Text area header"));
- header->setVisible(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+ header->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowHeaders", true));
}
/** Sets the modules. */
@@ -348,15 +424,15 @@ bool CDisplayWindow::init() {
parentWidget()->setFocusPolicy(Qt::ClickFocus);
initActions();
initToolbars();
- if ( ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ if (!btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
setToolBarsHidden();
btMainWindow()->clearMdiToolBars();
clearMainWindowToolBars();
initConnections();
setupPopupMenu();
- m_filterOptions = CBTConfig::getFilterOptionDefaults();
- m_displayOptions = CBTConfig::getDisplayOptionDefaults();
+ m_filterOptions = btConfig().getFilterOptions();
+ m_displayOptions = btConfig().getDisplayOptions();
emit sigDisplayOptionsChanged(m_displayOptions);
emit sigFilterOptionsChanged(m_filterOptions);
emit sigModulesChanged(modules());
@@ -374,13 +450,13 @@ static void prepareToolBar(QToolBar* bar, const QString& title, bool visible) {
/** Setup the Navigation toolbar. */
void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
- prepareToolBar(bar, tr("Navigation"), CBTConfig::get(CBTConfig::showTextWindowNavigator) );
+ prepareToolBar(bar, tr("Navigation"), btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
m_mainToolBar = bar;
}
/** Setup the Tools toolbar. */
void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
- prepareToolBar(bar, tr("Tool"), CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
+ prepareToolBar(bar, tr("Tool"), btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
m_buttonsToolBar = bar;
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 4935d8f..72199d1 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +17,6 @@
#include <QStringList>
#include "backend/managers/cswordbackend.h"
#include "btglobal.h"
-#include "frontend/profile/cprofilewindow.h"
class BtActionCollection;
@@ -25,14 +26,13 @@ class CKeyChooser;
class CMDIArea;
class BtModuleChooserBar;
class CSwordModuleInfo;
-class QCloseEvent;
class QMenu;
class QToolBar;
class BTHistory;
class BibleTime;
-/** The base class for all display windows of BibleTime.
- *
+/** The base class for all display windows of BibleTime.
+ *
* Inherits QMainWindow.
*
* Inherited by CReadWindow and CWriteWindow.
@@ -46,6 +46,9 @@ class CDisplayWindow : public QMainWindow {
/** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
+ /** Returns a pointer to the parent widget of type QMdiSubWindow or pointer to self if none found. */
+ QWidget * getProfileWindow() const;
+
/** Returns pointer to the mdi area object.*/
inline CMDIArea *mdi() const {
return m_mdi;
@@ -63,10 +66,10 @@ class CDisplayWindow : public QMainWindow {
}
/** Store the settings of this window in the given CProfileWindow object.*/
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ virtual void storeProfileSettings(const QString & windowGroup);
/** Load the settings the given CProfileWindow object into this window.*/
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ virtual void applyProfileSettings(const QString & windowGroup);
/** Returns the display options used by this display window. */
inline const DisplayOptions &displayOptions() const {
@@ -228,7 +231,7 @@ class CDisplayWindow : public QMainWindow {
friend class CBibleReadWindow;
- CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ CDisplayWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
virtual ~CDisplayWindow();
/**
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index e280c6d..12059d1 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.cpp
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,11 +17,10 @@
#include "frontend/displaywindow/clexiconreadwindow.h"
#include "frontend/displaywindow/cplainwritewindow.h"
#include "frontend/displaywindow/creadwindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/cmdiarea.h"
-CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent) {
+CReadWindow* CDisplayWindowFactory::createReadInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent) {
CReadWindow* win = 0;
switch (modules.first()->type()) {
case CSwordModuleInfo::Bible:
@@ -43,8 +42,8 @@ CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*>
return win;
}
-CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type) {
- if (type == CWriteWindow::HTMLWindow) {
+CPlainWriteWindow * CDisplayWindowFactory::createWriteInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent, CPlainWriteWindow::WriteWindowType type) {
+ if (type == CPlainWriteWindow::HTMLWindow) {
return new CHTMLWriteWindow(modules, parent);
}
else {
@@ -53,7 +52,7 @@ CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*
return 0;
}
-const CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
+CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
if (qobject_cast<CBibleReadWindow*>(widget) != 0 )
return CSwordModuleInfo::Bible;
if (qobject_cast<CCommentaryReadWindow*>(widget) != 0 )
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index 06d9aa4..e065e50 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,20 +13,18 @@
#define CDISPLAYWINDOWFACTORY_H
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-class CMDIArea;
class CReadWindow;
class CSwordModuleInfo;
-class CWriteWindow;
/// \todo Make CDisplayWindowFactory a namespace instead?
class CDisplayWindowFactory {
public:
- static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type = CWriteWindow::HTMLWindow);
- static const CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
+ static CReadWindow* createReadInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
+ static CPlainWriteWindow* createWriteInstance(const QList<CSwordModuleInfo*> & modules, CMDIArea * parent, CPlainWriteWindow::WriteWindowType type = CPlainWriteWindow::HTMLWindow);
+ static CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
private:
CDisplayWindowFactory();
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index 705daf0..20c8323 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,26 +14,22 @@
#include "bibletime.h"
#include "backend/keys/cswordkey.h"
#include "frontend/display/chtmlwritedisplay.h"
-#include "frontend/display/cwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
#include "util/cresmgr.h"
-using namespace Profile;
-
-CHTMLWriteWindow::CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+CHTMLWriteWindow::CHTMLWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
: CPlainWriteWindow(modules, parent) {}
void CHTMLWriteWindow::initView() {
- CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
- Q_ASSERT(writeDisplay);
- setDisplayWidget( writeDisplay );
- setCentralWidget( displayWidget()->view() );
+ m_writeDisplay = new CHTMLWriteDisplay(this, this);
+ Q_ASSERT(m_writeDisplay);
+ setDisplayWidget(m_writeDisplay);
+ setCentralWidget(m_writeDisplay->view() );
// Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
@@ -48,19 +44,11 @@ void CHTMLWriteWindow::initView() {
addToolBar(formatToolBar());
}
-void CHTMLWriteWindow::initActions() {
- insertKeyboardActions(actionCollection());
- CPlainWriteWindow::initActions();
-}
-
-void CHTMLWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
-}
-
void CHTMLWriteWindow::initConnections() {
- CWriteWindow::initConnections();
+ CPlainWriteWindow::initConnections();
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+ connect(m_writeDisplay->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
void CHTMLWriteWindow::initToolbars() {
@@ -69,39 +57,41 @@ void CHTMLWriteWindow::initToolbars() {
CPlainWriteWindow::initToolbars();
//Formatting toolbar
- ((CWriteDisplay*)displayWidget())->setupToolbar( formatToolBar(), actionCollection() );
+ m_writeDisplay->setupToolbar( formatToolBar(), actionCollection() );
}
-void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+void CHTMLWriteWindow::storeProfileSettings(const QString & windowGroup) {
+ CPlainWriteWindow::storeProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
Q_ASSERT(action != 0);
- profileWindow->windowSettings = action->isChecked();
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "syncWindowEnabled", action->isChecked());
}
-void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- action->setChecked(true);
- }
+void CHTMLWriteWindow::applyProfileSettings(const QString & windowGroup) {
+ CPlainWriteWindow::applyProfileSettings(windowGroup);
+
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action != 0);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ action->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncWindowEnabled", false));
}
/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
}
/** Loads the original text from the module. */
void CHTMLWriteWindow::restoreText() {
lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
@@ -113,7 +103,7 @@ bool CHTMLWriteWindow::syncAllowed() const {
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CHTMLWriteDisplay*)displayWidget())->toHtml();
+ QString t = m_writeDisplay->toHtml();
//since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
re.setMinimal(true);
@@ -125,11 +115,11 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
this->key()->setKey(oldKey);
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
else {
- util::showCritical( this, tr("Module not writable"),
+ message::showCritical( this, tr("Module not writable"),
QString::fromLatin1("<qt><b>%1</b><br />%2</qt>")
.arg( tr("Module is not writable.") )
.arg( tr("Either the module may not be edited, or you do not have write permission.") ) );
@@ -139,5 +129,5 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
void CHTMLWriteWindow::setupMainWindowToolBars() {
CPlainWriteWindow::setupMainWindowToolBars();
//Formatting toolbar
- ((CWriteDisplay*)displayWidget())->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
+ m_writeDisplay->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 8aec012..2d2eee6 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,9 +15,7 @@
#include "frontend/displaywindow/cplainwritewindow.h"
-class QAction;
-
-/**
+/**
* The write window class which offers a WYSIWYG text editor for creating a personal commentary.
*
* Inherits CPlainWriteWindow.
@@ -25,17 +25,10 @@ class QAction;
class CHTMLWriteWindow : public CPlainWriteWindow {
Q_OBJECT
public:
- CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
-
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* );
+ CHTMLWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* );
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
/**
* Returns true if the sync toolbar is enabled.
@@ -49,18 +42,12 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual void initActions();
-
- /**
- * Insert the keyboard accelerators of this window into the given KAccel object.
- */
- static void insertKeyboardActions( BtActionCollection* const a );
- virtual CWriteWindow::WriteWindowType writeWindowType() {
- return CWriteWindow::HTMLWindow;
+ virtual WriteWindowType writeWindowType() const {
+ return HTMLWindow;
}
- /**
- * Called to add actions to mainWindow toolbars
+ /**
+ * Called to add actions to mainWindow toolbars
*/
virtual void setupMainWindowToolBars();
@@ -77,6 +64,7 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Saves the text for the current key. Directly writes the changed text into the module.
*/
virtual void saveCurrentText( const QString& );
+
};
#endif
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 7d76293..3b76f38 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,13 +17,10 @@
#include <QDebug>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordkey.h"
#include "frontend/cexportmanager.h"
#include "frontend/display/bthtmlreaddisplay.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
@@ -36,7 +33,7 @@
#include "util/tool.h"
-CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
+CLexiconReadWindow::CLexiconReadWindow(const QList<CSwordModuleInfo *> & moduleList, CMDIArea * parent)
: CReadWindow(moduleList, parent) {
moduleList.first();
setKey( CSwordKey::createInstance(moduleList.first()) );
@@ -158,7 +155,7 @@ void CLexiconReadWindow::initActions() {
addAction(m_actions.print.entry);
// init with the user defined settings
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
+ ac->readShortcuts("Lexicon shortcuts");
}
/** No descriptions */
@@ -194,7 +191,7 @@ void CLexiconReadWindow::initConnections() {
void CLexiconReadWindow::initView() {
// Create display widget for this window
- setDisplayWidget( CDisplay::createReadInstance(this) );
+ setDisplayWidget(new BtHtmlReadDisplay(this, this));
setCentralWidget( displayWidget()->view() );
setWindowIcon(util::tool::getIconForModule(modules().first()));
@@ -320,7 +317,7 @@ void CLexiconReadWindow::updatePopupMenu() {
void CLexiconReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
CReadWindow::reload(reason);
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, actionCollection());
+ actionCollection()->readShortcuts("Lexicon shortcuts");
}
/** No descriptions */
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index 36b47db..6233545 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -33,7 +35,7 @@ class QMenu;
class CLexiconReadWindow : public CReadWindow {
Q_OBJECT
public:
- CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ CLexiconReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
virtual ~CLexiconReadWindow();
/** Insert the keyboard accelerators of this window into the given actioncollection.*/
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index f0af601..f4b2d0b 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,30 +14,55 @@
#include <QRegExp>
#include <QToolBar>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.h"
-#include "frontend/display/cwritedisplay.h"
+#include "bibletimeapp.h"
+#include "frontend/display/cplainwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
+#include "frontend/messagedialog.h"
+#include "util/btsignal.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CPlainWriteWindow::CPlainWriteWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent) :
- CWriteWindow(moduleList, parent) {
+CPlainWriteWindow::CPlainWriteWindow(const QList<CSwordModuleInfo*> & moduleList, CMDIArea * parent)
+ : CDisplayWindow(moduleList, parent)
+ , m_writeDisplay(0)
+{
setKey( CSwordKey::createInstance(moduleList.first()) );
}
+void CPlainWriteWindow::setDisplayWidget(CDisplay * display) {
+ Q_ASSERT(dynamic_cast<CPlainWriteDisplay *>(display));
+ CDisplayWindow::setDisplayWidget(static_cast<CPlainWriteDisplay *>(display));
+ m_writeDisplay = static_cast<CPlainWriteDisplay *>(display);
+}
+
+void CPlainWriteWindow::lookupSwordKey(CSwordKey * newKey) {
+ //set the raw text to the display widget
+ if (!newKey)
+ return;
+
+ /*
+ Set passage of newKey to key() if they're different, otherwise we'd get
+ mixed up if we look up newkey which may have a different module set.
+ */
+ if (key() != newKey)
+ key()->setKey(newKey->key());
+
+ if (modules().count())
+ displayWidget()->setText(key()->rawText());
+
+ setWindowTitle(windowCaption());
+}
+
/** Initialize the state of this widget. */
void CPlainWriteWindow::initView() {
// qWarning("CPlainWriteWindow::initView()");
- setDisplayWidget( CDisplay::createWriteInstance(this) );
- setCentralWidget( displayWidget()->view() );
+ m_writeDisplay = new CPlainWriteDisplay(this, this);
+ setDisplayWidget(m_writeDisplay);
+ setCentralWidget(m_writeDisplay->view());
// Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
@@ -49,8 +74,6 @@ void CPlainWriteWindow::initView() {
}
void CPlainWriteWindow::initToolbars() {
- namespace DU = util::directory;
-
// Navigation toolbar
setKeyChooser( CKeyChooser::createInstance(modules(),
history(), key(), mainToolBar()) );
@@ -94,30 +117,35 @@ void CPlainWriteWindow::setupMainWindowToolBars() {
}
void CPlainWriteWindow::initConnections() {
- CWriteWindow::initConnections();
+ Q_ASSERT(keyChooser());
+ QObject::connect(key()->beforeChangedSignaller(), SIGNAL(signal()), this, SLOT(beforeKeyChange()));
QObject::connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
QObject::connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
-void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- profileWindow->windowSettings = action->isChecked();
+void CPlainWriteWindow::storeProfileSettings(const QString & windowGroup) {
+ CDisplayWindow::storeProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "writeWindowType",
+ static_cast<int>(writeWindowType()));
+ btConfig().setSessionValue(windowGroup + "syncWindowEnabled", action->isChecked());
}
-void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- action->setChecked(true);
- }
+void CPlainWriteWindow::applyProfileSettings(const QString & windowGroup) {
+ CDisplayWindow::applyProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action != 0);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ action->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncWindowEnabled", false));
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CWriteDisplay*)displayWidget())->plainText();
+ QString t = m_writeDisplay->plainText();
//since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
re.setMinimal(true);
@@ -127,12 +155,12 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
this->key()->setKey(oldKey);
textChanged();
}
else {
- util::showCritical( this, tr("Module not writable"),
+ message::showCritical( this, tr("Module not writable"),
QString::fromLatin1("<qt><b>%1</b><br/>%2</qt>")
.arg( tr("Module is not writable.") )
.arg( tr("Either the module may not be edited, or "
@@ -143,7 +171,7 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
/** Loads the original text from the module. */
void CPlainWriteWindow::restoreText() {
lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
@@ -151,17 +179,17 @@ void CPlainWriteWindow::restoreText() {
void CPlainWriteWindow::textChanged() {
QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
}
/** Deletes the module entry and clears the edit widget, */
void CPlainWriteWindow::deleteEntry() {
const_cast<CSwordModuleInfo*>(modules().first())->deleteEntry(key());
lookupSwordKey( key() );
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
}
/** Setups the popup menu of this display widget. */
@@ -202,11 +230,8 @@ void CPlainWriteWindow::initActions() {
}
void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
-
- namespace DU = util::directory;
-
QAction* action = new QAction(
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ util::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
tr("Sync with active Bible"),
a
);
@@ -216,7 +241,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
tr("Save text"),
a
);
@@ -225,7 +250,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
tr("Delete current entry"),
a
);
@@ -234,7 +259,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
tr("Restore original text"),
a
);
@@ -242,3 +267,55 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
action->setToolTip( tr("Restore original text, new text will be lost") );
a->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, action);
}
+
+void CPlainWriteWindow::saveCurrentText() {
+ if (key())
+ saveCurrentText(key()->key());
+}
+
+
+bool CPlainWriteWindow::queryClose() {
+ //save the text if it has changed
+ if (m_writeDisplay->isModified()) {
+ switch (message::showQuestion( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: //save and close
+ saveCurrentText();
+ m_writeDisplay->setModified( false );
+ return true;
+ case QMessageBox::No: //don't save and close
+ return true;
+ default: // cancel, don't close
+ return false;
+ }
+ }
+ return true;
+}
+
+void CPlainWriteWindow::beforeKeyChange() {
+ Q_ASSERT(displayWidget());
+ Q_ASSERT(keyChooser());
+ if (!isReady())
+ return;
+
+ // Get current key string for this window
+ QString thisWindowsKey;
+ CSwordKey* oldKey = key();
+ if (oldKey == 0)
+ return;
+ thisWindowsKey = oldKey->key();
+
+ //If the text changed and we'd do a lookup ask the user if the text should be saved
+ if (modules().first() && m_writeDisplay->isModified()) {
+
+ switch (message::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: { //save the changes
+ saveCurrentText( thisWindowsKey );
+ break;
+ }
+ default: {// set modified to false so it won't ask again
+ m_writeDisplay->setModified(false);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index 732ff8a..cf11a46 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,12 +12,11 @@
#ifndef CPLAINWRITEWINDOW_H
#define CPLAINWRITEWINDOW_H
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
class BtActionCollection;
-class QAction;
-class QString;
+class CPlainWriteDisplay;
/** The write window class which offers a plain text editor for creating a personal commentary.
*
@@ -25,19 +26,24 @@ class QString;
*
* @author The BibleTime team
*/
-class CPlainWriteWindow : public CWriteWindow {
+class CPlainWriteWindow : public CDisplayWindow {
Q_OBJECT
public:
- CPlainWriteWindow( QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+
+ enum WriteWindowType {
+ HTMLWindow = 1,
+ PlainTextWindow = 2
+ };
+
+ CPlainWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
/**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
+ * Set the displayWidget which is a subclass of QWebPage.
*/
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ void setDisplayWidget( CDisplay* display );
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
/**
* Setups the popup menu of this display widget.
@@ -49,6 +55,13 @@ class CPlainWriteWindow : public CWriteWindow {
*/
virtual bool syncAllowed() const;
+ public slots:
+
+ /**
+ Look up the given key and display the text. In our case we offer to edit the text.
+ */
+ virtual void lookupSwordKey(CSwordKey * key);
+
protected: // Protected methods
/**
* Initialize the state of this widget.
@@ -56,9 +69,9 @@ class CPlainWriteWindow : public CWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CWriteWindow::WriteWindowType writeWindowType() {
- return CWriteWindow::PlainTextWindow;
- };
+ virtual WriteWindowType writeWindowType() const {
+ return PlainTextWindow;
+ }
/** Called to add actions to mainWindow toolbars */
virtual void setupMainWindowToolBars();
@@ -71,7 +84,13 @@ class CPlainWriteWindow : public CWriteWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
+ /** \returns whether the window may be closed.*/
+ virtual bool queryClose();
+
protected slots: // Protected slots
+
+ void saveCurrentText();
+
/**
* Saves the text for the current key. Directly writes the changed text into the module.
*/
@@ -88,6 +107,13 @@ class CPlainWriteWindow : public CWriteWindow {
* Deletes the module entry and clears the edit widget.
*/
virtual void deleteEntry();
+
+ virtual void beforeKeyChange();
+
+ protected: /* Fields: */
+
+ CPlainWriteDisplay * m_writeDisplay;
+
};
#endif
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index 7f11dca..0d8f2d9 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,12 +19,9 @@
#include "frontend/cmdiarea.h"
#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-using namespace Profile;
-
CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
: CDisplayWindow(modules, parent),
m_readDisplayWidget(0) {
@@ -108,57 +105,6 @@ void CReadWindow::slotMoveToAnchor() {
((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
}
-/** Store the settings of this window in the given CProfileWindow object. */
-void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
- QRect rect;
- rect.setX(parentWidget()->x());
- rect.setY(parentWidget()->y());
- rect.setWidth(parentWidget()->width());
- rect.setHeight(parentWidget()->height());
- settings->windowGeometry = rect;
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->type = modules().first()->type();
- settings->maximized = (isMaximized() || parentWidget()->isMaximized());
- settings->hasFocus = (this == dynamic_cast<CReadWindow*>(mdi()->activeSubWindow()) ); //set property to true if this window is the active one.
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->key = key()->key();
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
- Q_FOREACH (const CSwordModuleInfo *module, modules()) {
- mods.append(module->name());
- }
- settings->modules = mods;
-}
-
-void CReadWindow::applyProfileSettings(CProfileWindow * const settings) {
- // parentWidget()->setUpdatesEnabled(false);
- setUpdatesEnabled(false);
-
- if (settings->maximized) { //maximize this window
- // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
- parentWidget()->showMaximized();
- }
- else {
- const QRect &rect = settings->windowGeometry;
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- }
-
- setUpdatesEnabled(true);
-}
-
void CReadWindow::insertKeyboardActions( BtActionCollection* const ) {}
/** No descriptions */
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index d00d4f0..2446e1e 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,15 +21,10 @@
class BtActionCollection;
class QResizeEvent;
-/** The base class for all read-only display windows.
- *
- * Inherits CDisplayWindow.
- *
- * Inherited by CLexiconReadWindow
- *
- * @author The BibleTime team
- */
-class CReadWindow : public CDisplayWindow {
+/**
+ \brief The base class for all read-only display windows.
+*/
+class CReadWindow: public CDisplayWindow {
Q_OBJECT
public:
@@ -36,15 +33,6 @@ class CReadWindow : public CDisplayWindow {
CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Load the settings the given CProfileWindow object into this window.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
-
protected:
/**
* Sets the display widget of this display window.
@@ -72,7 +60,7 @@ class CReadWindow : public CDisplayWindow {
* Update the status of the popup menu entries.
*/
virtual void copyDisplayedText();
- /**
+ /**
* Open the search dialog with the strong info of the last clicked word.
*/
void openSearchStrongsDialog();
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
deleted file mode 100644
index fbcf8de..0000000
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-
-#include "frontend/displaywindow/cwritewindow.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
-#include "frontend/display/cwritedisplay.h"
-#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
-#include "util/dialogutil.h"
-#include "util/btsignal.h"
-
-using namespace Profile;
-
-CWriteWindow::CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CDisplayWindow(modules, parent), m_writeDisplay(0) {}
-
-void CWriteWindow::insertKeyboardActions( BtActionCollection* const ) {}
-
-void CWriteWindow::initConnections() {
- Q_ASSERT(keyChooser());
- QObject::connect(key()->signaler(), SIGNAL(beforeChanged()), this, SLOT(beforeKeyChange()));
-}
-
-void CWriteWindow::initActions() {}
-
-
-void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
-
- settings->writeWindowType = writeWindowType();
- settings->windowGeometry.setRect(parentWidget()->x(),
- parentWidget()->y(),
- parentWidget()->width(),
- parentWidget()->height());
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->type = modules().first()->type();
- settings->maximized = isMaximized() || parentWidget()->isMaximized();
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString::fromLatin1(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->key = key()->key();
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
- Q_FOREACH(const CSwordModuleInfo *m, modules()) {
- mods.append(m->name());
- }
- settings->modules = mods;
-}
-
-void CWriteWindow::applyProfileSettings(CProfileWindow * const settings) {
- setUpdatesEnabled(false);
-
- if (settings->maximized) {
- parentWidget()->showMaximized();
- }
- else {
- const QRect &rect = settings->windowGeometry;
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- //setGeometry( settings->geometry() );
- }
- // displayWidget()->view()->horizontalScrollBar()->setValue( settings->scrollbarPositions().horizontal );
- // m_htmlWidget->view()->verticalScrollBar()->setValue( settings->scrollbarPositions().vertical );
-
- setUpdatesEnabled(true);
-}
-
-void CWriteWindow::setDisplayWidget( CDisplay* display ) {
- Q_ASSERT(dynamic_cast<CWriteDisplay*>(display));
- CDisplayWindow::setDisplayWidget((CWriteDisplay*)display);
- m_writeDisplay = (CWriteDisplay*)display;
-}
-
-void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
- //set the raw text to the display widget
- if (!newKey)
- return;
-
- if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
- key()->setKey(newKey->key());
- }
-
- if ( modules().count() ) {
- displayWidget()->setText( key()->rawText() );
- }
- setWindowTitle(windowCaption());
-}
-
-bool CWriteWindow::queryClose() {
- //save the text if it has changed
- if (m_writeDisplay->isModified()) {
- switch (util::showQuestion( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes) ) {
- case QMessageBox::Yes: //save and close
- saveCurrentText();
- m_writeDisplay->setModified( false );
- return true;
- case QMessageBox::No: //don't save and close
- return true;
- default: // cancel, don't close
- return false;
- }
- }
- return true;
-}
-
-void CWriteWindow::beforeKeyChange() {
- Q_ASSERT(displayWidget());
- Q_ASSERT(keyChooser());
- if (!isReady())
- return;
-
- // Get current key string for this window
- QString thisWindowsKey;
- CSwordKey* oldKey = key();
- if (oldKey == 0)
- return;
- thisWindowsKey = oldKey->key();
-
- //If the text changed and we'd do a lookup ask the user if the text should be saved
- if (modules().first() && ((CWriteDisplay*)displayWidget())->isModified()) {
-
- switch (util::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
- case QMessageBox::Yes: { //save the changes
- saveCurrentText( thisWindowsKey );
- break;
- }
- default: {// set modified to false so it won't ask again
- ((CWriteDisplay*)displayWidget())->setModified(false);
- break;
- }
- }
- }
-}
-
-void CWriteWindow::saveCurrentText() {
- if (key()) {
- saveCurrentText(key()->key());
- }
-}
-
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
deleted file mode 100644
index 3ff9d06..0000000
--- a/src/frontend/displaywindow/cwritewindow.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CWRITEWINDOW_H
-#define CWRITEWINDOW_H
-
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-
-class BtActionCollection;
-class CWriteDisplay;
-class QString;
-
-/** The base class for all write-only display windows.
- *
- * Inherits CDisplayWindow.
- *
- * Inherited by CPlainWriteWindow.
- *
- *@author The BibleTime team
- */
-class CWriteWindow : public CDisplayWindow {
- Q_OBJECT
- public:
- enum WriteWindowType {
- HTMLWindow = 1,
- PlainTextWindow = 2
- };
-
- /** Insert the keyboard accelerators of this window into the given actioncollection.*/
- static void insertKeyboardActions( BtActionCollection* const a );
-
- CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Load the settings the given CProfileWindow object into this window.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
-
- /** Initializes the signal / slot connections of this display window.*/
- virtual void initConnections();
-
- /** Initializes the internel keyboard actions.*/
- virtual void initActions();
-
- public slots:
- /**
- * Look up the given key and display the text. In our case we offer to edit the text.
- */
- virtual void lookupSwordKey( CSwordKey* key );
-
-
- protected: // Protected methods
- /**
- * Set the displayWidget which is a subclass of QWebPage.
- */
- void setDisplayWidget( CDisplay* display );
-
- /** Returns the type of the write window.*/
- virtual CWriteWindow::WriteWindowType writeWindowType() = 0;
-
- /** Returns true if the window may be closed.*/
- virtual bool queryClose();
-
- /** Saves the text for the current key. Directly writes the changed text into the module. */
- virtual void saveCurrentText( const QString& key ) = 0;
-
- /** Called to add actions to mainWindow toolbars */
- virtual void setupMainWindowToolBars() = 0;
-
- protected slots:
- /** Save text to the module
- */
- void saveCurrentText();
- /**
- */
- virtual void beforeKeyChange();
-
- private:
- CWriteDisplay* m_writeDisplay;
-};
-
-#endif
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 93651a5..22c9e69 100644
--- a/src/frontend/keychooser/bthistory.cpp
+++ b/src/frontend/keychooser/bthistory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,8 +44,7 @@ void BTHistory::move(QAction* historyItem) {
//find the action in the list
m_index = m_historyList.indexOf(historyItem);
//move to the selected item in the list, it will be the current item
- QString newKey = m_historyList.at(m_index)->text();
- emit historyMoved(newKey); // signal to "outsiders"; key has been changed
+ emit historyMoved(m_historyList.at(m_index)->text()); // signal to "outsiders"; key has been changed
sendChangedSignal();
m_inHistoryFunction = false;
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index a92a25e..6c65aca 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -60,7 +62,7 @@ class BTHistory: public QObject {
/**
* Signal will be sent when the current point in history has moved
*/
- void historyMoved(QString& newKey);
+ void historyMoved(QString newKey);
private:
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index 1c7fccb..9255980 100644
--- a/src/frontend/keychooser/cbookkeychooser.cpp
+++ b/src/frontend/keychooser/cbookkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,78 +13,76 @@
#include <QHBoxLayout>
#include <QList>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-QMap<QObject*, int> boxes;
+#define ID_PROPERTY_NAME "CBookKeyChooser_ID"
-CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key,
- QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent), m_layout(0)
+CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_layout(0)
{
-
setModules(modules, false);
- m_key = dynamic_cast<CSwordTreeKey*>(key);
- if (!m_modules.count()) {
+ m_key = dynamic_cast<CSwordTreeKey * >(key);
+ if (!m_modules.count())
m_key = 0;
- }
setModules(modules, true);
setKey(key);
adjustFont();
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ connect(this, SIGNAL(keyChanged(CSwordKey *)),
+ history(), SLOT(add(CSwordKey *)));
}
-void CBookKeyChooser::setKey(CSwordKey* newKey) {
+void CBookKeyChooser::setKey(CSwordKey * newKey) {
setKey(newKey, true);
}
/** Sets a new key to this keychooser */
-void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
- if (m_key != newKey) { //set the internal key to the new one
+void CBookKeyChooser::setKey(CSwordKey * newKey, const bool emitSignal) {
+ if (m_key != newKey) // Set the internal key to the new one
m_key = dynamic_cast<CSwordTreeKey*>(newKey);
- }
- QString oldKey = m_key->key(); //string backup of key
+ QString oldKey(m_key->key());
- if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ if (oldKey.isEmpty()) { // Don't set keys equal to "/", always use a key which may have content
m_key->firstChild();
oldKey = m_key->key();
}
- const int oldOffset = m_key->getOffset(); //backup key position
+ const int oldOffset = m_key->getOffset();
- QStringList siblings; //split up key
- if (m_key && !oldKey.isEmpty()) {
+ QStringList siblings; // Split up key
+ if (m_key && !oldKey.isEmpty())
siblings = oldKey.split('/', QString::SkipEmptyParts);
- }
int depth = 0;
- int index = 0;
m_key->root(); //start iteration at root node
- while ( m_key->firstChild() && (depth < siblings.count()) ) {
+ while (m_key->firstChild() && (depth < siblings.count())) {
QString key = m_key->key();
- index = (depth == 0) ? -1 : 0;
+ int index = (depth == 0) ? -1 : 0;
bool found = false;
do { //look for matching sibling
++index;
found = (m_key->getLocalNameUnicode() == siblings[depth]);
- }
- while (!found && m_key->nextSibling());
+ } while (!found && m_key->nextSibling());
- if (found)
+ if (found) {
key = m_key->key(); //found: change key to this level
- else
+ } else {
m_key->setKey(key); //not found: restore old key
+ }
setupCombo(key, depth, index);
@@ -98,41 +96,41 @@ void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
}
//clear the combos which were not filled
- for (; depth < m_modules.first()->depth(); ++depth) {
- CKeyChooserWidget* chooser = m_chooserWidgets.at(depth);
- if (chooser) chooser->reset(0, 0, false);
+ for (; depth < m_modules.first()->depth(); ++depth) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(depth);
+ if (chooser)
+ chooser->reset(0, 0, false);
}
if (oldKey.isEmpty()) {
m_key->root();
- }
- else {
+ } else {
//m_key->key(oldKey);
m_key->setOffset(oldOffset);
}
- if (emitSignal) emit keyChanged(m_key);
+ if (emitSignal)
+ emit keyChanged(m_key);
}
/** Returns the key of this kechooser. */
-CSwordKey* CBookKeyChooser::key() {
+CSwordKey * CBookKeyChooser::key() {
return m_key;
}
/** Sets another module to this keychooser */
-void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo *> & modules,
bool refresh)
{
typedef CSwordBookModuleInfo CSBMI;
m_modules.clear();
// for (modules.first(); modules.current(); modules.next()) {
- Q_FOREACH(const CSwordModuleInfo *m, modules) {
+ Q_FOREACH(const CSwordModuleInfo * m, modules) {
if (m->type() == CSwordModuleInfo::GenericBook ) {
- const CSBMI *book = dynamic_cast<const CSBMI*>(m);
- if (book != 0) {
+ const CSBMI * const book = dynamic_cast<const CSBMI *>(m);
+ if (book != 0)
m_modules.append(book);
- }
}
}
@@ -149,45 +147,43 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
for (int i = 0; i < m_modules.first()->depth(); ++i) {
// Create an empty keychooser, don't handle next/prev signals
- CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this);
- m_chooserWidgets.append( w );
+ CKeyChooserWidget * const w = new CKeyChooserWidget(0, this);
+ m_chooserWidgets.append(w);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
int totalWidth = 200; //only 1 level
if (m_modules.first()->depth() > 1) {
- if (m_modules.first()->depth() > 3)
+ if (m_modules.first()->depth() > 3) {
totalWidth = 400; //4+ levels
- else
+ } else {
totalWidth = 300; //2-3 levels
+ }
}
int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth());
- w->comboBox()->setMaximumWidth(maxWidth);
- w->comboBox()->setCurrentIndex(0);
+ w->comboBox().setMaximumWidth(maxWidth);
+ w->comboBox().setCurrentIndex(0);
- connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
+ connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int)));
m_layout->addWidget(w);
- boxes[w] = i;
-
+ w->setProperty(ID_PROPERTY_NAME, i+1);
w->show();
}
//set the tab order of the key chooser widgets
- CKeyChooserWidget* chooser = 0;
- CKeyChooserWidget* chooser_prev = 0;
+ CKeyChooserWidget * chooser = 0;
+ CKeyChooserWidget * chooser_prev = 0;
const int count = m_chooserWidgets.count();
- for (int i = 0; i < count; ++i) {
+ for (int i = 0; i < count; i++) {
chooser = m_chooserWidgets.at(i);
Q_ASSERT(chooser);
-
- if (chooser && chooser_prev) {
+ if (chooser_prev)
QWidget::setTabOrder(chooser_prev, chooser);
- }
chooser_prev = chooser;
}
@@ -201,21 +197,22 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** No descriptions */
void CBookKeyChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- QListIterator<CKeyChooserWidget*> it(m_chooserWidgets);
- while (it.hasNext()) {
- it.next()->comboBox()->setFont( CBTConfig::get( m_modules.first()->language() ).second );
- }
+ QListIterator<CKeyChooserWidget *> it(m_chooserWidgets);
+ while (it.hasNext())
+ it.next()->comboBox().setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
/** Refreshes the content. */
void CBookKeyChooser::refreshContent() {
- if (m_key) {
- updateKey( m_key ); //refresh with current key
- }
+ if (m_key)
+ updateKey(m_key); // Refresh with current key
}
-void CBookKeyChooser::setupCombo(const QString key, const int depth, const int currentItem) {
- CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
+void CBookKeyChooser::setupCombo(const QString & key,
+ const int depth,
+ const int currentItem)
+{
+ CKeyChooserWidget * const chooserWidget = m_chooserWidgets.at(depth);
CSwordTreeKey tmpKey(*m_key);
tmpKey.setKey(key);
@@ -223,32 +220,32 @@ void CBookKeyChooser::setupCombo(const QString key, const int depth, const int c
tmpKey.firstChild();
QStringList items;
- if (depth > 0) items << QString::null; //insert an empty item at the top
+ if (depth > 0)
+ items.append(QString::null); // Insert an empty item at the top
do {
- items << tmpKey.getLocalNameUnicode();
- }
- while (tmpKey.nextSibling());
+ items.append(tmpKey.getLocalNameUnicode());
+ } while (tmpKey.nextSibling());
- if (chooserWidget) chooserWidget->reset(items, currentItem, false);
+ if (chooserWidget)
+ chooserWidget->reset(items, currentItem, false);
}
/** A keychooser changed. Update and emit a signal if necessary. */
-void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
- const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code!
-
+void CBookKeyChooser::keyChooserChanged(int newIndex) {
+ Q_UNUSED(newIndex);
QStringList items;
- CKeyChooserWidget* chooser;
- for (int i = 0; i < m_chooserWidgets.count(); ++i) {
- chooser = m_chooserWidgets.at(i);
- const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null;
-
- if (currentText.isEmpty() || i > activeID) {
+ const int max = std::min(m_chooserWidgets.count(),
+ sender()->property(ID_PROPERTY_NAME).toInt());
+ for (int i = 0; i < max; i++) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(i);
+ Q_ASSERT(chooser);
+ const QString currentText = chooser->comboBox().currentText();
+ if (currentText.isEmpty())
break;
- }
- items << currentText;
+ items.append(currentText);
}
QString newKey("/");
@@ -259,11 +256,11 @@ void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
}
/** Updates the keychoosers for the given key but emit no signal. */
-void CBookKeyChooser::updateKey(CSwordKey* key) {
+void CBookKeyChooser::updateKey(CSwordKey * key) {
setKey(key, false);
}
-void CBookKeyChooser::setKey(QString& newKey) {
+void CBookKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index 3b32d48..c01e0e9 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,71 +22,79 @@ class CSwordBookModuleInfo;
class CSwordKey;
class CSwordTreeKey;
-namespace sword {
-class TreeKeyIdx;
-}
-
-/** The keychooser implementation for books.
- * @author The BibleTime team
- */
-class CBookKeyChooser : public CKeyChooser {
- Q_OBJECT
- public:
- CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Reimplemented from CKeyChooser.
- */
- virtual void refreshContent();
-
- /**
- * Sets another module to this keychooser
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = false);
- /**
- * Returns the key of this keychooser
- */
- virtual CSwordKey* key();
- /**
- * Sets a new key to this keychooser
- */
- virtual void setKey(CSwordKey*);
- /**
- * Sets a new key to this keychooser
- */
- void setKey(CSwordKey*, const bool emitSignal);
-
-
- public slots: // Public slots
- /**
- * Updates the keychoosers for the given key but emit no signal.
- */
- void updateKey(CSwordKey*);
-
- protected: // Protected methods
- /**
- * Fills the combo given by depth with the items from the key having depth "depth".
- * The parent sibling is given by key.
- */
- void setupCombo(const QString key, const int depth, const int currentItem);
- /** No descriptions */
- virtual void adjustFont();
-
- protected slots:
- /**
- * A keychooser changed. Update and emit a signal if necessary.
- */
- void keyChooserChanged(int);
- virtual void setKey(QString& newKey);
-
- private:
- QList<CKeyChooserWidget*> m_chooserWidgets;
- QList<const CSwordBookModuleInfo*> m_modules;
- CSwordTreeKey *m_key;
- QHBoxLayout* m_layout;
+/**
+ \brief The keychooser implementation for books.
+*/
+class CBookKeyChooser: public CKeyChooser {
+
+ Q_OBJECT
+
+public:
+
+ CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key = 0,
+ QWidget * parent = 0);
+
+ /**
+ Reimplemented from CKeyChooser.
+ */
+ virtual void refreshContent();
+
+ /**
+ * Sets another module to this keychooser
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = false);
+ /**
+ * Returns the key of this keychooser
+ */
+ virtual CSwordKey * key();
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ virtual void setKey(CSwordKey * key);
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ void setKey(CSwordKey * key, const bool emitSignal);
+
+public slots: // Public slots
+
+ /**
+ * Updates the keychoosers for the given key but emit no signal.
+ */
+ void updateKey(CSwordKey * key);
+
+protected: /* Methods: */
+
+ /**
+ * Fills the combo given by depth with the items from the key having depth "depth".
+ * The parent sibling is given by key.
+ */
+ void setupCombo(const QString & key, const int depth, const int currentItem);
+
+ /** No descriptions */
+ virtual void adjustFont();
+
+protected slots:
+
+ /**
+ * A keychooser changed. Update and emit a signal if necessary.
+ */
+ void keyChooserChanged(int);
+
+ virtual void setKey(const QString & newKey);
+
+private: /* Fields: */
+
+ QList<CKeyChooserWidget *> m_chooserWidgets;
+ QList<const CSwordBookModuleInfo *> m_modules;
+ CSwordTreeKey * m_key;
+ QHBoxLayout * m_layout;
+
};
#endif
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index a41922e..96917d8 100644
--- a/src/frontend/keychooser/cbooktreechooser.cpp
+++ b/src/frontend/keychooser/cbooktreechooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,16 +13,19 @@
#include <QHBoxLayout>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory* historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
+CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordTreeKey *>(key))
+{
setModules(modules, false);
@@ -109,8 +112,7 @@ void CBookTreeChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** From ckeychooser. */
void CBookTreeChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- m_treeView->setFont( CBTConfig::get(m_modules.first()->language()).second );
-
+ m_treeView->setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
@@ -183,7 +185,7 @@ void CBookTreeChooser::addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item)
}
}
-void CBookTreeChooser::setKey(QString& newKey) {
+void CBookTreeChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 409038e..17b5825 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -79,7 +81,7 @@ class CBookTreeChooser : public CKeyChooser {
protected slots: // Protected slots
void itemActivated( QTreeWidgetItem* item );
- void setKey(QString& newKey);
+ void setKey(const QString & newKey);
private:
QList<const CSwordBookModuleInfo*> m_modules;
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index b46ee51..96b5638 100644
--- a/src/frontend/keychooser/ckeychooser.cpp
+++ b/src/frontend/keychooser/ckeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,48 +21,44 @@
#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo*> &, BTHistory* historyPtr,
- CSwordKey *, QWidget *parent)
- : QWidget(parent),
- m_history(historyPtr) {
- bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo *> &,
+ BTHistory * historyPtr,
+ QWidget * parent)
+ : QWidget(parent)
+ , m_history(historyPtr)
+{
+ bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString)),
+ this, SLOT(setKey(const QString &)));
Q_ASSERT(ok);
}
-CKeyChooser* CKeyChooser::createInstance(
- const QList<const CSwordModuleInfo*> &modules, BTHistory *historyPtr,
- CSwordKey *key, QWidget *parent)
+CKeyChooser * CKeyChooser::createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
{
- if (!modules.count()) {
- /**
- \todo Verify and document that we need to return 0 here rather than
- fail with an assertion.
- */
- return 0;
- }
+ Q_ASSERT(!modules.empty());
+ Q_ASSERT(modules.first()->type() == CSwordModuleInfo::Commentary
+ || modules.first()->type() == CSwordModuleInfo::Bible
+ || modules.first()->type() == CSwordModuleInfo::Lexicon
+ || modules.first()->type() == CSwordModuleInfo::GenericBook);
+
+ switch (modules.first()->type()) {
- CSwordModuleInfo::ModuleType typeOfModules = modules.first()->type();
-/*
-#ifdef BT_DEBUG
- Q_FOREACH (const CSwordModuleInfo *module, modules) {
- Q_ASSERT(module->type() == typeOfModules);
- }
-#endif
-*/
- switch (typeOfModules) {
case CSwordModuleInfo::Commentary:
/* Fall thru - Bibles and commentaries use the same key chooser */
+
case CSwordModuleInfo::Bible:
return new CBibleKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::Lexicon:
return new CLexiconKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::GenericBook:
return new CBookKeyChooser(modules, historyPtr, key, parent);
+
default:
- /**
- \todo Verify and document that we need to return 0 here rather
- than fail with an assertion.
- */
- return 0;
+ abort();
+
}
}
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index 0ab9c5b..79706cc 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,83 +25,86 @@ class QAction;
* Do not use directly, create a KeyChooser with
* @ref #createInstance , this will create the proper one
* of the classes that inherit from @ref CKeyChooser
- *
- * @author The BibleTime team
- */
-class CKeyChooser : public QWidget {
- Q_OBJECT
- public:
-
- /**
- * Creates a proper Instance, either
- * @ref CLexiconKeyChooser or
- * @ref CBibleKeyChooser
- * @param info the @ref CModuleInfo to be represented by the KeyChooser
- * @param key if not NULL, the @ref CKey the KeyChooser should be set to
- * @param parent the parent of the widget to create
- */
- static CKeyChooser *createInstance(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key, QWidget *parent);
-
-
- public slots:
- /**
- Sets the CKey
- \param key the key which the widget should be set to.
- */
- virtual void setKey(CSwordKey* key) = 0;
-
- /**
- Updates the CKey.
- \param key the key which the widget should be set to.
- */
- virtual void updateKey(CSwordKey *key) = 0;
-
- /**
- \returns the current CKey.
- */
- virtual CSwordKey *key() = 0;
-
- /**
- Sets the module of this keychooser and refreshes the comboboxes
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = true) = 0;
-
- /**
- Refreshes the content of the different key chooser parts.
- */
- virtual void refreshContent() = 0;
-
- /**
- \returns the history object of this keychooser.
- */
- inline BTHistory *history() const { return m_history; }
-
- signals:
-
- /**
- * is emitted if the @ref CKey was changed by the user
- */
- void keyChanged(CSwordKey* newKey);
-
- protected:
-
- CKeyChooser(const QList<const CSwordModuleInfo*> &info,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Resets the appropriate font to for the modules.
- */
- virtual void adjustFont() = 0;
-
- protected slots:
- virtual void setKey(QString &newKey) = 0;
-
- private:
- BTHistory *m_history;
+ */
+class CKeyChooser: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ /**
+ \returns the history object of this keychooser.
+ */
+ inline BTHistory * history() const { return m_history; }
+
+ /**
+ * Creates a proper Instance, either
+ * @ref CLexiconKeyChooser or
+ * @ref CBibleKeyChooser
+ * @param info the @ref CModuleInfo to be represented by the KeyChooser
+ * @param key if not NULL, the @ref CKey the KeyChooser should be set to
+ * @param parent the parent of the widget to create
+ */
+ static CKeyChooser * createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key,
+ QWidget * parent);
+
+public slots:
+
+ /**
+ Sets the CKey
+ \param key the key which the widget should be set to.
+ */
+ virtual void setKey(CSwordKey * key) = 0;
+
+ /**
+ Updates the CKey.
+ \param key the key which the widget should be set to.
+ */
+ virtual void updateKey(CSwordKey * key) = 0;
+
+ /**
+ \returns the current CKey.
+ */
+ virtual CSwordKey * key() = 0;
+
+ /**
+ Sets the module of this keychooser and refreshes the comboboxes
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = true) = 0;
+
+ /**
+ Refreshes the content of the different key chooser parts.
+ */
+ virtual void refreshContent() = 0;
+
+signals:
+
+ /**
+ * is emitted if the @ref CKey was changed by the user
+ */
+ void keyChanged(CSwordKey * newKey);
+
+protected: /* Methods: */
+
+ CKeyChooser(const QList<const CSwordModuleInfo *> & info,
+ BTHistory * history,
+ QWidget * parent = 0);
+
+ /**
+ Resets the appropriate font to for the modules.
+ */
+ virtual void adjustFont() = 0;
+
+protected slots:
+
+ virtual void setKey(const QString & newKey) = 0;
+
+private: /* Fields: */
+
+ BTHistory * const m_history;
};
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index 36fc05b..ea3421e 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,58 +19,60 @@
class BtKeyLineEdit : public QLineEdit {
- public:
- BtKeyLineEdit(QWidget* parent)
- : QLineEdit(parent) {
- }
- protected:
- void focusInEvent(QFocusEvent* event) {
- Qt::FocusReason reason = event->reason();
- if (reason == Qt::OtherFocusReason) {
- selectAll();
- }
- QWidget::focusInEvent(event);
- }
-};
+public: /* Methods: */
+
+ BtKeyLineEdit(QWidget * parent)
+ : QLineEdit(parent) {}
+
+protected: /* Methods: */
+
+ virtual void focusInEvent(QFocusEvent * event) {
+ const Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason)
+ selectAll();
+ QWidget::focusInEvent(event);
+ }
+
+};
-CKCComboBox::CKCComboBox()
- : QComboBox() {
+CKCComboBox::CKCComboBox(QWidget * parent)
+ : QComboBox(parent)
+{
setFocusPolicy(Qt::WheelFocus);
setLineEdit(new BtKeyLineEdit(this));
- if (lineEdit()) {
- installEventFilter( lineEdit() );
- }
+ if (lineEdit())
+ installEventFilter(lineEdit());
}
-/** Reimplementation. */
-bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
+bool CKCComboBox::eventFilter(QObject * o, QEvent * e) {
if (e->type() == QEvent::FocusOut) {
- QFocusEvent* f = static_cast<QFocusEvent*>(e);
+ QFocusEvent * const f = static_cast<QFocusEvent *>(e);
if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
int index = findText(currentText());
- if (index == -1) {
- index = 0;// return 0 if not found
- }
- setCurrentIndex( index );
- emit focusOut( index );
-
+ if (index == -1)
+ index = 0; // return 0 if not found
+ setCurrentIndex(index);
+ emit focusOut(index);
return false;
}
- else if (f->reason() == Qt::PopupFocusReason) {
+
+ if (f->reason() == Qt::PopupFocusReason)
return false;
- }
- else if (f->reason() == Qt::ActiveWindowFocusReason) {
+
+ if (f->reason() == Qt::ActiveWindowFocusReason) {
emit activated(currentText());
return false;
}
- else if (f->reason() == Qt::MouseFocusReason) {
+
+ if (f->reason() == Qt::MouseFocusReason) {
emit activated(currentText());
return false;
}
- else if (o == this) {
+
+ if (o == this) {
emit activated(currentText());
return false;
}
@@ -80,8 +82,8 @@ bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
}
/** Scrolls in the list if the wheel of the mouse was used. */
-void CKCComboBox::wheelEvent( QWheelEvent* e ) {
- return QComboBox::wheelEvent(e);
+void CKCComboBox::wheelEvent(QWheelEvent * e) {
+ return QComboBox::wheelEvent(e); /// \bug rest method won't get executed.
const signed int change = (int)((float)e->delta() / (float)120);
int current = currentIndex();
@@ -89,18 +91,17 @@ void CKCComboBox::wheelEvent( QWheelEvent* e ) {
if ((current + change >= 0) && (current + change < count()) ) {
setCurrentIndex(current + change);
e->accept();
- emit activated( currentIndex() );
- }
- else {
+ emit activated(currentIndex());
+ } else {
e->ignore();
}
}
//**********************************************************************************/
-CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
+CKeyChooserWidget::CKeyChooserWidget(int count, QWidget * parent)
+ : QWidget(parent)
+{
for (int index = 1; index <= count; index++) {
m_list.append( QString::number(index) );
}
@@ -108,15 +109,11 @@ CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals,
reset(m_list, 0, false);
}
-CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
- if (list) {
- m_list = *list; //deep copy the items of list
- }
- else {
- m_list.clear();
- }
+CKeyChooserWidget::CKeyChooserWidget(QStringList * list, QWidget * parent )
+ : QWidget(parent)
+{
+ if (list)
+ m_list = *list;
init();
reset(m_list, 0, false);
@@ -129,14 +126,13 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
// return;
m_list.clear();
- for (int i = 1; i <= count; i++) { /// \todo CHECK
- m_list.append( QString::number(i) );
- }
+ for (int i = 1; i <= count; i++) /// \todo CHECK
+ m_list.append(QString::number(i));
reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList & list, int index, bool do_emit) {
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
@@ -147,37 +143,34 @@ void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit)
}
-void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList * list, int index, bool do_emit) {
//if (isResetting || !updatesEnabled())
- if (isResetting)
+ if (m_isResetting)
return;
// qWarning("starting insert");
- isResetting = true;
+ m_isResetting = true;
- oldKey = QString::null;
+ m_oldKey = QString::null;
// m_comboBox->setUpdatesEnabled(false);
//DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
m_comboBox->hide();
m_comboBox->clear();
- if (list) {
+ if (list)
m_comboBox->insertItems(-1, *list);
- }
- if (!list || (list && !list->count())) { //nothing in the combobox
+ if (!list || (list && !list->count())) { // nothing in the combobox
setEnabled(false);
- }
- else if (!isEnabled()) { //was disabled
+ } else if (!isEnabled()) { // was disabled
setEnabled(true);
}
- if (list->count()) {
+ if (list->count())
m_comboBox->setCurrentIndex(index);
- }
- if (do_emit) {
+
+ if (do_emit)
emit changed(m_comboBox->currentIndex());
- }
m_comboBox->sizeHint(); //without this function call the combo box won't be properly sized!
//DON'T REMOVE OR MOVE THE show()! Otherwise QComboBox's sizeHint() function won't work properly!
@@ -186,56 +179,56 @@ void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit)
// m_comboBox->setFont( m_comboBox->font() );
// m_comboBox->setUpdatesEnabled(true);
- isResetting = false;
+ m_isResetting = false;
// qWarning("inserted");
}
/** Initializes this widget. We need this function because we have more than one constructor. */
void CKeyChooserWidget::init() {
- oldKey = QString::null;
+ m_oldKey = QString::null;
setFocusPolicy(Qt::WheelFocus);
- m_comboBox = new CKCComboBox();
+ m_comboBox = new CKCComboBox(this);
setFocusProxy(m_comboBox);
- m_comboBox->setAutoCompletion( true );
+ m_comboBox->setAutoCompletion(true);
m_comboBox->setEditable(true);
m_comboBox->setInsertPolicy(QComboBox::NoInsert);
m_comboBox->setFocusPolicy(Qt::WheelFocus);
- m_mainLayout = new QHBoxLayout( this );
+ m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setSpacing(0);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
m_mainLayout->addWidget(m_comboBox);
m_scroller = new CScrollerWidgetSet(this);
- m_mainLayout->addWidget( m_scroller );
+ m_mainLayout->addWidget(m_scroller);
m_mainLayout->addSpacing(0);
setTabOrder(m_comboBox, 0);
setFocusProxy(m_comboBox);
- connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
+ connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
- connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)) );
-
- connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
+ connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)));
+ connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
// connect(m_comboBox, SIGNAL(activated(const QString&)), SLOT(slotReturnPressed(const QString&)));
- connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
+ connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()),
+ SLOT(slotReturnPressed()));
connect(m_comboBox, SIGNAL(focusOut(int)), SIGNAL(focusOut(int)));
updatelock = false;
- isResetting = false;
+ m_isResetting = false;
}
/** Is called when the return key was presed in the combobox. */
-void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
- Q_ASSERT(comboBox()->lineEdit());
+void CKeyChooserWidget::slotReturnPressed() {
+ Q_ASSERT(m_comboBox->lineEdit());
- QString text = comboBox()->lineEdit()->text();
- for (int index = 0; index < comboBox()->count(); ++index) {
- if (comboBox()->itemText(index) == text) {
+ const QString text(m_comboBox->lineEdit()->text());
+ for (int index = 0; index < m_comboBox->count(); ++index) {
+ if (m_comboBox->itemText(index) == text) {
// emit changed(index);
emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
break;
@@ -245,71 +238,74 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
/** Is called when the current item of the combo box was changed. */
void CKeyChooserWidget::slotComboChanged(int index) {
- if (!updatesEnabled()) {
+ if (!updatesEnabled())
return;
- }
setUpdatesEnabled(false);
- const QString key = comboBox()->itemText( index );
- if (oldKey.isNull() || (oldKey != key)) {
+ const QString key(m_comboBox->itemText(index));
+ if (m_oldKey.isNull() || (m_oldKey != key))
emit changed(index);
- }
- oldKey = key;
+ m_oldKey = key;
setUpdatesEnabled(true);
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- comboBox()->setToolTip(comboTip);
+void CKeyChooserWidget::setToolTips(const QString & comboTip,
+ const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_comboBox->setToolTip(comboTip);
m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
}
/** Sets the current item to the one with the given text */
-bool CKeyChooserWidget::setItem( const QString item ) {
+bool CKeyChooserWidget::setItem(const QString & item) {
bool ret = false;
- const int count = comboBox()->count();
+ const int count = m_comboBox->count();
for (int i = 0; i < count; ++i) {
- if (comboBox()->itemText(i) == item) {
- comboBox()->setCurrentIndex(i);
+ if (m_comboBox->itemText(i) == item) {
+ m_comboBox->setCurrentIndex(i);
ret = true;
break;
}
}
if (!ret)
- comboBox()->setCurrentIndex(-1);
+ m_comboBox->setCurrentIndex(-1);
return ret;
}
/* Handlers for the various scroller widgetset. */
void CKeyChooserWidget::lock() {
updatelock = true;
- comboBox()->setEditable(false);
- oldKey = comboBox()->currentText();
+ m_comboBox->setEditable(false);
+ m_oldKey = m_comboBox->currentText();
}
void CKeyChooserWidget::unlock() {
updatelock = false;
- comboBox()->setEditable(true);
- comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
- if (comboBox()->currentText() != oldKey) {
- emit changed(comboBox()->currentIndex());
- }
+ m_comboBox->setEditable(true);
+ m_comboBox->setEditText(m_comboBox->itemText(m_comboBox->currentIndex()));
+ if (m_comboBox->currentText() != m_oldKey)
+ emit changed(m_comboBox->currentIndex());
}
void CKeyChooserWidget::changeCombo(int n) {
- const int old_index = comboBox()->currentIndex();
+ const int old_index = m_comboBox->currentIndex();
int new_index = old_index + n;
//index of highest Item
- const int max = comboBox()->count() - 1;
- if (new_index > max) new_index = max;
- if (new_index < 0) new_index = 0;
+ const int max = m_comboBox->count() - 1;
+ if (new_index > max)
+ new_index = max;
+ if (new_index < 0)
+ new_index = 0;
if (new_index != old_index) {
- comboBox()->setCurrentIndex(new_index);
+ m_comboBox->setCurrentIndex(new_index);
if (!updatelock)
emit changed(new_index);
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 3121af8..a1fd31d 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,6 @@
#include <QComboBox>
-#include <QString>
#include <QStringList>
@@ -28,30 +29,27 @@ class QEvent;
* We use this class to control the focus move in the combobox
* This class is used in the key chooser widgets
*/
-class CKCComboBox : public QComboBox {
- Q_OBJECT
- public:
- CKCComboBox();
- /**
- * Returns the size this widget would like to have.
- */
- // virtual QSize sizeHint() const;
-
- protected:
- /**
- * Reimplementation.
- */
- virtual bool eventFilter( QObject *o, QEvent *e );
- /**
- * Scrolls in the list if the wheel of the mouse was used.
- */
- virtual void wheelEvent( QWheelEvent* e);
-
- signals:
- /**
- * Emitted when the user moves the focus away from the combo by pressing tab
- */
- void focusOut(int itemIndex);
+class CKCComboBox: public QComboBox {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKCComboBox(QWidget * parent = 0);
+
+protected: /* Methods: */
+
+ virtual bool eventFilter(QObject * o, QEvent * e);
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+signals:
+
+ /**
+ * Emitted when the user moves the focus away from the combo by pressing tab
+ */
+ void focusOut(int itemIndex);
+
};
/**
@@ -61,114 +59,122 @@ class CKCComboBox : public QComboBox {
*
* @author The BibleTime team
*/
-class CKeyChooserWidget : public QWidget {
- Q_OBJECT
-
- public:
- CKeyChooserWidget(QStringList *list = 0,
- const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- CKeyChooserWidget(int count = 0, const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- /**
- * This function does clear the combobox, then fill in
- * the StringList, set the ComboBox' current item to index
- * and if do_emit is true, it will emit @ref #changed
- *
- * @param list the stringlist to be inserted
- * @param index the index that the combobox is to jump to
- * @param do_emit should we emit @ref #changed(int)
- */
- void reset(const int count, int index, bool do_emit);
- void reset(const QStringList &list, int index, bool do_emit);
- void reset(const QStringList *list, int index, bool do_emit);
-
- /**
- * Initializes this widget. We need this function because
- * we have more than one constructor.
- */
- virtual void init();
- /**
- *
- */
- // virtual void adjustSize();
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString comboTip, const QString nextEntry, const QString scrollButton, const QString previousEntry);
- /**
- * Sets the current item to the one with the given text
- */
- bool setItem( const QString item);
- /**
- * Return the combobox of this key chooser widget.
- */
- QComboBox* comboBox() {
- return m_comboBox;
- };
-
- public slots:
- /**
- * is called to lock the combobox
- */
- void lock()
- ;
- /**
- * is called to unlock the combobox
- */
- void unlock();
- /**
- * is called to move the combobox to a certain index
- * @param index the index to jump to
- */
- void changeCombo(int index);
- void slotComboChanged(int index);
-
- signals:
- /**
- * Is emitted if the widget changed, but
- * only if it is not locked or being reset
- *
- * @param the current ComboBox index
- */
- void changed(int index);
- /**
- * Is emitted if the widget was left with a focus out event.
- * @param index The new index of the ComboBox
- */
- void focusOut(int index);
-
- protected:
- /**
- * indicates wheter we are resetting at the moment
- */
- bool isResetting;
- /**
- *
- */
- QString oldKey;
-
- protected slots: // Protected slots
- /**
- * Is called when the return key was presed in the combobox.
- */
- void slotReturnPressed( /*const QString&*/ );
-
-
- private:
-
- QStringList m_list;
- bool m_useNextPrevSignals;
- bool updatelock;
-
- /**
- * Members should never be public!!
- */
- CKCComboBox* m_comboBox;
- QHBoxLayout *m_mainLayout;
- CScrollerWidgetSet * m_scroller;
+class CKeyChooserWidget: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKeyChooserWidget(QStringList * list = 0,
+ QWidget * parent = 0);
+
+ CKeyChooserWidget(int count = 0,
+ QWidget * parent = 0);
+
+ /**
+ * This function does clear the combobox, then fill in
+ * the StringList, set the ComboBox' current item to index
+ * and if do_emit is true, it will emit @ref #changed
+ *
+ * @param list the stringlist to be inserted
+ * @param index the index that the combobox is to jump to
+ * @param do_emit should we emit @ref #changed(int)
+ */
+ void reset(const int count, int index, bool do_emit);
+
+ void reset(const QStringList & list, int index, bool do_emit);
+
+ void reset(const QStringList * list, int index, bool do_emit);
+
+ /**
+ * Initializes this widget. We need this function because
+ * we have more than one constructor.
+ */
+ virtual void init();
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & comboTip,
+ const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+ /**
+ * Sets the current item to the one with the given text
+ */
+ bool setItem(const QString & item);
+
+ /**
+ * Return the combobox of this key chooser widget.
+ */
+ QComboBox & comboBox() const {
+ Q_ASSERT(m_comboBox);
+ return *m_comboBox;
+ }
+
+public slots:
+
+ /**
+ * is called to lock the combobox
+ */
+ void lock();
+
+ /**
+ * is called to unlock the combobox
+ */
+ void unlock();
+
+ /**
+ * is called to move the combobox to a certain index
+ * @param index the index to jump to
+ */
+ void changeCombo(int index);
+
+ void slotComboChanged(int index);
+
+signals:
+
+ /**
+ * Is emitted if the widget changed, but
+ * only if it is not locked or being reset
+ *
+ * @param the current ComboBox index
+ */
+ void changed(int index);
+
+ /**
+ * Is emitted if the widget was left with a focus out event.
+ * @param index The new index of the ComboBox
+ */
+ void focusOut(int index);
+
+protected slots:
+
+ /**
+ * Is called when the return key was presed in the combobox.
+ */
+ void slotReturnPressed();
+
+private: /* Fields: */
+
+ QStringList m_list;
+ bool updatelock;
+
+ /**
+ * Members should never be public!!
+ */
+ CKCComboBox * m_comboBox;
+ QHBoxLayout * m_mainLayout;
+ CScrollerWidgetSet * m_scroller;
+
+ /**
+ * indicates wheter we are resetting at the moment
+ */
+ bool m_isResetting;
+
+ QString m_oldKey;
+
};
#endif
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 42fb4e8..2c6545a 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,11 +19,12 @@
#include "util/cresmgr.h"
-CLexiconKeyChooser::CLexiconKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordLDKey*>(key))
+CLexiconKeyChooser::CLexiconKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordLDKey *>(key))
{
setModules(modules, false);
@@ -34,12 +35,12 @@ CLexiconKeyChooser::CLexiconKeyChooser(
m_layout->setDirection(QBoxLayout::LeftToRight);
m_layout->setSizeConstraint(QLayout::SetNoConstraint);
- m_widget = new CKeyChooserWidget(0, false, this);
+ m_widget = new CKeyChooserWidget(0, this);
setFocusProxy(m_widget);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
- m_widget->comboBox()->setMaximumWidth(200);
+ m_widget->comboBox().setMaximumWidth(200);
m_widget->setToolTips(
tr("Entries of the current work"),
@@ -70,8 +71,8 @@ void CLexiconKeyChooser::updateKey(CSwordKey* key) {
}
QString newKey = m_key->key();
- const int index = m_widget->comboBox()->findText(newKey);
- m_widget->comboBox()->setCurrentIndex(index);
+ const int index = m_widget->comboBox().findText(newKey);
+ m_widget->comboBox().setCurrentIndex(index);
}
void CLexiconKeyChooser::setKey(CSwordKey* key) {
@@ -87,7 +88,7 @@ void CLexiconKeyChooser::setKey(CSwordKey* key) {
void CLexiconKeyChooser::activated(int index) {
// qWarning("activated");
- const QString text = m_widget->comboBox()->itemText(index);
+ const QString text = m_widget->comboBox().itemText(index);
// To prevent from eternal loop, because activated() is emitted again
if (m_key && m_key->key() != text) {
@@ -169,7 +170,7 @@ void CLexiconKeyChooser::setModules(const QList<const CSwordModuleInfo*> &module
}
}
-void CLexiconKeyChooser::setKey(QString& newKey) {
+void CLexiconKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index e014448..5f14747 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -77,7 +79,7 @@ class CLexiconKeyChooser : public CKeyChooser {
virtual void updateKey(CSwordKey* key);
protected slots:
- virtual void setKey(QString& newKey);
+ virtual void setKey(const QString & newKey);
};
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 9a92b5f..775d4db 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,10 +24,6 @@ CScrollButton::CScrollButton(QWidget *parent)
setCursor(Qt::SplitVCursor);
}
-CScrollButton::~CScrollButton() {
- // Intentionally empty
-}
-
void CScrollButton::mousePressEvent(QMouseEvent *e) {
if (m_isLocked) return;
if (e->button() != Qt::LeftButton) return;
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 06d272d..2b3f662 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +27,6 @@ class CScrollButton: public QToolButton {
Q_OBJECT
public:
CScrollButton(QWidget *parent = 0);
- virtual ~CScrollButton();
signals:
/**
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 4ad8750..e169ae9 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.cpp
+++ b/src/frontend/keychooser/cscrollerwidgetset.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,64 +16,69 @@
#include "frontend/keychooser/cscrollbutton.h"
-const unsigned int WIDTH = 16;
-const unsigned int ARROW_HEIGHT = 12;
-const unsigned int MOVER_HEIGHT = 6;
+#define WIDTH (static_cast<unsigned int>(16))
+#define ARROW_HEIGHT (static_cast<unsigned int>(12))
+#define MOVER_HEIGHT (static_cast<unsigned int>(6))
-CScrollerWidgetSet::CScrollerWidgetSet(QWidget *parent) : QWidget(parent) {
+
+CScrollerWidgetSet::CScrollerWidgetSet(QWidget * parent)
+ : QWidget(parent)
+{
m_layout = new QVBoxLayout(this);
m_layout->setSpacing(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);
- btn_up = new QToolButton(this);
- btn_up->setArrowType(Qt::UpArrow);
+ m_buttonUp = new QToolButton(this);
+ m_buttonUp->setArrowType(Qt::UpArrow);
- btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_up->setFocusPolicy(Qt::NoFocus);
- btn_up->setAutoRaise(true);
+ m_buttonUp->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonUp->setFocusPolicy(Qt::NoFocus);
+ m_buttonUp->setAutoRaise(true);
- btn_fx = new CScrollButton(this);
- btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
- btn_fx->setFocusPolicy(Qt::NoFocus);
+ m_scrollButton = new CScrollButton(this);
+ m_scrollButton->setFixedSize(WIDTH, MOVER_HEIGHT);
+ m_scrollButton->setFocusPolicy(Qt::NoFocus);
- btn_down = new QToolButton(this);
- btn_down->setArrowType(Qt::DownArrow);
- btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_down->setFocusPolicy(Qt::NoFocus);
- btn_down->setAutoRaise(true);
+ m_buttonDown = new QToolButton(this);
+ m_buttonDown->setArrowType(Qt::DownArrow);
+ m_buttonDown->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonDown->setFocusPolicy(Qt::NoFocus);
+ m_buttonDown->setAutoRaise(true);
- m_layout->addWidget( btn_up, 0 );
- m_layout->addWidget( btn_fx, 0 );
- m_layout->addWidget( btn_down, 0 );
+ m_layout->addWidget(m_buttonUp, 0);
+ m_layout->addWidget(m_scrollButton, 0);
+ m_layout->addWidget(m_buttonDown, 0);
setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.
- connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
- connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
- connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
- connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
- connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
+ connect(m_scrollButton, SIGNAL(lock()), SLOT(slotLock()));
+ connect(m_scrollButton, SIGNAL(unlock()), SLOT(slotUnlock()));
+ connect(m_scrollButton, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
+ connect(m_buttonUp, SIGNAL(clicked()), SLOT(slotUpClick()));
+ connect(m_buttonDown, SIGNAL(clicked()), SLOT(slotDownClick()));
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CScrollerWidgetSet::setToolTips( const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- btn_fx->setToolTip(scrollButtonTip);
- btn_down->setToolTip(nextEntryTip);
- btn_up->setToolTip(previousEntryTip);
+void CScrollerWidgetSet::setToolTips(const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_scrollButton->setToolTip(scrollButtonTip);
+ m_buttonDown->setToolTip(nextEntryTip);
+ m_buttonUp->setToolTip(previousEntryTip);
}
-void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
+void CScrollerWidgetSet::wheelEvent(QWheelEvent * e) {
/**
* The problem is, that wheel events do everytime have the delta value 120
*/
- const int vchange = ((e->delta() > 0) ? (-1) : (1));
+ const int vchange = ((e->delta() > 0) ? -1 : 1);
- if (vchange != 0) {//do not emit a change with value 0
+ if (vchange != 0) { // Do not emit a change with value 0
emit change(vchange);
e->accept();
- }
- else {
+ } else {
e->ignore();
}
}
@@ -81,15 +86,19 @@ void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
void CScrollerWidgetSet::slotLock() {
emit scroller_pressed();
}
+
void CScrollerWidgetSet::slotUnlock() {
emit scroller_released();
}
+
void CScrollerWidgetSet::slotScroller(int n) {
emit change(n);
}
+
void CScrollerWidgetSet::slotUpClick() {
slotScroller(-1);
}
+
void CScrollerWidgetSet::slotDownClick() {
slotScroller(1);
}
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index f2ae643..2894928 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,51 +23,53 @@ class QVBoxLayout;
/**
* This class implements the Scroller Widget-set, which
* consists of two normal ref @QToolButton and a enhanced @ref CScrollButton
- *
- * @author The BibleTime team
- */
-class CScrollerWidgetSet : public QWidget {
- Q_OBJECT
-
- public:
- CScrollerWidgetSet(QWidget *parent = 0);
-
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString nextEntry, const QString scrollButton, const QString previousEntry);
-
- signals:
- /**
- * Is emitted to proceed to some other entry relative to the
- * current, indicated by the int value.
- * \param count offset to change to
- */
- void change(int count);
-
- /**
- * These emit when the scroll button is pressed or released
- */
- void scroller_pressed();
- void scroller_released();
-
- protected:
-
- virtual void wheelEvent( QWheelEvent* e );
-
- QToolButton* btn_up;
- QToolButton* btn_down;
- CScrollButton* btn_fx;
-
- protected slots:
- void slotLock();
- void slotUnlock();
- void slotUpClick();
- void slotDownClick();
- void slotScroller(int);
-
- private:
- QVBoxLayout *m_layout;
+ */
+class CScrollerWidgetSet: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CScrollerWidgetSet(QWidget * parent = 0);
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+signals:
+
+ /**
+ * Is emitted to proceed to some other entry relative to the
+ * current, indicated by the int value.
+ * \param count offset to change to
+ */
+ void change(int count);
+
+ void scroller_pressed();
+
+ void scroller_released();
+
+protected: /* Methods: */
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+protected slots:
+
+ void slotLock();
+ void slotUnlock();
+ void slotUpClick();
+ void slotDownClick();
+ void slotScroller(int);
+
+private: /* Fields: */
+
+ QVBoxLayout * m_layout;
+ QToolButton * m_buttonUp;
+ QToolButton * m_buttonDown;
+ CScrollButton * m_scrollButton;
};
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
index 5feb371..2ac2574 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,11 +21,12 @@
#include <QStringList>
#include <QToolButton>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/keychooser/cscrollerwidgetset.h"
#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
#include "util/btsignal.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtLineEdit : public QLineEdit {
@@ -52,16 +53,13 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
{
Q_UNUSED(name);
- namespace DU = util::directory;
-
-
updatelock = false;
m_module = mod;
setFocusPolicy(Qt::WheelFocus);
QToolButton* clearRef = new QToolButton(this);
- clearRef->setIcon(DU::getIcon("edit_clear_locationbar"));
+ clearRef->setIcon(util::getIcon("edit_clear_locationbar"));
clearRef->setAutoRaise(true);
clearRef->setStyleSheet("QToolButton{margin:0px;}");
connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
@@ -138,7 +136,7 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
- bool ok = connect(m_key->signaler(), SIGNAL(changed()), this, SLOT(updateText()));
+ bool ok = connect(m_key->afterChangedSignaller(), SIGNAL(signal()), this, SLOT(updateText()));
Q_ASSERT(ok);
setKey(key); // The order of these two functions is important.
@@ -287,7 +285,7 @@ void BtBibleKeyWidget::slotChangeVerse(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setVerse(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock) emit changed(m_key);
@@ -298,7 +296,7 @@ void BtBibleKeyWidget::slotChangeChapter(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setChapter(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
@@ -310,7 +308,7 @@ void BtBibleKeyWidget::slotChangeBook(QString bookname) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->book( bookname );
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
index 644bc75..7d94c94 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index 8030aaf..70f800a 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index bdd56da..646b7ef 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index ac94299..9a8d35e 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,13 +25,15 @@ BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent)
void BtVerseKeyMenu::startFirstClickDelayTimer() {
m_firstClickLock = true;
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_timerId = startTimer(300);
}
void BtVerseKeyMenu::timerEvent(QTimerEvent* e) {
if (e->timerId() == m_timerId) {
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_firstClickLock = false;
}
else {
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index 343277c..18caab5 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 358c9c4..e481020 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,11 +20,12 @@
#include "util/cresmgr.h"
-CBibleKeyChooser::CBibleKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordVerseKey*>(key))
+CBibleKeyChooser::CBibleKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordVerseKey *>(key))
{
typedef CSwordBibleModuleInfo CSBMI;
@@ -126,7 +127,7 @@ void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {
void CBibleKeyChooser::adjustFont() {}
-void CBibleKeyChooser::setKey(QString& newKey) {
+void CBibleKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
index d2c5363..91ad265 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -70,10 +72,8 @@ class CBibleKeyChooser : public CKeyChooser {
void refreshContent();
protected slots:
- /**
- Reimplemented from CKeyChooser::setModules().
- */
- virtual void setKey(QString& newKey);
+
+ virtual void setKey(const QString & newKey);
private:
BtBibleKeyWidget* w_ref;
diff --git a/src/frontend/messagedialog.cpp b/src/frontend/messagedialog.cpp
new file mode 100644
index 0000000..f064f06
--- /dev/null
+++ b/src/frontend/messagedialog.cpp
@@ -0,0 +1,91 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "messagedialog.h"
+
+#include <QAction>
+#include <QDialogButtonBox>
+#include <QMessageBox>
+#include <QPushButton>
+
+
+namespace message {
+
+namespace {
+
+void replaceText(QDialogButtonBox *box, QDialogButtonBox::StandardButton flag,
+ const QString &text) {
+ QPushButton *button(box->button(flag));
+ if (button != 0) {
+ button->setText(text);
+ }
+}
+
+QMessageBox::StandardButton bt_messageBox(QMessageBox::Icon icon,
+ QWidget * parent,
+ const QString &title,
+ const QString &text,
+ QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton defaultButton)
+{
+ QMessageBox messageBox(icon, title, text, QMessageBox::Ok, parent);
+ messageBox.setTextFormat(Qt::RichText);
+ //We need the button box to translate the strings (the idea of this whole function)
+ QDialogButtonBox* box = dynamic_cast<QDialogButtonBox*>(messageBox.button(QMessageBox::Ok)->parent());
+ Q_ASSERT(box);
+ messageBox.setStandardButtons(buttons);
+ messageBox.setDefaultButton(defaultButton);
+ prepareDialogBox(box);
+ return (QMessageBox::StandardButton)messageBox.exec();
+}
+
+} // anonymous namespace
+
+void setQActionCheckedNoTrigger(QAction * const action, const bool checked) {
+ Q_ASSERT(action);
+ const bool signalsWereBlocked = action->blockSignals(true);
+ action->setChecked(checked);
+ action->blockSignals(signalsWereBlocked);
+}
+
+void prepareDialogBox(QDialogButtonBox *box) {
+ replaceText(box, QDialogButtonBox::Ok , QPushButton::tr("OK" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Open , QPushButton::tr("Open" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Save , QPushButton::tr("Save" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Cancel , QPushButton::tr("Cancel" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Close , QPushButton::tr("Close" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Discard , QPushButton::tr("Discard" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Apply , QPushButton::tr("Apply" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Reset , QPushButton::tr("Reset" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::RestoreDefaults, QPushButton::tr("Restore defaults", "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Help , QPushButton::tr("Help" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::SaveAll , QPushButton::tr("Save All" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::Yes , QPushButton::tr("Yes" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::YesToAll, QPushButton::tr("Yes to all", "Dialog Button"));
+ replaceText(box, QDialogButtonBox::No , QPushButton::tr("No" , "Dialog Button"));
+ replaceText(box, QDialogButtonBox::NoToAll , QPushButton::tr("No to all" , "Dialog Button"));
+}
+
+QMessageBox::StandardButton showWarning(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
+ return bt_messageBox(QMessageBox::Warning, parent, title, text, buttons, defaultButton);
+}
+
+QMessageBox::StandardButton showInformation(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
+ return bt_messageBox(QMessageBox::Information, parent, title, text, buttons, defaultButton);
+}
+
+QMessageBox::StandardButton showCritical(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
+ return bt_messageBox(QMessageBox::Critical, parent, title, text, buttons, defaultButton);
+}
+
+QMessageBox::StandardButton showQuestion(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
+ return bt_messageBox(QMessageBox::Question, parent, title, text, buttons, defaultButton);
+}
+
+} // namespace message
diff --git a/src/frontend/messagedialog.h b/src/frontend/messagedialog.h
new file mode 100644
index 0000000..3f1a34b
--- /dev/null
+++ b/src/frontend/messagedialog.h
@@ -0,0 +1,49 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef UTIL_DIALOG_UTIL_H
+#define UTIL_DIALOG_UTIL_H
+
+#include <QMessageBox>
+
+class QAction;
+class QDialogButtonBox;
+
+namespace message {
+
+/**
+ Change the state of a QAction without triggering their signals.
+ \param action The QAction instance to set the state for.
+ \param[in] checked The new state.
+*/
+void setQActionCheckedNoTrigger(QAction * const action, const bool checked = true);
+
+/**
+ Translates standard buttons in a QDialogButtonBox.
+*/
+void prepareDialogBox(QDialogButtonBox *box);
+
+/*
+ Use util::showWarning() etc. instead of QMessageBox static functions.
+ QMessageBox button texts are not translated trustworthily.
+*/
+
+QMessageBox::StandardButton showWarning(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+QMessageBox::StandardButton showCritical(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+QMessageBox::StandardButton showInformation(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+QMessageBox::StandardButton showQuestion(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+} // namespace message
+
+#endif
diff --git a/src/frontend/profile/cprofile.cpp b/src/frontend/profile/cprofile.cpp
deleted file mode 100644
index b1eca08..0000000
--- a/src/frontend/profile/cprofile.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/profile/cprofile.h"
-
-#include <QDomDocument>
-#include <QFile>
-#include <QString>
-#include <QTextStream>
-#include "util/directory.h"
-
-
-#define CURRENT_SYNTAX_VERSION 3
-
-namespace Profile {
-
-CProfile::CProfile( const QString& file, const QString& name )
- : m_name(name.isEmpty() ? QObject::tr("unknown") : name),
- m_filename(file),
- m_mdiArrangementMode((CMDIArea::MDIArrangementMode)0) { //0 is not a valid enum entry, means "unknown"
- namespace DU = util::directory;
-
- if (!m_filename.isEmpty() && name.isEmpty()) {
- loadBasics();
- }
- else if (m_filename.isEmpty() && !name.isEmpty()) {
- m_filename = name;
- m_filename.replace(QRegExp("\\s=#."), "_");
- m_filename = DU::getUserSessionsDir().absolutePath() + "/" + m_filename + ".xml";
- init(m_filename);
- }
- else {
- qWarning("CProfile: empty file name!");
- }
-}
-
-CProfile::~CProfile() {
- qDeleteAll(m_profileWindows); //there's no autodelete feature in qt4
- m_profileWindows.clear(); //delete all CProfileWindows objects
-}
-
-/** Loads the profile from the file given in the constructor. */
-QList<CProfileWindow*> CProfile::load() {
- QFile file(m_filename);
- if (!file.exists()) {
- //qWarning() << "Standard profile not found at filename " << m_filename;
- return QList<CProfileWindow*>();
- }
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- if ( document.tagName() != "BibleTimeProfile" && document.tagName() != "BibleTime" ) { //BibleTime was used in syntax version 1.0
- qWarning("CProfile::load: Missing BibleTime doc");
- return m_profileWindows;
- }
- if (document.hasAttribute("name")) {
- m_name = document.attribute("name");
- }
-
- //load settings of the main window
- {
- // see if there's a section with the name MAINWINDOW
- QDomElement elem = document.firstChild().toElement();
- QDomElement mainWindow;
- while (!elem.isNull()) {
- if (elem.tagName() == "MAINWINDOW") {
- mainWindow = elem;
- break; //found the element
- }
- elem = elem.nextSibling().toElement();
- }
- if (!mainWindow.isNull()) { //was found
-
- QByteArray bgeometry;
- bgeometry += mainWindow.attribute("geometry");
- setMainwindowGeometry(QByteArray::fromHex(bgeometry));
-
- QByteArray bstate;
- bstate += mainWindow.attribute("state");
- setMainwindowState(QByteArray::fromHex(bstate));
-
- QDomElement mdi_element = mainWindow.namedItem("MDI").toElement();
- if (!mdi_element.isNull()) {
- if (mdi_element.hasAttribute("ArrangementMode")) {
- this->setMDIArrangementMode((CMDIArea::MDIArrangementMode)mdi_element.attribute("ArrangementMode").toInt());
- }
- }
- }
- }
-
- m_profileWindows.clear();
- QDomElement elem = document.firstChild().toElement();
- while (!elem.isNull()) {
- CProfileWindow* p = 0;
- if (elem.tagName() == "BIBLE") {
- p = new CProfileWindow(CSwordModuleInfo::Bible);
- }
- else if (elem.tagName() == "COMMENTARY") {
- p = new CProfileWindow(CSwordModuleInfo::Commentary);
- }
- else if (elem.tagName() == "LEXICON") {
- p = new CProfileWindow(CSwordModuleInfo::Lexicon);
- }
- else if (elem.tagName() == "BOOK") {
- p = new CProfileWindow(CSwordModuleInfo::GenericBook);
- }
-
- if (p) {
- m_profileWindows.append(p);
-
- if (elem.hasAttribute("windowSettings")) {
- p->windowSettings = elem.attribute("windowSettings").toInt();
- }
- if (elem.hasAttribute("writeWindowType")) {
- p->writeWindowType = elem.attribute("writeWindowType").toInt();
- }
- if (elem.hasAttribute("hasFocus")) {
- p->hasFocus = elem.attribute("hasFocus").toInt();
- }
-
- QRect rect;
-
- QDomElement object = elem.namedItem("GEOMETRY").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("x")) {
- rect.setX(object.attribute("x").toInt());
- }
- if (object.hasAttribute("y")) {
- rect.setY(object.attribute("y").toInt());
- }
- if (object.hasAttribute("width")) {
- rect.setWidth(object.attribute("width").toInt());
- }
- if (object.hasAttribute("height")) {
- rect.setHeight(object.attribute("height").toInt());
- }
- if (object.hasAttribute("isMaximized")) {
- p->maximized = object.attribute("isMaximized").toInt();
- }
- }
- p->windowGeometry = rect;
-
- object = elem.namedItem("MODULES").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("list")) {
- const QString sep = object.hasAttribute("separator") ? object.attribute("separator") : "|";
- p->modules = object.attribute("list").split(sep);
- }
- }
-
- object = elem.namedItem("KEY").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("name"))
- p->key = object.attribute("name");
- }
-
- object = elem.namedItem("SCROLLBARS").toElement();
- if (!object.isNull()) {
- p->scrollbarPosH = object.hasAttribute("horizontal")
- ? object.attribute("horizontal").toInt()
- : 0;
- p->scrollbarPosV = object.hasAttribute("vertical")
- ? object.attribute("vertical").toInt()
- : 0;
- }
- }
- elem = elem.nextSibling().toElement();
- }
-
- // Are any windows maximized?
- bool maximized = false;
- for (int i = 0; i < m_profileWindows.count(); i++) {
- if (m_profileWindows.at(i)->maximized)
- maximized = true;
- }
- // Set all windows the same for maximized
- for (int i = 0; i < m_profileWindows.count(); i++) {
- m_profileWindows.at(i)->maximized = maximized;
- }
-
- return m_profileWindows;
-}
-
-/** Saves the profile to the file given in the constructor. */
-bool CProfile::save(QList<CProfileWindow*> windows) {
- /** Save the settings using a XML file
- * Save the CProfileWindow objects using a XML file which name is in m_filename
- */
- bool ret = false;
- QDomDocument doc("DOC");
- doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
-
- QDomElement content = doc.createElement("BibleTimeProfile");
- content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
- content.setAttribute("name", m_name);
- doc.appendChild(content);
-
- //save mainwindow settings
- {
- QDomElement mainWindow = doc.createElement("MAINWINDOW");
-
- QString sgeometry = QString(getMainwindowGeometry().toHex());
- mainWindow.setAttribute("geometry", sgeometry);
-
- QString sstate = QString(getMainwindowState().toHex());
- mainWindow.setAttribute("state", sstate);
-
- QDomElement mdi = doc.createElement("MDI");
- mainWindow.appendChild(mdi);
- mdi.setAttribute("ArrangementMode", static_cast<int>(this->getMDIArrangementMode()));
-
- content.appendChild(mainWindow);
- }
-
- //for (CProfileWindow* p = windows.first(); p; p = windows.next()) {
- foreach(CProfileWindow* p, windows) {
- QDomElement window;
- switch (p->type) {
- case CSwordModuleInfo::Bible:
- window = doc.createElement("BIBLE");
- break;
- case CSwordModuleInfo::Commentary:
- window = doc.createElement("COMMENTARY");
- break;
- case CSwordModuleInfo::Lexicon:
- window = doc.createElement("LEXICON");
- break;
- case CSwordModuleInfo::GenericBook:
- window = doc.createElement("BOOK");
- break;
- default:
- break;
- }
- if (window.isNull())
- break;
- window.setAttribute("windowSettings", p->windowSettings);
- window.setAttribute("writeWindowType", p->writeWindowType);
- window.setAttribute("hasFocus", p->hasFocus);
-
- //save geomtery
- const QRect & r = p->windowGeometry;
- QDomElement geometry = doc.createElement("GEOMETRY");
- geometry.setAttribute("x", r.x());
- geometry.setAttribute("y", r.y());
- geometry.setAttribute("width", r.width());
- geometry.setAttribute("height", r.height());
- geometry.setAttribute("isMaximized", static_cast<int>(p->maximized));
- window.appendChild( geometry );
-
- QDomElement modules = doc.createElement("MODULES");
- modules.setAttribute("separator", "|");
- modules.setAttribute("list", p->modules.join("|"));
- window.appendChild( modules );
-
- QDomElement key = doc.createElement("KEY");
- key.setAttribute("name", p->key);
- window.appendChild( key );
-
- QDomElement scrollbars = doc.createElement("SCROLLBARS");
- scrollbars.setAttribute("horizontal", p->scrollbarPosH);
- scrollbars.setAttribute("vertical", p->scrollbarPosV);
- window.appendChild( scrollbars );
-
- content.appendChild( window );
- }
-
- QFile file(m_filename);
- if ( file.open(QIODevice::WriteOnly) ) {
- ret = true;
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
- else
- ret = false;
-
- return ret;
-}
-
-/** Saves the profile to the file given in the constructor. */
-bool CProfile::save() {
- return save(m_profileWindows);
-}
-
-/** Initializes the XML for the first time (use to create a new profile) */
-void CProfile::init(const QString file) {
- const QString oldFile = m_filename;
- m_filename = file;
- save(QList<CProfileWindow*>());
- m_filename = oldFile;
-}
-
-/** Changes the name of this profile. */
-void CProfile::setName( const QString& newName ) {
- m_name = newName;
- saveBasics(); //save chanegd name
-}
-
-/** Loads the basic settings requires for proper operation. */
-void CProfile::loadBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
- QDomElement document = doc.documentElement();
- if (document.hasAttribute("name"))
- m_name = document.attribute("name");
-}
-
-void CProfile::saveBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t(&file);
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- document.setAttribute("name", m_name);
-
- if (file.open(QIODevice::WriteOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
-}
-
-void CProfile::setMDIArrangementMode(const CMDIArea::MDIArrangementMode newArrangementMode) {
- m_mdiArrangementMode = newArrangementMode;
-}
-
-CMDIArea::MDIArrangementMode CProfile::getMDIArrangementMode(void) {
- return m_mdiArrangementMode;
-}
-
-void CProfile::setMainwindowGeometry(const QByteArray& geometry) {
- m_mainwindowGeometry = geometry;
-}
-
-QByteArray CProfile::getMainwindowGeometry() {
- return m_mainwindowGeometry;
-}
-
-void CProfile::setMainwindowState(const QByteArray& state) {
- m_mainwindowState = state;
-}
-
-QByteArray CProfile::getMainwindowState() {
- return m_mainwindowState;
-}
-
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofile.h b/src/frontend/profile/cprofile.h
deleted file mode 100644
index 654160e..0000000
--- a/src/frontend/profile/cprofile.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CPROFILE_H
-#define CPROFILE_H
-
-#include <QByteArray>
-#include <QList>
-#include "frontend/cmdiarea.h"
-#include "frontend/profile/cprofilewindow.h"
-
-
-namespace Profile {
-
-/** Manages one profile file. Provides functions to save and restore settings of the available display windows.
- * @author The BibleTime team
- */
-class CProfile {
- public:
- CProfile(const QString& fileName, const QString& name = QString::null);
- ~CProfile();
-
- /**
- * Saves the profile to the file given in the constructor.
- * @param windows The list of windows available in the profile.
- */
- bool save( QList<CProfileWindow*> windows );
- /**
- * Saves the profile to the file given in the constructor.
- */
- bool save();
- /**
- * Loads the profile from the file given in the constructor.
- * @return The list of profiled window which exist in the profile.
- */
- QList<CProfileWindow*> load();
- /**
- * Returns the name of this profile.
- */
- inline const QString &name() const {
- return m_name;
- }
- /**
- * Returns the filename used for this profile.
- */
- inline const QString &filename() const {
- return m_filename;
- }
- /**
- * Initializes the XML for the first time (use to create a new profile)
- */
- void init(const QString);
- /**
- * Chnages the name of this profile.
- */
- void setName( const QString& );
- /**
- * Returns true if the main window was maximized as the profile was saved.
- */
- bool maximized() const;
- /**
- * Set the parameter to true if the main window is maximized.
- */
- void setMaximized( const bool maximized );
- /**
- * Sets the MDI arrangement mode
- */
- void setMDIArrangementMode(const CMDIArea::MDIArrangementMode);
- /**
- * Returns mdi arrangement mode
- */
- CMDIArea::MDIArrangementMode getMDIArrangementMode(void);
- /**
- * set mainwindow saveGeometry - size and position of window
- */
- void setMainwindowGeometry(const QByteArray& geometry);
- /**
- * Return mainwindow saveGeometry - size and position of window
- */
- QByteArray getMainwindowGeometry();
- /**
- * set mainwindow saveState - position of docking windows and toolbar
- */
- void setMainwindowState(const QByteArray& state);
- /**
- * Return mainwindow saveState - position of docking windows and toolbar
- */
- QByteArray getMainwindowState();
-
- private:
- /**
- * Loads the basic settings requires for proper operation.
- */
- void loadBasics();
- void saveBasics();
-
- QList<CProfileWindow*> m_profileWindows;
- QString m_name;
- QString m_filename;
- CMDIArea::MDIArrangementMode m_mdiArrangementMode;
- QByteArray m_mainwindowGeometry;
- QByteArray m_mainwindowState;
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/profile/cprofilemgr.cpp b/src/frontend/profile/cprofilemgr.cpp
deleted file mode 100644
index 4b8bcc3..0000000
--- a/src/frontend/profile/cprofilemgr.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/profile/cprofilemgr.h"
-
-#include <QDir>
-#include <QFile>
-#include <QList>
-#include "util/directory.h"
-
-
-namespace Profile {
-
-CProfileMgr::CProfileMgr() : m_startupProfile(0) {
- namespace DU = util::directory;
-
- //m_profiles.setAutoDelete(true);
-
- m_profilePath = DU::getUserSessionsDir().absolutePath() + "/";
-
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- if ((*it) != "_startup_.xml") {
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- else {
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
-}
-
-CProfileMgr::~CProfileMgr() {
- qDeleteAll(m_profiles);
- m_profiles.clear();
- delete m_startupProfile;
-}
-
-/** Creates a new profile with the name "name" (first parameter). @return The profile object */
-CProfile *CProfileMgr::create(const QString &name) {
- CProfile* p = new CProfile(QString::null, name);
- m_profiles.append(p);
-
- return p;
-}
-
-/** Removes the profile from the list and from the directory containg the profile files. */
-bool CProfileMgr::remove( CProfile* p ) {
- bool ret = false;
- QFile f( p->filename() );
- if (f.exists())
- f.remove();
-
- int i = m_profiles.indexOf(p);
- if (i != -1)
- delete m_profiles.takeAt(i);
-
- ret = true;
- return ret;
-}
-
-bool CProfileMgr::remove( const QString& profile) {
- bool ret = false;
- QListIterator<CProfile*> it(m_profiles);
- while (it.hasNext()) {
- CProfile* p = it.next();
- if (p->name() == profile) {
- remove(p);
- ret = true;
- }
- }
- return ret;
-}
-
-/** Returns the profile with the desired name. If there's no such profile 0 is returned. */
-CProfile * CProfileMgr::profile(const QString & name) const {
- Q_FOREACH (CProfile * const p, m_profiles) {
- if (p && p->name() == name)
- return p;
- }
- return 0;
-}
-
-/** Returns the startup profile if it exists, otherwise return 0. */
-CProfile* CProfileMgr::startupProfile() {
- if (!m_startupProfile) {
- m_startupProfile = new CProfile(QString::null, "_startup_");
- }
-
- return m_startupProfile;
-}
-
-/** Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile. */
-void CProfileMgr::refresh() {
- qDeleteAll(m_profiles);
- m_profiles.clear(); //delete all profiles
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- CProfile p(m_profilePath + *it);
- if (p.name() == "_startup_") { //new startup profile
- if (!m_startupProfile) { //don't put this in the if clause above,it doesn't work!
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
- else if (!profile(p.name())) { //don't have it already
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- }
-}
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilemgr.h b/src/frontend/profile/cprofilemgr.h
deleted file mode 100644
index 00bb321..0000000
--- a/src/frontend/profile/cprofilemgr.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CPROFILEMGR_H
-#define CPROFILEMGR_H
-
-#include <QList>
-#include <QString>
-#include "frontend/profile/cprofile.h"
-
-
-namespace Profile {
-/** The manager for profiles.
- * Provides functions to create, delete, save and load profiles.
- * @author The BibleTime team
- */
-class CProfileMgr {
- public:
- CProfileMgr();
- ~CProfileMgr();
-
- /** Creates a new profile with the name "name" (first parameter).
- * @return The profile object
- */
- CProfile *create(const QString &name);
- /**
- * @return a list of available profiles
- */
- inline const QList<CProfile*> &profiles() const {
- return m_profiles;
- }
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( CProfile* p );
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( const QString& );
- /**
- * Returns the profile with the desired name. If there's no such profile 0 is returned.
- */
- CProfile * profile(const QString & profileName) const;
- /**
- * Returns the startup profile if it exists, otherwise return 0.
- */
- CProfile* startupProfile();
- /**
- * Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile.
- */
- void refresh();
-
- protected:
- QList<CProfile*> m_profiles;
- QString m_profilePath;
- CProfile* m_startupProfile;
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/profile/cprofilewindow.cpp b/src/frontend/profile/cprofilewindow.cpp
deleted file mode 100644
index 682c99a..0000000
--- a/src/frontend/profile/cprofilewindow.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/profile/cprofilewindow.h"
-
-
-namespace Profile {
-
-CProfileWindow::CProfileWindow(CSwordModuleInfo::ModuleType t)
- : type(t)
- , windowGeometry()
- , modules()
- , key(QString::null)
- , scrollbarPosH(0)
- , scrollbarPosV(0)
- , maximized(false)
- , hasFocus(false)
- , windowSettings(0)
- , writeWindowType(0)
-{
- // Intentionally empty
-}
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilewindow.h b/src/frontend/profile/cprofilewindow.h
deleted file mode 100644
index 78d2b71..0000000
--- a/src/frontend/profile/cprofilewindow.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2011 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CPROFILEWINDOW_H
-#define CPROFILEWINDOW_H
-
-#include <QRect>
-#include <QString>
-#include <QStringList>
-#include "backend/drivers/cswordmoduleinfo.h"
-
-
-class CSwordModuleInfo;
-
-namespace Profile {
-
-/** Contains the settings for one window saved in the profile.
- * @author The BibleTime team
- */
-struct CProfileWindow {
-
- CProfileWindow(CSwordModuleInfo::ModuleType type = CSwordModuleInfo::Unknown);
-
- CSwordModuleInfo::ModuleType type;
- QRect windowGeometry;
- QStringList modules;
- QString key;
- int scrollbarPosH;
- int scrollbarPosV;
- bool maximized;
- bool hasFocus;
- int windowSettings;
- int writeWindowType;
-
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index ece0ced..10e4566 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,7 +18,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
#include "frontend/searchdialog/analysis/csearchanalysisview.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
namespace Search {
@@ -59,7 +59,7 @@ void CSearchAnalysisDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
m_buttonBox->addButton(QDialogButtonBox::Save);
//tr("Save as HTML"),
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
vboxLayout->addWidget(m_buttonBox);
bool ok = QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index b4edcad..454e105 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index 23b2962..c516184 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,6 +17,7 @@
#include <QRect>
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
+#include "util/htmlescape.h"
namespace Search {
@@ -61,17 +62,6 @@ CSearchAnalysisItem::~CSearchAnalysisItem() {
delete m_bufferPixmap;
}
-/** Sets the resultcount of this item for the given module */
-void CSearchAnalysisItem::setCountForModule( const int moduleIndex, const int count) {
- m_resultCountArray[moduleIndex] = count;
-}
-
-/** Returns the resultcount of this item for the given module */
-int CSearchAnalysisItem::getCountForModule( const int moduleIndex) {
- return m_resultCountArray[moduleIndex];
-}
-
-
bool CSearchAnalysisItem::hasHitsInAnyModule() {
foreach (const int hits, m_resultCountArray) {
if (hits) return true;
@@ -142,33 +132,36 @@ int CSearchAnalysisItem::width() {
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
typedef CSwordModuleSearch::Results::const_iterator RCI;
+ using util::htmlEscape;
- QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
- toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
+ QString toolTipString("<center><b>");
+ toolTipString.append(htmlEscape(m_bookName)).append("</b></center><hr/>")
+ .append("<table cellspacing=\"0\" cellpadding=\"3\" width=\"10"
+ "0%\" height=\"100%\" align=\"center\">");
/// \todo Fix that loop
int i = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- const CSwordModuleInfo *info = it.key();
-
- /// \warning This is a workaround for sword constness
- sword::ListKey &results = const_cast<sword::ListKey &>(it.value());
-
- const QColor c = CSearchAnalysisScene::getColor(i);
-
- toolTipString.append(
- QString("<tr bgcolor=\"white\"><td><b><font color=\"%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
- .arg(c.name())
- .arg(info ? info->name() : QString::null)
- .arg( m_resultCountArray[i] )
- .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)results.Count())*(double)100 : 0.0, 0, 'g', 2)
- );
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ const CSwordModuleInfo * const info = it.key();
+
+ const int count = it.value().getCount();
+ const double percent = (info && count)
+ ? ((static_cast<double>(m_resultCountArray.at(i))
+ * static_cast<double>(100.0))
+ / static_cast<double>(count))
+ : 0.0;
+ toolTipString.append("<tr bgcolor=\"white\"><td><b><font color=\"")
+ .append(CSearchAnalysisScene::getColor(i).name()).append("\">")
+ .append(info ? info->name() : QString::null)
+ .append("</font></b></td><td>")
+ .append(m_resultCountArray.at(i))
+ .append(" (")
+ .append(QString::number(percent, 'g', 2))
+ .append("%)</td></tr>");
++i;
}
- toolTipString += "</table>";
-
- return toolTipString;
+ return toolTipString.append("</table>");
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index 7db96a9..ec2cd03 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -27,15 +29,21 @@ class CSearchAnalysisItem : public QGraphicsRectItem {
const CSwordModuleSearch::Results &results);
~CSearchAnalysisItem();
+
/**
- * Sets the resultcount of this item
+ Sets the resultcount of this item.
*/
- void setCountForModule( const int moduleIndex, const int count);
+ inline void setCountForModule(const int moduleIndex, const int count) {
+ m_resultCountArray[moduleIndex] = count;
+ }
/**
- * Returns the resultcount of this item
+ Returns the resultcount of this item.
*/
- int getCountForModule( const int moduleIndex);
+ inline int getCountForModule(const int moduleIndex) const {
+ return m_resultCountArray[moduleIndex];
+ }
+
/**
* Does one of the modules contain hits?
*/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index c5b9d02..e630846 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index 232fe64..f199aaf 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index a039e19..9b375e8 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,12 @@
#include <QFileDialog>
#include <QHashIterator>
#include <QTextCodec>
+#include <QTextDocument>
#include "backend/keys/cswordversekey.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"
#include "frontend/searchdialog/analysis/csearchanalysislegenditem.h"
#include "frontend/searchdialog/csearchdialog.h"
+#include "util/htmlescape.h"
#include "util/tool.h"
@@ -88,7 +90,7 @@ void CSearchAnalysisScene::analyse(
bool ok = true;
while (ok && analysisItem) {
moduleIndex = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
qApp->processEvents( QEventLoop::AllEvents );
if (!m_lastPosList.contains(it.key())) {
m_lastPosList.insert(it.key(), 0);
@@ -120,7 +122,7 @@ void CSearchAnalysisScene::setResults(
typedef CSwordModuleSearch::Results::const_iterator RCI;
m_results.clear();
- for (RCI it = results.begin(); it != results.end(); it++) {
+ for (RCI it = results.begin(); it != results.end(); ++it) {
const CSwordModuleInfo *m = it.key();
if ( (m->type() == CSwordModuleInfo::Bible) || (m->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
m_results.insert(m, it.value());
@@ -205,13 +207,12 @@ QColor CSearchAnalysisScene::getColor(int index) {
unsigned int CSearchAnalysisScene::getCount(const QString &book,
const CSwordModuleInfo* module)
{
- /// \warning This is a workaround for sword constness
- sword::ListKey result = m_results[module];
+ const sword::ListKey & result = m_results[module];
const int length = book.length();
unsigned int i = m_lastPosList[module];
unsigned int count = 0;
- const unsigned int resultCount = result.Count();
+ const unsigned int resultCount = result.getCount();
while (i < resultCount) {
if (strncmp(book.toUtf8(), (const char *) *result.getElement(i), length))
break;
@@ -223,67 +224,86 @@ unsigned int CSearchAnalysisScene::getCount(const QString &book,
}
void CSearchAnalysisScene::saveAsHTML() {
- typedef CSwordModuleSearch::Results::const_iterator RCI;
-
- const QString fileName = QFileDialog::getSaveFileName(0, tr("Save Search Analysis"), QString::null, tr("HTML files (*.html;*.HTML;*.HTM;*.htm)") );
- if (fileName.isEmpty()) return;
-
- int count = 0;
- QString countStr = "";
- QString m_searchAnalysisHTML = "";
- QString tableTitle = "";
- QString tableTotals = "";
- QString VerseRange = "";
- const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
- const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
- CSwordVerseKey key(0);
+ using util::htmlEscape;
- key.setKey("Genesis 1:1");
-
- CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
-
- QString text = "<html>\n<head>\n<title>" + tr("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
- text += "<table>\n<tr><th>" + tr("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";
-
- tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
- tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
-
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- const CSwordModuleInfo *mod = it.key();
- tableTitle += QString("<th align=\"left\">") + mod->name() + QString("</th>");
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
- /// \warning This is a workaround for sword constness
- sword::ListKey searchResult = it.value();
- countStr.setNum(searchResult.Count());
+ const QString fileName = QFileDialog::getSaveFileName(0,
+ tr("Save Search Analysis"),
+ QString::null,
+ tr("XHTML files (*.html *.HTML *.HTM *.htm);;All files (*)"));
+ if (fileName.isEmpty())
+ return;
- tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
+ QString text("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>");
+ {
+ const QString title(tr("BibleTime Search Analysis"));
+ text += title;
+ text += "</title>"
+ "<style type=\"text/css\">"
+ "body{background-color:#fff;color:#000}"
+ "table{border-collapse:collapse}"
+ "td{border:1px solid #333}"
+ "th{font-size:130%;text-align:left;vertical-align:top}"
+ "td,th{text-align:left;padding:0.2em 0.5em}"
+ ".r{text-align:right}"
+ "</style>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
+ "</head><body><h1>";
+ text += title;
}
- tableTitle += QString("</tr>\n");
- tableTotals += QString("</tr>\n");
-
- m_searchAnalysisHTML = "";
- bool ok = true;
- while (ok) {
- m_searchAnalysisHTML += QString("<tr><td>") + key.book() + QString("</td>");
- analysisItem = m_itemList.value( key.book() );
+ text += "</h1><p><span style=\"font-weight:bold\">";
+ text += tr("Search text:");
+ text += "</span>&nbsp;";
+ text += htmlEscape(CSearchDialog::getSearchDialog()->searchText());
+ text += "</p><table><caption>";
+ text += tr("Results by work and book");
+ text += "</caption><tr><th>";
+ text += tr("Book");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<th>";
+ text += htmlEscape(it.key()->name());
+ text += "</th>";
+ }
+ text += "</tr>";
- int moduleIndex = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- count = analysisItem->getCountForModule(moduleIndex);
- countStr.setNum(count);
- m_searchAnalysisHTML += QString("<td align=\"right\">") + countStr + QString("</td>");
+ CSwordVerseKey key(0);
+ key.setKey("Genesis 1:1");
- ++moduleIndex;
+ do {
+ text += "<tr><td>";
+ const QString keyBook(key.book());
+ text += htmlEscape(keyBook);
+ text += "</td>";
+
+ int mi = 0; // Module index
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it, ++mi) {
+ text += "<td class=\"r\">";
+ text += QString::number(m_itemList.value(keyBook)->getCountForModule(mi));
+ text += "</td>";
}
- m_searchAnalysisHTML += QString("</tr>\n");
- ok = key.next(CSwordVerseKey::UseBook);
+ text += "</tr>";
+ } while (key.next(CSwordVerseKey::UseBook));
+ text += "<tr><th class=\"r\">";
+ text += tr("Total hits");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<td class=\"r\">";
+ text += QString::number(it.value().getCount());
+ text += "</td>";
}
- text += QString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + QString("</table>\n");
- text += QString("<center>") + tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>") + QString("</center>");
- text += QString("</body></html>");
+ text += "</tr></table><p style=\"text-align:center;font-size:x-small\">";
+ text += tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>");
+ text += "</p></body></html>";
- util::tool::savePlainFile(fileName, text, false, QTextCodec::codecForName("UTF8"));
+ util::tool::savePlainFile(fileName, text, true, QTextCodec::codecForName("UTF8"));
}
void CSearchAnalysisScene::resizeHeight(int height) {
@@ -291,4 +311,4 @@ void CSearchAnalysisScene::resizeHeight(int height) {
slotResized();
}
-}
+} // namespace Search {
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index f8bb966..d1927d5 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index d177f63..277c1a3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index 19d53c1..4b072f3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
index 1d5f556..a5bfd2c 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -43,10 +43,6 @@ BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
retranslateUi();
}
-BtSearchModuleChooserDialog::~BtSearchModuleChooserDialog() {
- // Intentionally empty
-}
-
void BtSearchModuleChooserDialog::retranslateUi() {
setWindowTitle(tr("Works to Search in"));
util::tool::initExplanationLabel(label(), QString::null,
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.h b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
index 103682c..79802b5 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.h
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -26,7 +26,6 @@ class BtSearchModuleChooserDialog: public BtModuleChooserDialog {
public:
BtSearchModuleChooserDialog(QWidget *parent = 0,
Qt::WindowFlags flags = 0);
- ~BtSearchModuleChooserDialog();
inline void setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
bookshelfWidget()->treeModel()->setCheckedModules(modules);
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index 902666b..d850344 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.cpp
+++ b/src/frontend/searchdialog/btsearchoptionsarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,20 +16,25 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
-#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
#include "frontend/searchdialog/crangechooserdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+namespace {
+const QString SearchTypeKey = "GUI/SearchDialog/searchType";
+} // anonymous namespace
+
namespace Search {
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
@@ -57,10 +62,6 @@ BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType() {
return BtSearchOptionsArea::FullType;
}
-QPushButton* BtSearchOptionsArea::searchButton() const {
- return m_searchButton;
-}
-
void BtSearchOptionsArea::setSearchText(const QString& text) {
bool found = false;
int i = 0;
@@ -82,8 +83,6 @@ void BtSearchOptionsArea::setSearchText(const QString& text) {
}
void BtSearchOptionsArea::initView() {
- namespace DU = util::directory;
-
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
this->setSizePolicy(sizePolicy);
hboxLayout = new QHBoxLayout(this);
@@ -103,17 +102,17 @@ void BtSearchOptionsArea::initView() {
m_searchButton = new QPushButton(this);
m_searchButton->setText(tr("&Search"));
- m_searchButton->setIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ m_searchButton->setIcon(util::getIcon(CResMgr::searchdialog::icon));
m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
gridLayout->addWidget(m_searchButton, 0, 2);
m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
- m_chooseModulesButton->setIcon(DU::getIcon(CResMgr::searchdialog::chooseworks_icon));
+ m_chooseModulesButton->setIcon(util::getIcon(CResMgr::searchdialog::chooseworks_icon));
m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
gridLayout->addWidget(m_chooseModulesButton, 2, 2);
m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
- m_chooseRangeButton->setIcon(DU::getIcon(CResMgr::searchdialog::setupscope_icon));
+ m_chooseRangeButton->setIcon(util::getIcon(CResMgr::searchdialog::setupscope_icon));
m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
gridLayout->addWidget(m_chooseRangeButton, 3, 2);
@@ -243,7 +242,7 @@ void BtSearchOptionsArea::setModules(const QList<const CSwordModuleInfo*> &modul
for (int i = 0; i < m_modulesCombo->count(); ++i) {
historyList.append(m_modulesCombo->itemText(i));
}
- CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
+ btConfig().setValue("history/searchModuleHistory", historyList);
emit sigSetSearchButtonStatus(!modules.isEmpty());
}
@@ -284,7 +283,7 @@ void BtSearchOptionsArea::reset() {
}
void BtSearchOptionsArea::saveSettings() {
- CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
+ btConfig().setValue("properties/searchTexts", m_searchTextCombo->historyItems());
SearchType t = FullType;
if (m_typeAndButton->isChecked()) {
t = AndType;
@@ -292,25 +291,25 @@ void BtSearchOptionsArea::saveSettings() {
if (m_typeOrButton->isChecked()) {
t = OrType;
}
- CBTConfig::set(CBTConfig::searchType, t);
+ btConfig().setValue(SearchTypeKey, t);
}
void BtSearchOptionsArea::readSettings() {
- QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
+ const QStringList texts = btConfig().value<QStringList>("properties/searchTexts", QStringList());
//for some reason the slot was called when setting the upmost item
disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- for (int i = 0; i < texts.size(); i++) {
- if (texts.at(i).size() > 0)
- m_searchTextCombo->addItem(texts.at(i));
+ Q_FOREACH (const QString & text, texts) {
+ if (text.size() > 0)
+ m_searchTextCombo->addItem(text);
}
connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
+ m_modulesCombo->insertItems(0, btConfig().value<QStringList>("history/searchModuleHistory", QStringList()));
for (int i = 0; i < m_modulesCombo->count(); ++i) {
m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
}
- int stype = CBTConfig::get(CBTConfig::searchType);
+ int stype = btConfig().value<int>(SearchTypeKey, AndType);
switch (stype) {
case AndType:
m_typeAndButton->setChecked(true);
@@ -336,8 +335,8 @@ void BtSearchOptionsArea::setupRanges() {
}
void BtSearchOptionsArea::syntaxHelp() {
- // The dialog is deleted on close:
- BtSearchSyntaxHelpDialog *dlg = new BtSearchSyntaxHelpDialog(this);
+ BtSearchSyntaxHelpDialog * dlg = new BtSearchSyntaxHelpDialog(this);
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
}
@@ -349,23 +348,22 @@ void BtSearchOptionsArea::refreshRanges() {
//m_rangeChooserCombo->insertItem(tr("Last search result"));
//insert the user-defined ranges
- m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
-
+ m_rangeChooserCombo->insertItems(1, btConfig().getSearchScopesForCurrentLocale().keys());
}
sword::ListKey BtSearchOptionsArea::searchScope() {
if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
QString scope = map[ m_rangeChooserCombo->currentText() ];
if (!scope.isEmpty()) {
- return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
+ return sword::VerseKey().parseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
}
}
return sword::ListKey();
}
bool BtSearchOptionsArea::hasSearchScope() {
- return (searchScope().Count() > 0);
+ return (searchScope().getCount() > 0);
}
void BtSearchOptionsArea::addToHistory(const QString& text) {
@@ -419,7 +417,7 @@ void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
} // namespace Search
QDataStream &operator<<(QDataStream &out, const Search::BtSearchOptionsArea::SearchType &searchType) {
- out << (qint8) searchType;
+ out << static_cast<qint8>(searchType);
return out;
}
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index 375b5e7..a6483ac 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -56,7 +58,7 @@ class BtSearchOptionsArea : public QWidget {
SearchType searchType();
- QPushButton* searchButton() const;
+ inline QPushButton * searchButton() const { return m_searchButton; }
/**
Returns the list of used modules.
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 262ff23..6a82a4f 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,6 @@
#include "frontend/searchdialog/btsearchresultarea.h"
#include <QApplication>
-#include <QDebug>
#include <QFrame>
#include <QMenu>
#include <QProgressDialog>
@@ -22,13 +21,19 @@
#include <QWidget>
#include "backend/keys/cswordversekey.h"
#include "backend/rendering/cdisplayrendering.h"
-#include "frontend/display/cdisplay.h"
+#include "backend/config/btconfig.h"
+#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/searchdialog/cmoduleresultview.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/searchdialog/csearchresultview.h"
#include "util/tool.h"
+namespace {
+const QString MainSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/mainSplitterSizes";
+const QString ResultSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/resultSplitterSizes";
+} // anonymous namespace
+
namespace Search {
BtSearchResultArea::BtSearchResultArea(QWidget *parent)
@@ -76,7 +81,7 @@ void BtSearchResultArea::initView() {
QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
frameLayout->setContentsMargins(0, 0, 0, 0);
- m_previewDisplay = CDisplay::createReadInstance(0, m_displayFrame);
+ m_previewDisplay = new BtHtmlReadDisplay(0, m_displayFrame);
m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
frameLayout->addWidget(m_previewDisplay->view());
@@ -143,10 +148,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for bibles render 5 context verses
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//first go back and then go forward the keys to be in context
vk.previous(CSwordVerseKey::UseVerse);
@@ -174,10 +179,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for commentaries only one verse, but with heading
else if (module->type() == CSwordModuleInfo::Commentary) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//include Headings in display, they are indexed and searched too
if (vk.getVerse() == 1) {
@@ -198,295 +203,11 @@ void BtSearchResultArea::updatePreview(const QString& key) {
text = render.renderSingleKey(key, modules, settings);
}
- m_previewDisplay->setText( highlightSearchedText(text, searchedText) );
+ m_previewDisplay->setText( CSwordModuleSearch::highlightSearchedText(text, searchedText) );
m_previewDisplay->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key) );
}
}
-QStringList BtSearchResultArea::queryParser(const QString& queryString) {
- QString token;
- QStringList tokenList;
- int cnt, pos;
-
- token = "";
- cnt = 0;
- while (cnt < queryString.length()) {
- // add to token
- if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
- token = token + queryString[cnt];
- cnt++;
- }
- else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
- token = token + queryString[cnt];
- cnt++;
- }
- // token break
- else if (queryString[cnt] == ' ') {
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- token = "";
- cnt++;
- }
- // clucene appears to ignore quoted strings in the sence
- // that it treats all the words within quoted strings as
- // regular tokens and not as a single token.
- else if (queryString[cnt] == '"') {
- cnt++;
- }
- // wild card - treat as a special token break
- //else if (queryString[cnt] == '*') {
- // token = token + queryString[cnt];
- // token = token.simplified();
- // if ((token != "*") && (token != ""))
- // tokenList.append(token);
- // // start next token with wildcard (kin*m -> kin* *m)
- // token = "*";
- // cnt++;
- //}
- // the ! token is also a token break
- else if (queryString[cnt] == '!') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("!");
- token = "";
- cnt++;
- }
- // the - token is also a token break
- else if (queryString[cnt] == '-') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("-");
- token = "";
- cnt++;
- }
- // the + token is also a token break
- else if (queryString[cnt] == '+') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the + token
- tokenList.append("+");
- token = "";
- cnt++;
- }
- // the || token is also a token break
- else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("||");
- token = "";
- cnt += 2;
- }
- // the && token is also a token break
- else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("&&");
- token = "";
- cnt += 2;
- }
- else cnt++;
- }
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
-
- cnt = 0;
- QStringList::iterator it;
- for ( it = tokenList.begin(); it != tokenList.end(); it++ ) {
- //-----------------------------------------------------------
- // remove all the NOT(!) tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- //-----------------------------------------------------------
- // remove all the operator tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
- ((*it) == "AND") || ((*it) == "&&") ) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- // if the token contains a ^ then trim the remainder of the
- // token from the ^
- //What??? error: invalid conversion from ‘const void*’ to ‘int’
- // and how come "contains" returns bool but is used as int?
- //else if ( (pos = (*it).contains("^")) >= 0 ) {
- else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
- (*it) = (*it).left(pos - 1);
- }
- // if the token contains a ~ then trim the remainder of the
- // token from the ~
- else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
- (*it) = (*it).left(pos - 2) + "*";
- }
- }
- return(tokenList);
-}
-
-QString BtSearchResultArea::highlightSearchedText(const QString& content, const QString& searchedText) {
- QString ret = content;
-
- const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-
- // int index = 0;
- int index = ret.indexOf("<body", 0);
- int matchLen = 0;
- int length = searchedText.length();
-
- // Highlighting constants -
- // \todo We need to make the highlight color configurable.
- const QString rep1("<span style=\"background-color:#FFFF66;\">");
- const QString rep2("</span>");
- const unsigned int repLength = rep1.length() + rep1.length();
- const QString rep3("style=\"background-color:#FFFF66;\" ");
- const unsigned int rep3Length = rep3.length();
-
-
- QString newSearchText;
-
- newSearchText = searchedText;
-
- // find the strongs search lemma and highlight it
- // search the searched text for "strong:" until it is not found anymore
- QStringList list;
-
- // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
- // \todo find all possible seperators
- QString regExp = "\\s";
- list = searchedText.split(QRegExp(regExp));
- foreach (QString newSearchText, list) {
- int sstIndex; // strong search text index for finding "strong:"
- int idx1, idx2;
- QString sNumber, lemmaText;
-
- sstIndex = newSearchText.indexOf("strong:");
- if (sstIndex == -1)
- continue;
-
- // set the start index to the start of <body>
- int strongIndex = index;
-
- // Get the strongs number from the search text.
- // First, find the first space after "strong:"
- sstIndex = sstIndex + 7;
- // get the strongs number -> the text following "strong:" to the end of the string.
- sNumber = newSearchText.mid(sstIndex, -1);
- // find all the "lemma=" inside the the content
- while ((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
- // get the strongs number after the lemma and compare it with the
- // strongs number we are looking for
- idx1 = ret.indexOf("\"", strongIndex) + 1;
- idx2 = ret.indexOf("\"", idx1 + 1);
- lemmaText = ret.mid(idx1, idx2 - idx1);
-
- // this is interesting because we could have a strongs number like: G3218|G300
- // To handle this we will use some extra cpu cycles and do a partial match against
- // the lemmaText
- if (lemmaText.contains(sNumber)) {
- // strongs number is found now we need to highlight it
- // I believe the easiest way is to insert rep3 just before "lemma="
- ret = ret.insert(strongIndex, rep3);
- strongIndex += rep3Length;
- }
- strongIndex += 6; // 6 is the length of "lemma="
- }
- }
- //---------------------------------------------------------------------
- // now that the strong: stuff is out of the way continue with
- // other search options
- //---------------------------------------------------------------------
-
- // try to figure out how to use the lucene query parser
-
- //using namespace lucene::queryParser;
- //using namespace lucene::search;
- //using namespace lucene::analysis;
- //using namespace lucene::util;
-
- //wchar_t *buf;
- //char buf8[1000];
- //standard::WhitespaceAnalyzer analyzer;
- //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //QSharedPointer<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
- //StringReader reader(m_wcharBuffer);
- //TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
- //Token token;
- //while(tokenStream->next(&token) != 0) {
- // lucene_wcstoutf8(buf8, token.termText(), 1000);
- // printf("%s\n", buf8);
- //}
-
- //===========================================================
- // since I could not figure out the lucene query parser, I
- // made a simple parser.
- //===========================================================
- QStringList words = queryParser(newSearchText);
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- foreach (QString word, words) { //search for every word in the list
- QRegExp findExp;
- if (word.contains("*")) {
- length = word.length() - 1;
- word.replace('*', "\\S*"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else if (word.contains("?")) {
- length = word.length() - 1;
- word.replace('?', "\\S?"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else {
- length = word.length();
- findExp = QRegExp("\\b" + word + "\\b");
- }
-
- // index = 0; //for every word start at the beginning
- index = ret.indexOf("<body", 0);
- findExp.setCaseSensitivity(cs);
- //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
- while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
- matchLen = findExp.matchedLength();
- if (!util::tool::inHTMLTag(index, ret)) {
- length = matchLen;
- ret = ret.insert( index + length, rep2 );
- ret = ret.insert( index, rep1 );
- index += repLength;
- }
- index += length;
- }
- }
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- //qWarning("\n\n\n%s", ret.latin1());
- return ret;
-}
-
/** Initializes the signal slot conections of the child widgets, */
void BtSearchResultArea::initConnections() {
connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
@@ -506,26 +227,28 @@ void BtSearchResultArea::initConnections() {
* Load the settings from the resource file
*/
void BtSearchResultArea::loadDialogSettings() {
- QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
- if (mainSplitterSizes.count() > 0) {
+ QList<int> mainSplitterSizes = btConfig().value< QList<int> >(MainSplitterSizesKey, QList<int>());
+ if (mainSplitterSizes.count() > 0)
m_mainSplitter->setSizes(mainSplitterSizes);
- }
- else {
+ else
+ {
int w = this->size().width();
int w2 = m_moduleListBox->sizeHint().width();
mainSplitterSizes << w2 << w - w2;
m_mainSplitter->setSizes(mainSplitterSizes);
}
- QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) m_resultListSplitter->setSizes(resultSplitterSizes);
+
+ QList<int> resultSplitterSizes = btConfig().value< QList<int> >(ResultSplitterSizesKey, QList<int>());
+ if (resultSplitterSizes.count() > 0)
+ m_resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
void BtSearchResultArea::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, m_mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, m_resultListSplitter->sizes());
+ btConfig().setValue(MainSplitterSizesKey, m_mainSplitter->sizes());
+ btConfig().setValue(ResultSplitterSizesKey, m_resultListSplitter->sizes());
}
/******************************************************************************
@@ -533,15 +256,12 @@ void BtSearchResultArea::saveDialogSettings() const {
******************************************************************************/
StrongsResultList::StrongsResultList(const CSwordModuleInfo *module,
- const sword::ListKey &results,
+ const sword::ListKey & result,
const QString &strongsNumber)
{
using namespace Rendering;
- /// \warning This is a workaround for Sword constness
- sword::ListKey result = results;
-
- int count = result.Count();
+ int count = result.getCount();
if (!count)
return;
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index bd75a02..e7a167d 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -134,16 +136,6 @@ class BtSearchResultArea : public QWidget {
void initConnections();
/**
- * This function breakes the queryString into clucene tokens
- */
- QStringList queryParser(const QString& queryString);
-
- /**
- * This function highlights the searched text in the content using the search type given by search flags
- */
- QString highlightSearchedText(const QString& content, const QString& searchedText);
-
- /**
* Load the settings from the resource file
*/
void loadDialogSettings();
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
index a1debc3..f1acddc 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,7 +13,7 @@
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QWebView>
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
@@ -22,7 +22,6 @@ namespace Search {
BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- setAttribute(Qt::WA_DeleteOnClose);
resize(550, 340);
QVBoxLayout *l = new QVBoxLayout;
@@ -42,10 +41,6 @@ BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFl
retranslateUi();
}
-BtSearchSyntaxHelpDialog::~BtSearchSyntaxHelpDialog() {
- // Intentionally empty
-}
-
void BtSearchSyntaxHelpDialog::retranslateUi() {
namespace DU = util::directory;
@@ -219,7 +214,7 @@ void BtSearchSyntaxHelpDialog::retranslateUi() {
m_webView->setHtml(html, QUrl::fromLocalFile(DU::getIconDir().path()));
- util::prepareDialogBox(m_buttons);
+ message::prepareDialogBox(m_buttons);
}
void BtSearchSyntaxHelpDialog::linkClicked(const QUrl &url) {
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
index 89cc805..74b74b5 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +24,6 @@ class BtSearchSyntaxHelpDialog: public QDialog {
Q_OBJECT
public:
BtSearchSyntaxHelpDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtSearchSyntaxHelpDialog();
protected:
void retranslateUi();
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index cf77627..231bd65 100644
--- a/src/frontend/searchdialog/chistorycombobox.cpp
+++ b/src/frontend/searchdialog/chistorycombobox.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index dffbcd8..922b042 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index ab4810b..5bbc32f 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,10 +18,12 @@
#include <QtAlgorithms>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -43,8 +45,6 @@ CModuleResultView::~CModuleResultView() {
/** Initializes this widget. */
void CModuleResultView::initView() {
- namespace DU = util::directory;
-
// see also csearchresultview.cpp
setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
@@ -62,7 +62,7 @@ void CModuleResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
+ m_actions.copyMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
m_actions.copyMenu->addAction(m_actions.copy.result);
@@ -72,7 +72,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
+ m_actions.saveMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
m_actions.saveMenu->addAction(m_actions.save.result);
@@ -82,7 +82,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
m_actions.printMenu->addAction(m_actions.print.result);
@@ -96,48 +96,45 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-void CModuleResultView::setupTree(
- const CSwordModuleSearch::Results &results,
- const QString &searchedText)
+void CModuleResultView::setupTree(const CSwordModuleSearch::Results & results,
+ const QString & searchedText)
{
+ /// \todo implement sorting in this method.
+
clear();
m_results = results;
- /// \todo this class is for sorting
- //util::CSortListViewItem* item = 0;
- //util::CSortListViewItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
-
qDeleteAll(m_strongsResults);
m_strongsResults.clear();
bool strongsAvailable = false;
- Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
- sword::ListKey result = results.value(m);
-
- item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
- /// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
-
- item->setIcon(0, util::tool::getIconForModule(m) );
- //----------------------------------------------------------------------
- // we need to make a decision here. Either don't show any Strong's
- // number translations, or show the first one in the search text, or
- // figure out how to show them all.
- // I choose option number 2 at this time.
- //----------------------------------------------------------------------
- int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
- if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
- QString sNumber;
- //--------------------------------------------------
- // get the strongs number from the search text
- //--------------------------------------------------
- // first find the first space after "strong:"
- // this should indicate a change in search token
- sstIndex = sstIndex + 7;
- sTokenIndex = searchedText.indexOf(" ", sstIndex);
- sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
+ Q_FOREACH(const CSwordModuleInfo * m, results.keys()) {
+ /// \todo Remove this constructor hack once sword gets it right:
+ const int count = sword::ListKey(results.value(m)).getCount();
+ QTreeWidgetItem * item = new QTreeWidgetItem(this,
+ QStringList(m->name())
+ << QString::number(count));
+
+ item->setIcon(0, util::tool::getIconForModule(m));
+ /*
+ We need to make a decision here. Either don't show any Strong's
+ number translations, or show the first one in the search text, or
+ figure out how to show them all. I choose option number 2 at this time.
+ */
+
+ // strong search text index for finding "strong:"
+ int sstIndex = searchedText.indexOf("strong:", 0);
+ if (sstIndex != -1) {
+ /*
+ Get the strongs number from the search text. First find the first
+ space after "strong:". This should indicate a change in search
+ token
+ */
+ sstIndex += 7;
+ const int sTokenIndex = searchedText.indexOf(" ", sstIndex);
+ const QString sNumber(searchedText.mid(sstIndex, sTokenIndex - sstIndex));
setupStrongsResults(m, results[m], item, sNumber);
@@ -146,7 +143,7 @@ void CModuleResultView::setupTree(
}
};
- //Allow to hide the module strongs if there are any available
+ // Allow to hide the module strongs if there are any available
setRootIsDecorated( strongsAvailable );
}
@@ -269,8 +266,8 @@ void CModuleResultView::printResult() {
CSwordModuleInfo *m = activeModule();
if (m != 0) {
CExportManager mgr(true, tr("Printing search result"));
- mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
- CBTConfig::getFilterOptionDefaults());
+ mgr.printKeyList(m_results[m], m, btConfig().getDisplayOptions(),
+ btConfig().getFilterOptions());
};
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index 526ac16..24571d9 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/crangechooserdialog.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 6a8c89d..efece49 100644
--- a/src/frontend/searchdialog/crangechooserdialog.cpp
+++ b/src/frontend/searchdialog/crangechooserdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,8 +19,8 @@
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
-#include "util/dialogutil.h"
+#include "backend/config/btconfig.h"
+#include "frontend/messagedialog.h"
// Sword includes:
#include "versekey.h"
@@ -37,8 +37,8 @@ CRangeChooserDialog::CRangeChooserDialog(QWidget *parentDialog)
retranslateUi();
// Add the existing scopes
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
- CBTConfig::StringMap::Iterator it;
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
+ BtConfig::StringMap::Iterator it;
for (it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
}
@@ -74,7 +74,7 @@ void CRangeChooserDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
| QDialogButtonBox::RestoreDefaults);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
QHBoxLayout *rangeButtonsLayout = new QHBoxLayout();
rangeButtonsLayout->addWidget(m_newRangeButton);
@@ -176,6 +176,7 @@ void CRangeChooserDialog::addNewRange() {
void CRangeChooserDialog::selectedRangeChanged(QListWidgetItem * current,
QListWidgetItem * previous)
{
+ Q_UNUSED(current);
if (previous) {
Q_ASSERT(dynamic_cast<RangeItem*>(previous) != 0);
saveCurrentToRange(static_cast<RangeItem*>(previous));
@@ -211,9 +212,9 @@ void CRangeChooserDialog::updateResultList() {
//HACK: repair range to work with Sword 1.5.6
const QString range = m_rangeEdit->toPlainText().replace(QRegExp("\\s{0,}-\\s{0,}"), "-");
- sword::ListKey verses = VK().ParseVerseList(range.toUtf8().constData(),
+ sword::ListKey verses = VK().parseVerseList(range.toUtf8().constData(),
"Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
+ for (int i = 0; i < verses.getCount(); i++) {
new QListWidgetItem(QString::fromUtf8(verses.getElement(i)->getRangeText()),
m_resultList);
}
@@ -238,22 +239,23 @@ void CRangeChooserDialog::accept() {
// Save the new sorted map of search scopes:
m_rangeList->sortItems();
- CBTConfig::StringMap map;
+ BtConfig::StringMap map;
for (int i = 0; i < m_rangeList->count(); i++) {
Q_ASSERT(dynamic_cast<RangeItem*>(m_rangeList->item(i)) != 0);
const RangeItem * item = static_cast<RangeItem*>(m_rangeList->item(i));
map[item->caption()] = item->range();
}
- CBTConfig::set(CBTConfig::searchScopes, map);
+ btConfig().setSearchScopesWithCurrentLocale(map);
QDialog::accept();
}
void CRangeChooserDialog::restoreDefaults() {
- typedef CBTConfig::StringMap::ConstIterator SMCI;
+ typedef BtConfig::StringMap::ConstIterator SMCI;
m_rangeList->clear();
- const CBTConfig::StringMap map = CBTConfig::getDefault(CBTConfig::searchScopes);
+ btConfig().deleteSearchScopesWithCurrentLocale();
+ const BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
for (SMCI it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index db2ad30..a9cbaf4 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 8ce55d4..54981e3 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,18 +20,23 @@
#include <QVBoxLayout>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/cswordmodulesearch.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/btmoduleindexdialog.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "frontend/searchdialog/btsearchresultarea.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
+namespace {
+const QString GeometryKey = "GUI/SearchDialog/geometry";
+} // anonymous namespace
+
namespace Search {
static CSearchDialog* m_staticDialog = 0;
@@ -78,9 +83,7 @@ CSearchDialog* CSearchDialog::getSearchDialog() {
CSearchDialog::CSearchDialog(QWidget *parent)
: QDialog(parent), /*m_searchButton(0),*/ m_closeButton(0),
m_searchResultArea(0), m_searchOptionsArea(0) {
- namespace DU = util::directory;
-
- setWindowIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ setWindowIcon(util::getIcon(CResMgr::searchdialog::icon));
setWindowTitle(tr("Search"));
setAttribute(Qt::WA_DeleteOnClose);
@@ -123,7 +126,7 @@ void CSearchDialog::startSearch() {
moduleNames.append("</center><br>");
// Ask the user about unindexed modules:
- int result = util::showQuestion(
+ int result = message::showQuestion(
this, tr("Missing indices"),
tr("The following modules need to be indexed before they can be"
" searched in:") + moduleNames + tr("Indexing could take a l"
@@ -185,7 +188,7 @@ QString CSearchDialog::prepareSearchText(const QString& orig) {
qDebug() << "After syntax characters removed:" << text;
text.replace(andWords, "\"and\"");
text.replace(orWords, "\"or\"");
- qDebug() << "After andor repclaced:" << text;
+ qDebug() << "After \"and\" and \"or\" replaced:" << text;
text.replace(" ", " AND ");
}
if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::OrType) {
@@ -219,7 +222,6 @@ void CSearchDialog::setSearchText( const QString &searchText ) {
/** Initializes this object. */
void CSearchDialog::initView() {
- namespace DU = util::directory;
QVBoxLayout* verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
@@ -244,7 +246,7 @@ void CSearchDialog::initView() {
m_closeButton = new QPushButton(this);
m_closeButton->setText(tr("&Close"));
- m_closeButton->setIcon(DU::getIcon(CResMgr::searchdialog::close_icon));
+ m_closeButton->setIcon(util::getIcon(CResMgr::searchdialog::close_icon));
horizontalLayout->addWidget(m_closeButton);
verticalLayout->addLayout(horizontalLayout);
@@ -283,15 +285,11 @@ void CSearchDialog::closeButtonClicked() {
}
void CSearchDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::searchDialogWidth), CBTConfig::get(CBTConfig::searchDialogHeight));
- move(CBTConfig::get(CBTConfig::searchDialogX), CBTConfig::get(CBTConfig::searchDialogY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void CSearchDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchDialogWidth, size().width());
- CBTConfig::set(CBTConfig::searchDialogHeight, size().height());
- CBTConfig::set(CBTConfig::searchDialogX, x());
- CBTConfig::set(CBTConfig::searchDialogY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index dd2fcd2..dde8537 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index 7966e56..c08e5cc 100644
--- a/src/frontend/searchdialog/csearchresultview.cpp
+++ b/src/frontend/searchdialog/csearchresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +16,12 @@
#include <QTreeWidgetItem>
#include <QWidget>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/cdragdrop.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -33,8 +35,6 @@ CSearchResultView::CSearchResultView(QWidget* parent)
/** Initializes the view of this widget. */
void CSearchResultView::initView() {
- namespace DU = util::directory;
-
setToolTip(tr("Search result of the selected work"));
setHeaderLabel(tr("Results"));
setDragEnabled(true);
@@ -45,7 +45,7 @@ void CSearchResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
+ m_actions.copyMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyItems()) );
@@ -59,7 +59,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
+ m_actions.saveMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveItems()) );
@@ -71,7 +71,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printItems()) );
@@ -91,16 +91,14 @@ void CSearchResultView::initConnections() {
/** Setups the list with the given module. */
void CSearchResultView::setupTree(const CSwordModuleInfo *m,
- const sword::ListKey &results)
+ const sword::ListKey & result)
{
clear();
if (!m) return;
m_module = m;
- /// \warning This is a workaround for Sword constness
- sword::ListKey &result = const_cast<sword::ListKey&>(results);
- const int count = result.Count();
+ const int count = result.getCount();
if (!count) return;
setUpdatesEnabled(false);
@@ -169,7 +167,7 @@ void CSearchResultView::printItems() {
foreach (QTreeWidgetItem* k, items) {
list.append( k->text(0) );
}
- mgr.printKeyList( list, module(), CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() );
+ mgr.printKeyList( list, module(), btConfig().getDisplayOptions(), btConfig().getFilterOptions() );
}
void CSearchResultView::saveItems() {
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 1d37cbd..76b6d38 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.cpp b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
index 4d943c4..7fcf6b5 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.cpp
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.h b/src/frontend/settingsdialogs/btfontchooserwidget.h
index 9eb1f4d..eba5607 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.h
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontsettings.cpp b/src/frontend/settingsdialogs/btfontsettings.cpp
index 77a8b0b..57a8aba 100644
--- a/src/frontend/settingsdialogs/btfontsettings.cpp
+++ b/src/frontend/settingsdialogs/btfontsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,11 +16,13 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/btfontchooserwidget.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
// Sword includes:
#include <localemgr.h>
@@ -28,10 +30,8 @@
BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::fonts::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::fonts::icon), parent)
{
- namespace DU = util::directory;
-
m_languageLabel = new QLabel(this);
m_languageComboBox = new QComboBox(this);
m_languageLabel->setBuddy(m_languageComboBox);
@@ -58,13 +58,13 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
? &L::abbrev
: &L::translatedName;
- m_fontMap.insert((l->*f)(), CBTConfig::get(l));
+ m_fontMap.insert((l->*f)(), btConfig().getFontForLanguage(*l));
}
for (FontMap::ConstIterator it = m_fontMap.constBegin(); it != m_fontMap.constEnd(); ++it) {
const QString &k = it.key();
if (m_fontMap[k].first) { // show font icon
- m_languageComboBox->addItem(DU::getIcon("fonts.svg"), k);
+ m_languageComboBox->addItem(util::getIcon("fonts.svg"), k);
} else { // don't show icon for font
m_languageComboBox->addItem(k);
}
@@ -84,7 +84,7 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
connect(m_languageComboBox, SIGNAL(activated(const QString&)),
this, SLOT(newDisplayWindowFontAreaSelected(const QString&)));
- const CBTConfig::FontSettingsPair &v = m_fontMap.value(m_languageComboBox->currentText());
+ const BtConfig::FontSettingsPair &v = m_fontMap.value(m_languageComboBox->currentText());
m_fontChooser->setFont(v.second);
useOwnFontClicked(v.first);
m_languageCheckBox->setChecked(v.first);
@@ -116,12 +116,12 @@ void BtFontSettingsPage::save() const {
// We possibly use a language, for which we have only the abbrevation
if (!lang->abbrev().isEmpty()) {
// Create a temp language:
- CLanguageMgr::Language l(k, k, k);
- CBTConfig::set(&l, it.value());
+ const CLanguageMgr::Language l(k, k, k);
+ btConfig().setFontForLanguage(l, it.value());
}
}
else {
- CBTConfig::set(lang, it.value());
+ btConfig().setFontForLanguage(*lang, it.value());
}
}
}
@@ -129,23 +129,21 @@ void BtFontSettingsPage::save() const {
void BtFontSettingsPage::newDisplayWindowFontSelected(const QFont &newFont) {
const QString languageName = m_languageComboBox->currentText();
m_fontMap.insert(languageName,
- CBTConfig::FontSettingsPair(m_fontMap[languageName].first, newFont));
+ BtConfig::FontSettingsPair(m_fontMap[languageName].first, newFont));
}
void BtFontSettingsPage::newDisplayWindowFontAreaSelected(const QString &usage) {
- const CBTConfig::FontSettingsPair &p = m_fontMap[usage];
+ const BtConfig::FontSettingsPair &p = m_fontMap[usage];
useOwnFontClicked(p.first);
m_languageCheckBox->setChecked(p.first);
m_fontChooser->setFont(p.second);
}
void BtFontSettingsPage::useOwnFontClicked(bool isOn) {
- namespace DU = util::directory;
-
m_fontChooser->setEnabled(isOn);
m_fontMap[m_languageComboBox->currentText()].first = isOn;
m_languageComboBox->setItemIcon(m_languageComboBox->currentIndex(),
- isOn ? DU::getIcon("fonts.svg") : QIcon());
+ isOn ? util::getIcon("fonts.svg") : QIcon());
}
void BtFontSettingsPage::retranslateUi() {
diff --git a/src/frontend/settingsdialogs/btfontsettings.h b/src/frontend/settingsdialogs/btfontsettings.h
index 659cd75..70d0d20 100644
--- a/src/frontend/settingsdialogs/btfontsettings.h
+++ b/src/frontend/settingsdialogs/btfontsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +16,7 @@
#include <QMap>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
class BtFontChooserWidget;
@@ -30,7 +32,7 @@ class BtFontSettingsPage: public BtConfigDialog::Page {
private: /* Types: */
- typedef QMap<QString, CBTConfig::FontSettingsPair> FontMap;
+ typedef QMap<QString, BtConfig::FontSettingsPair> FontMap;
public: /* Methods: */
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.cpp b/src/frontend/settingsdialogs/btlanguagesettings.cpp
index be2dd17..37e53c8 100644
--- a/src/frontend/settingsdialogs/btlanguagesettings.cpp
+++ b/src/frontend/settingsdialogs/btlanguagesettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,11 +14,12 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
// Sword includes:
#include <localemgr.h>
@@ -29,7 +30,7 @@ typedef std::list<sword::SWBuf>::const_iterator SBLCI;
BtLanguageSettingsPage::BtLanguageSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::languages::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::languages::icon), parent)
{
m_swordLocaleCombo = new QComboBox(this);
m_languageNamesLabel = new QLabel(this);
@@ -44,7 +45,7 @@ BtLanguageSettingsPage::BtLanguageSettingsPage(CConfigurationDialog *parent)
}
void BtLanguageSettingsPage::save() {
- CBTConfig::set(CBTConfig::language, m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()).toString());
+ btConfig().setValue("language", m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()));
}
void BtLanguageSettingsPage::resetLanguage() {
@@ -67,14 +68,14 @@ void BtLanguageSettingsPage::resetLanguage() {
}
}
}
- CBTConfig::set(CBTConfig::language, best);
+ btConfig().setValue("language", best);
}
QVector<QString> BtLanguageSettingsPage::bookNameAbbreviationsTryVector() {
QVector<QString> atv;
atv.reserve(4);
{
- QString settingsLanguage = CBTConfig::get(CBTConfig::language);
+ QString settingsLanguage = btConfig().value<QString>("language");
if (!settingsLanguage.isEmpty())
atv.append(settingsLanguage);
}
@@ -132,5 +133,7 @@ void BtLanguageSettingsPage::retranslateUi() {
setHeaderText(tr("Languages"));
m_languageNamesLabel->setText(tr("Language for names of Bible books:"));
- m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
+ const QString toolTip(tr("The languages which can be used for the biblical book names. Translations are provided by the Sword library."));
+ m_languageNamesLabel->setToolTip(toolTip);
+ m_swordLocaleCombo->setToolTip(toolTip);
}
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.h b/src/frontend/settingsdialogs/btlanguagesettings.h
index 7c3b0c9..89caaf2 100644
--- a/src/frontend/settingsdialogs/btlanguagesettings.h
+++ b/src/frontend/settingsdialogs/btlanguagesettings.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
index a5d856d..10601f6 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.cpp
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -2,13 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/settingsdialogs/btshortcutsdialog.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include <QDialogButtonBox>
#include <QGridLayout>
@@ -56,7 +56,7 @@ BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
gridLayout->addWidget(m_alternateLabel, 1, 1);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- util::prepareDialogBox(buttons);
+ message::prepareDialogBox(buttons);
vLayout->addWidget(buttons);
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
index f475ebd..722cef9 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.h
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index 618e5ed..2e943eb 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.cpp
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
index f9a812a..d58ac08 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.h
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.cpp b/src/frontend/settingsdialogs/btstandardworkstab.cpp
new file mode 100644
index 0000000..9cef549
--- /dev/null
+++ b/src/frontend/settingsdialogs/btstandardworkstab.cpp
@@ -0,0 +1,203 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/settingsdialogs/btstandardworkstab.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QFormLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/settingsdialogs/cswordsettings.h"
+#include "util/tool.h"
+
+
+BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
+ : QWidget(parent)
+{
+ typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->setMargin(5);
+ mainLayout->setSpacing(2);
+
+ m_explanationLabel = new QLabel(this);
+ m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_explanationLabel->setMaximumHeight(50);
+ m_explanationLabel->setMinimumWidth(300);
+ mainLayout->addWidget(m_explanationLabel);
+
+ QFormLayout *formLayout = new QFormLayout;
+ formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+
+#define STANDARD_WORKS_TAB_ADD_ROW(name) \
+ if (true) { \
+ m_ ## name ## Label = new QLabel(this); \
+ m_ ## name ## Combo = new QComboBox(this); \
+ formLayout->addRow(m_ ## name ## Label, m_ ## name ## Combo); \
+ } else (void) 0
+
+ STANDARD_WORKS_TAB_ADD_ROW(standardBible);
+ STANDARD_WORKS_TAB_ADD_ROW(standardCommentary);
+ STANDARD_WORKS_TAB_ADD_ROW(standardLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardDailyDevotional);
+ STANDARD_WORKS_TAB_ADD_ROW(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardGreekStrongsLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardHebrewMorphLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardGreekMorphLexicon);
+
+ mainLayout->addLayout(formLayout);
+ mainLayout->addStretch();
+
+ //fill the comboboxes with the right modules
+
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
+ QString modDescript;
+ for (MLCI it(modules.begin()); it != modules.end(); it++) {
+ modDescript = (*it)->config(CSwordModuleInfo::Description);
+
+ switch ((*it)->type()) {
+ case CSwordModuleInfo::Bible:
+ m_standardBibleCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Commentary:
+ m_standardCommentaryCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Lexicon: {
+ bool inserted = false;
+ if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
+ m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekDef)) {
+ m_standardGreekStrongsLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
+ m_standardHebrewMorphLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekParse)) {
+ m_standardGreekMorphLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
+ m_standardDailyDevotionalCombo->addItem(modDescript);
+ inserted = true;
+ }
+
+ if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
+ m_standardLexiconCombo->addItem(modDescript);
+ }
+ break;
+ }
+ default://unknown type
+ break;
+ } //switch
+ } //for
+
+ //using two lists and one loop is better than six loops with almost the same code :)
+ QList<QComboBox*> comboList;
+ QStringList moduleList;
+
+ // fill combobox and modulelist
+ const CSwordModuleInfo* m;
+
+#define STANDARD_WORKS_COMBO_ADD(name) \
+ comboList.append(m_ ## name ## Combo); \
+ m = btConfig().getDefaultSwordModuleByType(#name); \
+ moduleList << (m != 0 ? m->config(CSwordModuleInfo::Description) : QString::null);
+
+ STANDARD_WORKS_COMBO_ADD(standardBible);
+ STANDARD_WORKS_COMBO_ADD(standardCommentary);
+ STANDARD_WORKS_COMBO_ADD(standardLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardDailyDevotional);
+ STANDARD_WORKS_COMBO_ADD(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardGreekStrongsLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardHebrewMorphLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardGreekMorphLexicon);
+
+ QString module = QString::null;
+ int item = 0;
+ int count = 0;
+ QListIterator<QComboBox*> it(comboList);
+ while (it.hasNext()) {
+ //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
+ QComboBox* combo = it.next();
+ module = moduleList[comboList.indexOf(combo)];
+ count = combo->count();
+
+ for (item = 0; item < count; item++) {
+ if (combo->itemText(item) == module ) {
+ combo->setCurrentIndex(item);
+ break;
+ }
+ }
+ }
+
+ retranslateUi();
+}
+
+#define STANDARD_WORKS_SET_DEFAULT(name) \
+ btConfig().setDefaultSwordModuleByType(\
+ #name, \
+ CSwordBackend::instance()->findModuleByDescription(m_ ## name ## Combo->currentText()) \
+ );
+
+void BtStandardWorksTab::save() {
+ STANDARD_WORKS_SET_DEFAULT(standardBible);
+ STANDARD_WORKS_SET_DEFAULT(standardCommentary);
+ STANDARD_WORKS_SET_DEFAULT(standardLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardDailyDevotional);
+ STANDARD_WORKS_SET_DEFAULT(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardGreekStrongsLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardHebrewMorphLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardGreekMorphLexicon);
+}
+
+void BtStandardWorksTab::retranslateUi() {
+ util::tool::initExplanationLabel(
+ m_explanationLabel, "",
+ tr("Standard works are used when no particular work is specified, for example "
+ "when a hyperlink into a Bible or lexicon was clicked."));
+
+ m_standardBibleLabel->setText(tr("Bible:"));
+ m_standardBibleCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
+
+ m_standardCommentaryLabel->setText(tr("Commentary:"));
+ m_standardCommentaryCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
+
+ m_standardLexiconLabel->setText(tr("Lexicon:"));
+ m_standardLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
+
+ m_standardDailyDevotionalLabel->setText(tr("Daily devotional:"));
+ m_standardDailyDevotionalCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
+
+ m_standardHebrewStrongsLexiconLabel->setText(tr("Hebrew Strong's lexicon:"));
+ m_standardHebrewStrongsLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardHebrewStrongsLexiconCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
+
+ m_standardGreekStrongsLexiconLabel->setText(tr("Greek Strong's lexicon:"));
+ m_standardGreekStrongsLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardGreekStrongsLexiconCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
+
+ m_standardHebrewMorphLexiconLabel->setText(tr("Hebrew morphological lexicon:"));
+ m_standardHebrewMorphLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardHebrewMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
+
+ m_standardGreekMorphLexiconLabel->setText(tr("Greek morphological lexicon:"));
+ m_standardGreekMorphLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardGreekMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
+}
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.h b/src/frontend/settingsdialogs/btstandardworkstab.h
new file mode 100644
index 0000000..0b91b4c
--- /dev/null
+++ b/src/frontend/settingsdialogs/btstandardworkstab.h
@@ -0,0 +1,55 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTSTANDARDWORKSTAB_H
+#define BTSTANDARDWORKSTAB_H
+
+#include <QWidget>
+
+
+class CSwordSettingsPage;
+class QCheckBox;
+class QComboBox;
+class QLabel;
+
+class BtStandardWorksTab: public QWidget {
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtStandardWorksTab(CSwordSettingsPage * parent);
+
+ void save();
+
+ protected: /* Methods: */
+
+ void retranslateUi();
+
+ private: /* Fields: */
+
+ QLabel * m_explanationLabel;
+
+#define STANDARD_WORKS_TAB_FIELD(name) \
+ QLabel * m_ ## name ## Label; \
+ QComboBox * m_ ## name ## Combo
+
+ STANDARD_WORKS_TAB_FIELD(standardBible);
+ STANDARD_WORKS_TAB_FIELD(standardCommentary);
+ STANDARD_WORKS_TAB_FIELD(standardLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardDailyDevotional);
+ STANDARD_WORKS_TAB_FIELD(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardGreekStrongsLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardHebrewMorphLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardGreekMorphLexicon);
+};
+
+#endif /* BTSTANDARDWORKSTAB_H */
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.cpp b/src/frontend/settingsdialogs/bttextfilterstab.cpp
new file mode 100644
index 0000000..e8da038
--- /dev/null
+++ b/src/frontend/settingsdialogs/bttextfilterstab.cpp
@@ -0,0 +1,87 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/settingsdialogs/bttextfilterstab.h"
+
+#include <QCheckBox>
+#include <QLabel>
+#include <QVBoxLayout>
+#include "backend/config/btconfig.h"
+#include "frontend/settingsdialogs/cswordsettings.h"
+#include "util/tool.h"
+
+
+#define TEXT_FILTERS_TAB_ADD_ROW(name,def) \
+ m_ ## name ## Check = new QCheckBox(this); \
+ m_ ## name ## Check->setChecked(btConfig().sessionValue<bool>(#name,(def))); \
+ layout->addWidget(m_ ## name ## Check);
+
+BtTextFiltersTab::BtTextFiltersTab(CSwordSettingsPage *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setMargin(5);
+ layout->setSpacing(2);
+
+ m_explanationLabel = new QLabel(this);
+ m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_explanationLabel->setMaximumHeight(50);
+ layout->addWidget(m_explanationLabel);
+
+ btConfig().beginGroup("presentation");
+ TEXT_FILTERS_TAB_ADD_ROW(lineBreaks, false);
+ TEXT_FILTERS_TAB_ADD_ROW(verseNumbers, false);
+ TEXT_FILTERS_TAB_ADD_ROW(headings, true);
+ TEXT_FILTERS_TAB_ADD_ROW(hebrewPoints, true);
+ TEXT_FILTERS_TAB_ADD_ROW(hebrewCantillation, true);
+ TEXT_FILTERS_TAB_ADD_ROW(morphSegmentation, true);
+ TEXT_FILTERS_TAB_ADD_ROW(greekAccents, true);
+ TEXT_FILTERS_TAB_ADD_ROW(textualVariants, false);
+ TEXT_FILTERS_TAB_ADD_ROW(scriptureReferences, true);
+ btConfig().endGroup();
+
+ layout->addStretch(4);
+
+ retranslateUi();
+}
+
+#define TEXT_FILTERS_TAB_SAVE(name) \
+ btConfig().setSessionValue(#name, m_ ## name ## Check->isChecked())
+
+void BtTextFiltersTab::save() {
+ btConfig().beginGroup("presentation");
+ TEXT_FILTERS_TAB_SAVE(lineBreaks);
+ TEXT_FILTERS_TAB_SAVE(verseNumbers);
+ TEXT_FILTERS_TAB_SAVE(headings);
+ TEXT_FILTERS_TAB_SAVE(hebrewPoints);
+ TEXT_FILTERS_TAB_SAVE(hebrewCantillation);
+ TEXT_FILTERS_TAB_SAVE(morphSegmentation);
+ TEXT_FILTERS_TAB_SAVE(greekAccents);
+ TEXT_FILTERS_TAB_SAVE(textualVariants);
+ TEXT_FILTERS_TAB_SAVE(scriptureReferences);
+ btConfig().endGroup();
+}
+
+
+void BtTextFiltersTab::retranslateUi() {
+ util::tool::initExplanationLabel(m_explanationLabel, "",
+ tr("Filters control the appearance of text. Here you can specify "
+ "default settings for all filters. You can override these "
+ "settings in each display window."));
+
+ m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
+ m_verseNumbersCheck->setText(tr("Show verse numbers"));
+ m_headingsCheck->setText(tr("Show section headings"));
+ m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
+ m_greekAccentsCheck->setText(tr("Show Greek accents"));
+ m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
+ m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
+ m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
+ m_textualVariantsCheck->setText(tr("Use textual variants"));
+}
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.h b/src/frontend/settingsdialogs/bttextfilterstab.h
new file mode 100644
index 0000000..3f6e904
--- /dev/null
+++ b/src/frontend/settingsdialogs/bttextfilterstab.h
@@ -0,0 +1,54 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTTEXTFILTERSTAB_H
+#define BTTEXTFILTERSTAB_H
+
+#include <QWidget>
+
+class CSwordSettingsPage;
+class QCheckBox;
+class QLabel;
+
+
+class BtTextFiltersTab: public QWidget {
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtTextFiltersTab(CSwordSettingsPage * parent);
+
+ void save();
+
+ protected: /* Methods: */
+
+ void retranslateUi();
+
+ private: /* Fields: */
+
+ QLabel * m_explanationLabel;
+
+#define TEXT_FILTERS_TAB_FIELD(name) QCheckBox * m_ ## name ## Check
+
+ TEXT_FILTERS_TAB_FIELD(lineBreaks);
+ TEXT_FILTERS_TAB_FIELD(verseNumbers);
+ TEXT_FILTERS_TAB_FIELD(headings);
+ TEXT_FILTERS_TAB_FIELD(hebrewPoints);
+ TEXT_FILTERS_TAB_FIELD(hebrewCantillation);
+ TEXT_FILTERS_TAB_FIELD(morphSegmentation);
+ TEXT_FILTERS_TAB_FIELD(greekAccents);
+ TEXT_FILTERS_TAB_FIELD(textualVariants);
+ TEXT_FILTERS_TAB_FIELD(scriptureReferences);
+
+};
+
+#endif /* BTTEXTFILTERSTAB_H */
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index 177ea2f..d85bf51 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,25 +13,25 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QList>
-#include <QMessageBox>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QWidget>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cbiblereadwindow.h"
#include "frontend/displaywindow/cbookreadwindow.h"
#include "frontend/displaywindow/ccommentaryreadwindow.h"
#include "frontend/displaywindow/clexiconreadwindow.h"
#include "frontend/displaywindow/creadwindow.h"
+#include "frontend/messagedialog.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::keys::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::keys::icon), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
@@ -48,21 +48,16 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
SLOT(slotKeyChooserTypeChanged(const QString&)) );
Q_ASSERT(ok);
+ // m_*.title strings are empty here, they are filled and added to the stacked widget in the retranslateUi() function
m_keyChooserStack = new QStackedWidget(this);
-
- m_typeChooser->addItem(m_application.title);
- m_typeChooser->addItem(m_general.title);
- m_typeChooser->addItem(m_bible.title);
- m_typeChooser->addItem(m_commentary.title);
- m_typeChooser->addItem(m_lexicon.title);
- m_typeChooser->addItem(m_book.title);
+ retranslateUi();
// create shortcuteditors
// ------ Application -------------- //
m_application.actionCollection = new BtActionCollection(this);
BibleTime::insertKeyboardActions( m_application.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::application, m_application.actionCollection);
+ m_application.actionCollection->readShortcuts("Application shortcuts");
m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_application.keyChooser);
ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -72,7 +67,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- All display windows ------ //
m_general.actionCollection = new BtActionCollection(this);
CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, m_general.actionCollection);
+ m_general.actionCollection->readShortcuts("Displaywindow shortcuts");
m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_general.keyChooser);
ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -82,7 +77,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Bible windows ------ //
m_bible.actionCollection = new BtActionCollection(this);
CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection);
+ m_bible.actionCollection->readShortcuts("Bible shortcuts");
m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_bible.keyChooser);
ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -92,7 +87,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Commentary windows ------ //
m_commentary.actionCollection = new BtActionCollection(this);
CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
+ m_commentary.actionCollection->readShortcuts("Commentary shortcuts");
m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_commentary.keyChooser);
ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -102,8 +97,8 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Lexicon windows ------ //
m_lexicon.actionCollection = new BtActionCollection(this);
CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection);
- m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack );
+ m_lexicon.actionCollection->readShortcuts("Lexicon shortcuts");
+ m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_lexicon.keyChooser);
ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
@@ -112,7 +107,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Book windows ------ //
m_book.actionCollection = new BtActionCollection(this);
CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, m_book.actionCollection);
+ m_book.actionCollection->readShortcuts("Book shortcuts");
m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_book.keyChooser);
ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -157,17 +152,12 @@ void CAcceleratorSettingsPage::completeKeyChangeRequest(BtShortcutsEditor* short
QString conflicts = findConflictsWithKeys(keys, list);
if (!conflicts.isEmpty()) {
QString message = QObject::tr("This shortcut conflicts with the shortcut for the following actions:");
- message.append("\n");
+ message.append("<br/><br/>");
message.append(conflicts);
- QMessageBox msgBox(this);
- msgBox.setIcon(QMessageBox::Question);
- msgBox.setText(message);
- msgBox.setInformativeText(QObject::tr("Do you want to clear the conflicting shortcuts and continue?"));
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
- int ret = msgBox.exec();
- if ( ret == QMessageBox::Yes) {
+ if (message::showQuestion(this,
+ QObject::tr("Do you want to clear the conflicting shortcuts and continue?"),
+ message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
clearConflictsWithKeys(keys, list);
shortcutsEditor->changeShortcutInDialog(keys);
}
@@ -244,12 +234,12 @@ void CAcceleratorSettingsPage::save() {
if (m_book.keyChooser)
m_book.keyChooser->commitChanges();
- CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
- CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
- CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
- CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
- CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
- CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
+ m_application.actionCollection->writeShortcuts("Application shortcuts"); //application
+ m_general.actionCollection->writeShortcuts("Displaywindow shortcuts"); //read display windows
+ m_bible.actionCollection->writeShortcuts("Bible shortcuts"); //bible
+ m_commentary.actionCollection->writeShortcuts("Commentary shortcuts"); //commentary
+ m_lexicon.actionCollection->writeShortcuts("Lexicon shortcuts"); //lexicon
+ m_book.actionCollection->writeShortcuts("Book shortcuts"); //book
}
void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
index 1bd4173..49408d5 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index 4c5bf1b..951880b 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.cpp
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,16 +14,21 @@
#include <QLayout>
#include <QPushButton>
#include <QWidget>
+#include "backend/config/btconfig.h"
#include "frontend/settingsdialogs/cacceleratorsettings.h"
#include "frontend/settingsdialogs/cdisplaysettings.h"
#include "frontend/settingsdialogs/btfontsettings.h"
#include "frontend/settingsdialogs/btlanguagesettings.h"
#include "frontend/settingsdialogs/cswordsettings.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+namespace {
+const QString GeometryKey = "GUI/SettingsDialog/geometry";
+} // anonymous namespace
+
CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection* actionCollection )
: BtConfigDialog(parent),
m_actionCollection(actionCollection),
@@ -61,7 +66,7 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_bbox->addButton(QDialogButtonBox::Ok);
m_bbox->addButton(QDialogButtonBox::Apply);
m_bbox->addButton(QDialogButtonBox::Cancel);
- util::prepareDialogBox(m_bbox);
+ message::prepareDialogBox(m_bbox);
setButtonBox(m_bbox);
bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
Q_ASSERT(ok);
@@ -99,13 +104,9 @@ void CConfigurationDialog::slotButtonClicked(QAbstractButton* button) {
}
void CConfigurationDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::configDialogWidth), CBTConfig::get(CBTConfig::configDialogHeight));
- move(CBTConfig::get(CBTConfig::configDialogPosX), CBTConfig::get(CBTConfig::configDialogPosY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void CConfigurationDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::configDialogWidth, size().width());
- CBTConfig::set(CBTConfig::configDialogHeight, size().height());
- CBTConfig::set(CBTConfig::configDialogPosX, x());
- CBTConfig::set(CBTConfig::configDialogPosY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index d38b4e4..fbd4944 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.cpp b/src/frontend/settingsdialogs/cdisplaysettings.cpp
index 6af4547..5b690f6 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.cpp
+++ b/src/frontend/settingsdialogs/cdisplaysettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,12 +14,13 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWebView>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/rendering/cdisplayrendering.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -46,13 +47,13 @@ QSize CWebViewerWidget::sizeHint () const {
/** Initializes the startup section of the OD. */
CDisplaySettingsPage::CDisplaySettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::startup::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::startup::icon), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
{ //startup logo
m_showLogoCheck = new QCheckBox(this);
- m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
+ m_showLogoCheck->setChecked(btConfig().value<bool>("GUI/showSplashScreen", true));
mainLayout->addWidget(m_showLogoCheck);
}
mainLayout->addSpacing(20);
@@ -161,14 +162,14 @@ void CDisplaySettingsPage::updateStylePreview() {
/// \todo Remove the following hack:
const QString oldStyleName = CDisplayTemplateMgr::activeTemplateName();
- CBTConfig::set(CBTConfig::displayStyle, styleName);
+ btConfig().setValue("GUI/activeTemplateName", styleName);
CDisplayRendering render;
m_stylePreviewViewer->setHtml( render.renderKeyTree(tree));
- CBTConfig::set(CBTConfig::displayStyle, oldStyleName);
+ btConfig().setValue("GUI/activeTemplateName", oldStyleName);
}
void CDisplaySettingsPage::save() {
- CBTConfig::set(CBTConfig::logo, m_showLogoCheck->isChecked());
- CBTConfig::set(CBTConfig::displayStyle, m_styleChooserCombo->currentText());
+ btConfig().setValue("GUI/showSplashScreen", m_showLogoCheck->isChecked() );
+ btConfig().setValue("GUI/activeTemplateName", m_styleChooserCombo->currentText());
}
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.h b/src/frontend/settingsdialogs/cdisplaysettings.h
index b18a26f..834c846 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.h
+++ b/src/frontend/settingsdialogs/cdisplaysettings.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/clistwidget.cpp b/src/frontend/settingsdialogs/clistwidget.cpp
index 3a2a4c7..9504009 100644
--- a/src/frontend/settingsdialogs/clistwidget.cpp
+++ b/src/frontend/settingsdialogs/clistwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,10 +17,6 @@ CListWidget::CListWidget(QWidget* parent)
// Intentionally empty
}
-CListWidget::~CListWidget() {
- // Intentionally empty
-}
-
QSize CListWidget::sizeHint () const {
return QSize(100, 120);
}
diff --git a/src/frontend/settingsdialogs/clistwidget.h b/src/frontend/settingsdialogs/clistwidget.h
index ecd5f98..393754c 100644
--- a/src/frontend/settingsdialogs/clistwidget.h
+++ b/src/frontend/settingsdialogs/clistwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,7 +19,7 @@ class CListWidget : public QListWidget {
Q_OBJECT
public:
CListWidget(QWidget* parent = 0);
- ~CListWidget();
+
virtual QSize sizeHint () const;
void setCharWidth(int width);
};
diff --git a/src/frontend/settingsdialogs/cswordsettings.cpp b/src/frontend/settingsdialogs/cswordsettings.cpp
index 60c0e7c..f8f0ebf 100644
--- a/src/frontend/settingsdialogs/cswordsettings.cpp
+++ b/src/frontend/settingsdialogs/cswordsettings.cpp
@@ -2,322 +2,36 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/settingsdialogs/cswordsettings.h"
-#include <QCheckBox>
-#include <QComboBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QList>
-#include <QString>
-#include <QStringList>
-#include <QTabWidget>
#include <QVBoxLayout>
-#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "bibletimeapp.h"
+#include "frontend/settingsdialogs/btstandardworkstab.h"
+#include "frontend/settingsdialogs/bttextfilterstab.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/tool.h"
+#include "util/geticon.h"
-/*******************************************************************************
- StandardWorksTab
-*******************************************************************************/
-
-StandardWorksTab::StandardWorksTab(CSwordSettingsPage *parent)
- : QWidget(parent)
-{
- typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
-
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- mainLayout->setMargin(5);
- mainLayout->setSpacing(2);
-
- m_explanationLabel = new QLabel(this);
- m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_explanationLabel->setMaximumHeight(50);
- m_explanationLabel->setMinimumWidth(300);
- mainLayout->addWidget(m_explanationLabel);
-
- QFormLayout *formLayout = new QFormLayout;
-
-#define STANDARD_WORKS_TAB_ADD_ROW(name) \
- if (true) { \
- m_ ## name ## Label = new QLabel(this); \
- m_ ## name ## Combo = new QComboBox(this); \
- formLayout->addRow(m_ ## name ## Label, m_ ## name ## Combo); \
- } else (void) 0
-
- STANDARD_WORKS_TAB_ADD_ROW(standardBible);
- STANDARD_WORKS_TAB_ADD_ROW(standardCommentary);
- STANDARD_WORKS_TAB_ADD_ROW(standardLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardDailyDevotional);
- STANDARD_WORKS_TAB_ADD_ROW(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardGreekMorphLexicon);
-
- mainLayout->addLayout(formLayout);
- mainLayout->addStretch();
-
- //fill the comboboxes with the right modules
-
- const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
- QString modDescript;
- for (MLCI it(modules.begin()); it != modules.end(); it++) {
- modDescript = (*it)->config(CSwordModuleInfo::Description);
-
- switch ((*it)->type()) {
- case CSwordModuleInfo::Bible:
- m_standardBibleCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Commentary:
- m_standardCommentaryCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Lexicon: {
- bool inserted = false;
- if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
- m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekDef)) {
- m_standardGreekStrongsLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
- m_standardHebrewMorphLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekParse)) {
- m_standardGreekMorphLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
- m_standardDailyDevotionalCombo->addItem(modDescript);
- inserted = true;
- }
-
- if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
- m_standardLexiconCombo->addItem(modDescript);
- }
- break;
- }
- default://unknown type
- break;
- } //switch
- } //for
-
- //using two lists and one loop is better than six loops with almost the same code :)
- QList<QComboBox*> comboList;
- QStringList moduleList;
-
-#define STANDARD_WORKS_TAB_CASE(name) \
- case CBTConfig::name: \
- comboList.append(m_ ## name ## Combo); \
- break
-
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
- //fill the combobox list in the right order (i.e. same order as the CBTConfig::module enum list)
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType) {
- STANDARD_WORKS_TAB_CASE(standardBible);
- STANDARD_WORKS_TAB_CASE(standardCommentary);
- STANDARD_WORKS_TAB_CASE(standardLexicon);
- STANDARD_WORKS_TAB_CASE(standardDailyDevotional);
- STANDARD_WORKS_TAB_CASE(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_CASE(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_CASE(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_CASE(standardGreekMorphLexicon);
- }
- ; //switch
-
- //fill the module list
- CSwordModuleInfo* const m = CBTConfig::get( (CBTConfig::modules)(i) );
- if (m) {
- moduleList << m->config(CSwordModuleInfo::Description);
- }
- else {
- moduleList << QString::null;
- }
- } //for
-
- QString module = QString::null;
- int item = 0;
- int count = 0;
- QListIterator<QComboBox*> it(comboList);
- while (it.hasNext()) {
- //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
- QComboBox* combo = it.next();
- module = moduleList[comboList.indexOf(combo)];
- count = combo->count();
- combo->setMaximumWidth(300);
-
- for (item = 0; item < count; item++) {
- if (combo->itemText(item) == module ) {
- combo->setCurrentIndex(item);
- break;
- }
- }
- }
-
- retranslateUi();
-}
-
-void StandardWorksTab::save() {
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
- QString moduleDescription;
-
-
-#define STANDARD_WORKS_TAB_SCASE(name) \
- case CBTConfig::name: \
- moduleDescription = m_ ## name ## Combo->currentText(); \
- break;
-
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType) {
- STANDARD_WORKS_TAB_SCASE(standardBible);
- STANDARD_WORKS_TAB_SCASE(standardCommentary);
- STANDARD_WORKS_TAB_SCASE(standardLexicon);
- STANDARD_WORKS_TAB_SCASE(standardDailyDevotional);
- STANDARD_WORKS_TAB_SCASE(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_SCASE(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_SCASE(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_SCASE(standardGreekMorphLexicon);
- default:
- qWarning("Unhandled module type.");
- };
-
- CSwordModuleInfo * const module = CSwordBackend::instance()->findModuleByDescription(moduleDescription);
- CBTConfig::set(moduleType, module);
- }
-}
-
-void StandardWorksTab::retranslateUi() {
- util::tool::initExplanationLabel(
- m_explanationLabel, "",
- tr("Standard works are used when no particular work is specified, for example "
- "when a hyperlink into a Bible or lexicon was clicked."));
-
- m_standardBibleLabel->setText(tr("Bible:"));
- m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
-
- m_standardCommentaryLabel->setText(tr("Commentary:"));
- m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
-
- m_standardLexiconLabel->setText(tr("Lexicon:"));
- m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
-
- m_standardDailyDevotionalLabel->setText(tr("Daily devotional:"));
- m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
-
- m_standardHebrewStrongsLexiconLabel->setText(tr("Hebrew Strong's lexicon:"));
- m_standardHebrewStrongsLexiconCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
-
- m_standardGreekStrongsLexiconLabel->setText(tr("Greek Strong's lexicon:"));
- m_standardGreekStrongsLexiconCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
-
- m_standardHebrewMorphLexiconLabel->setText(tr("Hebrew morphological lexicon:"));
- m_standardHebrewMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
-
- m_standardGreekMorphLexiconLabel->setText(tr("Greek morphological lexicon:"));
- m_standardGreekMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
-}
-
-
-/*******************************************************************************
- TextFiltersTab
-*******************************************************************************/
-
-TextFiltersTab::TextFiltersTab(CSwordSettingsPage *parent)
- : QWidget(parent)
-{
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(5);
- layout->setSpacing(2);
-
- m_explanationLabel = new QLabel(this);
- m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_explanationLabel->setMaximumHeight(50);
- m_explanationLabel->setMinimumWidth(300);
- layout->addWidget(m_explanationLabel);
-
-#define TEXT_FILTERS_TAB_ADD_ROW(name) \
- m_ ## name ## Check = new QCheckBox(this); \
- m_ ## name ## Check->setChecked(CBTConfig::get(CBTConfig::name)); \
- layout->addWidget(m_ ## name ## Check);
-
- TEXT_FILTERS_TAB_ADD_ROW(lineBreaks);
- TEXT_FILTERS_TAB_ADD_ROW(verseNumbers);
- TEXT_FILTERS_TAB_ADD_ROW(headings);
- TEXT_FILTERS_TAB_ADD_ROW(hebrewPoints);
- TEXT_FILTERS_TAB_ADD_ROW(hebrewCantillation);
- TEXT_FILTERS_TAB_ADD_ROW(morphSegmentation);
- TEXT_FILTERS_TAB_ADD_ROW(greekAccents);
- TEXT_FILTERS_TAB_ADD_ROW(textualVariants);
- TEXT_FILTERS_TAB_ADD_ROW(scriptureReferences);
-
- layout->addStretch(4);
-
- retranslateUi();
-}
-
-void TextFiltersTab::save() {
-#define TEXT_FILTERS_TAB_SAVE(name) CBTConfig::set(CBTConfig::name, m_ ## name ## Check->isChecked())
-
- TEXT_FILTERS_TAB_SAVE(lineBreaks);
- TEXT_FILTERS_TAB_SAVE(verseNumbers);
- TEXT_FILTERS_TAB_SAVE(headings);
- TEXT_FILTERS_TAB_SAVE(hebrewPoints);
- TEXT_FILTERS_TAB_SAVE(hebrewCantillation);
- TEXT_FILTERS_TAB_SAVE(morphSegmentation);
- TEXT_FILTERS_TAB_SAVE(greekAccents);
- TEXT_FILTERS_TAB_SAVE(textualVariants);
- TEXT_FILTERS_TAB_SAVE(scriptureReferences);
-}
-
-
-void TextFiltersTab::retranslateUi() {
- util::tool::initExplanationLabel(m_explanationLabel, "",
- tr("Filters control the appearance of text. Here you can specify "
- "default settings for all filters. You can override these "
- "settings in each display window."));
-
- m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
- m_verseNumbersCheck->setText(tr("Show verse numbers"));
- m_headingsCheck->setText(tr("Show section headings"));
- m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
- m_greekAccentsCheck->setText(tr("Show Greek accents"));
- m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
- m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
- m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
- m_textualVariantsCheck->setText(tr("Use textual variants"));
-}
-
-
-/*******************************************************************************
- CSwordSettingsPage
-*******************************************************************************/
-
-CSwordSettingsPage::CSwordSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::sword::icon), parent)
+CSwordSettingsPage::CSwordSettingsPage(CConfigurationDialog * parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::sword::icon), parent)
{
static const QString nullString;
m_tabWidget = new QTabWidget(this);
- m_worksTab = new StandardWorksTab(this);
+ m_worksTab = new BtStandardWorksTab(this);
m_tabWidget->addTab(m_worksTab, nullString);
- m_filtersTab = new TextFiltersTab(this);
+ m_filtersTab = new BtTextFiltersTab(this);
m_tabWidget->addTab(m_filtersTab, nullString);
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QVBoxLayout * mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(m_tabWidget);
retranslateUi();
diff --git a/src/frontend/settingsdialogs/cswordsettings.h b/src/frontend/settingsdialogs/cswordsettings.h
index c54630d..18a4268 100644
--- a/src/frontend/settingsdialogs/cswordsettings.h
+++ b/src/frontend/settingsdialogs/cswordsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,90 +16,9 @@
#include <QWidget>
+class BtTextFiltersTab;
class CConfigurationDialog;
-class CSwordSettingsPage;
-class QCheckBox;
-class QComboBox;
-class QLabel;
-
-
-/*******************************************************************************
- StandardWorksTab
-*******************************************************************************/
-
-class StandardWorksTab: public QWidget {
-
- Q_OBJECT
-
- public: /* Methods: */
-
- StandardWorksTab(CSwordSettingsPage *parent);
-
- void save();
-
- protected: /* Methods: */
-
- void retranslateUi();
-
- private: /* Fields: */
-
- QLabel *m_explanationLabel;
-
-#define STANDARD_WORKS_TAB_FIELD(name) \
- QLabel *m_ ## name ## Label; \
- QComboBox *m_ ## name ## Combo
-
- STANDARD_WORKS_TAB_FIELD(standardBible);
- STANDARD_WORKS_TAB_FIELD(standardCommentary);
- STANDARD_WORKS_TAB_FIELD(standardLexicon);
- STANDARD_WORKS_TAB_FIELD(standardDailyDevotional);
- STANDARD_WORKS_TAB_FIELD(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_FIELD(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_FIELD(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_FIELD(standardGreekMorphLexicon);
-};
-
-
-/*******************************************************************************
- TextFiltersTab
-*******************************************************************************/
-
-class TextFiltersTab: public QWidget {
-
- Q_OBJECT
-
- public: /* Methods: */
-
- TextFiltersTab(CSwordSettingsPage *parent);
-
- void save();
-
- protected: /* Methods: */
-
- void retranslateUi();
-
- private: /* Fields: */
-
- QLabel *m_explanationLabel;
-
-#define TEXT_FILTERS_TAB_FIELD(name) QCheckBox *m_ ## name ## Check
-
- TEXT_FILTERS_TAB_FIELD(lineBreaks);
- TEXT_FILTERS_TAB_FIELD(verseNumbers);
- TEXT_FILTERS_TAB_FIELD(headings);
- TEXT_FILTERS_TAB_FIELD(hebrewPoints);
- TEXT_FILTERS_TAB_FIELD(hebrewCantillation);
- TEXT_FILTERS_TAB_FIELD(morphSegmentation);
- TEXT_FILTERS_TAB_FIELD(greekAccents);
- TEXT_FILTERS_TAB_FIELD(textualVariants);
- TEXT_FILTERS_TAB_FIELD(scriptureReferences);
-
-};
-
-
-/*******************************************************************************
- CSwordSettingsPage
-*******************************************************************************/
+class BtStandardWorksTab;
class CSwordSettingsPage: public BtConfigDialog::Page {
@@ -105,7 +26,7 @@ class CSwordSettingsPage: public BtConfigDialog::Page {
public: /* Methods: */
- CSwordSettingsPage(CConfigurationDialog *parent = 0);
+ CSwordSettingsPage(CConfigurationDialog * parent = 0);
void save();
@@ -115,9 +36,9 @@ class CSwordSettingsPage: public BtConfigDialog::Page {
private: /* Fields: */
- QTabWidget *m_tabWidget;
- StandardWorksTab *m_worksTab;
- TextFiltersTab *m_filtersTab;
+ QTabWidget * m_tabWidget;
+ BtStandardWorksTab * m_worksTab;
+ BtTextFiltersTab * m_filtersTab;
};
diff --git a/src/frontend/tips/bttipdialog.cpp b/src/frontend/tips/bttipdialog.cpp
index 5c4052d..75b7a6d 100644
--- a/src/frontend/tips/bttipdialog.cpp
+++ b/src/frontend/tips/bttipdialog.cpp
@@ -2,18 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bttipdialog.h"
-#include "backend/config/cbtconfig.h"
-#include "util/cresmgr.h"
-#include "util/dialogutil.h"
-#include "util/directory.h"
-
#include <QCheckBox>
#include <QDesktopServices>
#include <QDialogButtonBox>
@@ -21,6 +16,13 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QWebView>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
+#include "util/cresmgr.h"
+#include "frontend/messagedialog.h"
+#include "util/directory.h"
+#include "util/geticon.h"
+#include "util/htmlescape.h"
namespace {
@@ -52,20 +54,20 @@ inline QString make_icon(const QString &icon) {
namespace DU = util::directory;
QString fileName = DU::getIconDir().filePath(icon);
QString iconUrl = QUrl::fromLocalFile(fileName).toString();
- return "<img src=\"" + iconUrl + "\" width=\"32\" />";
+ return "<img src=\"" + util::htmlEscape(iconUrl) + "\" width=\"32\" />";
}
+const QString LastTipNumberKey = "GUI/lastTipNumber";
+
} // anonymous namespace
BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- namespace DU = util::directory;
-
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Tip Of The Day"));
- setWindowIcon(DU::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
+ setWindowIcon(util::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
resize(450, 240);
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -79,14 +81,14 @@ BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
m_showTipsCheckBox = new QCheckBox;
m_showTipsCheckBox->setText(tr("Show tips at startup"));
- bool showTips = CBTConfig::get(CBTConfig::showTipAtStartup);
+ bool showTips = btConfig().value<bool>("GUI/showTipAtStartup", true);
m_showTipsCheckBox->setChecked(showTips);
hLayout->addWidget(m_showTipsCheckBox);
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close,
Qt::Horizontal,
this);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
QPushButton *nextButton;
nextButton = m_buttonBox->addButton(tr("Next Tip"),
@@ -113,7 +115,7 @@ BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
this, SLOT(linkClicked(const QUrl&)));
Q_ASSERT(ok);
- m_tipNumber = CBTConfig::get(CBTConfig::tipNumber);
+ m_tipNumber = btConfig().value<int>(LastTipNumberKey, 0);
initTips();
displayTip();
}
@@ -183,7 +185,7 @@ void BtTipDialog::displayTip() {
}
void BtTipDialog::startupBoxChanged(bool checked) {
- CBTConfig::set(CBTConfig::showTipAtStartup, checked);
+ btConfig().setValue("GUI/showTipAtStartup", checked);
}
void BtTipDialog::nextTip() {
@@ -191,7 +193,7 @@ void BtTipDialog::nextTip() {
if (m_tipNumber >= m_tips.count()) {
m_tipNumber = 0;
}
- CBTConfig::set(CBTConfig::tipNumber, m_tipNumber);
+ btConfig().setValue(LastTipNumberKey, m_tipNumber);
displayTip();
}
diff --git a/src/frontend/tips/bttipdialog.h b/src/frontend/tips/bttipdialog.h
index cd00394..e8058ee 100644
--- a/src/frontend/tips/bttipdialog.h
+++ b/src/frontend/tips/bttipdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/