summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.cpp (renamed from src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp)22
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkfolder.h)8
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.cpp149
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkitem.h)30
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.cpp21
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkitembase.h)9
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.cpp (renamed from src/frontend/mainindex/bookmarks/btbookmarkloader.cpp)19
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkloader.h)2
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.cpp78
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.h62
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.cpp (renamed from src/frontend/mainindex/bookmarks/cbookmarkindex.cpp)88
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.h (renamed from src/frontend/mainindex/bookmarks/cbookmarkindex.h)17
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp48
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h33
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp9
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h41
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp12
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp15
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp59
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h27
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp164
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h50
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp136
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h44
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp423
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h65
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp87
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h33
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp140
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h59
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp21
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp117
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h9
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp28
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h12
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp62
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h38
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp282
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.h96
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp399
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.h86
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp312
-rw-r--r--src/frontend/bookshelfmanager/instbackend.h74
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp143
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h33
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp7
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h4
-rw-r--r--src/frontend/btaboutdialog.cpp274
-rw-r--r--src/frontend/btaboutdialog.h49
-rw-r--r--src/frontend/btaboutmoduledialog.cpp38
-rw-r--r--src/frontend/btaboutmoduledialog.h18
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp323
-rw-r--r--src/frontend/btbookshelfdockwidget.h67
-rw-r--r--src/frontend/btbookshelfgroupingmenu.cpp113
-rw-r--r--src/frontend/btbookshelfgroupingmenu.h53
-rw-r--r--src/frontend/btbookshelfview.cpp (renamed from src/frontend/mainindex/btbookshelfview.cpp)10
-rw-r--r--src/frontend/btbookshelfview.h (renamed from src/frontend/mainindex/btbookshelfview.h)2
-rw-r--r--src/frontend/btbookshelfwidget.cpp203
-rw-r--r--src/frontend/btbookshelfwidget.h116
-rw-r--r--src/frontend/btmenuview.cpp227
-rw-r--r--src/frontend/btmenuview.h107
-rw-r--r--src/frontend/btmodulechooserdialog.cpp65
-rw-r--r--src/frontend/btmodulechooserdialog.h48
-rw-r--r--src/frontend/btmoduleindexdialog.cpp103
-rw-r--r--src/frontend/btmoduleindexdialog.h65
-rw-r--r--src/frontend/btopenworkaction.cpp111
-rw-r--r--src/frontend/btopenworkaction.h82
-rw-r--r--src/frontend/cdragdrop.cpp11
-rw-r--r--src/frontend/cdragdrop.h34
-rw-r--r--src/frontend/cexportmanager.cpp165
-rw-r--r--src/frontend/cexportmanager.h76
-rw-r--r--src/frontend/cinfodisplay.cpp82
-rw-r--r--src/frontend/cinfodisplay.h4
-rw-r--r--src/frontend/cinputdialog.cpp88
-rw-r--r--src/frontend/cinputdialog.h41
-rw-r--r--src/frontend/cmdiarea.cpp91
-rw-r--r--src/frontend/cmdiarea.h16
-rw-r--r--src/frontend/cmodulechooserdialog.cpp147
-rw-r--r--src/frontend/cmodulechooserdialog.h107
-rw-r--r--src/frontend/cmoduleindexdialog.cpp99
-rw-r--r--src/frontend/cmoduleindexdialog.h56
-rw-r--r--src/frontend/cprinter.cpp25
-rw-r--r--src/frontend/cprinter.h11
-rw-r--r--src/frontend/crossrefrendering.cpp18
-rw-r--r--src/frontend/crossrefrendering.h10
-rw-r--r--src/frontend/display/btcolorwidget.cpp2
-rw-r--r--src/frontend/display/btcolorwidget.h5
-rw-r--r--src/frontend/display/btfontsizewidget.cpp6
-rw-r--r--src/frontend/display/btfontsizewidget.h6
-rw-r--r--src/frontend/display/bthtml.js2
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp6
-rw-r--r--src/frontend/display/bthtmlfindtext.h3
-rw-r--r--src/frontend/display/bthtmlfindtext.ui2
-rw-r--r--src/frontend/display/bthtmljsobject.cpp26
-rw-r--r--src/frontend/display/bthtmljsobject.h7
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp102
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h7
-rw-r--r--src/frontend/display/cdisplay.cpp13
-rw-r--r--src/frontend/display/cdisplay.h22
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp176
-rw-r--r--src/frontend/display/chtmlwritedisplay.h16
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp25
-rw-r--r--src/frontend/display/cplainwritedisplay.h20
-rw-r--r--src/frontend/display/creaddisplay.cpp12
-rw-r--r--src/frontend/display/creaddisplay.h8
-rw-r--r--src/frontend/display/cwritedisplay.cpp2
-rw-r--r--src/frontend/display/cwritedisplay.h2
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp20
-rw-r--r--src/frontend/displaywindow/btactioncollection.h2
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp14
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h22
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp39
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h21
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp3
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h2
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp19
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h19
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp3
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h2
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp15
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h5
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h12
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp47
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h4
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp59
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h4
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp35
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h4
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp161
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h120
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp33
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h6
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp105
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h35
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp68
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h27
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp172
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h28
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp15
-rw-r--r--src/frontend/displaywindow/creadwindow.h18
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp10
-rw-r--r--src/frontend/displaywindow/cwritewindow.h33
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp249
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.h29
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp125
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.h87
-rw-r--r--src/frontend/keychooser/bthistory.cpp4
-rw-r--r--src/frontend/keychooser/bthistory.h2
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp34
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h16
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp34
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h35
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp52
-rw-r--r--src/frontend/keychooser/ckeychooser.h57
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp12
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h23
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp67
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h34
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp2
-rw-r--r--src/frontend/keychooser/cscrollbutton.h8
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp2
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h7
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp (renamed from src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp)84
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.h (renamed from src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h)28
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp14
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h16
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp2
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h2
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp51
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h33
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.cpp150
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp39
-rw-r--r--src/frontend/profile/cprofile.cpp2
-rw-r--r--src/frontend/profile/cprofile.h2
-rw-r--r--src/frontend/profile/cprofilemgr.cpp4
-rw-r--r--src/frontend/profile/cprofilemgr.h4
-rw-r--r--src/frontend/profile/cprofilewindow.cpp2
-rw-r--r--src/frontend/profile/cprofilewindow.h2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp14
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp36
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h19
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp80
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h22
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h12
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h45
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp188
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h15
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp245
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h145
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp229
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h40
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h2
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp130
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h22
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp2
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h2
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp135
-rw-r--r--src/frontend/searchdialog/csearchdialog.h62
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp56
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h38
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp61
-rw-r--r--src/frontend/searchdialog/csearchresultview.h27
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.cpp164
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.h (renamed from src/frontend/settingsdialogs/clanguagesettings.h)30
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.cpp145
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.h60
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp3
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp6
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h4
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp41
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h16
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp16
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h8
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp37
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h13
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp2
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.h2
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.cpp266
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp2
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h2
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp50
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h17
-rw-r--r--src/frontend/tips/bttipdialog.cpp193
-rw-r--r--src/frontend/tips/bttipdialog.h62
234 files changed, 6908 insertions, 5763 deletions
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp b/src/frontend/bookmarks/btbookmarkfolder.cpp
index 2091a54..1cc2583 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/bookmarks/btbookmarkfolder.cpp
@@ -2,23 +2,23 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
#include <QDebug>
#include <QFileDialog>
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
+BtBookmarkFolder::BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent)
: BtBookmarkItemBase(parent) {
setText(0, name);
setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
@@ -27,7 +27,7 @@ BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
bool BtBookmarkFolder::enableAction(MenuAction action) {
if (action == ChangeFolder || action == NewFolder || action == DeleteEntries || action == ImportBookmarks )
return true;
- if (action == ExportBookmarks || action == ImportBookmarks )
+ if (action == SortFolderBookmarks || action == ExportBookmarks || action == ImportBookmarks )
return true;
if ((action == PrintBookmarks) && childCount())
return true;
@@ -57,13 +57,13 @@ void BtBookmarkFolder::importBookmarks() {
};
}
-QString BtBookmarkFolder::toolTip() {
- return QString();
+QString BtBookmarkFolder::toolTip() const {
+ return QString::null;
}
void BtBookmarkFolder::newSubFolder() {
if (dynamic_cast<BtBookmarkFolder*>(this)) {
- BtBookmarkFolder* f = new BtBookmarkFolder(this, QObject::tr("New folder"));
+ BtBookmarkFolder* f = new BtBookmarkFolder(QObject::tr("New folder"), this);
treeWidget()->setCurrentItem(f);
f->update();
@@ -123,7 +123,7 @@ bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
BtBookmarkFolder* BtBookmarkFolder::deepCopy() {
qDebug() << "BtBookmarkFolder::deepCopy";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, this->text(0));
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(this->text(0));
foreach(QTreeWidgetItem* subitem, getChildList()) {
if (BtBookmarkItem* bmItem = dynamic_cast<BtBookmarkItem*>(subitem)) {
newFolder->addChild(new BtBookmarkItem(*bmItem));
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h b/src/frontend/bookmarks/btbookmarkfolder.h
index 9f065f4..90021f8 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/bookmarks/btbookmarkfolder.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef BTBOOKMARKFOLDER_H
#define BTBOOKMARKFOLDER_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#define CURRENT_SYNTAX_VERSION 1
@@ -18,7 +18,7 @@
class BtBookmarkFolder : public BtBookmarkItemBase {
public:
friend class BtBookmarkLoader;
- BtBookmarkFolder(QTreeWidgetItem* parent, QString name);
+ BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent = 0);
~BtBookmarkFolder() {}
/** See the base class. */
@@ -44,7 +44,7 @@ class BtBookmarkFolder : public BtBookmarkItemBase {
void rename();
void update();
- QString toolTip();
+ QString toolTip() const;
};
#endif
diff --git a/src/frontend/bookmarks/btbookmarkitem.cpp b/src/frontend/bookmarks/btbookmarkitem.cpp
new file mode 100644
index 0000000..fff3d2c
--- /dev/null
+++ b/src/frontend/bookmarks/btbookmarkitem.cpp
@@ -0,0 +1,149 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookmarks/btbookmarkitem.h"
+
+#include <QSharedPointer>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
+#include "btglobal.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/bteditbookmarkdialog.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+BtBookmarkItem::BtBookmarkItem(const CSwordModuleInfo *module,
+ const QString &key,
+ const QString &description,
+ const QString &title)
+ : m_description(description),
+ m_moduleName(module ? module->name() : QString::null),
+ m_title(title)
+{
+ if (((module && (module->type() == CSwordModuleInfo::Bible)) || (module->type() == CSwordModuleInfo::Commentary)) ) {
+ CSwordVerseKey vk(0);
+ vk.setKey(key);
+ vk.setLocale("en");
+ m_key = vk.key(); //the m_key member is always the english key!
+ }
+ else {
+ m_key = key;
+ };
+
+ update();
+}
+
+BtBookmarkItem::BtBookmarkItem(QTreeWidgetItem* parent)
+ : BtBookmarkItemBase(parent) {}
+
+BtBookmarkItem::BtBookmarkItem(const BtBookmarkItem& other)
+ : BtBookmarkItemBase(0),
+ m_key(other.m_key),
+ m_description(other.m_description),
+ m_moduleName(other.m_moduleName),
+ m_title(other.m_title)
+{
+ update();
+}
+
+CSwordModuleInfo *BtBookmarkItem::module() const {
+ return CSwordBackend::instance()->findModuleByName(m_moduleName);
+}
+
+QString BtBookmarkItem::key() const {
+ const QString englishKeyName = englishKey();
+ if (!module()) {
+ return englishKeyName;
+ }
+
+ QString returnKeyName = englishKeyName;
+ if ((module()->type() == CSwordModuleInfo::Bible) || (module()->type() == CSwordModuleInfo::Commentary)) {
+ CSwordVerseKey vk(0);
+ vk.setKey(englishKeyName);
+ vk.setLocale(CSwordBackend::instance()->booknameLanguage().toLatin1() );
+
+ returnKeyName = vk.key(); //the returned key is always in the currently set bookname language
+ }
+
+ return returnKeyName;
+}
+
+QString BtBookmarkItem::toolTip() const {
+ if (!module()) {
+ return QString::null;
+ }
+
+ FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
+ filterOptions.footnotes = false;
+ filterOptions.scriptureReferences = false;
+ CSwordBackend::instance()->setFilterOptions(filterOptions);
+
+ QString ret;
+ QSharedPointer<CSwordKey> k( CSwordKey::createInstance(module()) );
+ k->setKey(key());
+
+ // const CLanguageMgr::Language* lang = module()->language();
+ // CBTConfig::FontSettingsPair fontPair = CBTConfig::get(lang);
+
+ Q_ASSERT(k.data());
+ QString header = QString::fromLatin1("%1 (%2)")
+ .arg(key())
+ .arg(module()->name());
+ if (title() != header) {
+ ret = QString::fromLatin1("<b>%1</b><br>%2<hr>%3")
+ .arg(header)
+ .arg(title())
+ .arg(description())
+ ;
+ }
+ else {
+ ret = QString::fromLatin1("<b>%1</b><hr>%2")
+ .arg(header)
+ .arg(description())
+ ;
+ }
+
+ return ret;
+}
+
+bool BtBookmarkItem::enableAction(MenuAction action) {
+ if (action == EditBookmark || (module() && (action == PrintBookmarks)) || action == DeleteEntries)
+ return true;
+
+ return false;
+}
+
+void BtBookmarkItem::rename() {
+ BtEditBookmarkDialog d(QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown")),
+ m_title,
+ m_description, treeWidget());
+
+ if (d.exec() == QDialog::Accepted) {
+ m_title = d.titleText();
+ m_description = d.descriptionText();
+ update();
+ }
+}
+
+void BtBookmarkItem::update() {
+ namespace DU = util::directory;
+
+ qDebug() << "BtBookmarkItem::update";
+ setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+
+ if (m_title.isEmpty()) {
+ m_title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
+ }
+ setText(0,m_title);
+ setToolTip(0, toolTip());
+}
+
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.h b/src/frontend/bookmarks/btbookmarkitem.h
index 6677f61..3166e61 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.h
+++ b/src/frontend/bookmarks/btbookmarkitem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef BTBOOKMARKITEM_H
#define BTBOOKMARKITEM_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#include <QString>
@@ -25,7 +25,8 @@ class BtBookmarkItem : public BtBookmarkItemBase {
BtBookmarkItem(QTreeWidgetItem* parent);
/** Creates a bookmark with module, key and description. */
- BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description);
+ BtBookmarkItem(const CSwordModuleInfo *module, const QString &key,
+ const QString &description, const QString &title);
/** Creates a copy. */
BtBookmarkItem(const BtBookmarkItem& other);
@@ -33,18 +34,23 @@ class BtBookmarkItem : public BtBookmarkItemBase {
~BtBookmarkItem() {}
/** Returns the used module, 0 if there is no such module. */
- CSwordModuleInfo* module();
+ CSwordModuleInfo *module() const;
/** Returns the used key. */
- QString key();
+ QString key() const;
/** Returns the used description. */
- const QString& description();
- /** Sets the description text for this bookmark. */
- virtual void setDescription(QString text);
+ inline const QString &description() const {
+ return m_description;
+ }
+
+ /** Returns the title. */
+ inline const QString &title() const {
+ return m_title;
+ }
/** Returns a tooltip for this bookmark. */
- virtual QString toolTip();
+ virtual QString toolTip() const;
/** Returns whether the action is supported by this item. */
virtual bool enableAction(MenuAction action);
@@ -56,11 +62,15 @@ class BtBookmarkItem : public BtBookmarkItemBase {
private:
/** Returns the english key.*/
- QString englishKey() const;
+ inline const QString &englishKey() const {
+ return m_key;
+ }
+ private:
QString m_key;
QString m_description;
QString m_moduleName;
+ QString m_title;
};
#endif
diff --git a/src/frontend/bookmarks/btbookmarkitembase.cpp b/src/frontend/bookmarks/btbookmarkitembase.cpp
new file mode 100644
index 0000000..1a80f7d
--- /dev/null
+++ b/src/frontend/bookmarks/btbookmarkitembase.cpp
@@ -0,0 +1,21 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookmarks/btbookmarkitembase.h"
+
+
+BtBookmarkItemBase::BtBookmarkItemBase() {
+ // Intentionally empty
+}
+
+BtBookmarkItemBase::BtBookmarkItemBase(QTreeWidgetItem *parent)
+ : QTreeWidgetItem(parent)
+{
+ // Intentionally empty
+}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h b/src/frontend/bookmarks/btbookmarkitembase.h
index 78754f7..8452473 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/bookmarks/btbookmarkitembase.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +25,9 @@ class BtBookmarkItemBase : public QTreeWidgetItem {
NewFolder = 0,
ChangeFolder,
- ChangeBookmark,
+ EditBookmark,
+ SortFolderBookmarks,
+ SortAllBookmarks,
ImportBookmarks,
ExportBookmarks,
PrintBookmarks,
@@ -43,8 +45,7 @@ class BtBookmarkItemBase : public QTreeWidgetItem {
BtBookmarkItemBase(QTreeWidgetItem* parent);
virtual ~BtBookmarkItemBase() {}
- virtual QString toolTip() = 0;
- virtual CBookmarkIndex* bookmarkWidget() const;
+ virtual QString toolTip() const = 0;
/** Returns true if the given action should be enabled in the popup menu. */
virtual bool enableAction( MenuAction action ) = 0;
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp b/src/frontend/bookmarks/btbookmarkloader.cpp
index ddf656e..ed1dd29 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/bookmarks/btbookmarkloader.cpp
@@ -2,12 +2,12 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include <QDebug>
#include <QDomElement>
@@ -19,8 +19,8 @@
#include <QTextStream>
#include <QTreeWidgetItem>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
#include "util/tool.h"
@@ -64,7 +64,7 @@ QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeW
QTreeWidgetItem* newItem = 0;
if (element.tagName() == "Folder") {
qDebug() << "BtBookmarkLoader::handleXmlElement: found folder";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(parent, QString());
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(QString::null, parent);
if (element.hasAttribute("caption")) {
newFolder->setText(0, element.attribute("caption"));
}
@@ -91,6 +91,9 @@ QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeW
if (element.hasAttribute("description")) {
newBookmarkItem->m_description = element.attribute("description");
}
+ if (element.hasAttribute("title")) {
+ newBookmarkItem->m_title = element.attribute("title");
+ }
newBookmarkItem->update();
newItem = newBookmarkItem;
}
@@ -107,7 +110,7 @@ QString BtBookmarkLoader::loadXmlFromFile(QString fileName) {
}
QFile file(fileName);
if (!file.exists())
- return QString();
+ return QString::null;
QString xml;
if (file.open(QIODevice::ReadOnly)) {
@@ -166,7 +169,9 @@ void BtBookmarkLoader::saveItem(QTreeWidgetItem* item, QDomElement& parentElemen
elem.setAttribute("description", bookmarkItem->description());
elem.setAttribute("modulename", bookmarkItem->m_moduleName);
elem.setAttribute("moduledescription", bookmarkItem->module() ? bookmarkItem->module()->config(CSwordModuleInfo::Description) : QString::null);
-
+ if ( ! bookmarkItem->title().isEmpty()) {
+ elem.setAttribute("title", bookmarkItem->m_title);
+ }
parentElement.appendChild(elem);
}
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.h b/src/frontend/bookmarks/btbookmarkloader.h
index 3102ca2..8b819ce 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.h
+++ b/src/frontend/bookmarks/btbookmarkloader.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.cpp b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
new file mode 100644
index 0000000..614498f
--- /dev/null
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
@@ -0,0 +1,78 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "bteditbookmarkdialog.h"
+
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QFormLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QTextEdit>
+#include <QWidget>
+#include "util/cresmgr.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
+
+BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
+ const QString &title,
+ const QString &description,
+ QWidget *parent,
+ Qt::WindowFlags wflags)
+ : QDialog(parent, wflags)
+{
+ namespace DU = util::directory;
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+ resize(400, 300);
+ setWindowIcon(DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+
+ m_layout = new QFormLayout;
+
+ m_keyLabel = new QLabel(this);
+ m_keyTextLabel = new QLabel(key, this);
+ m_layout->addRow(m_keyLabel, m_keyTextLabel);
+
+ m_titleLabel = new QLabel(this);
+ m_titleEdit = new QLineEdit(title, this);
+ m_layout->addRow(m_titleLabel, m_titleEdit);
+
+ m_descriptionLabel = new QLabel(this);
+ m_descriptionEdit = new QTextEdit(description, this);
+ m_descriptionEdit->setWordWrapMode(QTextOption::WordWrap);
+ m_layout->addRow(m_descriptionLabel, m_descriptionEdit);
+
+ mainLayout->addLayout(m_layout);
+
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel
+ | QDialogButtonBox::NoButton
+ | QDialogButtonBox::Ok,
+ Qt::Horizontal,
+ this);
+ util::prepareDialogBox(m_buttonBox);
+ mainLayout->addWidget(m_buttonBox);
+
+ QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+ retranslateUi();
+
+ m_titleEdit->setFocus();
+}
+
+void BtEditBookmarkDialog::retranslateUi() {
+ setWindowTitle(tr("Edit Bookmark"));
+ m_keyLabel->setText(tr("Location:"));
+ m_titleLabel->setText(tr("Title:"));
+ m_descriptionLabel->setText(tr("Description:"));
+
+ /// \todo Add tooltips and what's this texts etc.
+}
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.h b/src/frontend/bookmarks/bteditbookmarkdialog.h
new file mode 100644
index 0000000..c3455e2
--- /dev/null
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.h
@@ -0,0 +1,62 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTEDITBOOKMARKDIALOG_H
+#define BTEDITBOOKMARKDIALOG_H
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QTextEdit>
+
+class QDialogButtonBox;
+class QFormLayout;
+class QLabel;
+class QWidget;
+
+/**
+ \brief A dialog box for editing bookmarks.
+*/
+class BtEditBookmarkDialog : public QDialog {
+ Q_OBJECT
+
+ public: /* Methods: */
+ BtEditBookmarkDialog(const QString &key,
+ const QString &title,
+ const QString &description,
+ QWidget *parent = 0,
+ Qt::WindowFlags wflags = Qt::Dialog);
+
+ /**
+ * Returns the description written in the description box.
+ */
+ inline const QString descriptionText() {
+ return m_descriptionEdit->toPlainText();
+ }
+
+ /**
+ * Returns the title written in the title box.
+ */
+ inline const QString titleText() { return m_titleEdit->text(); }
+
+ protected: /* Methods: */
+ void retranslateUi();
+
+ private: /* Fields: */
+ QFormLayout *m_layout;
+ QLabel *m_keyLabel;
+ QLabel *m_keyTextLabel;
+ QLabel *m_titleLabel;
+ QLineEdit *m_titleEdit;
+ QLabel *m_descriptionLabel;
+ QTextEdit *m_descriptionEdit;
+ QDialogButtonBox *m_buttonBox;
+
+};
+
+#endif
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/bookmarks/cbookmarkindex.cpp
index 1f88125..b6adbfa 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/bookmarks/cbookmarkindex.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
+#include "frontend/bookmarks/cbookmarkindex.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QAction>
#include <QApplication>
#include <QCursor>
@@ -18,7 +18,6 @@
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
-#include <QHeaderView>
#include <QInputDialog>
#include <QList>
#include <QMenu>
@@ -35,15 +34,16 @@
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cprinter.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
#include "util/dialogutil.h"
+#include "bibletime.h"
CBookmarkIndex::CBookmarkIndex(QWidget *parent)
@@ -68,7 +68,7 @@ CBookmarkIndex::~CBookmarkIndex() {
void CBookmarkIndex::initView() {
//qDebug() << "CBookmarkIndex::initView";
- header()->hide();
+ setHeaderHidden(true);
setFocusPolicy(Qt::WheelFocus);
@@ -92,7 +92,10 @@ void CBookmarkIndex::initView() {
m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
m_actions.changeFolder = newQAction(tr("Rename folder"), CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);
- m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
+ m_actions.editBookmark = newQAction(tr("Edit bookmark..."), CResMgr::mainIndex::editBookmark::icon, 0, this, SLOT(editBookmark()), this);
+ /// \todo Add icons for sorting bookmarks
+ m_actions.sortFolderBookmarks = newQAction(tr("Sort folder bookmarks..."), QString::null, 0, this, SLOT(sortFolderBookmarks()), this);
+ m_actions.sortAllBookmarks = newQAction(tr("Sort all bookmarks..."), QString::null, 0, this, SLOT(sortAllBookmarks()), this);
m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);
@@ -106,7 +109,9 @@ void CBookmarkIndex::initView() {
QAction* separator = new QAction(this);
separator->setSeparator(true);
m_popup->addAction(separator);
- m_popup->addAction(m_actions.changeBookmark);
+ m_popup->addAction(m_actions.editBookmark);
+ m_popup->addAction(m_actions.sortFolderBookmarks);
+ m_popup->addAction(m_actions.sortAllBookmarks);
m_popup->addAction(m_actions.importBookmarks);
m_popup->addAction(m_actions.exportBookmarks);
m_popup->addAction(m_actions.printBookmarks);
@@ -125,7 +130,12 @@ void CBookmarkIndex::initView() {
*/
QAction* CBookmarkIndex::newQAction(const QString& text, const QString& pix, const int /*shortcut*/, const QObject* receiver, const char* slot, QObject* parent) {
namespace DU = util::directory;
- QAction* action = new QAction(DU::getIcon(pix), text, parent);
+ QAction *action;
+ if (pix.isEmpty()) {
+ action = new QAction(text, parent);
+ } else {
+ action = new QAction(DU::getIcon(pix), text, parent);
+ }
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
return action;
}
@@ -451,9 +461,10 @@ void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem*
QString moduleName = mdata->bookmark().module();
QString keyText = mdata->bookmark().key();
QString description = mdata->bookmark().description();
- CSwordModuleInfo* minfo = CPointers::backend()->findModuleByName(moduleName);
+ CSwordModuleInfo *minfo = CSwordBackend::instance()->findModuleByName(moduleName);
+ QString title; // TODO
- QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description);
+ QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description, title);
// connect(newItem, SIGNAL(bookmarkModified()), this, SLOT(needToSaveBookmarks()) );
parentItem->insertChild(indexInParent, newItem);
@@ -494,8 +505,12 @@ QAction* CBookmarkIndex::action( BtBookmarkItemBase::MenuAction type ) const {
case BtBookmarkItemBase::ChangeFolder:
return m_actions.changeFolder;
- case BtBookmarkItemBase::ChangeBookmark:
- return m_actions.changeBookmark;
+ case BtBookmarkItemBase::EditBookmark:
+ return m_actions.editBookmark;
+ case BtBookmarkItemBase::SortFolderBookmarks:
+ return m_actions.sortFolderBookmarks;
+ case BtBookmarkItemBase::SortAllBookmarks:
+ return m_actions.sortAllBookmarks;
case BtBookmarkItemBase::ImportBookmarks:
return m_actions.importBookmarks;
case BtBookmarkItemBase::ExportBookmarks:
@@ -531,6 +546,7 @@ void CBookmarkIndex::contextMenu(const QPoint& p) {
//case BtBookmarkItemBase::ExportBookmarks:
//case BtBookmarkItemBase::ImportBookmarks:
case BtBookmarkItemBase::NewFolder:
+ case BtBookmarkItemBase::SortAllBookmarks:
//case BtBookmarkItemBase::PrintBookmarks:
a->setEnabled(true);
break;
@@ -592,7 +608,7 @@ void CBookmarkIndex::createNewFolder() {
}
else {
// create a top level folder
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, QObject::tr("New folder"));
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(tr("New folder"));
//parentFolder->addChild(newFolder);
insertTopLevelItem(topLevelItemCount() - 1, newFolder);
newFolder->update();
@@ -610,8 +626,8 @@ void CBookmarkIndex::changeFolder() {
}
}
-/** Changes the current bookmark. */
-void CBookmarkIndex::changeBookmark() {
+/** Edits the current bookmark. */
+void CBookmarkIndex::editBookmark() {
BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(currentItem());
Q_ASSERT(i);
@@ -620,6 +636,28 @@ void CBookmarkIndex::changeBookmark() {
}
}
+/** Sorts the current folder bookmarks. */
+void CBookmarkIndex::sortFolderBookmarks() {
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ Q_ASSERT(i);
+
+ if (i) {
+ i->sortChildren(0, Qt::AscendingOrder);
+ }
+}
+
+/** Sorts all bookmarks. */
+void CBookmarkIndex::sortAllBookmarks() {
+ sortItems(0, Qt::AscendingOrder);
+ int index = indexOfTopLevelItem(m_extraItem);
+ if (index >= 0) {
+ QTreeWidgetItem* item = takeTopLevelItem(index);
+ if (item != 0) {
+ addTopLevelItem(m_extraItem);
+ }
+ }
+}
+
/** Exports the bookmarks being in the selected folder. */
void CBookmarkIndex::exportBookmarks() {
BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
@@ -671,7 +709,7 @@ void CBookmarkIndex::printBookmarks() {
qWarning("Tried to print empty bookmark list.");
return;
}
- boost::scoped_ptr<Printing::CPrinter> printer(
+ QSharedPointer<Printing::CPrinter> printer(
new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
);
printer->printKeyTree(tree);
@@ -740,7 +778,11 @@ bool CBookmarkIndex::isMultiAction( const BtBookmarkItemBase::MenuAction type )
case BtBookmarkItemBase::ChangeFolder:
return false;
- case BtBookmarkItemBase::ChangeBookmark:
+ case BtBookmarkItemBase::EditBookmark:
+ return false;
+ case BtBookmarkItemBase::SortFolderBookmarks:
+ return false;
+ case BtBookmarkItemBase::SortAllBookmarks:
return false;
case BtBookmarkItemBase::ImportBookmarks:
return false;
@@ -799,13 +841,13 @@ void CBookmarkIndex::magTimeout() {
//qDebug() << "CBookmarkIndex::timerEvent: update the infodisplay";
// Update the mag
if (bitem->module()) {
- (CPointers::infoDisplay())->setInfo(
+ (BibleTime::instance()->infoDisplay())->setInfo(
InfoDisplay::CInfoDisplay::CrossReference,
bitem->module()->name() + ":" + bitem->key()
);
}
else {
- (CPointers::infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
+ (BibleTime::instance()->infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
}
}
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/bookmarks/cbookmarkindex.h
index 90f9ab2..2875a5d 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/bookmarks/cbookmarkindex.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef CBOOKMARKINDEX_H
#define CBOOKMARKINDEX_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#include <QList>
#include <QTimer>
@@ -18,7 +18,6 @@
#include <QTreeWidgetItem>
#include <QToolTip>
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "util/cpointers.h"
class BTMimeData;
@@ -126,7 +125,13 @@ class CBookmarkIndex : public QTreeWidget {
void exportBookmarks();
/** Changes the current bookmark. */
- void changeBookmark();
+ void editBookmark();
+
+ /** Sorts the current folder bookmarks. */
+ void sortFolderBookmarks();
+
+ /** Sorts all bookmarks. */
+ void sortAllBookmarks();
/** Helps with the extra item. */
void slotItemEntered(QTreeWidgetItem*, int);
@@ -170,7 +175,9 @@ class CBookmarkIndex : public QTreeWidget {
QAction* newFolder;
QAction* changeFolder;
- QAction* changeBookmark;
+ QAction* editBookmark;
+ QAction* sortFolderBookmarks;
+ QAction* sortAllBookmarks;
QAction* importBookmarks;
QAction* exportBookmarks;
QAction* printBookmarks;
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 565765d..3d02388 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,8 +20,6 @@
#include <QListWidgetItem>
#include <QStackedWidget>
#include <QVBoxLayout>
-#include "util/directory.h"
-#include "util/tool.h"
BtConfigDialog::BtConfigDialog(QWidget* parent)
@@ -44,14 +42,6 @@ BtConfigDialog::BtConfigDialog(QWidget* parent)
m_pageLayout->addWidget(m_pageWidget);
- // Horizontal line
- QFrame* line = new QFrame();
- line->setGeometry(QRect(1, 1, 1, 3));
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
- line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_pageLayout->addWidget(line);
-
connect(m_contentsList,
SIGNAL(currentRowChanged(int)),
this, SLOT(slotChangePage(int))
@@ -62,22 +52,14 @@ BtConfigDialog::BtConfigDialog(QWidget* parent)
BtConfigDialog::~BtConfigDialog() {}
void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
- namespace DU = util::directory;
-
// this is a friend
pageWidget->m_parentDialog = this;
- QVBoxLayout* containerLayout = new QVBoxLayout;
- QLabel* headerLabel = util::tool::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
- containerLayout->addWidget(headerLabel);
- containerLayout->addWidget(pageWidget);
- QWidget* containerWidget = new QWidget(m_pageWidget);
- containerWidget->setLayout(containerLayout);
- m_pageWidget->addWidget(containerWidget);
+ m_pageWidget->addWidget(pageWidget);
QListWidgetItem* item = new QListWidgetItem(m_contentsList);
- item->setIcon(DU::getIcon(pageWidget->iconName()));
+ item->setIcon(pageWidget->icon());
item->setText(pageWidget->header());
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
@@ -96,11 +78,16 @@ void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
}
void BtConfigDialog::addButtonBox(QDialogButtonBox* box) {
- m_pageLayout->addWidget(box);
-}
+ // First add a horizontal ruler:
+ QFrame *line = new QFrame();
+ line->setGeometry(QRect(1, 1, 1, 3));
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_pageLayout->addWidget(line);
-BtConfigPage* BtConfigDialog::currentPage() {
- return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget());
+ // Add button box:
+ m_pageLayout->addWidget(box);
}
void BtConfigDialog::slotChangePage(int newIndex) {
@@ -113,6 +100,13 @@ void BtConfigDialog::slotChangePage(int newIndex) {
-BtConfigPage::BtConfigPage() {}
+BtConfigPage::BtConfigPage(QWidget *parent)
+ : QWidget(parent)
+ , m_parentDialog(0)
+{
+ setLayout(new QVBoxLayout);
+}
-BtConfigPage::~BtConfigPage() {}
+BtConfigPage::~BtConfigPage() {
+ // Intentionally empty
+}
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index 547cb4e..dce22ab 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,10 +17,11 @@
class BtConfigPage;
-class QListWidgetItem;
+class QDialogButtonBox;
+class QLabel;
class QListWidget;
+class QListWidgetItem;
class QStackedWidget;
-class QDialogButtonBox;
class QVBoxLayout;
/**
@@ -34,7 +35,7 @@ class QVBoxLayout;
class BtConfigDialog : public QDialog {
Q_OBJECT
public:
- BtConfigDialog(QWidget* parent);
+ BtConfigDialog(QWidget *parent = 0);
virtual ~BtConfigDialog();
/** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
@@ -42,9 +43,6 @@ class BtConfigDialog : public QDialog {
/** Adds a button box to the lower edge of the dialog. */
void addButtonBox(QDialogButtonBox* buttonBox);
- /** Returns the currently selected page. */
- BtConfigPage* currentPage();
-
public slots:
/** Changes the current page using the given index number. */
void slotChangePage(int newIndex);
@@ -64,24 +62,29 @@ class BtConfigDialog : public QDialog {
*/
class BtConfigPage : public QWidget {
Q_OBJECT
+ friend class BtConfigDialog;
+
public:
- BtConfigPage();
+ /**
+ Constructs a configuration dialog base, with QVBoxLayout as layout() and a header
+ label as the first widget in this layout.
+ \param[in] parent The parent widget.
+ */
+ BtConfigPage(QWidget *parent = 0);
virtual ~BtConfigPage();
/** Implement these to return the correct values.
* For example: header(){return tr("General");}
*/
- virtual QString iconName() = 0;
- virtual QString label() = 0;
- virtual QString header() = 0;
- BtConfigDialog* parentDialog() {
+ virtual const QIcon &icon() const = 0;
+ virtual QString header() const = 0;
+
+ inline BtConfigDialog *parentDialog() const {
return m_parentDialog;
}
private:
- friend class BtConfigDialog;
- BtConfigDialog* m_parentDialog;
-
+ BtConfigDialog *m_parentDialog;
};
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
index ace804f..756fcae 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#include "frontend/bookshelfmanager/btinstallmgr.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include <QDebug>
#include <QList>
#include <QObject>
@@ -25,8 +25,9 @@
using namespace sword;
BtInstallMgr::BtInstallMgr()
- : InstallMgr(instbackend::configPath().toLatin1(), this),
- m_firstCallOfPreStatus(true) { //use this class also as status reporter
+ : InstallMgr(BtInstallBackend::configPath().toLatin1(), this),
+ m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true)
+{ //use this class also as status reporter
qDebug() << "BtInstallMgr::BtInstallMgr";
this->setFTPPassive(true);
}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
index 7eff1ae..7d39440 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ b/src/frontend/bookshelfmanager/btinstallmgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,53 +21,42 @@
#include <ftptrans.h>
-class CSwordBackend;
-
-typedef QList<sword::InstallSource*> InstallSourceList;
-
/**
* Our own reimplementation to provide installation and status bar updates.
*/
class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
Q_OBJECT
public:
-
BtInstallMgr();
- virtual ~BtInstallMgr();
-
- /**
- * Refreshing the source should be cancellable (othewise it might freeze the app if there is
- * for example something wrong with the network).
- */
- void slotRefreshCanceled();
+ ~BtInstallMgr();
/** Re-implemented from sword::InstallMgr. */
- virtual bool isUserDisclaimerConfirmed() const;
+ bool isUserDisclaimerConfirmed() const;
+
+ signals:
+ /** Download status. Percent of total and file.*/
+ void percentCompleted(const int total, const int file);
+ void downloadStarted();
protected:
- /* Reimplementations of methods in StatusReporter */
/**
- * Gets the total and current file status, emits the signal with those values as percents.
+ Reimplementation of sword::StatusReporter::statusUpdate().
*/
- virtual void statusUpdate(double dltotal, double dlnow);
+ void statusUpdate(double dltotal, double dlnow);
+
/**
+ * Reimplementation of sword::StatusReporter::preStatus().
+ * \warning This method is not always called before statusUpdate().
* Called before starting to download each file of the module package.
* The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
* This function is not utilized in the UI ATM.
*/
- virtual void preStatus(long totalBytes, long completedBytes, const char *message);
+ void preStatus(long totalBytes, long completedBytes, const char *message);
+ private:
long m_totalBytes;
long m_completedBytes;
-
- private:
bool m_firstCallOfPreStatus;
-
- signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted( const int, const int);
- void downloadStarted();
};
-
#endif
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index b261305..f0547b8 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -2,21 +2,18 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include <QDialogButtonBox>
#include "backend/config/cbtconfig.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include "util/cpointers.h"
-#include "util/dialogutil.h"
static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
@@ -48,13 +45,6 @@ BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent)
slotChangePage(0);
- // Dialog button (Close)
- QDialogButtonBox* bbox = new QDialogButtonBox(this);
- bbox->addButton(QDialogButtonBox::Close);
- util::prepareDialogBox(bbox);
- addButtonBox(bbox);
- connect(bbox, SIGNAL(rejected()), SLOT(close()));
-
loadDialogSettings();
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index c51efd2..0392cc2 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,7 +44,7 @@ class BtModuleManagerDialog : public BtConfigDialog {
//signals:
-// void swordSetupChanged();
+// void swordSetupChanged();
};
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index e326641..14aecb9 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QComboBox>
#include <QDir>
#include <QFileInfo>
@@ -25,7 +25,7 @@
#include <QProgressDialog>
#include <QApplication>
#include <QDebug>
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include "util/dialogutil.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
@@ -102,11 +102,10 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//BTInstallMgr iMgr;
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
- sword::InstallSource is = instbackend::source(m_captionEdit->text());
+ sword::InstallSource is = BtInstallBackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
util::showInformation( this, tr( "Error" ),
- /** \bug Double space in the following string: */
- tr("A source with this caption already exists. Please provide a different caption."));
+ tr("A source with this caption already exists. Please provide a different caption."));
return;
}
@@ -177,17 +176,15 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
qApp->processEvents();
qWarning() << "Start downloading the list of sources";
int ret = iMgr.refreshRemoteSourceConfiguration();
- bool success = false;
+
if ( !ret ) { //make sure the sources were updated sucessfully
qDebug() << "download succeeded";
- success = true;
m_progressDialog->setValue(100); //make sure the dialog closes
m_remoteListAdded = true;
accept();
}
else {
qWarning("InstallMgr: getting remote list returned an error.");
- success = false;
}
delete m_progressDialog;
m_progressDialog = 0;
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index 12df221..e69e9a9 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 984700c..026aad5 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,20 +19,20 @@
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/cmoduleindexdialog.h"
+#include "frontend/btmoduleindexdialog.h"
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-BtIndexPage::BtIndexPage()
- : BtConfigPage() {
+BtIndexPage::BtIndexPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
namespace DU = util::directory;
- QVBoxLayout *vboxLayout;
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *vboxLayout = static_cast<QVBoxLayout*>(layout());
QHBoxLayout *hboxLayout;
- vboxLayout = new QVBoxLayout(this);
m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
@@ -75,22 +75,20 @@ BtIndexPage::BtIndexPage()
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ connect(CSwordBackend::instance(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
populateModuleList();
}
BtIndexPage::~BtIndexPage() {
CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
-
-}
-QString BtIndexPage::label() {
- return tr("Create new search indexes and delete created indexes for the installed works.");
}
-QString BtIndexPage::iconName() {
- return CResMgr::bookshelfmgr::indexpage::icon;
+
+const QIcon &BtIndexPage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon);
}
-QString BtIndexPage::header() {
+
+QString BtIndexPage::header() const {
return tr("Search Indexes");
}
@@ -114,7 +112,7 @@ void BtIndexPage::populateModuleList() {
- const QList<CSwordModuleInfo*> &modules(CPointers::backend()->moduleList());
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
for (MLCI it(modules.begin()); it != modules.end(); ++it) {
QTreeWidgetItem* item = 0;
@@ -138,11 +136,11 @@ void BtIndexPage::populateModuleList() {
/** Creates indices for selected modules if no index currently exists */
void BtIndexPage::createIndices() {
bool indicesCreated = false;
- QList<CSwordModuleInfo*> moduleList;
+ QList<const CSwordModuleInfo*> moduleList;
for (int i = 0; i < m_modsWithoutIndices->childCount(); i++) {
if (m_modsWithoutIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
if (module) {
moduleList.append( module );
indicesCreated = true;
@@ -152,7 +150,7 @@ void BtIndexPage::createIndices() {
//Shows the progress dialog
if (indicesCreated) {
- CModuleIndexDialog::getInstance()->indexAllModules( moduleList );
+ BtModuleIndexDialog::indexAllModules(moduleList);
populateModuleList();
}
}
@@ -163,7 +161,7 @@ void BtIndexPage::deleteIndices() {
for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
if (module) {
module->deleteIndex();
indicesDeleted = true;
@@ -177,27 +175,6 @@ void BtIndexPage::deleteIndices() {
}
}
-void BtIndexPage::deleteOrphanedIndices() {
- QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
- dir.setFilter(QDir::Dirs);
- CSwordModuleInfo* module;
-
- for (unsigned int i = 0; i < dir.count(); i++) {
- if (dir[i] != "." && dir[i] != "..") {
- if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
- if (!module->hasIndex()) { //index files found, but wrong version etc.
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- else { //no module exists
- if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- }
- }
-}
-
void BtIndexPage::slotSwordSetupChanged() {
populateModuleList();
}
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 795cc0b..89a7e35 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,20 +26,14 @@ class BtIndexPage : public BtConfigPage {
Q_OBJECT
public:
- /**
- * Constructor
- */
- BtIndexPage();
-
- /**
- * Destructor
- */
+ BtIndexPage(QWidget *parent = 0);
~BtIndexPage();
- // BtConfigPage methods
- QString header();
- QString iconName();
- QString label();
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
public slots:
void slotSwordSetupChanged();
@@ -63,13 +57,6 @@ class BtIndexPage : public BtConfigPage {
*/
void deleteIndices();
- public:
- /**
- * Deletes orphaned indices if the autoDeleteOrphanedIndices is true
- * Always deletes indices of existing modules where hasIndex() returns false
- */
- static void deleteOrphanedIndices();
-
private:
QCheckBox *m_autoDeleteOrphanedIndicesBox;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 8fd87ec..01ca55b 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -1,127 +1,83 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-#include <QBrush>
-#include <QDebug>
-#include <QList>
-#include <QPushButton>
-#include <QString>
-#include <QTreeWidgetItem>
-#include <QWidget>
-#include "backend/btmoduletreeitem.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/cmodulechooserdialog.h"
+#include <QAction>
+#include <QHeaderView>
+#include <QToolButton>
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "frontend/btbookshelfview.h"
+#include "util/tool.h"
-BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty)
- : CModuleChooserDialog(parent, title, label, empty) {
- qDebug() << "BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start";
- init();
- okButton()->setText(tr("Install"));
- m_nameList = QStringList();
+namespace {
+const QString groupingOrderKey("GUI/BookshelfManager/InstallConfirmDialog/grouping");
}
-// Do nothing, the tree is initialized outside this class.
-void BtInstallModuleChooserDialog::initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*) {}
-
-void BtInstallModuleChooserDialog::initModuleItem(QString name, QTreeWidgetItem* sourceItem) {
- /// \todo Use new bookshelf model instead
- /// \bug Valgrind reports memory leak:
- QTreeWidgetItem* moduleItem = new QTreeWidgetItem(sourceItem);
- moduleItem->setText(0, name);
- moduleItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- moduleItem->setCheckState(0, Qt::Checked);
+BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
+ QWidget *parent,
+ Qt::WindowFlags flags)
+ : BtModuleChooserDialog(parent, flags), m_shown(false)
+{
+ resize(550, 340);
- // prevent double items
- if (m_nameList.contains(name)) {
- qDebug() << "item already in list:" << name;
- //moduleItem->setCheckState(0, Qt::Unchecked);
- QBrush bg(Qt::red);
- moduleItem->setBackground(0, bg);
- //find and change the other offending items
- foreach (QTreeWidgetItem* doubleItem, treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive, 0)) {
- //doubleItem->setCheckState(0, Qt::Unchecked);
- //qDebug() << "CInstallModuleChooserDialog::initModuleItem" << doubleItem;
- doubleItem->setBackground(0, bg);
- }
- m_doubleCheckedModules[name] = true;
- enableOk(false);
+ // Read grouping order from settings or the default from argument:
+ BtBookshelfTreeModel::Grouping groupingOrder(false);
+ if (!groupingOrder.loadFrom(groupingOrderKey)) {
+ groupingOrder = g;
}
- m_nameList << name;
-}
-void BtInstallModuleChooserDialog::slotItemChecked(QTreeWidgetItem* item, int column) {
- QString moduleName = item->text(0);
- qDebug() << "BtInstallModuleChooserDialog::slotItemChecked start";
- // handle only non-toplevel items which has duplicates and where the first column was changed
- if (item->parent() && column == 0 && (findModuleItemsByName(moduleName).count() > 1)) {
- //prevent handling when the color is changed
- if (item->data(1, Qt::UserRole).toBool() == false) {
- qDebug() << "was not updating";
- item->setData(1, Qt::UserRole, true);
- }
- else {
- qDebug() << "was updating";
- item->setData(1, Qt::UserRole, false);
- return;
- }
+ BtInstallModuleChooserDialogModel *treeModel;
+ treeModel = new BtInstallModuleChooserDialogModel(groupingOrder, this);
+ connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
- QList<QTreeWidgetItem*> doubleNameItems = findModuleItemsByName(moduleName);
- QList<QTreeWidgetItem*> doubleCheckedItems;
- foreach (QTreeWidgetItem* nItem, doubleNameItems) {
- if (nItem->checkState(0) == Qt::Checked) {
- doubleCheckedItems << nItem;
- }
- }
+ m_bookshelfModel = new BtBookshelfModel(this);
+ bookshelfWidget()->postFilterModel()->setShowShown(true);
+ bookshelfWidget()->setTreeModel(treeModel);
+ bookshelfWidget()->setSourceModel(m_bookshelfModel);
+ bookshelfWidget()->showHideAction()->setVisible(false);
+ bookshelfWidget()->showHideButton()->hide();
+ bookshelfWidget()->treeView()->header()->show();
- if (doubleCheckedItems.count() > 1) {
- enableOk(false);
- // color the items
- qDebug() << "there were more than 1 item of the name" << moduleName;
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- QBrush bg(Qt::red);
- i->setBackground(0, bg);
- }
- m_doubleCheckedModules[moduleName] = true;
- }
- else if (doubleCheckedItems.count() == 1) {
- qDebug() << "there were 1 checked items of the name" << moduleName;
- // uncolor the items
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- i->setBackground(0, i->parent()->background(0));
- }
- m_doubleCheckedModules.remove(moduleName);
- if (m_doubleCheckedModules.count() == 0) {
- enableOk(true);
- }
- }
- }
+ retranslateUi();
}
-QList<QTreeWidgetItem*> BtInstallModuleChooserDialog::findModuleItemsByName(QString name) {
- qDebug() << "BtInstallModuleChooserDialog::findModuleItemsByName:" << name << treeWidget()->topLevelItemCount();
- QList<QTreeWidgetItem*> doubleNamedAllItems = treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive);
- //qDebug() << "doubleNamedAllItems: " << doubleNamedAllItems.count();
- QList<QTreeWidgetItem*> doubleNamedModuleItems;
- foreach (QTreeWidgetItem* item, doubleNamedAllItems) {
- //qDebug() << "item:" << item;
- if (item->parent()) {
- doubleNamedModuleItems << item;
- }
- }
- //qDebug() << "module items:" << doubleNamedModuleItems.count();
- return doubleNamedModuleItems;
+void BtInstallModuleChooserDialog::addModuleItem(CSwordModuleInfo *module,
+ const QString &sourceName)
+{
+ module->setProperty("installSourceName", sourceName);
+ m_bookshelfModel->addModule(module);
+}
+
+void BtInstallModuleChooserDialog::retranslateUi() {
+ setWindowTitle(tr("Install/Update works?"));
+ util::tool::initExplanationLabel(
+ label(), QString::null,
+ tr("Do you really want to install these works?") + "<br/><br/><small>" +
+ tr("Only one version of a work can be installed at the same time. Select only "
+ "one if there are items marked with red.") + "</small>");
+}
+
+void BtInstallModuleChooserDialog::showEvent(QShowEvent *event) {
+ Q_UNUSED(event);
+
+ if (m_shown) return;
+ bookshelfWidget()->treeView()->expandAll();
+ bookshelfWidget()->treeView()->header()->resizeSections(QHeaderView::ResizeToContents);
+ m_shown = true;
}
-void BtInstallModuleChooserDialog::enableOk(bool enabled) {
- qDebug() << "BtInstallModuleChooserDialog::enableOk" << enabled;
- okButton()->setEnabled(enabled);
+void BtInstallModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ g.saveTo(groupingOrderKey);
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 06144ff..070df6f 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -1,51 +1,55 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#ifndef BTINSTALLMODULECHOOSERDIALOG_H
#define BTINSTALLMODULECHOOSERDIALOG_H
-#include "frontend/cmodulechooserdialog.h"
+#include "frontend/btmodulechooserdialog.h"
-#include <QList>
-#include <QMap>
-#include <QObject>
-#include <QString>
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
-class BTModuleTreeItem;
-class QWidget;
-class QTreeWidgetItem;
+class BtBookshelfModel;
+class BtInstallModuleChooserDialogModel;
+class CSwordModuleInfo;
/**
* Confirmation dialog for installation. Lets the user
* uncheck modules from the list.
*/
-class BtInstallModuleChooserDialog : public CModuleChooserDialog {
- Q_OBJECT
-
+class BtInstallModuleChooserDialog: public BtModuleChooserDialog {
+ Q_OBJECT
public:
- BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty);
+ BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
+ QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
- void initModuleItem(QString name, QTreeWidgetItem* sourceItem);
- void enableOk(bool enabled);
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return bookshelfWidget()->treeModel()->checkedModules();
+ }
- public slots:
- void slotItemChecked(QTreeWidgetItem* item, int column);
+ void addModuleItem(CSwordModuleInfo *module, const QString &sourceName);
protected:
- virtual void initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*);
+ void retranslateUi();
+ void showEvent(QShowEvent *event);
+
+ protected slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
- QList<QTreeWidgetItem*> findModuleItemsByName(QString name);
private:
- QStringList m_nameList;
- QMap<QString, bool> m_doubleCheckedModules;
+ BtBookshelfModel *m_bookshelfModel;
+ bool m_shown;
};
-#endif
+#endif // BTINSTALLMODULECHOOSERDIALOG_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
new file mode 100644
index 0000000..880ea6a
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
@@ -0,0 +1,136 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
+
+#include <QBrush>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+
+#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
+ BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
+
+BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
+ const Grouping &grouping,
+ QObject *parent)
+ : BtBookshelfTreeModel(grouping, parent), m_dataChangedFired(false)
+{
+ setDefaultChecked(BtBookshelfTreeModel::CHECKED);
+ setCheckable(true);
+ connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ this, SLOT(parentDataChanged(QModelIndex,QModelIndex)),
+ Qt::DirectConnection);
+}
+
+BtInstallModuleChooserDialogModel::~BtInstallModuleChooserDialogModel() {
+ // Intentionally empty
+}
+
+QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
+ switch (role) {
+ case Qt::BackgroundRole:
+ if (isMulti(i)) return QBrush(Qt::red);
+ return BtBookshelfTreeModel::data(i, role);
+ case Qt::ForegroundRole:
+ if (isMulti(i)) return QBrush(Qt::white);
+ return BtBookshelfTreeModel::data(i, role);
+ case Qt::DisplayRole:
+ switch (i.column()) {
+ case 0:
+ return BtBookshelfTreeModel::data(i, role);
+ case 1:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module != 0) return module->property("installSourceName");
+ break;
+ }
+ case 2:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module == 0) break;
+ CSwordBackend *b = CSwordBackend::instance();
+ CSwordModuleInfo *imodule = b->findModuleByName(module->name());
+ if (imodule == 0) {
+ return module->config(CSwordModuleInfo::ModuleVersion);
+ } else {
+ return imodule->config(CSwordModuleInfo::ModuleVersion)
+ + " => "
+ + module->config(CSwordModuleInfo::ModuleVersion);
+ }
+ }
+ default: break;
+ }
+ default:
+ if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+int BtInstallModuleChooserDialogModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 3;
+}
+
+QVariant BtInstallModuleChooserDialogModel::headerData(int section,
+ Qt::Orientation orientation,
+ int role) const
+{
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ switch (section) {
+ case 0: return tr("Work");
+ case 1: return tr("Installation source");
+ case 2: return tr("Version");
+ default: break;
+ }
+ }
+
+ return QVariant();
+}
+
+void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight)
+{
+ Q_UNUSED(topLeft);
+ Q_UNUSED(bottomRight);
+
+ if (m_dataChangedFired) return;
+ m_dataChangedFired = true;
+ resetData();
+ m_dataChangedFired = false;
+}
+
+bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo *m1) const {
+ if (m1 != 0 && checkedModules().contains(m1)) {
+ Q_FOREACH(CSwordModuleInfo *m2, m_modules.keys()) {
+ if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool BtInstallModuleChooserDialogModel::isMulti(const QModelIndex &i) const {
+ if (!i.isValid()) return false;
+
+ if (!hasChildren(i)) {
+ return isMulti(MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent())));
+ } else {
+ for (int row = 0; row < rowCount(i); row++) {
+ if (isMulti(i.child(row, 0))) return true;
+ }
+ }
+ return false;
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
new file mode 100644
index 0000000..6120fa8
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
@@ -0,0 +1,44 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLMODULECHOOSERDIALOGMODEL_H
+#define BTINSTALLMODULECHOOSERDIALOGMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+#include <QMap>
+
+
+class BtInstallModuleChooserDialogModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+ public:
+ BtInstallModuleChooserDialogModel(const Grouping &grouping, QObject *parent = 0);
+ ~BtInstallModuleChooserDialogModel();
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ private slots:
+ void parentDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+ private:
+ bool isMulti(CSwordModuleInfo *module) const;
+ bool isMulti(const QModelIndex &index) const;
+
+ private:
+ QMap<QString, int> m_nameCounts;
+ bool m_dataChangedFired;
+};
+
+#endif // BTINSTALLMODULECHOOSERDIALOGMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index b71599a..d3bac59 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -2,63 +2,60 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
-#include <QAction>
#include <QApplication>
-#include <QButtonGroup>
#include <QComboBox>
-#include <QDialog>
-#include <QFileInfo>
+#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
-#include <QMessageBox>
-#include <QProgressBar>
-#include <QProgressDialog>
#include <QPushButton>
-#include <QSpacerItem>
-#include <QStackedWidget>
-#include <QTabBar>
-#include <QTimer>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
+#include <QSettings>
+#include <QSharedPointer>
+#include <QStackedLayout>
#include <QToolButton>
-#include <QVBoxLayout>
-#include <QWidget>
#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallbackend.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-#include "frontend/bookshelfmanager/installpage/btsourcewidget.h"
-#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "frontend/cmodulechooserdialog.h"
-#include "util/directory.h"
-#include "util/cpointers.h"
+#include "frontend/btbookshelfview.h"
#include "util/cresmgr.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
+#include "util/tool.h"
+
-// Sword includes:
-#include <swversion.h>
+namespace {
+const QString groupingOrderKey ("GUI/BookshelfManager/InstallPage/grouping");
+const QString headerStateKey ("GUI/BookshelfManager/InstallPage/headerState");
+const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule");
+} // anonymous namespace
// *********************************************************
// *********** Config dialog page: Install/Update **********
// *********************************************************
-BtInstallPage::BtInstallPage()
- : BtConfigPage() {
- qDebug() << "BtInstallPage::BtInstallPage() start";
+BtInstallPage::BtInstallPage(QWidget *parent)
+ : BtConfigPage(parent)
+ , m_groupingOrder(groupingOrderKey)
+ , m_modulesSelected(0)
+ , m_modulesSelectedSources(0)
+{
+ // Read settings:
+ m_headerState = CBTConfig::getConfig()->value(headerStateKey).toByteArray();
+
+ // Initialize widgets:
initView();
initConnections();
}
@@ -75,68 +72,105 @@ QString BtInstallPage::selectedInstallPath() {
void BtInstallPage::initView() {
namespace DU = util::directory;
- qDebug() << "void BtInstallPage::initView() start";
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
-
- // installation path chooser
- QHBoxLayout* pathLayout = new QHBoxLayout();
- // beautify the layout
- int top;
- int bottom;
- int left;
- int right;
- pathLayout->getContentsMargins(&left, &top, &right, &bottom);
- pathLayout->setContentsMargins(left, top + 7, right, bottom + 7 );
- QLabel* pathLabel = new QLabel(tr("Install folder:"));
- m_pathCombo = new QComboBox();
+ // Warning label:
+
+ m_warningLabel = util::tool::explanationLabel(this, tr("WARNING!!!"),
+ tr("If you live in a persecuted country and don't want to risk "
+ "detection don't use remote sources."));
+
+ // Source chooser:
+ m_sourceGroupBox = new QGroupBox(tr("Select installation &source:"), this);
+ m_sourceGroupBox->setFlat(true);
+
+ m_sourceComboBox = new QComboBox(this);
+ m_sourceComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ initSourcesCombo();
+
+ m_sourceAddButton = new QPushButton(tr("&Add..."));
+ m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+
+ m_sourceDeleteButton = new QPushButton(tr("&Delete..."));
+ m_sourceDeleteButton->setToolTip(tr("Delete this source"));
+ m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+
+ QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
+ sourceChooserLayout->setContentsMargins(0, 0, 0, 0);
+ sourceChooserLayout->addWidget(m_sourceComboBox, 1);
+ sourceChooserLayout->addWidget(m_sourceAddButton);
+ sourceChooserLayout->addWidget(m_sourceDeleteButton);
+ m_sourceGroupBox->setLayout(sourceChooserLayout);
+
+ // Works chooser:
+ m_worksGroupBox = new QGroupBox(tr("Select &works to install:"), this);
+ m_worksGroupBox->setFlat(true);
+ m_worksLayout = new QStackedLayout();
+ m_worksGroupBox->setLayout(m_worksLayout);
+ slotSourceIndexChanged(m_sourceComboBox->currentIndex());
+
+ // Installation path chooser:
+ m_installGroupBox = new QGroupBox(this);
+ m_installGroupBox->setFlat(true);
+ retranslateInstallGroupBox();
+
+ m_pathLabel = new QLabel(tr("Install &folder:"));
+ m_pathCombo = new QComboBox(this);
m_pathCombo->setMinimumContentsLength(20);
m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
- initPathCombo(); // set the paths and the current path
+ m_pathLabel->setBuddy(m_pathCombo);
+ initPathCombo();
+
m_configurePathButton = new QToolButton(this);
m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
- pathLayout->addWidget(pathLabel);
- pathLayout->addWidget(m_pathCombo);
- pathLayout->addWidget(m_configurePathButton);
- mainLayout->addLayout(pathLayout);
-
- // Source widget
- m_sourceWidget = new BtSourceWidget(this);
- mainLayout->addWidget(m_sourceWidget);
- // Install button
- QHBoxLayout *installButtonLayout = new QHBoxLayout();
- installButtonLayout->setContentsMargins(0, 5, 0, 5);
- QSpacerItem *installButtonSpacer = new QSpacerItem(371, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- installButtonLayout->addItem(installButtonSpacer);
- m_installButton = new QPushButton(tr("Install..."), this);
+ m_installButton = new QPushButton(tr("&Install..."), this);
m_installButton->setToolTip(tr("Install or update selected works"));
m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
- installButtonLayout->addWidget(m_installButton);
- mainLayout->addLayout(installButtonLayout);
+ QHBoxLayout *pathLayout = new QHBoxLayout();
+ pathLayout->setContentsMargins(0, 0, 0, 0);
+ pathLayout->addWidget(m_pathLabel);
+ pathLayout->addWidget(m_pathCombo);
+ pathLayout->addWidget(m_configurePathButton);
+ pathLayout->addWidget(m_installButton);
+ m_installGroupBox->setLayout(pathLayout);
+
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
+ mainLayout->addWidget(m_warningLabel);
+ mainLayout->addWidget(m_sourceGroupBox);
+ mainLayout->addWidget(m_worksGroupBox, 1);
+ mainLayout->addWidget(m_installGroupBox);
}
void BtInstallPage::initConnections() {
- qDebug() << "void BtInstallPage::initConnections() start";
- QObject::connect(m_pathCombo, SIGNAL(activated(const QString&)), this , SLOT(slotPathChanged(const QString&)));
- QObject::connect(m_configurePathButton, SIGNAL(clicked()), this, SLOT(slotEditPaths()));
- QObject::connect(m_installButton, SIGNAL(clicked()), m_sourceWidget, SLOT(slotInstall()) );
-
- QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), this, SLOT(slotSwordSetupChanged()));
- //source widget has its own connections, not here
+ connect(m_sourceComboBox, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(slotSourceIndexChanged(int)));
+ connect(m_sourceAddButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceAdd()));
+ connect(m_sourceDeleteButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceDelete()));
+ connect(m_installButton, SIGNAL(clicked()),
+ this, SLOT(slotInstall()));
+ connect(m_pathCombo, SIGNAL(activated(const QString&)),
+ this , SLOT(slotPathChanged(const QString&)));
+ connect(m_configurePathButton, SIGNAL(clicked()),
+ this, SLOT(slotEditPaths()));
+ connect(CSwordBackend::instance(),
+ SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
+ this, SLOT(slotSwordSetupChanged()));
}
void BtInstallPage::initPathCombo() {
- qDebug() << "void BtInstallPage::initPathCombo() start";
//populate the combo list
m_pathCombo->clear();
- QStringList targets = instbackend::targetList();
+ QStringList targets = BtInstallBackend::targetList();
for (QStringList::iterator it = targets.begin(); it != targets.end(); ++it) {
// Add the path only if it's writable
if ((*it).isEmpty()) continue;
@@ -154,43 +188,252 @@ void BtInstallPage::initPathCombo() {
m_pathCombo->setCurrentIndex(index);
}
+void BtInstallPage::initSourcesCombo() {
+ /// \todo Implement a proper model for this
+
+ m_sourceComboBox->clear();
+ QStringList sourceList = BtInstallBackend::sourceNameList();
+
+ // Add a default entry, the Crosswire main repository
+ if (sourceList.empty()) {
+ /// \todo Open a dialog which asks whether to get list from server and add sources
+ sword::InstallSource is("FTP"); //default return value
+ is.caption = "CrossWire Bible Society";
+ is.source = "ftp.crosswire.org";
+ is.directory = "/pub/sword/raw";
+ // passive ftp is not needed here, it's the default
+
+ BtInstallBackend::addSource(is);
+
+ sourceList = BtInstallBackend::sourceNameList();
+ Q_ASSERT(!sourceList.empty());
+ }
+
+ // Read selected module from config:
+ QString selected = CBTConfig::getConfig()->value(selectedModuleKey).toString();
+
+ // Populate combo box
+ bool selectionOk = false;
+ for (int i = 0; i < sourceList.size(); i++) {
+ m_sourceComboBox->addItem(sourceList.at(i));
+
+ // Select configured item:
+ if (!selectionOk && sourceList.at(i) == selected) {
+ m_sourceComboBox->setCurrentIndex(i);
+ selectionOk = true;
+ }
+ }
+
+ // Set selection, if it wasn't properly configured:
+ if (!selectionOk) {
+ m_sourceComboBox->setCurrentIndex(0);
+ CBTConfig::getConfig()->setValue(selectedModuleKey, sourceList.at(0));
+ }
+}
+
+void BtInstallPage::activateSource(const sword::InstallSource &src) {
+ qDebug() << "Selected source" << src.caption;
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ BtInstallPageWorksWidget *w = m_sourceMap.value(QString(src.caption), 0);
+ if (w == 0) {
+ if (parentDialog() != 0) parentDialog()->setEnabled(false);
+ qApp->processEvents();
+ w = new BtInstallPageWorksWidget(src, m_groupingOrder, this);
+ m_sourceMap.insert(QString(src.caption), w);
+ m_worksLayout->addWidget(w);
+ connect(w->treeModel(), SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+ connect(w->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
+ this, SLOT(slotSelectedModulesChanged()));
+ if (parentDialog() != 0) parentDialog()->setEnabled(true);
+ } else {
+ disconnect(w->treeView()->header(), SIGNAL(geometriesChanged()),
+ this, SLOT(slotHeaderChanged()));
+ }
+ m_worksLayout->setCurrentWidget(w);
+ w->treeModel()->setGroupingOrder(m_groupingOrder);
+ w->treeView()->header()->restoreState(m_headerState);
+ connect(w->treeView()->header(), SIGNAL(geometriesChanged()),
+ this, SLOT(slotHeaderChanged()));
+ qApp->restoreOverrideCursor();
+}
+
+void BtInstallPage::retranslateInstallGroupBox() {
+ if (m_modulesSelected > 0) {
+ m_installGroupBox->setTitle(tr("Start installation of %1 works from %2 sources:")
+ .arg(m_modulesSelected)
+ .arg(m_modulesSelectedSources));
+ } else {
+ m_installGroupBox->setTitle(tr("Start installation:"));
+ }
+}
+
+void BtInstallPage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ m_groupingOrder = g;
+ m_groupingOrder.saveTo(groupingOrderKey);
+}
+
+void BtInstallPage::slotHeaderChanged() {
+ typedef BtInstallPageWorksWidget IPWW;
+ Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()) != 0);
+ IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ m_headerState = w->treeView()->header()->saveState();
+ CBTConfig::getConfig()->setValue(headerStateKey, m_headerState);
+}
+
+void BtInstallPage::slotInstall() {
+ qDebug() << "BtInstallPage::slotInstall";
+
+ // check that the destination path is writable, do nothing if not and user doesn't want to continue
+ QDir dir = selectedInstallPath();
+ bool canWrite = true;
+ if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (!fi.exists() || !fi.isWritable()) {
+ canWrite = false;
+ }
+ }
+ else {
+ canWrite = false;
+ }
+ if (!canWrite) {
+ const int result = util::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
+ if (result != QMessageBox::Ignore) {
+ return;
+ }
+ }
+
+ // create the confirmation dialog
+ BtInstallModuleChooserDialog *dlg = new BtInstallModuleChooserDialog(m_groupingOrder, this);
+
+ // Add all checked modules from all tabs:
+ Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
+ Q_FOREACH (CSwordModuleInfo *module, w->treeModel()->checkedModules()) {
+ dlg->addModuleItem(module, QString(w->installSource().caption));
+ }
+ }
+
+ if (dlg->exec() == QDialog::Accepted) {
+ QSet<const CSwordModuleInfo*> cm;
+ Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
+ cm.insert(m);
+ }
+
+ if (cm.empty()) return;
+
+ /// \todo first remove all modules which will be updated from the module list
+ // but what modules? all with the same real name? (there may be _n modules...)
+
+ BtModuleManagerDialog *parentDlg = dynamic_cast<BtModuleManagerDialog*>(parentDialog());
+
+ BtInstallProgressDialog *dlg = new BtInstallProgressDialog(cm, selectedInstallPath(), parentDlg);
+
+ if (!parentDlg) qDebug() << "error, wrong parent!";
+
+ m_installButton->setEnabled(false);
+
+ // the progress dialog is now modal, it can be made modeless later.
+ dlg->exec();
+
+ qDebug() << "BtSourceWidget::slotInstallAccepted end";
+ }
+ delete dlg;
+}
+
void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
}
void BtInstallPage::slotEditPaths() {
- qDebug() << "void BtInstallPage::slotEditPaths() start";
-
BtInstallPathDialog* dlg = new BtInstallPathDialog();
int result = dlg->exec();
if (result == QDialog::Accepted) {
//dynamic_cast<BtModuleManagerDialog*>(parentDialog())->slotSwordSetupChanged();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
+ CSwordBackend::instance()->reloadModules(CSwordBackend::PathChanged);
}
}
-// implement the BtConfigPage methods
+void BtInstallPage::slotSourceAdd() {
+ typedef CSwordSetupInstallSourcesDialog SSISD;
-QString BtInstallPage::iconName() {
- return CResMgr::bookshelfmgr::installpage::icon;
+ QSharedPointer<SSISD> dlg(new SSISD());
+ if (dlg->exec() == QDialog::Accepted) {
+ if (!dlg->wasRemoteListAdded()) {
+ sword::InstallSource newSource = dlg->getSource();
+ if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
+ BtInstallBackend::addSource(newSource);
+ }
+ initSourcesCombo();
+ for (int i = 0; i < m_sourceComboBox->count(); i++) {
+ if (m_sourceComboBox->itemText(i) == newSource.caption) {
+ m_sourceComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+ }
}
-QString BtInstallPage::label() {
- // \todo move the warning to a dialog which is shown when adding a source.
- return tr("Install and update works. Add remote or local sources, refresh them, select the works to be installed/updated and click Install.<br/><b>WARNING:</b> If you live in a persecuted country and don't want to risk detection don't use remote sources.");
+
+void BtInstallPage::slotSourceDelete() {
+ typedef BtInstallPageWorksWidget IPWW;
+
+ int ret = util::showWarning(this, tr("Delete Source?"),
+ tr("Do you really want to delete this source?"),
+ QMessageBox::Yes | QMessageBox::No);
+
+ if (ret == QMessageBox::Yes) {
+ Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()));
+ IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ w->deleteSource();
+ initSourcesCombo();
+ slotSourceIndexChanged(m_sourceComboBox->currentIndex());
+ delete w;
+ }
}
-QString BtInstallPage::header() {
- return tr("Install/Update");
+
+void BtInstallPage::slotSourceIndexChanged(int index) {
+ if (index < 0) index = 0;
+
+ /// \todo use pointers instead of text
+ QString moduleName = m_sourceComboBox->itemText(index);
+ CBTConfig::getConfig()->setValue(selectedModuleKey, moduleName);
+ activateSource(BtInstallBackend::source(moduleName));
}
-void BtInstallPage::slotSwordSetupChanged() {
- qDebug() << "BtInstallPage::slotSwordSetupChanged";
- initPathCombo();
-// for (int i = 0; i < m_sourceWidget->count(); i++ ) {
-// BtSourceArea* sourceArea = dynamic_cast<BtSourceArea*>(m_sourceWidget->widget(i));
-// Q_ASSERT(sourceArea);
-// sourceArea->createModuleTree();
-// }
+void BtInstallPage::slotSelectedModulesChanged() {
+ m_modulesSelected = 0;
+ m_modulesSelectedSources = 0;
+ Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
+ int selected = w->treeModel()->checkedModules().size();
+ if (selected > 0) {
+ m_modulesSelectedSources++;
+ m_modulesSelected += selected;
+ }
+ }
+
+ m_installButton->setEnabled(m_modulesSelected > 0);
+ retranslateInstallGroupBox();
+}
+
+// implement the BtConfigPage methods
+
+const QIcon &BtInstallPage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon);
}
+QString BtInstallPage::header() const {
+ return tr("Install/Update");
+}
+void BtInstallPage::slotSwordSetupChanged() {
+ QString moduleName = m_sourceComboBox->currentText();
+ initSourcesCombo();
+ qDeleteAll(m_sourceMap.values());
+ m_sourceMap.clear();
+ m_sourceComboBox->setCurrentIndex(m_sourceComboBox->findText(moduleName));
+ initPathCombo();
+ m_modulesSelected = 0;
+ m_modulesSelectedSources = 0;
+ retranslateInstallGroupBox();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index fde9919..88d1f92 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,29 +12,34 @@
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include <QString>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-// Sword includes:
-#include <installmgr.h>
+namespace sword {
+class InstallSource;
+}
-class BtSourceWidget;
+class BtInstallPageWorksWidget;
class QComboBox;
+class QGroupBox;
class QPushButton;
+class QStackedLayout;
class QToolButton;
/**
* The Install page includes module path chooser, source/module handler and install button.
*/
-class BtInstallPage : public BtConfigPage {
+class BtInstallPage: public BtConfigPage {
Q_OBJECT
+
public:
- BtInstallPage();
+ BtInstallPage(QWidget *parent = 0);
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
- // reimplemented from btinstallpage
- QString iconName();
- QString label();
- QString header();
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
void setInstallEnabled(bool b);
@@ -47,18 +52,46 @@ class BtInstallPage : public BtConfigPage {
void initView();
void initConnections();
void initPathCombo();
+ void initSourcesCombo();
+
+ void activateSource(const sword::InstallSource &src);
+ void retranslateInstallGroupBox();
private slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
+ void slotHeaderChanged();
+ void slotInstall();
void slotPathChanged(const QString& pathText);
void slotEditPaths();
+ void slotSourceAdd();
+ void slotSourceDelete();
+ void slotSourceIndexChanged(int index);
+ void slotSelectedModulesChanged();
private:
+ BtBookshelfTreeModel::Grouping m_groupingOrder;
+ QByteArray m_headerState;
+
+ QMap<QString, BtInstallPageWorksWidget*> m_sourceMap;
+
+ QLabel *m_warningLabel;
+
+ QGroupBox *m_sourceGroupBox;
+ QComboBox *m_sourceComboBox;
+ QPushButton *m_sourceAddButton;
+ QPushButton *m_sourceDeleteButton;
+
+ QGroupBox *m_worksGroupBox;
+ QStackedLayout *m_worksLayout;
+
+ QGroupBox *m_installGroupBox;
+ QLabel *m_pathLabel;
+ QComboBox *m_pathCombo;
+ QToolButton *m_configurePathButton;
+ QPushButton *m_installButton;
- QComboBox* m_pathCombo;
- //QPushButton* m_configurePathButton;
- QToolButton* m_configurePathButton;
- BtSourceWidget* m_sourceWidget;
- QPushButton* m_installButton;
+ unsigned m_modulesSelected;
+ unsigned m_modulesSelectedSources;
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
new file mode 100644
index 0000000..9aa6743
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
@@ -0,0 +1,87 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
+
+
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+
+#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
+ BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
+
+BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent)
+ : BtBookshelfTreeModel(grouping, parent)
+{
+ setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
+ setCheckable(true);
+}
+
+BtInstallPageModel::~BtInstallPageModel() {
+ // Intentionally empty
+}
+
+QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
+ switch (role) {
+ case Qt::DisplayRole:
+ switch (i.column()) {
+ case 0:
+ return BtBookshelfTreeModel::data(i, role);
+ case 1:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module == 0) break;
+ CSwordBackend *b = CSwordBackend::instance();
+ CSwordModuleInfo *imodule = b->findModuleByName(module->name());
+ if (imodule == 0) {
+ return module->config(CSwordModuleInfo::ModuleVersion);
+ } else {
+ return imodule->config(CSwordModuleInfo::ModuleVersion)
+ + " => "
+ + module->config(CSwordModuleInfo::ModuleVersion);
+ }
+ }
+ case 2:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module != 0) return module->config(CSwordModuleInfo::Description);
+ }
+ default: break;
+ }
+ default:
+ if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+int BtInstallPageModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 3;
+}
+
+QVariant BtInstallPageModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ switch (section) {
+ case 0: return tr("Work");
+ case 1: return tr("Version");
+ case 2: return tr("Description");
+ default: break;
+ }
+ }
+
+ return QVariant();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
new file mode 100644
index 0000000..8a02409
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
@@ -0,0 +1,33 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLPAGEMODEL_H
+#define BTINSTALLPAGEMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+#include <QMap>
+
+
+class BtInstallPageModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+ public:
+ BtInstallPageModel(const Grouping &grouping, QObject *parent = 0);
+ ~BtInstallPageModel();
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+};
+
+#endif // BTINSTALLPAGEMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
new file mode 100644
index 0000000..6b9fb53
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
@@ -0,0 +1,140 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
+
+#include <QApplication>
+#include <QAction>
+#include <QDebug>
+#include <QTimer>
+#include <QToolButton>
+#include "backend/btinstallbackend.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
+#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
+#include "frontend/btbookshelfview.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+namespace {
+
+/** Filters out already installed modules which can't be updated right now. */
+bool filter(CSwordModuleInfo *mInfo) {
+ typedef CSwordModuleInfo CSMI;
+ typedef sword::SWVersion SV;
+
+ const CSMI *installedModule = CSwordBackend::instance()->findModuleByName(mInfo->name());
+ if (installedModule) {
+ // Already installed, check if it's an update:
+ const SV curVersion(installedModule->config(CSMI::ModuleVersion).toLatin1());
+ const SV newVersion(mInfo->config(CSMI::ModuleVersion).toLatin1());
+ if (curVersion >= newVersion) {
+ return false;
+ }
+ }
+ return true;
+}
+
+}
+
+BtInstallPageWorksWidget::BtInstallPageWorksWidget(
+ const sword::InstallSource &source,
+ const BtBookshelfTreeModel::Grouping &g,
+ BtInstallPage *parent, Qt::WindowFlags flags)
+ : BtBookshelfWidget(parent, flags)
+ , m_source(source)
+ , m_parent(parent)
+ , m_backend(0)
+ , m_myModel(0)
+{
+ namespace DU = util::directory;
+
+ qDebug() << "Creating new BtInstallPageWorksWidget for source" << source.caption;
+
+ setTreeModel(new BtInstallPageModel(g, this));
+
+ treeView()->setHeaderHidden(false);
+ showHideButton()->hide();
+ showHideAction()->setVisible(false);
+
+ m_sourceRefreshButton = new QToolButton(this);
+ m_sourceRefreshButton->setAutoRaise(true);
+ m_sourceRefreshButton ->setToolTip(tr("Refresh the list of works from this source"));
+ m_sourceRefreshButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
+ setRightCornerWidget(m_sourceRefreshButton);
+
+ connect(m_sourceRefreshButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceRefresh()));
+
+ // Delayed init, part 1 - disable parent:
+ parent->setEnabled(false);
+}
+
+BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
+ qDebug() << "Deleting BtInstallPageWorksWidget for source" << m_source.caption;
+
+ delete m_backend;
+}
+
+void BtInstallPageWorksWidget::deleteSource() {
+ qDebug() << "Deleting source" << m_source.caption;
+
+ setEnabled(false);
+ m_myModel->clear();
+ BtInstallBackend::deleteSource(QString(m_source.caption));
+}
+
+void BtInstallPageWorksWidget::updateTree() {
+ qDebug() << "Updating BtInstallPageWorksWidget tree for source" << m_source.caption;
+
+ m_myModel->clear();
+
+ // Is this necessary?
+ m_source = BtInstallBackend::source(QString(m_source.caption));
+ m_backend = BtInstallBackend::backend(m_source);
+
+ // Repopulate model:
+ Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
+ if (filter(module)) m_myModel->addModule(module);
+ }
+}
+
+void BtInstallPageWorksWidget::paintEvent(QPaintEvent *e) {
+ // Delayed init, part 2 - queue init when painted:
+ if (m_myModel == 0) {
+ QTimer::singleShot(0, this, SLOT(slotDelayedInit()));
+ }
+ BtBookshelfWidget::paintEvent(e);
+}
+
+void BtInstallPageWorksWidget::slotDelayedInit() {
+ // Delayed init, part 3 - initialize + reenable parent
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ m_backend = BtInstallBackend::backend(m_source);
+ Q_ASSERT(m_backend != 0);
+ m_myModel = new BtBookshelfModel(this);
+ Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
+ if (filter(module)) m_myModel->addModule(module);
+ }
+ setSourceModel(m_myModel);
+ m_parent->setEnabled(true);
+ qApp->restoreOverrideCursor();
+}
+
+void BtInstallPageWorksWidget::slotSourceRefresh() {
+ qDebug() << "Refreshing source" << m_source.caption;
+
+ if (BtInstallBackend::isRemote(m_source)) {
+ BtRefreshProgressDialog d(m_source, this);
+ if (!d.runAndDelete()) return;
+ }
+ updateTree();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
new file mode 100644
index 0000000..1a9bd8f
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
@@ -0,0 +1,59 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLPAGEWORKSWIDGET_H
+#define BTINSTALLPAGEWORKSWIDGET_H
+
+
+#include "frontend/btbookshelfwidget.h"
+
+// Sword includes
+#include <installmgr.h>
+
+
+class BtInstallPage;
+
+class BtInstallPageWorksWidget: public BtBookshelfWidget {
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtInstallPageWorksWidget(const sword::InstallSource &source,
+ const BtBookshelfTreeModel::Grouping &g,
+ BtInstallPage *parent, Qt::WindowFlags f = 0);
+
+ ~BtInstallPageWorksWidget();
+
+ inline const sword::InstallSource &installSource() const {
+ return m_source;
+ }
+ void deleteSource();
+
+ private: /* Methods: */
+
+ void updateTree();
+
+ /** Reimplemented from QWidget. */
+ virtual void paintEvent(QPaintEvent *e);
+
+ private slots:
+
+ void slotDelayedInit();
+ void slotSourceRefresh();
+
+ private: /* Fields: */
+
+ sword::InstallSource m_source;
+ BtInstallPage *m_parent;
+ QToolButton *m_sourceRefreshButton;
+ CSwordBackend *m_backend;
+ BtBookshelfModel *m_myModel;
+};
+
+#endif // BTINSTALLPAGEWORKSWIDGET_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index 9efb9f0..a272d89 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,13 +15,12 @@
#include <QDir>
#include <QFileDialog>
#include <QGridLayout>
-#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
#include <QString>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include "util/dialogutil.h"
#include "util/directory.h"
#include "util/cresmgr.h"
@@ -47,7 +46,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>"));
mainLayout->addWidget(mainLabel);
- QString swordConfPath = instbackend::swordConfigFilename();
+ QString swordConfPath = BtInstallBackend::swordConfigFilename();
/// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this);
QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this);
confPathLabel->setWordWrap(true);
@@ -55,7 +54,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_swordPathListBox = new QTreeWidget(this);
- m_swordPathListBox->header()->hide();
+ m_swordPathListBox->setHeaderHidden(true);
QString rwfolderitem(tr("Folders where new works can be installed"));
m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));;
@@ -65,7 +64,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));;
m_nonexistingItem->setFlags(Qt::ItemIsEnabled);
- QStringList targets = instbackend::targetList();
+ QStringList targets = BtInstallBackend::targetList();
foreach (QString pathname, targets) {
addPathToList(pathname);
@@ -76,19 +75,19 @@ BtInstallPathDialog::BtInstallPathDialog() {
QVBoxLayout* buttonLayout = new QVBoxLayout();
- m_addButton = new QPushButton(tr("Add..."), this);
+ m_addButton = new QPushButton(tr("&Add..."), this);
m_addButton->setToolTip(tr("Add new folder"));
m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
buttonLayout->addWidget(m_addButton);
- m_editButton = new QPushButton(tr("Edit..."), this);
+ m_editButton = new QPushButton(tr("&Edit..."), this);
m_editButton->setToolTip(tr("Edit the selected folder"));
m_editButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
buttonLayout->addWidget(m_editButton);
- m_removeButton = new QPushButton(tr("Remove"), this);
+ m_removeButton = new QPushButton(tr("&Remove"), this);
m_removeButton->setToolTip(tr("Remove the selected folder"));
m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
@@ -162,7 +161,7 @@ void BtInstallPathDialog::addPathToList(QString pathname) {
i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
}
}
- if (i && QDir(pathname) == instbackend::swordDir()) {
+ if (i && QDir(pathname) == BtInstallBackend::swordDir()) {
i->setFlags(Qt::NoItemFlags);
i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
}
@@ -231,7 +230,7 @@ void BtInstallPathDialog::writeSwordConfig() {
++it;
}
qDebug() << "save the target list" << targets;
- instbackend::setTargetList(targets); //creates new Sword config
+ BtInstallBackend::setTargetList(targets); //creates new Sword config
}
void BtInstallPathDialog::accept() {
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index e72da3c..9adf6bc 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index 365d5c8..465ec03 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,11 +22,13 @@
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
-#include "util/cpointers.h"
-BtInstallProgressDialog::BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination)
- : QDialog(parent) {
+BtInstallProgressDialog::BtInstallProgressDialog(
+ const QSet<const CSwordModuleInfo*> &modules,
+ const QString &destination, QWidget *parent, Qt::WindowFlags flags)
+ : QDialog(parent, flags)
+{
// 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"));
@@ -39,39 +41,34 @@ BtInstallProgressDialog::BtInstallProgressDialog(QWidget* parent, QTreeWidget* s
m_statusWidget->header()->setMovable(false);
//m_statusWidget->setColumnWidth(1, util::tool::mWidth(m_statusWidget, 2));
- foreach (QTreeWidgetItem* sourceItem, selectedModulesTreeWidget->invisibleRootItem()->takeChildren()) {
- // create items and threads for modules under this source
- foreach (QTreeWidgetItem* moduleItem, sourceItem->takeChildren()) {
- if (moduleItem->checkState(0) == Qt::Checked) {
- // create a thread for this module
- BtInstallThread* thread = new BtInstallThread(this, moduleItem->text(0), sourceItem->text(0), destination);
- m_waitingThreads.insert(sourceItem->text(0), thread);
- m_threadsByModule.insert(moduleItem->text(0), thread);
- // progress widget/item
- QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
- stopButton->setFixedSize(stopButton->sizeHint());
-
- // the item
- QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
- m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
- progressItem->setSizeHint(2, stopButton->sizeHint());
- progressItem->setText(0, moduleItem->text(0));
- progressItem->setFlags(Qt::ItemIsEnabled);
- m_statusWidget->setItemWidget(progressItem, 2, stopButton);
- progressItem->setText(1, tr("Waiting for turn..."));
-
- //connect the signals between the dialog, items and threads
- QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
- //is this needed or is statusUpdated enough?
- QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
-
- QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
-
- }
- }
+ 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());
+ progressItem->setText(0, module->name());
+ progressItem->setFlags(Qt::ItemIsEnabled);
+ m_statusWidget->setItemWidget(progressItem, 2, stopButton);
+ progressItem->setText(1, tr("Waiting for turn..."));
+
+ //connect the signals between the dialog, items and threads
+ QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
+ //is this needed or is statusUpdated enough?
+ QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
+
+ QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
}
m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
@@ -93,22 +90,22 @@ void BtInstallProgressDialog::startThreads() {
// remove all the updated modules from the backend module list at once
//foreach (QString mName, m_threadsByModule.keys()) {
//}
- //QList<CSwordModuleInfo*> CPointers::backend()->takeModulesFromList(m_threadsByModule.keys());
+ //QList<CSwordModuleInfo*> CSwordBackend::instance()()->takeModulesFromList(m_threadsByModule.keys());
qDebug() << "start threads...";
//loop through the multimap of the waiting threads, start at most 3 threads for each source
QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
// concurrency is disabled for now
-// while (threadIterator != m_waitingThreads.end()) {
-// QString sourceName = threadIterator.key();
-// qDebug() << sourceName;
-// 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;
-// }
+// while (threadIterator != m_waitingThreads.end()) {
+// QString sourceName = threadIterator.key();
+// qDebug() << sourceName;
+// 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
@@ -157,16 +154,16 @@ void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString
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);
-// qDebug() << threadsForSource;
-// if (!threadsForSource.isEmpty()) {
-// qDebug() << "Threads are waiting for turn";
-// BtInstallThread* thread = threadsForSource.at(0);
-// m_waitingThreads.remove(source, thread);
-// m_runningThreads.insert(source, thread);
-// thread->start();
-// }
+// //start a waiting thread if there are any
+// QList<BtInstallThread*> threadsForSource = m_waitingThreads.values(source);
+// qDebug() << threadsForSource;
+// if (!threadsForSource.isEmpty()) {
+// qDebug() << "Threads are waiting for turn";
+// 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();
@@ -238,7 +235,7 @@ void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
return;
}
// other parts of the UI/engine must be updated
- CPointers::backend()->reloadModules(CSwordBackend::AddedModules);
+ CSwordBackend::instance()->reloadModules(CSwordBackend::AddedModules);
}
bool BtInstallProgressDialog::threadsDone() {
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
index 1d8113a..8b990ad 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,13 +17,16 @@
class BtInstallThread;
+class CSwordModuleInfo;
class QTreeWidget;
class QTreeWidgetItem;
class BtInstallProgressDialog : public QDialog {
Q_OBJECT
public:
- BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination);
+ BtInstallProgressDialog(const QSet<const CSwordModuleInfo*> &modules,
+ const QString &destination, QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
~BtInstallProgressDialog();
@@ -43,7 +46,7 @@ class BtInstallProgressDialog : public QDialog {
virtual void closeEvent(QCloseEvent* event);
//signals:
-// void swordSetupChanged();
+// void swordSetupChanged();
private:
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
index 53ae071..2d04a51 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,14 +16,14 @@
#include <QThread>
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "util/cpointers.h"
+#include "backend/btinstallbackend.h"
// Sword includes:
#include <filemgr.h>
-BtInstallThread::BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName)
+BtInstallThread::BtInstallThread(const QString &moduleName, const QString &sourceName,
+ const QString &destinationName, QObject *parent)
: QThread(parent),
done(false),
m_module(moduleName),
@@ -45,8 +45,8 @@ void BtInstallThread::run() {
emit preparingInstall(m_module, m_source);
//This is 0 before set here - remember when using the value when cancelling
// the installation before this has been run
- m_installSource.reset(new sword::InstallSource(instbackend::source(m_source)));
- m_backendForSource.reset(instbackend::backend(*m_installSource));
+ 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
@@ -74,9 +74,9 @@ void BtInstallThread::run() {
// manager for the destination path
sword::SWMgr lMgr( m_destination.toLatin1() );
- if (instbackend::isRemote(*m_installSource)) {
+ if (BtInstallBackend::isRemote(*m_installSource)) {
qDebug() << "calling install";
- int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.get());
+ int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.data());
if (status != 0) {
qWarning() << "Error with install: " << status << "module:" << m_module;
}
@@ -123,7 +123,7 @@ void BtInstallThread::slotStopInstall() {
qDebug() << "BtInstallThread::slotStopInstall 3";
// cleanup: remove the module, remove the temp files
// if installation has already started
- if (m_installSource.get() != 0) {
+ if (m_installSource.data() != 0) {
qDebug() << "BtInstallThread::slotStopInstall 4";
// remove the installed module, just to be sure because mgr may
// have been terminated when copying files
@@ -148,9 +148,9 @@ void BtInstallThread::slotDownloadStarted() {
void BtInstallThread::removeModule() {
qDebug() << "BtInstallThread::removeModule start";
CSwordModuleInfo* m;
- m = CPointers::backend()->findModuleByName(m_module);
+ m = CSwordBackend::instance()->findModuleByName(m_module);
if (!m) {
- m = instbackend::backend(instbackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
+ m = BtInstallBackend::backend(BtInstallBackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
}
if (m) { //module found?
qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
@@ -164,7 +164,7 @@ void BtInstallThread::removeModule() {
prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
}
else {
- prefixPath = QString::fromLatin1(CPointers::backend()->prefixPath);
+ prefixPath = QString::fromLatin1(CSwordBackend::instance()->prefixPath);
}
sword::SWMgr mgr(prefixPath.toLatin1());
@@ -182,8 +182,8 @@ void BtInstallThread::removeTempFiles() {
// (take the remote conf file for this module, take DataPath,
// take the absolute path of the InstallMgr)
- //sword::InstallSource is = instbackend::source(m_source);
- if (instbackend::isRemote(*m_installSource)) {
+ //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);
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
index a50910f..8bb660d 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,11 +12,12 @@
#include <QThread>
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include "frontend/bookshelfmanager/btinstallmgr.h"
class BtInstallProgressDialog;
+class CSwordBackend;
/**
* Thread for installing a module.
@@ -54,7 +55,8 @@ temporary files manually.
class BtInstallThread : public QThread {
Q_OBJECT
public:
- BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName);
+ BtInstallThread(const QString &moduleName, const QString &sourceName,
+ const QString &destinationName, QObject *parent = 0);
~BtInstallThread();
@@ -77,10 +79,10 @@ class BtInstallThread : public QThread {
bool m_cancelled;
BtInstallMgr* m_iMgr;
//BtInstallMgr m_iMgr;
- boost::scoped_ptr<sword::InstallSource> m_installSource;
+ 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.
- boost::scoped_ptr<CSwordBackend> m_backendForSource;
+ QSharedPointer<CSwordBackend> m_backendForSource;
signals:
/** Emitted when the install progress status is updated. */
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
new file mode 100644
index 0000000..3666888
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
@@ -0,0 +1,62 @@
+#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
+
+#include <QApplication>
+#include <QDebug>
+#include "backend/btinstallbackend.h"
+#include "util/dialogutil.h"
+
+
+BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source,
+ QWidget *parent,
+ Qt::WindowFlags flags)
+ : QProgressDialog(parent, flags)
+ , m_source(source)
+{
+ qDebug() << "Creating BtRefreshProgressDialog for source" << source.caption;
+
+ Q_ASSERT(BtInstallBackend::isRemote(source));
+ setWindowTitle(tr("Refreshing source %1").arg(QString(source.caption)));
+ setCancelButtonText(tr("&Cancel"));
+ setLabelText(tr("Connecting..."));
+ Q_ASSERT(minimum() == 0);
+ setMaximum(100);
+ setValue(0);
+ setWindowModality(Qt::ApplicationModal);
+ setMinimumDuration(1000);
+
+ connect(this, SIGNAL(canceled()),
+ this, SLOT(slotCanceled()));
+ connect(&m_installMgr, SIGNAL(percentCompleted(int,int)),
+ this, SLOT(slotPercentCompleted(int,int)));
+}
+
+void BtRefreshProgressDialog::slotPercentCompleted(int, int current) {
+ qDebug() << "BtRefreshProgressDialog progress:" << current;
+
+ setValue(current);
+ qApp->processEvents();
+}
+
+void BtRefreshProgressDialog::slotCanceled() {
+ qDebug() << "BtRefreshProgressDialog cancel clicked.";
+
+ m_installMgr.terminate();
+}
+
+bool BtRefreshProgressDialog::runAndDelete() {
+ qDebug() << "BtRefreshProgressDialog runAndDelete()";
+
+ show();
+ qApp->processEvents();
+ bool r = (m_installMgr.refreshRemoteSource(&m_source) == 0);
+ if (r) {
+ setValue(100);
+ qApp->processEvents();
+ } else {
+ util::showWarning(this, tr("Warning"),
+ tr("Failed to refresh source %1")
+ .arg(QString(m_source.caption)));
+ }
+ deleteLater();
+ return r;
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
new file mode 100644
index 0000000..dfabcf6
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
@@ -0,0 +1,38 @@
+/*********
+*
+* 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 BTREFRESHPROGRESSDIALOG_H
+#define BTREFRESHPROGRESSDIALOG_H
+
+#include <QProgressDialog>
+
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+
+
+class BtRefreshProgressDialog: public QProgressDialog {
+ Q_OBJECT
+
+ public: /* Methods: */
+ BtRefreshProgressDialog(sword::InstallSource &source,
+ QWidget *parent = 0, Qt::WindowFlags f = 0);
+
+ bool runAndDelete();
+
+ private slots:
+
+ void slotPercentCompleted(int, int);
+ void slotCanceled();
+
+ private: /* Fields: */
+
+ sword::InstallSource m_source;
+ BtInstallMgr m_installMgr;
+};
+
+#endif // BTREFRESHPROGRESSDIALOG_H
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
deleted file mode 100644
index ca85822..0000000
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
-
-#include <QString>
-#include <QWidget>
-#include <QMap>
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QSpacerItem>
-#include <QLabel>
-#include <QPushButton>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QHeaderView>
-#include <QDebug>
-#include <QTime>
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "frontend/btaboutmoduledialog.h"
-#include "util/directory.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/tool.h"
-
-// Sword includes:
-#include <installmgr.h>
-
-
-// ****************************************************************
-// ******** Installation source and module list widget ************
-// ****************************************************************
-
-BtSourceArea::BtSourceArea(const QString& sourceName)
- : QWidget(),
- m_sourceName(sourceName),
- m_treeAlreadyInitialized(false),
- m_remoteBackend(0) { //important!
- setObjectName(sourceName);
- m_checkedModules = QMap<QString, bool>();
- qDebug() << "BtSourceArea::BtSourceArea, " << m_sourceName;
- initView();
-}
-
-BtSourceArea::~BtSourceArea() {
- qDebug() << "BtSourceArea::~BtSourceArea" << m_sourceName;
- delete m_remoteBackend;
-}
-
-void BtSourceArea::initView() {
- namespace DU = util::directory;
-
- qDebug() << "BtSourceArea::initView";
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
-
- // source related button row
- QHBoxLayout *sourceLayout = new QHBoxLayout();
- m_refreshButton = new QPushButton(tr("Refresh..."));
- m_refreshButton->setToolTip(tr("Refresh the list of works from this source"));
- m_refreshButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
- //m_refreshButton->setEnabled(false);
- QSpacerItem *sourceSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- //m_editButton = new QPushButton(tr("Edit..."));
- /// \todo after writing the edit widget:
- //m_editButton->setEnabled(false);
- m_deleteButton = new QPushButton(tr("Delete..."));
- m_deleteButton->setToolTip(tr("Delete this source"));
- m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
- //m_deleteButton->setEnabled(false);
- m_addButton = new QPushButton(tr("Add..."));
- m_addButton->setToolTip(tr("Add new source"));
- m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
-
- sourceLayout->addWidget(m_refreshButton);
- sourceLayout->addItem(sourceSpacer);
- //sourceLayout->addWidget(m_editButton);
- sourceLayout->addWidget(m_deleteButton);
- sourceLayout->addWidget(m_addButton);
-
- mainLayout->addLayout(sourceLayout);
- // There are no views for the stack yet, see initSources
- m_view = new QTreeWidget(this);
- m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Description"));
- m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20));
- mainLayout->addWidget(m_view);
-
- connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- connect(this, SIGNAL(signalCreateTree()), SLOT(slotCreateTree()), Qt::QueuedConnection);
-}
-
-void BtSourceArea::prepareRemove() {
- // don't create tree anymore, this will be removed
- disconnect(this, SIGNAL(signalCreateTree()), this, SLOT(slotCreateTree()));
-}
-
-QSize BtSourceArea::sizeHint() const {
- return QSize(100, m_refreshButton->height() + (m_view->header()->height() * 5));
-}
-
-void BtSourceArea::initTreeFirstTime() {
- if (!m_treeAlreadyInitialized) {
- createModuleTree();
- m_treeAlreadyInitialized = true;
- }
-}
-
-void BtSourceArea::createModuleTree() {
- qDebug() << "BtSourceArea::createModuleTree start";
- // Start creating tree with a queued connection.
- // This makes showing the dialog possible even before the tree is initialized.
- emit signalCreateTree();
-}
-void BtSourceArea::slotCreateTree() {
- qDebug() << "BtSourceArea::slotCreateTree" << QTime::currentTime ();
- //let the dialog become visible
- QCoreApplication::processEvents();
- // Creating the view and populating list may take time
- QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
-
- // disconnect the signal so that we don't have to run functions for every module
- // (note: what to do if we want to restore the item selection when rebuilding?
- disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- m_view->clear();
-
- /// \todo if the tree already exists for this source, maybe the selections should be preserved
- m_checkedModules.clear();
-
- sword::InstallSource is = instbackend::source(m_sourceName);
- delete m_remoteBackend; // the old one can be deleted
- m_remoteBackend = instbackend::backend(is);
- Q_ASSERT(m_remoteBackend);
- m_moduleList = m_remoteBackend->moduleList();
-
- // give the list to BTModuleTreeItem, create filter to remove
- // those modules which are installed already
- InstalledFilter alreadyInstalledFilter(m_sourceName);
- QList<BTModuleTreeItem::Filter*> filterList;
- filterList.append(&alreadyInstalledFilter);
- BTModuleTreeItem rootItem(filterList, BTModuleTreeItem::CatLangMod, &m_moduleList);
-
- addToTree(&rootItem, m_view->invisibleRootItem());
- QCoreApplication::processEvents();
- // receive signal when user checks modules
- connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- QApplication::restoreOverrideCursor();
- qDebug() << "BtSourceArea::createModuleTree end" << QTime::currentTime ();
-}
-
-void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
- //qDebug()<<"BtSourceArea::addToTree "<<item->text();
- //qDebug() << "BTMTItem type: " << item->type();
-
- foreach (BTModuleTreeItem* i, item->children()) {
- addToTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- CSwordModuleInfo* mInfo = item->moduleInfo();
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- //qDebug() << "item"<<item->text()<< "was cat or lang";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- //qDebug() << "item"<<item->text()<< "was a module";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- widgetItem->setCheckState(0, Qt::Unchecked);
-
- CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name());
- QString installedV;
-
- if (!installedModule) {
- /**
- \todo maybe? save the module list of a source before refreshing,
- compare after refreshing, mark the newly added modules if
- not newly added:
- state: installable (no indicator)
- else: status: newly added, color yellow
- */
- } else { // the module is already installed
- QBrush bg(QColor(255, 153, 153)); /// \bug Possible color conflict
- widgetItem->setBackground(0, bg);
- widgetItem->setBackground(1, bg);
- installedV = QString(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- // set the color for the parent items
- QTreeWidgetItem* parent1 = widgetItem->parent();
- if (parent1) {
- parent1->setBackground(0, bg);
- parent1->setBackground(1, bg);
- QTreeWidgetItem* parent2 = parent1->parent();
- if (parent2) {
- parent2->setBackground(0, bg);
- parent2->setBackground(1, bg);
- }
- }
- }
-
-
- QString descr(mInfo->config(CSwordModuleInfo::Description));
- QString toolTipText = util::tool::remoteModuleToolTip(mInfo, installedV);
-
- widgetItem->setText(1, descr);
- widgetItem->setToolTip(0, toolTipText);
- widgetItem->setToolTip(1, toolTipText);
- }
- }
-}
-
-QTreeWidget* BtSourceArea::treeWidget() {
- return m_view;
-}
-
-// return the selected modules
-QMap<QString, bool>* BtSourceArea::selectedModules() {
- return &m_checkedModules;
-}
-
-// when a module is checked/unchecked
-void BtSourceArea::slotSelectionChanged(QTreeWidgetItem* item, int column) {
- //qDebug() << "BtSourceArea::slotSelectionChanged";
- // modify the internal list of selected (actually checked) modules
- // if() leaves groups away
- if (!item->childCount() && column == 0) {
- foreach (CSwordModuleInfo* module, m_moduleList) {
- if (module->name() == item->text(0)) {
- if (item->checkState(0) == Qt::Checked) {
- qDebug() << module->name() << "was checked";
- m_checkedModules.insert(module->name(), true);
- }
- else {
- qDebug() << module->name() << "was unchecked";
- m_checkedModules.remove(module->name());
- }
- emit signalSelectionChanged(m_sourceName, m_checkedModules.count());
- break;
- }
- }
- }
-}
-
-void BtSourceArea::slotItemDoubleClicked(QTreeWidgetItem* item, int /*column*/) {
- CSwordModuleInfo* mInfo = m_remoteBackend->findModuleByName(item->text(0));
- if (mInfo) {
- BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, mInfo);
- dialog->show();
- dialog->raise();
- }
-}
-
-BtSourceArea::InstalledFilter::InstalledFilter(QString sourceName)
- : BTModuleTreeItem::Filter(),
- m_source(instbackend::source(sourceName)),
- m_swordBackend(instbackend::backend(m_source)) {
- // these are set once to optimize away repeated calls
- // m_source, m_swordBackend
-
-}
-//filter out already installed, not updateable modules
-bool BtSourceArea::InstalledFilter::filter(CSwordModuleInfo* mInfo) {
- //qDebug() << "BtSourceArea::InstalledFilter::filter, module " << mInfo->name();
- CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name());
- if (installedModule) {
- //qDebug() << "already installed, check if it's an update...";
- const sword::SWVersion installedVersion(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- const sword::SWVersion newVersion(mInfo->config(CSwordModuleInfo::ModuleVersion).toLatin1());
- if (installedVersion >= newVersion) {
- return false;
- }
- }
- return true;
-}
-
-void BtSourceArea::slotSwordSetupChanged() {
- createModuleTree();
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.h b/src/frontend/bookshelfmanager/installpage/btsourcearea.h
deleted file mode 100644
index ece20ed..0000000
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTSOURCEAREA_H
-#define BTSOURCEAREA_H
-
-#include <QWidget>
-
-#include <boost/scoped_ptr.hpp>
-#include <QApplication>
-#include <QMap>
-#include "backend/btmoduletreeitem.h"
-
-// Sword includes:
-#include <installmgr.h>
-
-
-class QTreeWidget;
-class QTreeWidgetItem;
-class QLabel;
-class QPushButton;
-
-/**
-* Area for one install source.
-*
-* - Tree widget for modules
-* - Buttons for handling the source(s): refresh, edit, remove, add
-*
-* Each source has
-* QTreeWidget, populated with the module tree if the source
-* module list is in a local cache. Refreshing the source refreshes
-* the cache and rebuilds the module tree. Sources are not refreshed
-* automatically, only by the user action, one source at a time.
-*/
-class BtSourceArea : public QWidget {
- Q_OBJECT
-
- friend class BtSourceWidget;
- public:
-
- struct InstalledFilter : BTModuleTreeItem::Filter {
- InstalledFilter(QString sourceName);
- bool filter(CSwordModuleInfo*);
- sword::InstallSource m_source;
- boost::scoped_ptr<CSwordBackend> m_swordBackend;
- };
-
- BtSourceArea(const QString& sourceName);
- ~BtSourceArea();
-
- void initView();
- void prepareRemove();
- /** Reimplemented from QWidget. */
- virtual QSize sizeHint() const;
- void initTreeFirstTime();
- QTreeWidget* treeWidget();
-
- QMap<QString, bool>* selectedModules();
-
- public slots:
- void slotSwordSetupChanged();
- /** Create a module tree for a tree widget */
- void createModuleTree();
-
- signals:
- void signalSelectionChanged(QString sourceName, int selectedCount);
- void signalCreateTree();
-
- private slots:
- void slotCreateTree();
- void slotSelectionChanged(QTreeWidgetItem* item, int column);
- void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
- private:
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
-
- QString m_sourceName;
- bool m_treeAlreadyInitialized;
- QMap<QString, bool> m_checkedModules;
- CSwordBackend* m_remoteBackend; // needed for the module list
- QList<CSwordModuleInfo*> m_moduleList;
-
- QTreeWidget* m_view;
- QLabel* m_refreshTimeLabel;
- QPushButton* m_refreshButton;
- QPushButton* m_editButton;
- QPushButton* m_deleteButton;
- QPushButton* m_addButton;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
deleted file mode 100644
index 81e84fb..0000000
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/installpage/btsourcewidget.h"
-
-#include <QApplication>
-#include <QFileInfo>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QProgressDialog>
-#include <QPushButton>
-#include <QString>
-#include <QTabBar>
-#include <QTabWidget>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QWidget>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
-#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "util/dialogutil.h"
-
-
-/**
-* Tab Widget that holds source widgets
-*/
-BtSourceWidget::BtSourceWidget(BtInstallPage* parent)
- : QTabWidget(parent),
- m_page(parent) {
- qDebug() << "BtSourceWidget::BtSourceWidget start";
- initSources();
- // send queued event because "Delete" is initiated from tab which should be deleted
- connect(this, SIGNAL(sigInitSources()), SLOT(initSources()), Qt::QueuedConnection);
- /// \todo choose the page from config
-
-}
-
-BtSourceArea* BtSourceWidget::area() {
- return dynamic_cast<BtSourceArea*>(currentWidget());
-}
-
-QString BtSourceWidget::currentSourceName() {
- qDebug() << "BtSourceWidget::currentSourceName: " << m_sourceNameList.at(currentIndex());
- return m_sourceNameList.at(currentIndex());
-}
-
-void BtSourceWidget::initSourceConnections() {
- qDebug() << "void BtSourceWidget::initSourceConnections() start";
- if (area()) {
- connect(area()->m_refreshButton, SIGNAL(clicked()), SLOT(slotRefresh()));
- //connect(area()->m_editButton, SIGNAL(clicked()), SLOT(slotEdit()));
- connect(area()->m_deleteButton, SIGNAL(clicked()), SLOT(slotDelete()), Qt::QueuedConnection);
- connect(area()->m_addButton, SIGNAL(clicked()), SLOT(slotAdd()));
- connect(area(), SIGNAL(signalSelectionChanged(QString, int)), SLOT(slotModuleSelectionChanged(QString, int)) );
- }
- qDebug() << "void BtSourceWidget::initSourceConnections() end";
-}
-
-void BtSourceWidget::slotEdit() {
- qDebug() << "BtSourceWidget::slotEdit";
- /// \todo open the source editor dialog
-
- // if the source was changed, init the sources
-
-}
-
-void BtSourceWidget::slotDelete() {
- qDebug() << "void BtSourceWidget::slotDelete() start";
- // ask for confirmation
- int ret = util::showWarning(this, tr("Delete Source?"),
- tr("Do you really want to delete this source?"),
- QMessageBox::Yes | QMessageBox::No);
-
- if (ret == QMessageBox::Yes) {
- instbackend::deleteSource(currentSourceName());
- initSources();
- }
-}
-
-void BtSourceWidget::slotAdd() {
-
- boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
- sword::InstallSource newSource(""); //empty, invalid Source
-
- if (dlg->exec() == QDialog::Accepted) {
- if (!dlg->wasRemoteListAdded()) {
- newSource = dlg->getSource();
- if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
- instbackend::addSource(newSource);
- }
- }
- initSources();
- }
-}
-
-
-void BtSourceWidget::slotRefresh() {
- qDebug() << "void BtSourceWidget::slotRefresh() start";
- // (re)build the module cache for the source
-
- QString sourceName = currentSourceName();
-
- // quick enough, make it modal so that we don't need to take care of anything else
- m_progressDialog = new QProgressDialog("", tr("Cancel"), 0 , 100, this);
- m_progressDialog->setWindowTitle(tr("Refreshing Source"));
- m_progressDialog->setMinimumDuration(0);
-
- /// \todo get rid of the backend code, BtInstallMgr and progressdialog could handle this
- //write method BtInstallMgr::slotRefreshCanceled()
- connect(m_progressDialog, SIGNAL(canceled()), SLOT(slotRefreshCanceled()));
-
- // BACKEND CODE **********************************************************
- // would this be possible: instbackend::refreshSource( arguments );
- qDebug() << "void BtSourceWidget::slotRefresh 1";
- BtInstallMgr iMgr;
- m_currentInstallMgr = &iMgr; //for the progress dialog
- sword::InstallSource is = instbackend::source(sourceName);
- bool success = false;
- qDebug() << "void BtSourceWidget::slotRefresh 2";
- // connect this directly to the dialog setValue(int) if possible
- connect(&iMgr, SIGNAL(percentCompleted(const int, const int)), SLOT(slotRefreshCompleted(const int, const int)));
-
- if (instbackend::isRemote(is)) {
- m_progressDialog->show();
- qApp->processEvents();
- this->slotRefreshCompleted(0, 0);
- m_progressDialog->setLabelText(tr("Connecting..."));
- m_progressDialog->setValue(0);
- qApp->processEvents();
- qDebug() << "void BtSourceWidget::slotRefresh 3";
- bool successful = iMgr.refreshRemoteSource( &is );
- if (!successful ) { //make sure the sources were updated sucessfully
- success = true;
- m_progressDialog->setValue(100); //make sure the dialog closes
- }
- else {
- qWarning("InstallMgr: refreshRemoteSources returned an error.");
- success = false;
- }
- }
- else {
- // Local source, update the list
- success = true;
- }
-
- delete m_progressDialog;
- m_progressDialog = 0;
-
- // rebuild the view tree and refresh the view
- if (success) {
- qDebug() << "void BtSourceWidget::slotRefresh 4";
- area()->createModuleTree();
- }
-}
-
-/// \todo try to move this to BtInstallMgr
-void BtSourceWidget::slotRefreshCanceled() {
- qDebug() << "BtSourceWidget::slotRefreshCanceled";
- Q_ASSERT(m_currentInstallMgr);
- if (m_currentInstallMgr) {
- m_currentInstallMgr->terminate();
- }
- qApp->processEvents();
-}
-
-/// \todo try to move this to progress dialog
-void BtSourceWidget::slotRefreshCompleted(const int, const int current) {
- qDebug() << "BtSourceWidget::slotRefreshCompleted";
- if (m_progressDialog) {
- if (m_progressDialog->labelText() != tr("Refreshing...")) {
- m_progressDialog->setLabelText(tr("Refreshing..."));
- }
- m_progressDialog->setValue(current);
- }
- qApp->processEvents();
-}
-
-// init the tabbar, setup the module tree for the current source
-void BtSourceWidget::initSources() {
- qDebug() << "void BtSourceWidget::initSources() start";
-
- //first clear all sources
- //int i = count();
- for (int i = count() - 1; i >= 0; i--) {
- BtSourceArea* a = dynamic_cast<BtSourceArea*>(widget(i));
- a->prepareRemove();
- }
- for (int i = count() - 1; i >= 0; i--) {
- qDebug() << "remove tab" << tabText(i);
- QWidget* w = widget(i);
- removeTab(i);
- delete w;
- qDebug() << "deleted";
- }
- m_sourceNameList.clear();
-
- // ***** Use the backend to get the list of sources *****
- instbackend::initPassiveFtpMode();
- QStringList sourceList = instbackend::sourceList();
- qDebug() << "got the source list from backend:" << sourceList;
- // Add a default entry, the Crosswire main repository
- if (!sourceList.count()) {
- /// \todo Open a dialog which asks whether to get list from server and add sources
- sword::InstallSource is("FTP"); //default return value
- is.caption = "CrossWire Bible Society";
- is.source = "ftp.crosswire.org";
- is.directory = "/pub/sword/raw";
- // passive ftp is not needed here, it's the default
-
- instbackend::addSource(is);
-
- sourceList = instbackend::sourceList();
- //Q_ASSERT( sourceList.count() > 0 );
- }
- qDebug() << "void BtSourceWidget::initSources 1";
- // Add the sources to the widget
- foreach (QString sourceName, sourceList) {
- addSource(sourceName);
- }
- // connect this after the tabs have been created,
- // otherwise the signal is caught too early.
- QObject::connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotTabSelected(int)));
- qDebug() << "void BtSourceWidget::initSources end";
- /// \todo select the current source from the config
- // It's important to choose something because the tree is not initialized until now
- setCurrentIndex(0);
- slotTabSelected(0); // setting the index wasn't enough if there were only 1 tab
-
- if (sourceList.count() == 0) {
- QHBoxLayout* l = new QHBoxLayout(this);
- QLabel* message = new QLabel(QString("<i>") + tr("No sources were found in the SWORD configuration and BibleTime couldn't create a default source. Check your SWORD configuration and that the configuration path is writable. Then restart the Bookshelf Manager.") + QString("</i>"), this);
- message->setWordWrap(true);
- l->addWidget(message);
- }
-}
-
-void BtSourceWidget::addSource(const QString& sourceName) {
- qDebug() << "void BtSourceWidget::addSource(const QString& sourceName) start, with name" << sourceName;
- // The source has already been added to the backend.
-
- QString type;
- QString server;
- QString path;
- sword::InstallSource is = instbackend::source(sourceName);
- if (instbackend::isRemote(is)) {
- type = tr("Remote:");
- server = is.source.c_str();
- path = is.directory.c_str();
- }
- else { // local source
- type = tr("Local:");
- QFileInfo fi( is.directory.c_str() );
- path = is.directory.c_str();
- if (!(fi.isDir() )) {
- path = path + QString(" ") + tr("Not a directory!"); /// \todo change this
- }
- if (!fi.isReadable()) {
- path = path + QString(" ") + tr("Not readable!"); /// \todo change this
- }
- }
-
- // Here the tab UI is created and added to the tab widget
- BtSourceArea* area = new BtSourceArea(sourceName);
- int tabNumber = this->addTab(area, sourceName);
-
- /// \todo add "remote/local", server, path etc.
- QString toolTip(QString("<p style='white-space:pre'>") + sourceName + QString("<br/><b>") + type + QString("</b> ") + server + path + QString("</p>"));
- tabBar()->setTabToolTip(tabNumber, toolTip);
-
- //select the new tab
- setCurrentIndex(tabNumber);
- m_sourceNameList.append(sourceName);
- initSourceConnections();
- qDebug() << "BtSourceWidget::addSource end";
-}
-
-//
-void BtSourceWidget::slotModuleSelectionChanged(QString sourceName, int selectedCount) {
- /// \todo editing sources should update the map also
- qDebug() << "BtSourceWidget::slotModuleSelectionChanged start";
-
- int overallCount = 0;
- m_selectedModulesCountMap.insert(sourceName, selectedCount);
- foreach (int count, m_selectedModulesCountMap) {
- qDebug() << "add" << count << "to overall count of selected modules";
- overallCount += count;
- }
-
- if (overallCount > 0) {
- m_page->setInstallEnabled(true);
- }
- else {
- m_page->setInstallEnabled(false);
- }
-}
-
-void BtSourceWidget::slotTabSelected(int /*index*/) {
- BtSourceArea* area = dynamic_cast<BtSourceArea*>(currentWidget());
- if (area) area->initTreeFirstTime();
-}
-
-void BtSourceWidget::slotInstall() {
- qDebug() << "void BtInstallPage::slotInstall start";
-
- // check that the destination path is writable, do nothing if not and user doesn't want to continue
- QDir dir = QDir(dynamic_cast<BtInstallPage*>(parent())->selectedInstallPath());
- bool canWrite = true;
- if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (!fi.exists() || !fi.isWritable()) {
- canWrite = false;
- }
- }
- else {
- canWrite = false;
- }
- if (!canWrite) {
- const int result = util::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
- if (result != QMessageBox::Ignore) {
- return;
- }
- }
-
- // create the confirmation dialog
- // (module tree dialog, modules taken from all sources)
- QString dlgTitle(tr("Install/Update works?"));
- QString dlgLabel(tr("Do you really want to install these works?") +
- QString("<br/><br/><small>") +
- tr("Only one version of a work can be installed at the same time. Select only one if there are items marked with red.") +
- QString("</small>"));
-
- // with empty list we avoid creating the module tree inside the dialog code
- QList<CSwordModuleInfo*> emptyList;
- BtInstallModuleChooserDialog* dlg = new BtInstallModuleChooserDialog(this, dlgTitle, dlgLabel, &emptyList);
- //dlg->setGrouping(BTModuleTreeItem::Mod);
- QTreeWidget* treeWidget = dlg->treeWidget();
- QTreeWidgetItem* rootItem = treeWidget->invisibleRootItem();
-
- QStringList nameList;
-
- // loop through each tab
- for (int tab = 0; tab < count(); ++tab) {
- BtSourceArea* sArea = dynamic_cast<BtSourceArea*>(widget(tab));
- if (sArea && sArea->selectedModules()->count() > 0) {
- // there are selected modules in the source, create items for these
- /// \todo Use new bookshelf model instead
- /// \bug Valgrind reports memory leak:
- QTreeWidgetItem* sourceItem = new QTreeWidgetItem(rootItem);
- sourceItem->setText(0, m_sourceNameList.at(tab));
- sourceItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsTristate | Qt::ItemIsEnabled);
- foreach (QString mName, sArea->selectedModules()->keys()) {
- dlg->initModuleItem(mName, sourceItem);
- }
- sourceItem->setExpanded(true);
- }
- }
-
- //user accepts the dialog
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), SLOT(slotInstallAccepted(QList<CSwordModuleInfo*>, QTreeWidget*)) );
- // user checks/unchecks an item, needed for preventing double items
- QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), dlg, SLOT(slotItemChecked(QTreeWidgetItem*, int)));
- dlg->exec();
- // The OK signal sent by the dialog is catched with slotInstallAccepted.
-}
-
-void BtSourceWidget::slotStopInstall(QTreeWidget* /*treeWidget*/) {
- qDebug() << "BtSourceWidget::slotStopInstall";
- // not needed?
-}
-
-void BtSourceWidget::slotInstallAccepted(QList<CSwordModuleInfo*> /*modules*/, QTreeWidget* treeWidget) {
- qDebug() << "BtSourceWidget::slotInstallAccepted";
-
- /// \todo first remove all modules which will be updated from the module list
- // but what modules? all with the same real name? (there may be _n modules...)
-
- BtModuleManagerDialog* parentDialog = dynamic_cast<BtModuleManagerDialog*>(dynamic_cast<BtInstallPage*>(parent())->parentDialog());
-
- BtInstallProgressDialog* dlg = new BtInstallProgressDialog(parentDialog, treeWidget, dynamic_cast<BtInstallPage*>(parent())->selectedInstallPath());
-
- if (!parentDialog) qDebug() << "error, wrong parent!";
-
- m_page->setInstallEnabled(false);
- // the progress dialog is now modal, it can be made modeless later.
- dlg->exec();
-
- qDebug() << "BtSourceWidget::slotInstallAccepted end";
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.h b/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
deleted file mode 100644
index fbe8426..0000000
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-#ifndef BTSOURCEWIDGET_H
-#define BTSOURCEWIDGET_H
-
-#include <QTabWidget>
-
-#include <QMap>
-#include <QString>
-
-
-class BtInstallMgr;
-class BtInstallPage;
-class BtSourceArea;
-class CSwordModuleInfo;
-class QProgressDialog;
-class QTreeWidget;
-
-/**
-* Tabwidget which holds the source widgets.
-* This widget implements the slots for the source action buttons and
-* applies the actions to the proper source(s).
-*/
-class BtSourceWidget : public QTabWidget {
- Q_OBJECT
- public:
- friend class BtInstallPage;
-
- BtSourceWidget(BtInstallPage* parent);
- virtual ~BtSourceWidget() {}
-
- BtSourceArea* area();
- QString currentSourceName();
-
- public slots:
- /** Install button has been clicked. */
- void slotInstall();
- /** "Stop All" button clicked */
- void slotStopInstall(QTreeWidget* treeWidget);
-
- private:
- void initSourceConnections();
-
- /** Add one source to tabs/stack. */
- void addSource(const QString& sourceName);
-
- private slots:
- /** Add tabs/views for each source. */
- void initSources();
-
- void slotRefresh();
-
- void slotRefreshCanceled();
-
- void slotRefreshCompleted(int, int);
-
- /** Edit button clicked. */
- void slotEdit();
- /** Delete button clicked. */
- void slotDelete();
- /** Add button clicked. */
- void slotAdd();
- /** Modules have been checked/unchecked in the view. */
- void slotModuleSelectionChanged(QString sourceName, int selectedCount);
-
- void slotTabSelected(int index);
- void slotInstallAccepted(QList<CSwordModuleInfo*> mi, QTreeWidget* treeWidget);
-
- signals:
- void sigInitSources();
-
- private:
- QStringList m_sourceNameList;
- BtInstallPage* m_page;
- QProgressDialog* m_progressDialog; // for refreshing
- BtInstallMgr* m_currentInstallMgr; // for refreshing
- QMap<QString, int> m_selectedModulesCountMap;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/frontend/bookshelfmanager/instbackend.cpp
deleted file mode 100644
index 463a6e5..0000000
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/bookshelfmanager/instbackend.h"
-
-#include <functional>
-#include <map>
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-#include <utility>
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "util/cpointers.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
-
-// Sword includes:
-#include <filemgr.h>
-#include <swconfig.h>
-#include <swbuf.h>
-
-
-using namespace sword;
-
-namespace instbackend {
-
-/** Adds the source described by Source to the backend. */
-bool addSource(sword::InstallSource& source) {
- qDebug() << "backend::addSource";
- SWConfig config(configFilename().toLatin1());
- if (!strcmp(source.type, "FTP")) {
- //make sure the path doesn't have a trailing slash, sword doesn't like it
- if (source.directory[ source.directory.length()-1 ] == '/') {
- source.directory--; //make one char shorter
- }
-
- config["Sources"].insert( std::make_pair(SWBuf("FTPSource"), source.getConfEnt()) );
- }
- else if (!strcmp(source.type, "DIR")) {
- config["Sources"].insert( std::make_pair(SWBuf("DIRSource"), source.getConfEnt()) );
- }
- config.Save();
- return true;
-}
-
-/** Returns the Source struct. */
-sword::InstallSource source(QString name) {
- qDebug() << "backend::source";
- BtInstallMgr mgr;
- InstallSourceMap::iterator source = mgr.sources.find(name.toLatin1().data());
- if (source != mgr.sources.end()) {
- return *(source->second);
- }
- else { //not found in Sword, may be a local DIR source
- SWConfig config(configFilename().toLatin1());
- SectionMap::iterator sourcesSection = config.Sections.find("Sources");
- if (sourcesSection != config.Sections.end()) {
- ConfigEntMap::iterator sourceBegin =
- sourcesSection->second.lower_bound("DIRSource");
- ConfigEntMap::iterator sourceEnd =
- sourcesSection->second.upper_bound("DIRSource");
-
- while (sourceBegin != sourceEnd) {
- InstallSource is("DIR", sourceBegin->second.c_str());
- if (!strcmp(is.caption, name.toLatin1()) ) { //found local dir source
- return is;
- }
-
- sourceBegin++;//next source
- }
- }
- }
-
- InstallSource is("EMPTY"); //default return value
- is.caption = "unknown caption";
- is.source = "unknown source";
- is.directory = "unknown dir";
- return is;
-}
-
-/** Deletes the source. */
-bool deleteSource(QString name) {
- qDebug() << "backend::deleteSource";
- sword::InstallSource is = source(name );
-
- SWConfig config(configFilename().toLatin1());
-
- //this code can probably be shortened by using the stl remove_if functionality
- std::pair< ConfigEntMap::iterator, ConfigEntMap::iterator > range =
- isRemote(is)
- ? config["Sources"].equal_range("FTPSource")
- : config["Sources"].equal_range("DIRSource");
-
- ConfigEntMap::iterator it = range.first;
- SWBuf sourceConfigEntry = is.getConfEnt();
- bool notFound = true;
- while (it != range.second) {
- //SWORD lib gave us a "nice" surprise: getConfEnt() adds uid, so old sources added by BT are not recognized here
- if (it->second == sourceConfigEntry) {
- config["Sources"].erase(it);
- notFound = false;
- break;
- }
- ++it;
- }
- if (notFound) {
- qDebug() << "source was not found, try without uid";
- //try again without uid
- QString sce(sourceConfigEntry.c_str());
- QStringList l = sce.split('|');
- l.removeLast();
- sce = l.join("|").append("|");
- it = range.first;
- while (it != range.second) {
- qDebug() << it->second;
- if (it->second == sce) {
- config["Sources"].erase(it);
- break;
- }
- ++it;
- }
- }
-
- config.Save();
- return true; /// \todo dummy
-}
-
-/** Refreshes the remote source module list. */
-bool refreshSource(QString /*name*/) {
- // not possible until manager and progressdialog work together
- return true; /// \todo dummy
-}
-
-/** Returns the moduleinfo list for the source. Delete the pointer after using. IS THIS POSSIBLE?*/
-QList<CSwordModuleInfo*> moduleList(QString /*name*/) {
- QList<CSwordModuleInfo*> list; /// \todo dummy
- return list;
-}
-
-bool isRemote(const sword::InstallSource& source) {
- return !strcmp(source.type, "FTP");
-}
-
-const QString configPath() {
- QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
- confPath.append("/InstallMgr");
- return confPath;
-}
-
-const QString configFilename() {
- return (configPath() + "/InstallMgr.conf");
-}
-
-QStringList targetList() {
- qDebug() << "backend::targetList";
- QStringList names = CPointers::backend()->swordDirList();
- return names;
-}
-
-bool setTargetList( const QStringList& targets ) {
- namespace DU = util::directory;
-
- qDebug() << "backend::setTargetList";
- //saves a new Sword config using the provided target list
- //QString filename = KGlobal::dirs()->saveLocation("data", "bibletime/") + "sword.conf"; //default is to assume the real location isn't writable
- //QString filename = util::DirectoryUtil::getUserBaseDir().canonicalPath().append("/.sword/sword.conf");
- //bool directAccess = false;
- QString filename = swordConfigFilename();
- QFileInfo i(filename);
- QFileInfo dirInfo(i.absolutePath());
-
-
- if ( !i.exists() && dirInfo.isWritable() ) {
- // if the file doesn't exist but the parent is writable, create it
- qWarning() << "The Sword config file does not exist, it has to be created";
- QFile f(filename);
- f.open(QIODevice::WriteOnly);
- f.close();
- i.refresh();
- }
- if ( i.exists() && i.isWritable() ) { //we can write to the file ourself
- qDebug() << "The Sword config file is writable";
- }
- else {
- // There is no way to save to the file
- qWarning() << "The Sword config file is not writable!";
- util::showWarning(0, QObject::tr("Can't write file"), QObject::tr("The Sword config file can't be written!"));
- return false;
- }
-
- filename = util::directory::convertDirSeparators(filename);
- SWConfig conf(filename.toLocal8Bit());
- conf.Sections.clear();
-
-#ifdef Q_WS_WIN
- // On Windows, add the sword directory to the config file.
- QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
- conf["Install"].insert(
- std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
- );
-#endif
-
- bool setDataPath = false;
- for (QStringList::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- QString t = DU::convertDirSeparators(*it);
-#ifdef Q_WS_WIN
- if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
-#else
- if (t.contains(DU::getUserHomeDir().canonicalPath().append("/.sword"))) {
-#endif
- //we don't want $HOME/.sword in the config
- continue;
- }
- else {
- qDebug() << "Add path to the conf file" << filename << ":" << t;
- conf["Install"].insert( std::make_pair(!setDataPath ? SWBuf("DataPath") : SWBuf("AugmentPath"), t.toLocal8Bit().data()) );
- setDataPath = true;
- }
- }
- qDebug() << "save the sword conf...";
- conf.Save();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
- return true;
-}
-
-QStringList sourceList() {
- qDebug() << "backend::sourceList";
- BtInstallMgr mgr;
- Q_ASSERT(mgr.installConf);
-
- QStringList names;
-
- //add Sword remote sources
- for (InstallSourceMap::iterator it = mgr.sources.begin(); it != mgr.sources.end(); it++) {
- names << QString::fromLocal8Bit(it->second->caption);
- }
-
- // Add local directory sources
- SWConfig config(configFilename().toLatin1());
- sword::SectionMap::iterator sourcesSection = config.Sections.find("Sources");
- if (sourcesSection != config.Sections.end()) {
- sword::ConfigEntMap::iterator sourceBegin = sourcesSection->second.lower_bound("DIRSource");
- sword::ConfigEntMap::iterator sourceEnd = sourcesSection->second.upper_bound("DIRSource");
-
- while (sourceBegin != sourceEnd) {
- InstallSource is("DIR", sourceBegin->second.c_str());
- names << QString::fromLatin1(is.caption.c_str());
-
- sourceBegin++;
- }
- }
-
- return names;
-}
-
-
-void initPassiveFtpMode() {
- qDebug() << "backend::initPassiveFtpMode";
- SWConfig config(configFilename().toLatin1());
- config["General"]["PassiveFTP"] = "true";
- config.Save();
-}
-const QString swordConfigFilename() {
- namespace DU = util::directory;
-
- qDebug() << "backend::swordConfigFilename";
-#ifdef Q_WS_WIN
- qDebug() << DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
- return DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
-// return DU::getApplicationDir().absolutePath().append("/sword.conf");
-#else
- qDebug() << DU::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
- return DU::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
-#endif
-}
-
-const QDir swordDir() {
- namespace DU = util::directory;
-
-#ifdef Q_WS_WIN
- return QDir(DU::getUserHomeDir().absolutePath().append("/Sword/"));
-#else
- return QDir(DU::getUserHomeDir().absolutePath().append("/.sword/"));
-#endif
-}
-
-CSwordBackend* backend( const sword::InstallSource& is) {
- qDebug() << "backend::backend";
- CSwordBackend* ret = 0;
- if (isRemote(is)) {
- ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
- }
- else {
- ret = new CSwordBackend( QString(is.directory.c_str()), false);
- }
-
- Q_ASSERT(ret);
- if (ret) {
- ret->initModules(CSwordBackend::OtherChange);
- }
- return ret;
-}
-
-}
diff --git a/src/frontend/bookshelfmanager/instbackend.h b/src/frontend/bookshelfmanager/instbackend.h
deleted file mode 100644
index 3a98e5a..0000000
--- a/src/frontend/bookshelfmanager/instbackend.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef INSTBACKEND_H
-#define INSTBACKEND_H
-
-#include <QDir>
-#include <QString>
-#include "backend/managers/cswordbackend.h"
-
-// Sword includes:
-#include <installmgr.h>
-
-
-class CSwordModuleInfo;
-
-namespace instbackend {
-
-/** Adds the source to the backend. */
-bool addSource(sword::InstallSource& source);
-
-/** Returns the source struct. */
-sword::InstallSource source(QString name);
-
-/** Deletes the source. */
-bool deleteSource(QString name);
-
-/** Refreshes the remote source module list. */
-bool refreshSource(QString name);
-
-/** Returns the moduleinfo list for the source. */
-QList<CSwordModuleInfo*> moduleList(QString name);
-
-/** Tells if the source is remote or local. */
-bool isRemote(const sword::InstallSource& source);
-
-/** Returns the list of available install target paths. */
-QStringList targetList();
-
-/** Saves the list of available install target paths to the sword config. Return success indicator.*/
-bool setTargetList( const QStringList& targets );
-
-QStringList sourceList();
-
-/** Returns the path of the sword installer configuration file. */
-const QString configPath();
-
-/** Returns the name of the sword installer configuration file. */
-const QString configFilename();
-
-/** Sets the passive mode for as default.
-* \todo see if we can en/disable this per source.
-*/
-void initPassiveFtpMode();
-
-/** Returns the file name for the Sword config file. */
-const QString swordConfigFilename();
-
-/** Returns the Sword directory ($HOME/.sword/) as a QDir, created with absolute path (not canonical).
-*/
-const QDir swordDir();
-
-/** Returns backend Sword manager for the source. */
-CSwordBackend* backend( const sword::InstallSource& is);
-
-}
-
-#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 3f602e0..a19ab89 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -12,90 +12,137 @@
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include <QGridLayout>
+#include <QAction>
+#include <QGroupBox>
+#include <QHBoxLayout>
#include <QHeaderView>
-#include <QList>
+#include <QMessageBox>
#include <QPushButton>
-#include <QTreeView>
-#include "backend/drivers/cswordmoduleinfo.h"
+#include <QToolButton>
+#include <QVBoxLayout>
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
-#include "util/cpointers.h"
+#include "frontend/btbookshelfview.h"
+#include "frontend/btbookshelfwidget.h"
#include "util/cresmgr.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
// Sword includes:
#include <swmgr.h>
#include <installmgr.h>
-BtRemovePage::BtRemovePage()
- : BtConfigPage() {
- namespace DU = util::directory;
-
- QGridLayout* layout = new QGridLayout(this);
- layout->setMargin(5);
-
- layout->setSpacing(10);
- layout->setColumnStretch(1, 1);
- layout->setRowStretch(2, 1);
-
- m_model = new BtRemovePageTreeModel(this);
- m_model->setSourceModel(CPointers::backend()->model());
-
- m_view = new QTreeView(this);
- m_view->header()->setResizeMode(QHeaderView::ResizeToContents);
- m_view->setModel(m_model);
+namespace {
+const QString groupingOrderKey("GUI/BookshelfManager/RemovePage/grouping");
+}
- layout->addWidget(m_view, 2, 0, 1, 2);
+BtRemovePage::BtRemovePage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ namespace DU = util::directory;
- m_removeButton = new QPushButton(tr("Remove..."), this);
+ m_worksGroupBox = new QGroupBox(tr("Select &works to uninstall:"), this);
+ m_worksGroupBox->setFlat(true);
+ QVBoxLayout *wLayout = new QVBoxLayout;
+ wLayout->setContentsMargins(0, 0, 0, 0);
+ m_worksGroupBox->setLayout(wLayout);
+
+ BtRemovePageTreeModel *treeModel = new BtRemovePageTreeModel(groupingOrderKey,
+ this);
+ connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+
+ m_bookshelfWidget = new BtBookshelfWidget(this);
+ m_bookshelfWidget->postFilterModel()->setShowHidden(true);
+ m_bookshelfWidget->setTreeModel(treeModel);
+ m_bookshelfWidget->setSourceModel(CSwordBackend::instance()->model());
+ m_bookshelfWidget->showHideAction()->setVisible(false);
+ m_bookshelfWidget->showHideButton()->hide();
+ m_bookshelfWidget->treeView()->header()->show();
+ m_bookshelfWidget->treeView()->header()->setResizeMode(QHeaderView::ResizeToContents);
+ wLayout->addWidget(m_bookshelfWidget);
+
+ m_uninstallGroupBox = new QGroupBox(this);
+ m_uninstallGroupBox->setFlat(true);
+ retranslateUninstallGroupBox();
+ QHBoxLayout *uLayout = new QHBoxLayout;
+ uLayout->setContentsMargins(0, 0, 0, 0);
+ m_uninstallGroupBox->setLayout(uLayout);
+ uLayout->addStretch(1);
+
+ m_removeButton = new QPushButton(tr("&Remove..."), this);
m_removeButton->setToolTip(tr("Remove the selected works"));
m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
m_removeButton->setEnabled(false);
- layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
+ uLayout->addWidget(m_removeButton, 0, Qt::AlignRight);
+
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
+ mainLayout->addWidget(m_worksGroupBox, 1);
+ mainLayout->addWidget(m_uninstallGroupBox);
connect(m_removeButton, SIGNAL(clicked()),
this, SLOT(slotRemoveModules()));
- connect(m_model, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
- this, SLOT(resetRemoveButton()));
- connect(m_model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
- this, SLOT(resetRemoveButton()));
+ connect(m_bookshelfWidget->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
+ this, SLOT(slotResetRemoveButton()));
+ connect(m_bookshelfWidget->treeModel(), SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(slotResetRemoveButton()));
}
-QString BtRemovePage::label() {
- return tr("Remove installed works. Select the works and click Remove button.");
+const QIcon &BtRemovePage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon);
}
-QString BtRemovePage::iconName() {
- return CResMgr::bookshelfmgr::removepage::icon;
+QString BtRemovePage::header() const {
+ return tr("Remove");
}
-QString BtRemovePage::header() {
- return tr("Remove");
+void BtRemovePage::retranslateUninstallGroupBox() {
+ int count = m_bookshelfWidget->treeModel()->checkedModules().count();
+ if (count > 0) {
+ m_uninstallGroupBox->setTitle(tr("Start removal of %1 works:")
+ .arg(count));
+ } else {
+ m_uninstallGroupBox->setTitle(tr("Start removal:"));
+ }
}
-void BtRemovePage::resetRemoveButton() {
- m_removeButton->setEnabled(!m_model->checkedModules().empty());
+void BtRemovePage::slotResetRemoveButton() {
+ retranslateUninstallGroupBox();
+ m_removeButton->setEnabled(!m_bookshelfWidget->treeModel()->checkedModules().empty());
}
void BtRemovePage::slotRemoveModules() {
// Do nothing when this signal fires without anything selected to remove:
- if (m_model->checkedModules().empty()) return;
+ if (m_bookshelfWidget->treeModel()->checkedModules().empty()) return;
QStringList moduleNames;
- foreach (CSwordModuleInfo *m, m_model->checkedModules()) {
- moduleNames.append(m->name());
+ const int textHeight = fontMetrics().height();
+ /// \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,
+ m_bookshelfWidget->treeModel()->checkedModules())
+ {
+ const QIcon icon = CSwordModuleInfo::moduleIcon(m);
+ const QSize iconSize = icon.actualSize(QSize(textHeight, textHeight));
+ moduleNames.append(moduleString
+ .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m))
+ .arg(iconSize.width())
+ .arg(iconSize.height())
+ .arg(m->name()));
}
const QString message = tr("You selected the following work(s): ")
- .append(moduleNames.join(", "))
- .append("\n\n")
+ .append("<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;")
+ .append(moduleNames.join(",&nbsp; "))
+ .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.
// Update the module list before really removing. Remember deleting the pointers later.
- QList<CSwordModuleInfo*> toBeDeleted = CPointers::backend()->takeModulesFromList(moduleNames);
+ QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames);
sword::InstallMgr installMgr;
QMap<QString, sword::SWMgr*> mgrDict; //maps config paths to SWMgr objects
@@ -131,3 +178,7 @@ void BtRemovePage::slotRemoveModules() {
mgrDict.clear();
}
}
+
+void BtRemovePage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ g.saveTo(groupingOrderKey);
+}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 2950619..11017d0 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -21,29 +21,36 @@
#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
+class BtBookshelfWidget;
+class QGroupBox;
class QPushButton;
-class QTreeView;
class BtRemovePage: public BtConfigPage {
Q_OBJECT
public:
- BtRemovePage();
+ BtRemovePage(QWidget *parent = 0);
- // BtConfigPage methods:
- QString header();
- QString iconName();
- QString label();
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
- protected slots:
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ private:
+ void retranslateUninstallGroupBox();
+
+ private slots:
void slotRemoveModules();
- void resetRemoveButton();
+ void slotResetRemoveButton();
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
- protected:
- BtRemovePageTreeModel *m_model;
+ private:
+ QGroupBox *m_worksGroupBox;
+ BtBookshelfWidget *m_bookshelfWidget;
- QTreeView *m_view;
- QPushButton *m_removeButton;
+ QGroupBox *m_uninstallGroupBox;
+ QPushButton *m_removeButton;
};
#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
index fe566d1..a0955b2 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -13,8 +13,9 @@
#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
-BtRemovePageTreeModel::BtRemovePageTreeModel(QObject *parent)
- : BtBookshelfTreeModel(parent) {
+BtRemovePageTreeModel::BtRemovePageTreeModel(const QString &configKey, QObject *parent)
+ : BtBookshelfTreeModel(configKey, parent)
+{
setCheckable(true);
setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
index 619a1ff..14e0a67 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -19,7 +19,7 @@ class BtRemovePageTreeModel: public BtBookshelfTreeModel {
Q_OBJECT
public:
- BtRemovePageTreeModel(QObject *parent = 0);
+ BtRemovePageTreeModel(const QString &configKey, QObject *parent = 0);
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
diff --git a/src/frontend/btaboutdialog.cpp b/src/frontend/btaboutdialog.cpp
new file mode 100644
index 0000000..5b62cf3
--- /dev/null
+++ b/src/frontend/btaboutdialog.cpp
@@ -0,0 +1,274 @@
+/*********
+*
+* 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/btaboutdialog.h"
+
+#include <QApplication>
+#include <QDesktopServices>
+#include <QDialogButtonBox>
+#include <QLabel>
+#include <QTabWidget>
+#include <QTextStream>
+#include <QVBoxLayout>
+#include <QWebView>
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
+// Sword includes:
+#include <swversion.h>
+
+
+#define MAKE_STYLE(t) "<style type=\"text/css\">"\
+ "body{"\
+ "background-color:" + (t)->palette().color(QPalette::Window).name() + ";"\
+ "color:" + (t)->palette().color(QPalette::WindowText).name() +\
+ "}"\
+ "h3{font-weight:bold;text-align:center}"\
+ "a{text-decoration:underline}"\
+ "a:link{color:" + (t)->palette().color(QPalette::Link).name() + "}"\
+ "a:visited{color:" + (t)->palette().color(QPalette::LinkVisited).name() + "}"\
+ "</style>"
+#define MAKE_HTML(t,x) "<html><head>" MAKE_STYLE(t) "</head><body>" + (x) + "</body></html>"
+#define MAKE_LINK(c,u,t) "<a href=\"" u "\">"; (c) += (t); (c) += "</a>"
+#define MAKE_LINK_STATIC(u,t) "<a href=\"" u "\">" t "</a>"
+#define MAKE_CONTR(c,n,r) "<li>" n " (";\
+ (c) += (r);\
+ (c) += ")</li>"
+#define MAKE_CONTR2(c,n,r,r2) "<li>" n " (";\
+ (c) += (r);\
+ (c) += ", ";\
+ (c) += (r2);\
+ (c) += ")</li>"
+
+BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags)
+ : QDialog(parent, wflags)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+ resize(550, 340);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+
+ QWidget *top = new QWidget(this);
+ QHBoxLayout *topLayout = new QHBoxLayout;
+ QLabel *iconLabel = new QLabel(this);
+ iconLabel->setPixmap(QIcon(util::directory::getIconDir().path() + "/bibletime.svg").pixmap(48));
+ topLayout->addWidget(iconLabel);
+ topLayout->addWidget(new QLabel("<h1>BibleTime " BT_VERSION "</h1>"), 1);
+ top->setLayout(topLayout);
+ mainLayout->addWidget(top, 0, Qt::AlignCenter);
+
+ m_tabWidget = new QTabWidget(this);
+ mainLayout->addWidget(m_tabWidget);
+
+ initTab(m_bibletimeTab);
+ initTab(m_contributorsTab);
+ initTab(m_swordTab);
+ initTab(m_qtTab);
+ initTab(m_licenceTab);
+
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ mainLayout->addWidget(m_buttonBox);
+ setLayout(mainLayout);
+
+ connect(m_buttonBox, SIGNAL(rejected()),
+ this, SLOT(reject()));
+
+ retranslateUi();
+}
+
+BtAboutDialog::~BtAboutDialog() {
+ // Intentionally empty
+}
+
+void BtAboutDialog::initTab(QWebView *&tab) {
+ tab = new QWebView(this);
+ m_tabWidget->addTab(tab, "");
+ tab->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ connect(tab, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
+}
+
+void BtAboutDialog::retranslateUi() {
+ setWindowTitle(tr("About BibleTime"));
+
+ retranslateBtTab();
+ retranslateContributorsTab();
+ retranslateSwordTab();
+ retranslateQtTab();
+ retranslateLicenceTab();
+
+ util::prepareDialogBox(m_buttonBox);
+}
+
+void BtAboutDialog::retranslateBtTab() {
+ m_tabWidget->setTabText(0, tr("&BibleTime"));
+
+ QString content("<p>");
+ content += tr("BibleTime is an easy to use but powerful Bible study tool.");
+ content += "</p><p>";
+ content += tr("We are looking for developers and translators. If you would like to join "
+ "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 += "</p><p>" MAKE_LINK_STATIC("http://www.bibletime.info", "www.bibletime.info")
+ "</p>";
+ m_bibletimeTab->setHtml(MAKE_HTML(m_bibletimeTab, content));
+}
+
+void BtAboutDialog::retranslateContributorsTab() {
+ m_tabWidget->setTabText(1, tr("&Contributors"));
+
+ const QString developer(tr("developer"));
+ const QString designer(tr("designer"));
+
+ /****************************************************************************************
+ *** NB!!! Credits are sorted alphabetically by last name! ***
+ ****************************************************************************************/
+
+ QString content("<p><b>");
+ content += tr("The following people contributed to BibleTime:");
+ content += "</b></p><ul>"
+ MAKE_CONTR(content, "Thomas Abthorpe", tr("documentation and translation manager"))
+ MAKE_CONTR2(content, "Joachim Ansorg", tr("project founder"), developer)
+ MAKE_CONTR(content, "David Blue", designer)
+ MAKE_CONTR(content, "Tim Brodie", developer)
+ MAKE_CONTR(content, "Timothy R. Butler", designer)
+ MAKE_CONTR(content, "Jim Campbell", developer)
+ MAKE_CONTR(content, "Lee Carpenter", developer)
+ MAKE_CONTR(content, "Jeremy Erickson", tr("packager"))
+ MAKE_CONTR(content, "Troy A. Griffitts", tr("creator of The Sword Project"))
+ MAKE_CONTR2(content, "Martin Gruner", tr("project manager"), developer)
+ MAKE_CONTR(content, "Thomas Hagedorn", tr("domain sponsor"))
+ MAKE_CONTR(content, "Bob Harman", tr("howto"))
+ MAKE_CONTR(content, "Gary Holmlund", developer)
+ MAKE_CONTR(content, "Nikolay Igotti", developer)
+ MAKE_CONTR(content, "Eeli Kaikkonnen", developer)
+ MAKE_CONTR(content, "Chris Kujawa", developer)
+ MAKE_CONTR(content, "Mark Lybarger", developer)
+ MAKE_CONTR(content, "Luke Mauldin", developer)
+ MAKE_CONTR(content, "James Ots", designer)
+ MAKE_CONTR(content, "Andrus Raag", tr("artist"))
+ MAKE_CONTR(content, "Jaak Ristioja", developer)
+ MAKE_CONTR(content, "Fred Saalbach", tr("documentation"))
+ MAKE_CONTR(content, "Gary Sims", developer)
+ 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, "David White", developer)
+ MAKE_CONTR(content, "Mark Zealey", developer)
+ "</ul><p><b>";
+
+
+ /****************************************************************************************
+ *** NB!!! Credits are sorted alphabetically by last name! ***
+ ****************************************************************************************/
+ content += tr("The following people translated BibleTime into their language:");
+ content += "</b></p><ul>"
+ "<li>Horatiu Alexe</li>"
+ "<li>Roy Alvear Aguirre</li>"
+ "<li>Luis Barron</li>"
+ "<li>Jan B&#x11B;lohoubek</li>"
+ "<li>Chun-shek Chan</li>"
+ "<li>Nouhoun Y. Diarra</li>"
+ "<li>Rafael Fagundes</li>"
+ "<li>Eeli Kaikkonen</li>"
+ "<li>Ilpo Kantonen</li>"
+ "<li>Pavel Laukko</li>"
+ "<li>Piotr Markiewicz</li>"
+ "<li>G&eacute;za Nov&aacute;k</li>"
+ "<li>Gabriel P&eacute;rez</li>"
+ "<li>Igor Plisco</li>"
+ "<li>Zdenko Podobn&yacute;</li>"
+ "<li>Jaak Ristioja</li>"
+ "<li>Igor Rykhlin</li>"
+ "<li>Vlad Savitsky</li>"
+ "<li>Henrik Sonesson</li>"
+ "<li>Johan van der Lingen</li>"
+ "<li>Jean Van Schaftingen</li>"
+ "<li>Roland Teschner</li>"
+ "<li>Giovanni Tedaldi</li>"
+ "<li>Dmitry Yurevich</li>"
+ "<li>Esteban Zeller</li>"
+ "</ul><p>";
+ content += tr("Some names may be missing, please email %1 if you notice errors or "
+ "omissions.").arg(MAKE_LINK_STATIC(
+ "mailto:bibletime-translations@lists.sourceforge.net",
+ "bibletime-translations@lists.sourceforge.net"));
+ content += "</p>";
+
+ m_contributorsTab->setHtml(MAKE_HTML(m_contributorsTab, content));
+}
+
+
+void BtAboutDialog::retranslateSwordTab() {
+ m_tabWidget->setTabText(2, tr("&SWORD"));
+
+ QString version(sword::SWVersion::currentVersion.getText());
+ QString content("<h3>");
+ content += tr("SWORD library version %1").arg(version);
+ content += "</h3><p>";
+ content += tr("BibleTime makes use of the SWORD Project. The SWORD Project is the "
+ "CrossWire Bible Society's free Bible software project. Its purpose is to "
+ "create cross-platform open-source tools &mdash; covered by the GNU "
+ "General Public License &mdash; that allow programmers and Bible "
+ "societies to write new Bible software more quickly and easily.");
+ content += "</p><p>";
+ content += tr("The SWORD Project: ");
+ content += MAKE_LINK_STATIC("http://www.crosswire.org/sword/",
+ "www.crosswire.org/sword") "</p>";
+
+ m_swordTab->setHtml(MAKE_HTML(m_swordTab, content));
+}
+
+void BtAboutDialog::retranslateQtTab() {
+ m_tabWidget->setTabText(3, tr("&Qt"));
+
+ QString content("<h3>");
+ content += tr("Qt toolkit version %1").arg(qVersion());
+ content += "</h3><p>";
+ content += tr("This program uses Qt version %1.").arg(qVersion());
+ content += "</p><p>";
+ content += tr("Qt is a cross-platform application and UI framework, created with C++ "
+ "language. It has been released under the LGPL license.");
+ content += " " MAKE_LINK(content, "about:qt", tr("More info...")) "</p>";
+ m_qtTab->setHtml(MAKE_HTML(m_qtTab, content));
+}
+
+void BtAboutDialog::retranslateLicenceTab() {
+ m_tabWidget->setTabText(4, tr("&License"));
+
+ QFile licFile(util::directory::getLicenseDir().path() + "/license.html");
+ if (licFile.open(QFile::ReadOnly)) {
+
+ QString text("<p>");
+ text += tr("BibleTime is released under the GPL license. You can download and use "
+ "the program for personal, private, public or "
+ "commercial purposes without restrictions, but can give away or "
+ "distribute the program only if you also distribute the corresponding source "
+ "code.");
+ text += "</p><p>";
+ text += tr("The complete legally binding license is below.");
+ text += "</p><hr/>";
+
+ QString content(QTextStream(&licFile).readAll().replace("<!-- TR TEXT -->", text));
+ content.replace("<!-- HEADER -->", MAKE_STYLE(m_licenceTab), Qt::CaseInsensitive);
+ m_licenceTab->setHtml(content);
+ licFile.close();
+ }
+}
+
+void BtAboutDialog::linkClicked(const QUrl &url) {
+ if (url.scheme() == "about") {
+ if (url.path() == "qt") {
+ qApp->aboutQt();
+ }
+ } else {
+ QDesktopServices::openUrl(url);
+ }
+}
diff --git a/src/frontend/btaboutdialog.h b/src/frontend/btaboutdialog.h
new file mode 100644
index 0000000..34c7bcf
--- /dev/null
+++ b/src/frontend/btaboutdialog.h
@@ -0,0 +1,49 @@
+/*********
+*
+* 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 BTABOUTDIALOG_H
+#define BTABOUTDIALOG_H
+
+#include <QDialog>
+
+class QDialogButtonBox;
+class QTabWidget;
+class QUrl;
+class QWebView;
+
+class BtAboutDialog: public QDialog {
+ Q_OBJECT
+ public:
+ BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ ~BtAboutDialog();
+
+ private:
+ void initTab(QWebView *&tab);
+
+ void retranslateUi();
+ void retranslateBtTab();
+ void retranslateContributorsTab();
+ void retranslateSwordTab();
+ void retranslateQtTab();
+ void retranslateLicenceTab();
+
+ private slots:
+ void linkClicked(const QUrl &url);
+
+ private:
+ QTabWidget *m_tabWidget;
+ QWebView *m_bibletimeTab;
+ QWebView *m_contributorsTab;
+ QWebView *m_swordTab;
+ QWebView *m_qtTab;
+ QWebView *m_licenceTab;
+ QDialogButtonBox *m_buttonBox;
+};
+
+#endif
diff --git a/src/frontend/btaboutmoduledialog.cpp b/src/frontend/btaboutmoduledialog.cpp
index 9241b71..e4847a6 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,28 +17,30 @@
#include "util/dialogutil.h"
-BTAboutModuleDialog::BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info)
- : QDialog(parent) {
- //Set the flag to destroy when closed - otherwise eats memory
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(tr("Information About %1").arg(info->name()));
+BTAboutModuleDialog::BTAboutModuleDialog(CSwordModuleInfo *moduleInfo, QWidget *parent,
+ Qt::WindowFlags flags)
+ : QDialog(parent, flags), m_moduleInfo(moduleInfo)
+{
resize(650, 400);
QVBoxLayout* vboxLayout = new QVBoxLayout(this);
- QTextEdit* textEdit = new QTextEdit(this);
- textEdit->setReadOnly(true);
- textEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
- vboxLayout->addWidget(textEdit);
- textEdit->setHtml(info->aboutText());
+ m_textEdit = new QTextEdit(this);
+ m_textEdit->setReadOnly(true);
+ m_textEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ vboxLayout->addWidget(m_textEdit);
- QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
- buttonBox->setOrientation(Qt::Horizontal);
- buttonBox->setStandardButtons(QDialogButtonBox::Close);
- util::prepareDialogBox(buttonBox);
- vboxLayout->addWidget(buttonBox);
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ QObject::connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ vboxLayout->addWidget(m_buttons);
+ retranslateUi();
- QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(moduleInfo, SIGNAL(destroyed()),
+ this, SLOT(close()));
+}
+void BTAboutModuleDialog::retranslateUi() {
+ setWindowTitle(tr("Information About %1").arg(m_moduleInfo->name()));
+ m_textEdit->setHtml(m_moduleInfo->aboutText());
+ util::prepareDialogBox(m_buttons);
}
diff --git a/src/frontend/btaboutmoduledialog.h b/src/frontend/btaboutmoduledialog.h
index 65c0696..eb4b15c 100644
--- a/src/frontend/btaboutmoduledialog.h
+++ b/src/frontend/btaboutmoduledialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,17 +14,27 @@
class CSwordModuleInfo;
-class QWidget;
+class QDialogButtonBox;
+class QTextEdit;
/**
Dialog to show the information about a module.
@author The BibleTime team <info@bibletime.info>
*/
-class BTAboutModuleDialog : public QDialog {
+class BTAboutModuleDialog: public QDialog {
Q_OBJECT
public:
- BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info);
+ BTAboutModuleDialog(CSwordModuleInfo *moduleInfo, QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
+
+ protected:
+ void retranslateUi();
+
+ private:
+ CSwordModuleInfo *m_moduleInfo;
+ QTextEdit *m_textEdit;
+ QDialogButtonBox *m_buttons;
};
#endif
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index 880c939..9159210 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -14,172 +14,100 @@
#include <QAction>
#include <QActionGroup>
-#include <QApplication>
-#include <QHBoxLayout>
-#include <QKeyEvent>
#include <QLabel>
-#include <QLineEdit>
#include <QMenu>
+#include <QMessageBox>
+#include <QPushButton>
#include <QSettings>
-#include <QToolBar>
-#include <QToolButton>
+#include <QStackedWidget>
#include <QVBoxLayout>
-#include "backend/bookshelfmodel/btbookshelfmodel.h"
-#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/btaboutmoduledialog.h"
-#include "frontend/mainindex/btbookshelfview.h"
-#include "util/cpointers.h"
+#include "bibletime.h"
+#include "frontend/btbookshelfview.h"
+#include "frontend/btbookshelfwidget.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+namespace {
+const QString groupingOrderKey("GUI/MainWindow/Docks/Bookshelf/grouping");
+}
+
+BtBookshelfDockWidget *BtBookshelfDockWidget::m_instance = 0;
+
BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
- : QDockWidget(parent, f) {
- QSettings *settings(CBTConfig::getConfig());
+ : QDockWidget(parent, f)
+{
+ Q_ASSERT(m_instance == 0);
+ m_instance = this;
setObjectName("BookshelfDock");
- // Setup models:
- settings->beginGroup("GUI/MainWindow/Docks/Bookshelf");
- {
- QVariant v(settings->value("grouping"));
- if (v.canConvert<BtBookshelfTreeModel::Grouping>()) {
- m_bookshelfTreeModel = new BtBookshelfTreeModel(v.value<BtBookshelfTreeModel::Grouping>(), this);
- }
- else {
- m_bookshelfTreeModel = new BtBookshelfTreeModel(this);
- }
- }
- settings->endGroup();
- m_bookshelfTreeModel->setDefaultChecked(BtBookshelfTreeModel::MODULE_HIDDEN);
- m_bookshelfTreeModel->setSourceModel(CPointers::backend()->model());
-
- m_filterProxyModel = new BtBookshelfFilterModel(this);
- m_filterProxyModel->setSourceModel(m_bookshelfTreeModel);
// Setup actions and menus:
initMenus();
- // Setup widgets:
- m_widget = new QWidget(this);
- QVBoxLayout *layout(new QVBoxLayout);
- layout->setContentsMargins(0, 0, 0, 0);
- QHBoxLayout *toolBar(new QHBoxLayout);
- // Add a small margin between the edge of the window and the label (looks better)
- toolBar->setContentsMargins(3, 0, 0, 0);
- m_nameFilterLabel = new QLabel(this);
- toolBar->addWidget(m_nameFilterLabel);
-
- m_nameFilterEdit = new QLineEdit(this);
- m_nameFilterEdit->installEventFilter(this);
- m_nameFilterLabel->setBuddy(m_nameFilterEdit);
- toolBar->addWidget(m_nameFilterEdit);
-
- m_groupingButton = new QToolButton(this);
- m_groupingButton->setPopupMode(QToolButton::InstantPopup);
- m_groupingButton->setMenu(m_groupingMenu);
- m_groupingButton->setIcon(m_groupingMenu->icon());
- m_groupingButton->setAutoRaise(true);
- toolBar->addWidget(m_groupingButton);
-
- m_showHideButton = new QToolButton(this);
- m_showHideButton->setDefaultAction(m_showHideAction);
- m_showHideButton->setAutoRaise(true);
- toolBar->addWidget(m_showHideButton);
- layout->addLayout(toolBar);
-
- m_view = new BtBookshelfView(this);
- m_view->setModel(m_filterProxyModel);
- layout->addWidget(m_view);
- m_widget->setLayout(layout);
- setWidget(m_widget);
-
- connect(m_nameFilterEdit, SIGNAL(textEdited(QString)),
- m_filterProxyModel, SLOT(setNameFilterFixedString(QString)));
- connect(m_view, SIGNAL(contextMenuActivated(QPoint)),
- this, SLOT(showContextMenu(QPoint)));
- connect(m_view,
- SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*, QPoint)),
- this, SLOT(showItemContextMenu(CSwordModuleInfo*, QPoint)));
- connect(m_view, SIGNAL(moduleActivated(CSwordModuleInfo*)),
- this, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)));
- connect(m_bookshelfTreeModel, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
- this, SLOT(moduleChecked(CSwordModuleInfo*, bool)));
+ // Setup tree model:
+ m_treeModel = new BtBookshelfTreeModel(groupingOrderKey, this);
+
+ // Get backend model:
+ BtBookshelfModel *bookshelfModel = CSwordBackend::instance()->model();
+
+ // Setup bookshelf widgets:
+ m_bookshelfWidget = new BtBookshelfWidget(this);
+ m_bookshelfWidget->setTreeModel(m_treeModel);
+ m_bookshelfWidget->setSourceModel(bookshelfModel);
+ m_bookshelfWidget->setItemContextMenu(m_itemContextMenu);
+ /// \bug The correct grouping action is not selected on startup.
+
+ // Setup welcome widgets:
+ m_welcomeWidget = new QWidget(this);
+ QVBoxLayout *welcomeLayout = new QVBoxLayout;
+ m_installLabel = new QLabel(this);
+ m_installLabel->setWordWrap(true);
+ m_installLabel->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
+ welcomeLayout->addWidget(m_installLabel, 0, Qt::AlignHCenter | Qt::AlignBottom);
+ m_installButton = new QPushButton(this);
+ welcomeLayout->addWidget(m_installButton, 0, Qt::AlignHCenter | Qt::AlignTop);
+ m_welcomeWidget->setLayout(welcomeLayout);
+
+ // Setup stacked widget:
+ m_stackedWidget = new QStackedWidget(this);
+ m_stackedWidget->addWidget(m_bookshelfWidget);
+ m_stackedWidget->addWidget(m_welcomeWidget);
+ m_stackedWidget->setCurrentWidget(bookshelfModel->moduleList().empty()
+ ? m_welcomeWidget
+ : m_bookshelfWidget);
+ setWidget(m_stackedWidget);
+
+ // Connect signals:
+ connect(m_bookshelfWidget->treeView(), SIGNAL(moduleActivated(CSwordModuleInfo*)),
+ this, SLOT(slotModuleActivated(CSwordModuleInfo*)));
+ connect(m_treeModel, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
+ this, SLOT(slotModuleChecked(CSwordModuleInfo*, bool)));
+ connect(m_treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+ connect(m_bookshelfWidget->showHideAction(), SIGNAL(toggled(bool)),
+ m_treeModel, SLOT(setCheckable(bool)));
+ connect(bookshelfModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
+ this, SLOT(slotModulesChanged()));
+ connect(bookshelfModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(slotModulesChanged()));
+ connect(m_installButton, SIGNAL(clicked()),
+ BibleTime::instance(), SLOT(slotSwordSetupDialog()));
retranslateUi();
}
-bool BtBookshelfDockWidget::eventFilter(QObject *object, QEvent *event) {
- Q_ASSERT(object == m_nameFilterEdit);
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *e = static_cast<QKeyEvent*>(event);
- switch (e->key()) {
- case Qt::Key_Up:
- case Qt::Key_Down:
- case Qt::Key_Enter:
- case Qt::Key_Return:
- QApplication::sendEvent(m_view, event);
- return true;
- default:
- break;
- }
- }
- return false;
-}
-
void BtBookshelfDockWidget::initMenus() {
namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
- m_contextMenu = new QMenu(this);
- m_groupingMenu = new QMenu(this);
- m_contextMenu->addMenu(m_groupingMenu);
- m_groupingMenu->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup = new QActionGroup(this);
- connect(m_groupingActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(groupingActionTriggered(QAction*)));
-
- m_groupingCatLangAction = new QAction(this);
- m_groupingCatLangAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingCatLangAction->setChecked(true);
- m_groupingActionGroup->addAction(m_groupingCatLangAction);
- m_groupingMenu->addAction(m_groupingCatLangAction);
-
- m_groupingCatAction = new QAction(this);
- m_groupingCatAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingCatAction);
- m_groupingMenu->addAction(m_groupingCatAction);
-
- m_groupingLangCatAction = new QAction(this);
- m_groupingLangCatAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingLangCatAction);
- m_groupingMenu->addAction(m_groupingLangCatAction);
-
- m_groupingLangAction = new QAction(this);
- m_groupingLangAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingLangAction);
- m_groupingMenu->addAction(m_groupingLangAction);
-
- m_groupingNoneAction = new QAction(this);
- m_groupingNoneAction->setIcon(DU::getIcon(RM::grouping::icon));
- m_groupingActionGroup->addAction(m_groupingNoneAction);
- m_groupingMenu->addAction(m_groupingNoneAction);
-
- m_showHideAction = new QAction(this);
- m_showHideAction->setIcon(DU::getIcon("layer-visible-on.svg"));
- m_showHideAction->setCheckable(true);
- connect(m_showHideAction, SIGNAL(toggled(bool)),
- this, SLOT(showHideEnabled(bool)));
- m_contextMenu->addAction(m_showHideAction);
-
m_itemContextMenu = new QMenu(this);
m_itemActionGroup = new QActionGroup(this);
connect(m_itemActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(itemActionTriggered(QAction*)));
+ this, SLOT(slotItemActionTriggered(QAction*)));
m_itemOpenAction = new QAction(this);
m_itemActionGroup->addAction(m_itemOpenAction);
@@ -212,87 +140,58 @@ void BtBookshelfDockWidget::initMenus() {
m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
m_itemActionGroup->addAction(m_itemAboutAction);
m_itemContextMenu->addAction(m_itemAboutAction);
+
+ connect(m_itemContextMenu, SIGNAL(aboutToShow()),
+ this, SLOT(slotPrepareItemContextMenu()));
}
void BtBookshelfDockWidget::retranslateUi() {
setWindowTitle(tr("Bookshelf"));
- m_nameFilterLabel->setText(tr("Fi&lter:"));
- m_groupingButton->setText(tr("Grouping"));
- m_groupingButton->setToolTip(tr("Change the grouping of items in the bookshelf."));
-
- m_groupingMenu->setTitle(tr("Grouping"));
- m_groupingCatLangAction->setText(tr("Category/Language"));
- m_groupingCatAction->setText(tr("Category"));
- m_groupingLangCatAction->setText(tr("Language/Category"));
- m_groupingLangAction->setText(tr("Language"));
- m_groupingNoneAction->setText(tr("No grouping"));
- m_showHideAction->setText(tr("Show/hide works"));
-
m_itemOpenAction->setText(tr("&Open"));
m_itemEditMenu->setTitle(tr("&Edit"));
m_itemEditPlainAction->setText(tr("&Plain text"));
m_itemEditHtmlAction->setText(tr("&HTML"));
m_itemUnlockAction->setText(tr("&Unlock..."));
m_itemAboutAction->setText(tr("&About..."));
-}
-void BtBookshelfDockWidget::moduleChecked(CSwordModuleInfo *module, bool c) {
- module->setHidden(!c);
+ m_installLabel->setText(tr("There are currently no works installed. Please "
+ "click the button below to install new works."));
+ m_installButton->setText(tr("&Install works..."));
}
-void BtBookshelfDockWidget::showContextMenu(QPoint pos) {
- m_contextMenu->popup(pos);
-}
-
-void BtBookshelfDockWidget::groupingActionTriggered(QAction *action) {
- BtBookshelfTreeModel::Grouping g;
- if (action == m_groupingCatAction) {
- g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
- }
- else if (action == m_groupingCatLangAction) {
- g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
- g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
- }
- else if (action == m_groupingLangAction) {
- g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
- }
- else if (action == m_groupingLangCatAction) {
- g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
- g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
- }
- m_bookshelfTreeModel->setGroupingOrder(g);
- m_view->setRootIsDecorated(!g.isEmpty());
-
- QSettings *settings(CBTConfig::getConfig());
- settings->beginGroup("GUI/MainWindow/Docks/Bookshelf");
- settings->setValue("grouping", QVariant::fromValue(g));
- settings->endGroup();
-}
-
-void BtBookshelfDockWidget::showHideEnabled(bool enable) {
- if (enable) {
- m_bookshelfTreeModel->setCheckable(true);
- m_filterProxyModel->setShowHidden(true);
- }
- else {
- m_filterProxyModel->setShowHidden(false);
- m_bookshelfTreeModel->setCheckable(false);
+void BtBookshelfDockWidget::slotModuleActivated(CSwordModuleInfo *module) {
+ if (!module->isLocked()) {
+ emit moduleOpenTriggered(module);
+ } else {
+ /**
+ \todo Implement a better unlock dialog, which could incorporate the following
+ 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!"),
+ tr("You are trying to access an encrypted module. Please "
+ "provide an unlock key in the following dialog to open the "
+ "module."));
+
+ /// \todo We need to keep the module name because unlocking currently reloads sword.
+ const QString moduleName(module->name());
+
+ if (BibleTime::moduleUnlock(module)) {
+ // Re-initialize module pointer:
+ module = CSwordBackend::instance()->findModuleByName(moduleName);
+ Q_ASSERT(module != 0);
+
+ emit moduleOpenTriggered(module);
+ }
}
}
-void BtBookshelfDockWidget::showItemContextMenu(CSwordModuleInfo *module,
- QPoint pos) {
- m_itemContextMenu->setProperty("BtModule", qVariantFromValue((void*) module));
- m_itemSearchAction->setText(tr("&Search in %1...").arg(module->name()));
- m_itemOpenAction->setEnabled(!module->isLocked());
- m_itemEditMenu->setEnabled(module->isWritable());
- m_itemUnlockAction->setEnabled(module->isLocked());
-
- m_itemContextMenu->popup(pos);
+void BtBookshelfDockWidget::slotModuleChecked(CSwordModuleInfo *module, bool c) {
+ module->setHidden(!c);
}
-void BtBookshelfDockWidget::itemActionTriggered(QAction *action) {
+void BtBookshelfDockWidget::slotItemActionTriggered(QAction *action) {
CSwordModuleInfo *module((CSwordModuleInfo*) m_itemContextMenu->property("BtModule").value<void*>());
if (module == 0) return;
@@ -315,3 +214,27 @@ void BtBookshelfDockWidget::itemActionTriggered(QAction *action) {
emit moduleAboutTriggered(module);
}
}
+
+void BtBookshelfDockWidget::slotPrepareItemContextMenu() {
+ void *v = m_itemContextMenu->property("BtModule").value<void*>();
+ CSwordModuleInfo *module = static_cast<CSwordModuleInfo*>(v);
+ m_itemOpenAction->setEnabled(!module->isLocked());
+ m_itemSearchAction->setText(tr("&Search in %1...").arg(module->name()));
+ m_itemSearchAction->setEnabled(!module->isLocked());
+ m_itemEditMenu->setEnabled(module->isWritable());
+ m_itemUnlockAction->setEnabled(module->isLocked());
+}
+
+void BtBookshelfDockWidget::slotModulesChanged() {
+ const BtBookshelfModel *bookshelfModel = CSwordBackend::instance()->model();
+ m_stackedWidget->setCurrentWidget(bookshelfModel->moduleList().empty()
+ ? m_welcomeWidget
+ : m_bookshelfWidget);
+}
+
+void BtBookshelfDockWidget::slotGroupingOrderChanged(
+ const BtBookshelfTreeModel::Grouping &g)
+{
+ g.saveTo(groupingOrderKey);
+ emit groupingOrderChanged(g);
+}
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index cfa20e6..58a014b 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -15,24 +15,28 @@
#include <QDockWidget>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "frontend/btbookshelfwidget.h"
+
-class CSwordModuleInfo;
-class BtBookshelfView;
-class BtBookshelfTreeModel;
-class BtBookshelfFilterModel;
class QAction;
class QActionGroup;
class QLabel;
-class QLineEdit;
class QMenu;
-class QToolBar;
-class QToolButton;
+class QPushButton;
+class QStackedWidget;
class BtBookshelfDockWidget: public QDockWidget {
Q_OBJECT
public:
BtBookshelfDockWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ static inline BtBookshelfDockWidget *getInstance() { return m_instance; }
+
+ inline const BtBookshelfTreeModel::Grouping &groupingOrder() const {
+ return m_treeModel->groupingOrder();
+ }
+
signals:
void moduleOpenTriggered(CSwordModuleInfo *module);
void moduleSearchTriggered(CSwordModuleInfo *module);
@@ -40,43 +44,30 @@ class BtBookshelfDockWidget: public QDockWidget {
void moduleEditHtmlTriggered(CSwordModuleInfo *module);
void moduleUnlockTriggered(CSwordModuleInfo *module);
void moduleAboutTriggered(CSwordModuleInfo *module);
+ void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping);
protected:
- bool eventFilter(QObject *object, QEvent *event);
void initMenus();
void retranslateUi();
protected slots:
- void moduleChecked(CSwordModuleInfo *module, bool checked);
- void showContextMenu(QPoint pos);
- void groupingActionTriggered(QAction *action);
- void showHideEnabled(bool enable);
- void showItemContextMenu(CSwordModuleInfo *module, QPoint pos);
- void itemActionTriggered(QAction *action);
+ void slotModuleActivated(CSwordModuleInfo *module);
+ void slotModuleChecked(CSwordModuleInfo *module, bool checked);
+ void slotItemActionTriggered(QAction *action);
+ void slotPrepareItemContextMenu();
+ void slotModulesChanged();
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
protected:
- // Models:
- BtBookshelfTreeModel *m_bookshelfTreeModel;
- BtBookshelfFilterModel *m_filterProxyModel;
-
- // Widgets:
- QWidget *m_widget;
- BtBookshelfView *m_view;
- QLabel *m_nameFilterLabel;
- QLineEdit *m_nameFilterEdit;
- QToolButton *m_groupingButton;
- QToolButton *m_showHideButton;
-
- // Popup menus:
- QMenu *m_contextMenu;
- QMenu *m_groupingMenu;
- QActionGroup *m_groupingActionGroup;
- QAction *m_groupingCatLangAction;
- QAction *m_groupingCatAction;
- QAction *m_groupingLangCatAction;
- QAction *m_groupingLangAction;
- QAction *m_groupingNoneAction;
- QAction *m_showHideAction;
+ BtBookshelfTreeModel *m_treeModel;
+
+ QStackedWidget *m_stackedWidget;
+ BtBookshelfWidget *m_bookshelfWidget;
+ QWidget *m_welcomeWidget;
+ QLabel *m_installLabel;
+ QPushButton *m_installButton;
+
+ // Item context menu:
QMenu *m_itemContextMenu;
QActionGroup *m_itemActionGroup;
QAction *m_itemOpenAction;
@@ -86,6 +77,8 @@ class BtBookshelfDockWidget: public QDockWidget {
QAction *m_itemEditHtmlAction;
QAction *m_itemUnlockAction;
QAction *m_itemAboutAction;
+
+ static BtBookshelfDockWidget *m_instance;
};
#endif // BTBOOKSHELFDOCKWIDGET_H
diff --git a/src/frontend/btbookshelfgroupingmenu.cpp b/src/frontend/btbookshelfgroupingmenu.cpp
new file mode 100644
index 0000000..de2bcf6
--- /dev/null
+++ b/src/frontend/btbookshelfgroupingmenu.cpp
@@ -0,0 +1,113 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/btbookshelfgroupingmenu.h"
+
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+namespace {
+bool groupsInitialized = false;
+BtBookshelfTreeModel::Grouping groupingNone(true);
+BtBookshelfTreeModel::Grouping groupingCat(true);
+BtBookshelfTreeModel::Grouping groupingCatLang;
+BtBookshelfTreeModel::Grouping groupingLang(true);
+BtBookshelfTreeModel::Grouping groupingLangCat(true);
+
+inline void initializeGroups() {
+ Q_ASSERT(groupingNone.empty());
+ groupingCat.append(BtBookshelfTreeModel::GROUP_CATEGORY);
+ Q_ASSERT(groupingCatLang.size() == 2);
+ Q_ASSERT(groupingCatLang.at(0) == BtBookshelfTreeModel::GROUP_CATEGORY);
+ Q_ASSERT(groupingCatLang.at(1) == BtBookshelfTreeModel::GROUP_LANGUAGE);
+ groupingLang.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
+ groupingLangCat.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
+ groupingLangCat.append(BtBookshelfTreeModel::GROUP_CATEGORY);
+ groupsInitialized = true;
+}
+
+inline void setActionRef(QAction *a, const BtBookshelfTreeModel::Grouping &g) {
+ a->setProperty("groupingPointer", QVariant::fromValue((void*) &g));
+}
+
+inline const BtBookshelfTreeModel::Grouping &getActionRef(const QAction *a) {
+ return *((const BtBookshelfTreeModel::Grouping*) a->property("groupingPointer").value<void*>());
+}
+
+} // anonymous namespace
+
+
+void BtBookshelfGroupingMenu::initMenu(bool showNoGrouping) {
+ namespace DU = util::directory;
+ namespace RM = CResMgr::mainIndex;
+
+ if (!groupsInitialized) initializeGroups();
+
+ setIcon(DU::getIcon(RM::grouping::icon));
+
+ m_groupingActionGroup = new QActionGroup(this);
+ m_groupingActionGroup->setExclusive(true);
+ connect(m_groupingActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotGroupingActionTriggered(QAction*)));
+
+ m_groupingCatLangAction = new QAction(this);
+ m_groupingCatLangAction->setCheckable(true);
+ setActionRef(m_groupingCatLangAction, groupingCatLang);
+ m_groupingActionGroup->addAction(m_groupingCatLangAction);
+ addAction(m_groupingCatLangAction);
+
+ m_groupingCatAction = new QAction(this);
+ m_groupingCatAction->setCheckable(true);
+ setActionRef(m_groupingCatAction, groupingCat);
+ m_groupingActionGroup->addAction(m_groupingCatAction);
+ addAction(m_groupingCatAction);
+
+ m_groupingLangCatAction = new QAction(this);
+ m_groupingLangCatAction->setCheckable(true);
+ setActionRef(m_groupingLangCatAction, groupingLangCat);
+ m_groupingActionGroup->addAction(m_groupingLangCatAction);
+ addAction(m_groupingLangCatAction);
+
+ m_groupingLangAction = new QAction(this);
+ m_groupingLangAction->setCheckable(true);
+ setActionRef(m_groupingLangAction, groupingLang);
+ m_groupingActionGroup->addAction(m_groupingLangAction);
+ addAction(m_groupingLangAction);
+
+ if (showNoGrouping) {
+ m_groupingNoneAction = new QAction(this);
+ m_groupingNoneAction->setCheckable(true);
+ setActionRef(m_groupingNoneAction, groupingNone);
+ m_groupingActionGroup->addAction(m_groupingNoneAction);
+ addAction(m_groupingNoneAction);
+ } else {
+ m_groupingNoneAction = 0;
+ }
+
+ retranslateUi();
+}
+
+void BtBookshelfGroupingMenu::retranslateUi() {
+ m_groupingCatLangAction->setText(tr("Category/Language"));
+ m_groupingCatAction->setText(tr("Category"));
+ m_groupingLangCatAction->setText(tr("Language/Category"));
+ m_groupingLangAction->setText(tr("Language"));
+
+ if (m_groupingNoneAction != 0) {
+ m_groupingNoneAction->setText(tr("No grouping"));
+ }
+}
+
+void BtBookshelfGroupingMenu::slotGroupingActionTriggered(QAction *action) {
+ emit signalGroupingOrderChanged(getActionRef(action));
+}
diff --git a/src/frontend/btbookshelfgroupingmenu.h b/src/frontend/btbookshelfgroupingmenu.h
new file mode 100644
index 0000000..83605a7
--- /dev/null
+++ b/src/frontend/btbookshelfgroupingmenu.h
@@ -0,0 +1,53 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTBOOKSHELFGROUPINGMENU_H
+#define BTBOOKSHELFGROUPINGMENU_H
+
+#include <QMenu>
+
+#include <backend/bookshelfmodel/btbookshelftreemodel.h>
+
+
+class QAction;
+class QActionGroup;
+
+class BtBookshelfGroupingMenu: public QMenu {
+ Q_OBJECT
+ public:
+ explicit inline BtBookshelfGroupingMenu(QWidget *parent = 0)
+ : QMenu(parent) { initMenu(true); }
+
+ explicit inline BtBookshelfGroupingMenu(bool showNoGrouping,
+ QWidget *parent = 0)
+ : QMenu(parent) { initMenu(showNoGrouping); }
+
+ signals:
+ void signalGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &);
+
+ private:
+ void initMenu(bool showNoGrouping);
+ void retranslateUi();
+
+ private slots:
+ void slotGroupingActionTriggered(QAction *action);
+
+ private:
+ QActionGroup *m_groupingActionGroup;
+ QAction *m_groupingCatLangAction;
+ QAction *m_groupingCatAction;
+ QAction *m_groupingLangCatAction;
+ QAction *m_groupingLangAction;
+ QAction *m_groupingNoneAction;
+};
+
+#endif // BTBOOKSHELFGROUPINGMENU_H
diff --git a/src/frontend/mainindex/btbookshelfview.cpp b/src/frontend/btbookshelfview.cpp
index 60b10d1..2dfa745 100644
--- a/src/frontend/mainindex/btbookshelfview.cpp
+++ b/src/frontend/btbookshelfview.cpp
@@ -4,24 +4,24 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
**********/
-#include "frontend/mainindex/btbookshelfview.h"
+#include "frontend/btbookshelfview.h"
#include <QApplication>
-#include <QHeaderView>
#include <QMouseEvent>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
BtBookshelfView::BtBookshelfView(QWidget *parent)
- : QTreeView(parent) {
- header()->hide();
+ : QTreeView(parent)
+{
+ setHeaderHidden(true);
/*
Uncommenting the following statement will hide the [+]expand/[-]collapse
diff --git a/src/frontend/mainindex/btbookshelfview.h b/src/frontend/btbookshelfview.h
index b91d60f..916559a 100644
--- a/src/frontend/mainindex/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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btbookshelfwidget.cpp b/src/frontend/btbookshelfwidget.cpp
new file mode 100644
index 0000000..d4f162e
--- /dev/null
+++ b/src/frontend/btbookshelfwidget.cpp
@@ -0,0 +1,203 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/btbookshelfwidget.h"
+
+#include <QActionGroup>
+#include <QApplication>
+#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QEvent>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QToolButton>
+#include <QVBoxLayout>
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
+#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
+#include "frontend/btbookshelfdockwidget.h"
+#include "frontend/btbookshelfgroupingmenu.h"
+#include "frontend/btbookshelfview.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
+ : QWidget(parent, flags)
+ , m_sourceModel(0)
+ , m_treeModel(0)
+ , m_leftCornerWidget(0)
+ , m_rightCornerWidget(0)
+{
+ // Setup post-filter:
+ m_postFilterModel = new BtBookshelfFilterModel(this);
+
+ // Init widgets and such:
+ initActions();
+ initMenus();
+ initWidgets();
+
+ // Connect treeview to model:
+ m_treeView->setModel(m_postFilterModel);
+
+ retranslateUi();
+
+ connect(m_nameFilterEdit, SIGNAL(textEdited(QString)),
+ m_postFilterModel, SLOT(setNameFilterFixedString(QString)));
+ connect(m_treeView, SIGNAL(contextMenuActivated(QPoint)),
+ this, SLOT(slotShowContextMenu(QPoint)));
+ connect(m_treeView, SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*, QPoint)),
+ this, SLOT(slotShowItemContextMenu(CSwordModuleInfo*, QPoint)));
+}
+
+BtBookshelfWidget::~BtBookshelfWidget() {
+ // Intentionally empty
+}
+
+void BtBookshelfWidget::setSourceModel(QAbstractItemModel *model) {
+ Q_ASSERT(model != 0);
+ m_sourceModel = model;
+ if (m_treeModel != 0) {
+ m_treeModel->setSourceModel(model);
+ }
+}
+
+void BtBookshelfWidget::setTreeModel(BtBookshelfTreeModel *model) {
+ Q_ASSERT(model != 0);
+ Q_ASSERT(m_treeModel == 0);
+ m_treeModel = model;
+ if (m_sourceModel != 0) {
+ model->setSourceModel(m_sourceModel);
+ }
+ m_postFilterModel->setSourceModel(model);
+}
+
+void BtBookshelfWidget::setLeftCornerWidget(QWidget *w) {
+ delete m_leftCornerWidget;
+ w->setParent(this);
+ m_toolBar->insertWidget(0, w, 0);
+}
+
+void BtBookshelfWidget::setRightCornerWidget(QWidget *w) {
+ delete m_rightCornerWidget;
+ w->setParent(this);
+ m_toolBar->insertWidget(m_toolBar->count(), w, 0);
+}
+
+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->setCheckable(true);
+ connect(m_showHideAction, SIGNAL(toggled(bool)),
+ m_postFilterModel, SLOT(setShowHidden(bool)));
+}
+
+void BtBookshelfWidget::initMenus() {
+ namespace DU = util::directory;
+ namespace RM = CResMgr::mainIndex;
+
+ // Grouping menu:
+ m_groupingMenu = new BtBookshelfGroupingMenu(this);
+ connect(m_groupingMenu, SIGNAL(signalGroupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingActionTriggered(BtBookshelfTreeModel::Grouping)));
+
+ // Context menu
+ m_contextMenu = new QMenu(this);
+ m_contextMenu->addMenu(m_groupingMenu);
+ m_contextMenu->addAction(m_showHideAction);
+
+ // Item context menu
+ m_itemContextMenu = m_contextMenu;
+}
+
+void BtBookshelfWidget::initWidgets() {
+ QVBoxLayout *layout(new QVBoxLayout);
+ layout->setContentsMargins(0, 0, 0, 0);
+ m_toolBar = new QHBoxLayout;
+ // Add a small margin between the edge of the window and the label (looks better)
+ m_toolBar->setContentsMargins(3, 0, 0, 0);
+ m_nameFilterLabel = new QLabel(this);
+ m_toolBar->addWidget(m_nameFilterLabel);
+
+ m_nameFilterEdit = new QLineEdit(this);
+ m_nameFilterEdit->installEventFilter(this);
+ m_nameFilterLabel->setBuddy(m_nameFilterEdit);
+ m_toolBar->addWidget(m_nameFilterEdit);
+
+ m_groupingButton = new QToolButton(this);
+ m_groupingButton->setPopupMode(QToolButton::InstantPopup);
+ m_groupingButton->setMenu(m_groupingMenu);
+ m_groupingButton->setIcon(m_groupingMenu->icon());
+ m_groupingButton->setAutoRaise(true);
+ m_toolBar->addWidget(m_groupingButton);
+
+ m_showHideButton = new QToolButton(this);
+ m_showHideButton->setDefaultAction(m_showHideAction);
+ m_showHideButton->setAutoRaise(true);
+ m_toolBar->addWidget(m_showHideButton);
+ layout->addLayout(m_toolBar);
+
+ m_treeView = new BtBookshelfView(this);
+ layout->addWidget(m_treeView);
+ setLayout(layout);
+}
+
+void BtBookshelfWidget::retranslateUi() {
+ m_nameFilterLabel->setText(tr("Fi&lter:"));
+ m_groupingButton->setText(tr("Grouping"));
+ m_groupingButton->setToolTip(tr("Change the grouping of items in the bookshelf."));
+ m_groupingMenu->setTitle(tr("Grouping"));
+ m_showHideAction->setText(tr("Show/hide works"));
+}
+
+bool BtBookshelfWidget::eventFilter(QObject *object, QEvent *event) {
+ Q_ASSERT(object == m_nameFilterEdit);
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *e = static_cast<QKeyEvent*>(event);
+ switch (e->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ QApplication::sendEvent(m_treeView, event);
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+void BtBookshelfWidget::slotGroupingActionTriggered(const BtBookshelfTreeModel::Grouping &grouping) {
+ m_treeModel->setGroupingOrder(grouping);
+ m_treeView->setRootIsDecorated(!grouping.isEmpty());
+}
+
+void BtBookshelfWidget::slotShowContextMenu(const QPoint &pos) {
+ m_contextMenu->popup(pos);
+}
+
+void BtBookshelfWidget::slotShowItemContextMenu(CSwordModuleInfo *module, const QPoint &pos)
+{
+ if (m_itemContextMenu != 0) {
+ m_itemContextMenu->setProperty("BtModule", qVariantFromValue((void*) module));
+ m_itemContextMenu->popup(pos);
+ } else {
+ m_itemContextMenu = m_contextMenu;
+ slotShowItemContextMenu(module, pos);
+ }
+}
diff --git a/src/frontend/btbookshelfwidget.h b/src/frontend/btbookshelfwidget.h
new file mode 100644
index 0000000..3f1e605
--- /dev/null
+++ b/src/frontend/btbookshelfwidget.h
@@ -0,0 +1,116 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTBOOKSHELFWIDGET_H
+#define BTBOOKSHELFWIDGET_H
+
+#include <QWidget>
+
+#include <backend/bookshelfmodel/btbookshelftreemodel.h>
+
+
+class BtBookshelfFilterModel;
+class BtBookshelfGroupingMenu;
+class BtBookshelfTreeModel;
+class BtBookshelfView;
+class QAbstractItemModel;
+class QAction;
+class QActionGroup;
+class QHBoxLayout;
+class QLabel;
+class QLineEdit;
+class QMenu;
+class QToolButton;
+
+class BtBookshelfWidget: public QWidget {
+ Q_OBJECT
+ public:
+ explicit BtBookshelfWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~BtBookshelfWidget();
+
+ void setSourceModel(QAbstractItemModel *model);
+
+ // Getters for models:
+ inline BtBookshelfTreeModel *treeModel() const { return m_treeModel; }
+ inline BtBookshelfFilterModel *postFilterModel() const { return m_postFilterModel; }
+
+ // Setters for models:
+ void setTreeModel(BtBookshelfTreeModel *model);
+
+ // Getters for widgets:
+ inline QWidget *leftCornerWidget() const { return m_leftCornerWidget; }
+ inline QLabel *nameFilterLabel() const { return m_nameFilterLabel; }
+ inline QLineEdit *nameFilterEdit() const { return m_nameFilterEdit; }
+ inline QToolButton *groupingButton() const { return m_groupingButton; }
+ inline QToolButton *showHideButton() const { return m_showHideButton; }
+ inline QWidget *rightCornerWidget() const { return m_rightCornerWidget; }
+ inline BtBookshelfView *treeView() const { return m_treeView; }
+ inline BtBookshelfGroupingMenu *groupingMenu() const { return m_groupingMenu; }
+ inline QMenu *contextMenu() const { return m_contextMenu; }
+ inline QMenu *itemContextMenu() const { return m_itemContextMenu; }
+
+ // Setters for widgets:
+ void setLeftCornerWidget(QWidget *w);
+ void setRightCornerWidget(QWidget *w);
+
+ // Getters for actions:
+ inline QAction *showHideAction() const { return m_showHideAction; }
+
+ // Setters for context menus:
+ inline void setContextMenu(QMenu *newMenu) { m_contextMenu = newMenu; }
+ inline void setItemContextMenu(QMenu *newMenu) { m_itemContextMenu = newMenu; }
+
+ bool eventFilter(QObject *object, QEvent *event);
+
+ protected:
+ void initActions();
+ void initMenus();
+ void initWidgets();
+ void retranslateUi();
+
+ protected slots:
+ void slotGroupingActionTriggered(const BtBookshelfTreeModel::Grouping &grouping);
+ void slotShowContextMenu(const QPoint &pos);
+ void slotShowItemContextMenu(CSwordModuleInfo *module, const QPoint &pos);
+
+ private:
+ // Models:
+ QAbstractItemModel *m_sourceModel;
+ BtBookshelfTreeModel *m_treeModel;
+ BtBookshelfFilterModel *m_postFilterModel;
+
+ // Widgets:
+ QHBoxLayout *m_toolBar;
+ QWidget *m_leftCornerWidget;
+ QWidget *m_rightCornerWidget;
+ QLabel *m_nameFilterLabel;
+ QLineEdit *m_nameFilterEdit;
+ QToolButton *m_groupingButton;
+ QToolButton *m_showHideButton;
+ BtBookshelfView *m_treeView;
+
+ // Popup menus:
+ QMenu *m_contextMenu;
+ BtBookshelfGroupingMenu *m_groupingMenu;
+ QAction *m_showHideAction;
+ QMenu *m_itemContextMenu;
+ QActionGroup *m_itemActionGroup;
+ QAction *m_itemOpenAction;
+ QAction *m_itemSearchAction;
+ QMenu *m_itemEditMenu;
+ QAction *m_itemEditPlainAction;
+ QAction *m_itemEditHtmlAction;
+ QAction *m_itemUnlockAction;
+ QAction *m_itemAboutAction;
+};
+
+#endif // BTBOOKSHELFWIDGET_H
diff --git a/src/frontend/btmenuview.cpp b/src/frontend/btmenuview.cpp
index ab9fdd1..b7ce9b4 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -16,135 +16,179 @@
BtMenuView::BtMenuView(QWidget *parent)
- : QMenu(parent), m_model(0), m_actions(0)
+ : QMenu(parent), m_model(0), m_parentIndex(QModelIndex()), m_actions(0)
{
connect(this, SIGNAL(aboutToShow()),
this, SLOT(slotAboutToShow()));
connect(this, SIGNAL(aboutToHide()),
this, SLOT(slotAboutToHide()));
+ connect(this, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotActionTriggered(QAction*)));
}
BtMenuView::~BtMenuView() {
- if (m_actions != 0) {
- delete m_actions;
- }
+ delete m_actions;
}
void BtMenuView::setModel(QAbstractItemModel *model) {
m_model = model;
+ delete m_actions;
+ m_actions = 0;
+ m_indexMap.clear();
+ m_parentIndex = QModelIndex();
}
-void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parent) {
- Q_ASSERT(m_model != 0);
+void BtMenuView::setParentIndex(const QModelIndex &parentIndex) {
+ if (parentIndex.isValid() && parentIndex.model() != m_model) return;
+ m_parentIndex = parentIndex;
+}
- int children = m_model->rowCount(parent);
- for (int i = 0; i < children; i++) {
- QModelIndex child(m_model->index(i, 0, parent));
- QVariant displayData(m_model->data(child, Qt::DisplayRole));
- QVariant iconData(m_model->data(child, Qt::DecorationRole));
- QVariant toolTipData(m_model->data(child, Qt::ToolTipRole));
- QVariant statusTipData(m_model->data(child, Qt::StatusTipRole));
- QVariant whatsThisData(m_model->data(child, Qt::WhatsThisRole));
-
- if (m_model->rowCount(child) > 0) {
- QMenu *childMenu = new QMenu(parentMenu);
-
- // Set text:
- if (qVariantCanConvert<QString>(displayData)) {
- childMenu->setTitle(displayData.toString());
- }
+void BtMenuView::preBuildMenu() {
+ // Intentionally empty. Reimplement in subclass if needed.
+}
- // Set icon:
- if (qVariantCanConvert<QIcon>(iconData)) {
- childMenu->setIcon(iconData.value<QIcon>());
- }
+void BtMenuView::postBuildMenu() {
+ // Intentionally empty. Reimplement in subclass if needed.
+}
- // Set tooltip:
- if (qVariantCanConvert<QString>(toolTipData)) {
- childMenu->setToolTip(toolTipData.toString());
- }
+QAction *BtMenuView::newAction(QMenu *parentMenu, const QModelIndex &itemIndex) {
+ QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
+ QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
+ QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
+ QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
+ QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));
- // Set status tip:
- if (qVariantCanConvert<QString>(statusTipData)) {
- childMenu->setStatusTip(statusTipData.toString());
- }
+ QAction *childAction = new QAction(parentMenu);
- // Set whatsthis:
- if (qVariantCanConvert<QString>(whatsThisData)) {
- childMenu->setWhatsThis(whatsThisData.toString());
- }
+ // Set text:
+ if (qVariantCanConvert<QString>(displayData)) {
+ childAction->setText(displayData.toString());
+ }
- parentMenu->addMenu(childMenu);
- buildMenu(childMenu, child);
- } else {
- QAction *childAction = new QAction(m_actions);
+ // Set icon:
+ if (qVariantCanConvert<QIcon>(iconData)) {
+ childAction->setIcon(iconData.value<QIcon>());
+ }
- // Set text:
- if (qVariantCanConvert<QString>(displayData)) {
- childAction->setText(displayData.toString());
- }
+ // Set tooltip:
+ if (qVariantCanConvert<QString>(toolTipData)) {
+ childAction->setToolTip(toolTipData.toString());
+ }
- // Set icon:
- if (qVariantCanConvert<QIcon>(iconData)) {
- childAction->setIcon(iconData.value<QIcon>());
- }
+ // Set status tip:
+ if (qVariantCanConvert<QString>(statusTipData)) {
+ childAction->setStatusTip(statusTipData.toString());
+ }
- // Set tooltip:
- if (qVariantCanConvert<QString>(toolTipData)) {
- childAction->setToolTip(toolTipData.toString());
- }
+ // Set whatsthis:
+ if (qVariantCanConvert<QString>(whatsThisData)) {
+ childAction->setWhatsThis(whatsThisData.toString());
+ }
- // Set status tip:
- if (qVariantCanConvert<QString>(statusTipData)) {
- childAction->setStatusTip(statusTipData.toString());
- }
+ // Set checkable:
+ if (m_model->flags(itemIndex).testFlag(Qt::ItemIsUserCheckable)) {
+ childAction->setCheckable(true);
+ }
- // Set whatsthis:
- if (qVariantCanConvert<QString>(whatsThisData)) {
- childAction->setWhatsThis(whatsThisData.toString());
- }
+ // Set checked:
+ QVariant checkData(m_model->data(itemIndex, Qt::CheckStateRole));
+ bool ok;
+ Qt::CheckState state = (Qt::CheckState) checkData.toInt(&ok);
+ if (ok) {
+ childAction->setChecked(state == Qt::Checked);
+ }
- // Set checkable:
- if (m_model->flags(child).testFlag(Qt::ItemIsUserCheckable)) {
- childAction->setCheckable(true);
- }
+ return childAction;
+}
- // Set checked:
- QVariant checkData(m_model->data(child, Qt::CheckStateRole));
- bool ok;
- Qt::CheckState state = (Qt::CheckState) checkData.toInt(&ok);
- if (ok) {
- childAction->setChecked(state == Qt::Checked);
- }
+QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
+ QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
+ QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
+ QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
+ QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
+ QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));
+
+ QMenu *childMenu = new QMenu(parentMenu);
+
+ // Set text:
+ if (qVariantCanConvert<QString>(displayData)) {
+ childMenu->setTitle(displayData.toString());
+ }
+
+ // Set icon:
+ if (qVariantCanConvert<QIcon>(iconData)) {
+ childMenu->setIcon(iconData.value<QIcon>());
+ }
+
+ // Set tooltip:
+ if (qVariantCanConvert<QString>(toolTipData)) {
+ childMenu->setToolTip(toolTipData.toString());
+ }
+ // Set status tip:
+ if (qVariantCanConvert<QString>(statusTipData)) {
+ childMenu->setStatusTip(statusTipData.toString());
+ }
- // Map index
- m_indexMap[childAction] = QPersistentModelIndex(child);
+ // Set whatsthis:
+ if (qVariantCanConvert<QString>(whatsThisData)) {
+ childMenu->setWhatsThis(whatsThisData.toString());
+ }
- // Add action to action group:
- m_actions->addAction(childAction);
+ return childMenu;
+}
- // Add action to menu:
- parentMenu->addAction(childAction);
+void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parentIndex) {
+ Q_ASSERT(m_model != 0);
+ Q_ASSERT(m_actions != 0);
+
+ int children = m_model->rowCount(parentIndex);
+ for (int i = 0; i < children; i++) {
+ QModelIndex childIndex(m_model->index(i, 0, parentIndex));
+
+ if (m_model->rowCount(childIndex) > 0) {
+ QMenu *childMenu = newMenu(parentMenu, childIndex);
+
+ if (childMenu != 0) {
+ // Add to menu:
+ parentMenu->addMenu(childMenu);
+
+ // Populate the menu if not prohibited:
+ QVariant populate(childMenu->property("BtMenuView_NoPopulate"));
+ if (!populate.isValid() || populate.toBool()) {
+ buildMenu(childMenu, childIndex);
+ }
+ }
+ } else {
+ QAction *childAction = newAction(parentMenu, childIndex);
+
+ if (childAction != 0) {
+ // Map index
+ m_indexMap.insert(childAction, childIndex);
+
+ // Add action to action group:
+ childAction->setActionGroup(m_actions);
+
+ // Add action to menu:
+ parentMenu->addAction(childAction);
+ }
}
}
}
void BtMenuView::slotAboutToShow() {
- if (m_actions != 0) {
- delete m_actions;
- m_actions = 0;
- }
+ delete m_actions;
+ m_actions = 0;
m_indexMap.clear();
- if (m_model == 0) return;
+ preBuildMenu();
- m_actions = new QActionGroup(this);
- connect(m_actions, SIGNAL(triggered(QAction*)),
- this, SLOT(slotActionTriggered(QAction*)));
+ if (m_model != 0) {
+ m_actions = new QActionGroup(this);
- QModelIndex parentIndex;
- buildMenu(this, parentIndex);
+ buildMenu(this, m_parentIndex);
+ }
+ postBuildMenu();
}
void BtMenuView::slotAboutToHide() {
@@ -152,10 +196,9 @@ void BtMenuView::slotAboutToHide() {
}
void BtMenuView::slotActionTriggered(QAction *action) {
- Q_ASSERT(m_indexMap.contains(action));
+ if (!m_indexMap.contains(action)) return;
QPersistentModelIndex itemIndex(m_indexMap.value(action));
if (itemIndex.isValid()) {
emit triggered(itemIndex);
}
}
-
diff --git a/src/frontend/btmenuview.h b/src/frontend/btmenuview.h
index dc913e4..87c0d90 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -18,36 +18,127 @@
#include <QMap>
#include <QPersistentModelIndex>
+
class QAbstractItemModel;
class QActionGroup;
/**
- \warning This menu does not properly handle changes in the source model while
- being shown, so beware to check whether the index emitted by
- triggered() is valid.
+ This is a special menu, which shows the contents of an item model. The menu is repopulated
+ with data from the item model each time before its shown, and it does not in any other way
+ react to changes in the model.
+
+ The menu is built from items in the model which are below the given parent index. By
+ default this parent index is invalid. When the menu is about to show, all items directly
+ below the parent index are inserted. If a child item has children of its own it is inserted
+ as a QMenu which will be built recursively. Otherwise the child item is inserted as a
+ QAction which may be triggered by the user.
+
+ When subclassing this menu, reimplement preBuildMenu() and postBuildMenu() to add new menu
+ items before or after the menu is populated with data from the associated item model. You
+ can also reimplement newAction() and newMenu() if you further want to tune the appearance
+ or behaviour of this menu.
+
+ \warning This menu might not properly handle changes in the source model while being shown,
+ so beware to check whether the index emitted by triggered() is valid.
*/
class BtMenuView: public QMenu {
Q_OBJECT
public:
BtMenuView(QWidget *parent = 0);
- ~BtMenuView();
+ virtual ~BtMenuView();
+ /**
+ Sets or resets the data model for this menu and resets the parent index to an
+ invalid index.
+ \param[in] model Pointer to the data model to represent.
+ \warning Do not (re)set the model when the menu is being shown!
+ */
void setModel(QAbstractItemModel *model);
+
+ /**
+ Returns a pointer to the data model associated with this menu.
+ \retval 0 If this menu is not associated to any model.
+ */
inline QAbstractItemModel *model() const { return m_model; }
+ /**
+ Sets or resets the parent index for the items of the associated model, which to
+ represent. The menu will only show data items below the given index. This function
+ has no effect if the given index is valid, but does not belong to the model
+ associated with this menu.
+ \param[in] parentIndex the new parent index.
+ \warning (Re)setting the parent index will only take effect the next time the menu
+ is to be shown.
+ \warning Changing the model using setModel() will automatically reset this index.
+ */
+ void setParentIndex(const QModelIndex &parentIndex);
+
+ /**
+ Returns the parent index of the items of the assiciated model, which are to be
+ represented by this menu. By default this is an invalid index.
+ */
+ QModelIndex parentIndex() const { return m_parentIndex; }
+
signals:
+ /**
+ This signal is emitted when the user activates a menu item corresponding to an
+ index in the associated model.
+ \param index The index of the model which was activated.
+ */
void triggered(QModelIndex index);
protected:
- void buildMenu(QMenu *parentMenu, const QModelIndex &parent);
+ /**
+ This method is called by BtMenuView before populating itself with data from the
+ model. Reimplement this method to add any menus/actions to this menu before the
+ items of the menu. The default implementation does nothing.
- protected slots:
- void slotActionTriggered(QAction *action);
+ The model might be unset before this method is called. When the menu is about to be
+ shown, this allows for this method to initialize the model on request. If the model
+ is unset after this method returns, the menu is not populated with data from the
+ item model.
+ */
+ virtual void preBuildMenu();
+
+ /**
+ This method is called by BtMenuView after populating itself with data from the
+ model. If there was no model set, this method is still called after preBuildMenu().
+ Reimplement this method to add any menus/actions to this menu after the items of
+ the menu. The default implementation does nothing.
+ */
+ virtual void postBuildMenu();
+
+ /**
+ This method is called by BtMenuView to initialize an action to add to this menu. If
+ the action corresponding to the given index is not to be added to this menu, please
+ return 0.
+ \param[in] parentMenu the parent menu under which the new action is to be added.
+ \param[in] itemIndex the index of the item corresponding to the action.
+ */
+ virtual QAction *newAction(QMenu *parentMenu, const QModelIndex &itemIndex);
+
+ /**
+ This method is called by BtMenuView to initialize a menu to add to this menu. If
+ the menu corresponding to the given index is not to be added to this menu, please
+ return 0. If the menu should not be populated by BtMenuView itself, please use
+ setProperty("BtMenuView_NoPopulate", true) on the menu to be returned by this
+ method.
+ \param[in] parentMenu the parent menu under which the new menu is to be added.
+ \param[in] itemIndex the index of the item corresponding to the menu.
+ */
+ virtual QMenu *newMenu(QMenu *parentMenu, const QModelIndex &itemIndex);
+
+ private:
+ void buildMenu(QMenu *parentMenu, const QModelIndex &parentIndex);
+
+ private slots:
void slotAboutToShow();
void slotAboutToHide();
+ void slotActionTriggered(QAction *action);
protected:
QAbstractItemModel *m_model;
+ QPersistentModelIndex m_parentIndex;
QActionGroup *m_actions;
QMap<QAction *, QPersistentModelIndex> m_indexMap;
};
diff --git a/src/frontend/btmodulechooserdialog.cpp b/src/frontend/btmodulechooserdialog.cpp
new file mode 100644
index 0000000..e8f3dd0
--- /dev/null
+++ b/src/frontend/btmodulechooserdialog.cpp
@@ -0,0 +1,65 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/btmodulechooserdialog.h"
+
+#include <QDialogButtonBox>
+#include <QLabel>
+#include <QVBoxLayout>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "frontend/btaboutmoduledialog.h"
+#include "frontend/btbookshelfview.h"
+#include "frontend/btbookshelfwidget.h"
+#include "util/dialogutil.h"
+#include "util/tool.h"
+
+
+BtModuleChooserDialog::BtModuleChooserDialog(QWidget *parent, Qt::WindowFlags flags)
+ : QDialog(parent, flags)
+{
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+
+ m_captionLabel = new QLabel(this);
+ mainLayout->addWidget(m_captionLabel);
+
+ m_bookshelfWidget = new BtBookshelfWidget(this);
+ connect(m_bookshelfWidget->treeView(), SIGNAL(moduleActivated(CSwordModuleInfo*)),
+ this, SLOT(slotModuleAbout(CSwordModuleInfo*)));
+ mainLayout->addWidget(m_bookshelfWidget);
+
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok,
+ Qt::Horizontal, this);
+ connect(m_buttonBox, SIGNAL(accepted()),
+ this, SLOT(accept()));
+ connect(m_buttonBox, SIGNAL(rejected()),
+ this, SLOT(reject()));
+ mainLayout->addWidget(m_buttonBox);
+
+ setLayout(mainLayout);
+
+ retranslateUi();
+}
+
+BtModuleChooserDialog::~BtModuleChooserDialog() {
+ // Intentionally empty
+}
+
+void BtModuleChooserDialog::retranslateUi() {
+ util::prepareDialogBox(m_buttonBox);
+}
+
+void BtModuleChooserDialog::slotModuleAbout(CSwordModuleInfo *module) {
+ BTAboutModuleDialog *dialog = new BTAboutModuleDialog(module, this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose); // Destroy dialog when closed
+ dialog->show();
+ dialog->raise();
+}
diff --git a/src/frontend/btmodulechooserdialog.h b/src/frontend/btmodulechooserdialog.h
new file mode 100644
index 0000000..706088c
--- /dev/null
+++ b/src/frontend/btmodulechooserdialog.h
@@ -0,0 +1,48 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTMODULECHOOSERDIALOG_H
+#define BTMODULECHOOSERDIALOG_H
+
+#include <QDialog>
+
+#include "frontend/btbookshelfwidget.h"
+
+
+class CSwordModuleInfo;
+class QDialogButtonBox;
+class QLabel;
+
+class BtModuleChooserDialog : public QDialog {
+ Q_OBJECT
+ public:
+ virtual ~BtModuleChooserDialog();
+
+ protected:
+ explicit BtModuleChooserDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+
+ void retranslateUi();
+
+ inline QLabel *label() const { return m_captionLabel; }
+ inline BtBookshelfWidget *bookshelfWidget() const { return m_bookshelfWidget; }
+ inline QDialogButtonBox *buttonBox() const { return m_buttonBox; }
+
+ protected slots:
+ void slotModuleAbout(CSwordModuleInfo *module);
+
+ private:
+ QLabel *m_captionLabel;
+ BtBookshelfWidget *m_bookshelfWidget;
+ QDialogButtonBox *m_buttonBox;
+};
+
+#endif // BTMODULECHOOSERDIALOG_H
diff --git a/src/frontend/btmoduleindexdialog.cpp b/src/frontend/btmoduleindexdialog.cpp
new file mode 100644
index 0000000..0fa879e
--- /dev/null
+++ b/src/frontend/btmoduleindexdialog.cpp
@@ -0,0 +1,103 @@
+/*********
+*
+* 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/btmoduleindexdialog.h"
+
+#include <QApplication>
+#include <QMutexLocker>
+#include "backend/managers/cswordbackend.h"
+
+
+QMutex BtModuleIndexDialog::m_singleInstanceMutex;
+
+bool BtModuleIndexDialog::indexAllModules(
+ const QList<const CSwordModuleInfo*> &modules)
+{
+ QMutexLocker lock(&m_singleInstanceMutex);
+
+ if (modules.empty()) return true;
+
+ BtModuleIndexDialog d(modules.size());
+ d.show();
+ d.raise();
+ return d.indexAllModules2(modules);
+}
+
+BtModuleIndexDialog::BtModuleIndexDialog(int numModules)
+ : QProgressDialog(tr("Preparing to index modules..."), tr("Cancel"), 0,
+ numModules * 100, 0),
+ m_currentModuleIndex(0)
+{
+ setWindowTitle(tr("Creating indices"));
+ setModal(true);
+}
+
+bool BtModuleIndexDialog::indexAllModules2(
+ const QList<const CSwordModuleInfo*> &modules)
+{
+ bool success = true;
+
+ QList<CSwordModuleInfo *> indexedModules;
+ Q_FOREACH(const CSwordModuleInfo *cm, modules) {
+ Q_ASSERT(!cm->hasIndex());
+
+ /// \warning const_cast
+ CSwordModuleInfo *m = const_cast<CSwordModuleInfo*>(cm);
+
+ /*
+ Keep track of created indices to delete them on failure or
+ cancellation:
+ */
+ indexedModules.append(m);
+
+ connect(this, SIGNAL(canceled()),
+ m, SLOT(cancelIndexing()));
+ connect(m, SIGNAL(indexingFinished()),
+ this, SLOT(slotFinished()));
+ connect(m, SIGNAL(indexingProgress(int)),
+ this, SLOT(slotModuleProgress(int)));
+
+ // Single module indexing blocks until finished:
+ setLabelText(tr("Creating index for work: %1").arg(m->name()));
+ m->buildIndex();
+ m_currentModuleIndex++;
+
+ disconnect(this, SIGNAL(canceled()),
+ m, SLOT(cancelIndexing()));
+ disconnect(m, SIGNAL(indexingFinished()),
+ this, SLOT(slotFinished()));
+ disconnect(m, SIGNAL(indexingProgress(int)),
+ this, SLOT(slotModuleProgress(int)));
+
+ if (wasCanceled()) {
+ success = false;
+ break;
+ }
+ }
+
+ if (!success) {
+ // Delete already created indices:
+ Q_FOREACH(CSwordModuleInfo *m, indexedModules) {
+ if (m->hasIndex()) {
+ m->deleteIndex();
+ }
+ }
+ }
+ return success;
+}
+
+void BtModuleIndexDialog::slotModuleProgress(int percentage) {
+ setValue(m_currentModuleIndex * 100 + percentage);
+ qApp->processEvents();
+}
+
+void BtModuleIndexDialog::slotFinished() {
+ setValue(m_currentModuleIndex * 100 + 100);
+ qApp->processEvents();
+}
diff --git a/src/frontend/btmoduleindexdialog.h b/src/frontend/btmoduleindexdialog.h
new file mode 100644
index 0000000..29a13c4
--- /dev/null
+++ b/src/frontend/btmoduleindexdialog.h
@@ -0,0 +1,65 @@
+/*********
+*
+* 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 BTMODULEINDEXDIALOG_H
+#define BTMODULEINDEXDIALOG_H
+
+#include <QProgressDialog>
+
+#include <QMutex>
+
+
+class CSwordModuleInfo;
+
+/**
+ This dialog is used to index a list of modules and to show progress for that.
+ While the indexing is in progress it creates a blocking, top level dialog which shows the progress
+ * while the indexing is done.
+*/
+class BtModuleIndexDialog: public QProgressDialog {
+ Q_OBJECT
+ Q_DISABLE_COPY(BtModuleIndexDialog)
+
+ public: /* Methods: */
+ /**
+ Creates and shows the indexing progress dialog and starts the actual
+ indexing. It shows the dialog with progress information. In case
+ indexing some module is unsuccessful or cancelled, any indices that
+ were created for other given modules are deleted. After indexing, the
+ dialog is closed.
+ \param[in] modules The list of modules to index.
+ \pre all given modules are unindexed
+ \returns whether the indexing was finished successfully.
+ */
+ static bool indexAllModules(const QList<const CSwordModuleInfo*> &modules);
+
+ private: /* Methods: */
+ BtModuleIndexDialog(int numModules);
+
+ /**
+ Shows the indexing progress dialog and starts the actual indexing. It
+ shows the dialog with progress information. In case indexing some
+ module is unsuccessful or cancelled, any indices that were created for
+ other given modules are deleted. After indexing, the dialog is closed.
+ \param[in] modules The list of modules to index.
+ \pre all given modules are unindexed
+ \returns whether the indexing was finished successfully.
+ */
+ bool indexAllModules2(const QList<const CSwordModuleInfo*> &modules);
+
+ private slots:
+ void slotModuleProgress(int percentage);
+ void slotFinished();
+
+ private: /* Fields: */
+ static QMutex m_singleInstanceMutex;
+ int m_currentModuleIndex;
+};
+
+#endif
diff --git a/src/frontend/btopenworkaction.cpp b/src/frontend/btopenworkaction.cpp
new file mode 100644
index 0000000..9f33fc5
--- /dev/null
+++ b/src/frontend/btopenworkaction.cpp
@@ -0,0 +1,111 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/btopenworkaction.h"
+
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/btbookshelfgroupingmenu.h"
+#include "util/directory.h"
+
+
+BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey,
+ QWidget *parent)
+ : BtMenuView(parent), m_treeModel(0), m_postFilterModel(0),
+ m_groupingConfigKey(groupingConfigKey)
+{
+ // Setup models:
+ m_treeModel = new BtBookshelfTreeModel(groupingConfigKey, this);
+ m_postFilterModel = new BtBookshelfFilterModel(this);
+ m_postFilterModel->setSourceModel(m_treeModel);
+ setModel(m_postFilterModel);
+
+ m_groupingMenu = new BtBookshelfGroupingMenu(false, this);
+
+ connect(this, SIGNAL(triggered(QModelIndex)),
+ this, SLOT(slotIndexTriggered(QModelIndex)));
+ connect(m_groupingMenu, SIGNAL(signalGroupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingActionTriggered(BtBookshelfTreeModel::Grouping)));
+
+ retranslateUi();
+}
+
+BtOpenWorkActionMenu::~BtOpenWorkActionMenu() {
+ // Intentionally empty
+}
+
+void BtOpenWorkActionMenu::setSourceModel(QAbstractItemModel *model) {
+ m_treeModel->setSourceModel(model);
+}
+
+void BtOpenWorkActionMenu::retranslateUi() {
+ m_groupingMenu->setTitle(tr("&Grouping order"));
+ m_groupingMenu->setStatusTip(tr("Sets the grouping order for the items in "
+ "this menu."));
+}
+
+void BtOpenWorkActionMenu::postBuildMenu() {
+ addSeparator();
+ addMenu(m_groupingMenu);
+}
+
+void BtOpenWorkActionMenu::slotIndexTriggered(const QModelIndex &index) {
+ static const int MPR = BtBookshelfModel::ModulePointerRole;
+
+ CSwordModuleInfo *i;
+ i = static_cast<CSwordModuleInfo *>(model()->data(index, MPR).value<void*>());
+ if (i != 0) {
+ emit triggered(i);
+ }
+}
+
+void BtOpenWorkActionMenu::slotGroupingActionTriggered(const BtBookshelfTreeModel::Grouping &grouping) {
+ m_treeModel->setGroupingOrder(grouping);
+ grouping.saveTo(m_groupingConfigKey);
+}
+
+BtOpenWorkAction::BtOpenWorkAction(const QString &groupingConfigKey,
+ QObject *parent)
+ : QAction(parent)
+{
+ m_menu = new BtOpenWorkActionMenu(groupingConfigKey);
+ m_menu->setSourceModel(CSwordBackend::instance()->model());
+
+ setMenu(m_menu);
+ setIcon(util::directory::getIcon("folder-open.svg"));
+ retranslateUi();
+ slotModelChanged();
+
+ BtBookshelfFilterModel *filterModel = m_menu->postFilterModel();
+ connect(m_menu, SIGNAL(triggered(CSwordModuleInfo*)),
+ this, SIGNAL(triggered(CSwordModuleInfo*)));
+ connect(filterModel, SIGNAL(layoutChanged()),
+ this, SLOT(slotModelChanged()));
+ connect(filterModel, SIGNAL(modelReset()),
+ this, SLOT(slotModelChanged()));
+ connect(filterModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
+ this, SLOT(slotModelChanged()));
+ connect(filterModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
+ this, SLOT(slotModelChanged()));
+}
+
+BtOpenWorkAction::~BtOpenWorkAction() {
+ delete m_menu;
+}
+
+void BtOpenWorkAction::retranslateUi() {
+ setText(tr("&Open work"));
+}
+
+void BtOpenWorkAction::slotModelChanged() {
+ setEnabled(m_menu->postFilterModel()->rowCount() > 0);
+}
diff --git a/src/frontend/btopenworkaction.h b/src/frontend/btopenworkaction.h
new file mode 100644
index 0000000..6b28908
--- /dev/null
+++ b/src/frontend/btopenworkaction.h
@@ -0,0 +1,82 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTOPENWORKACTION_H
+#define BTOPENWORKACTION_H
+
+#include <QAction>
+#include "frontend/btmenuview.h"
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+
+class BtBookshelfGroupingMenu;
+class BtBookshelfTreeModel;
+class BtBookshelfFilterModel;
+class CSwordModuleInfo;
+
+class BtOpenWorkActionMenu: public BtMenuView {
+ Q_OBJECT
+ public:
+ BtOpenWorkActionMenu(const QString &groupingConfigKey,
+ QWidget *parent = 0);
+ ~BtOpenWorkActionMenu();
+
+ void setSourceModel(QAbstractItemModel *model);
+ inline QAbstractItemModel *sourceModel() const { return m_treeModel->sourceModel(); }
+ inline BtBookshelfTreeModel *treeModel() const { return m_treeModel; }
+ inline BtBookshelfFilterModel *postFilterModel() const { return m_postFilterModel; }
+
+ signals:
+ void triggered(CSwordModuleInfo *module);
+
+ private:
+ void retranslateUi();
+
+ /* Reimplemented from BtMenuView. */
+ virtual void postBuildMenu();
+
+ private slots:
+ void slotIndexTriggered(const QModelIndex &index);
+ void slotGroupingActionTriggered(const BtBookshelfTreeModel::Grouping &grouping);
+
+ private:
+ // Models:
+ BtBookshelfTreeModel *m_treeModel;
+ BtBookshelfFilterModel *m_postFilterModel;
+
+ // Grouping menu:
+ BtBookshelfGroupingMenu *m_groupingMenu;
+ const QString m_groupingConfigKey;
+};
+
+class BtOpenWorkAction: public QAction {
+ Q_OBJECT
+ public:
+ explicit BtOpenWorkAction(const QString &groupingConfigKey,
+ QObject *parent = 0);
+ ~BtOpenWorkAction();
+
+ signals:
+ void triggered(CSwordModuleInfo *module);
+
+ protected:
+ void retranslateUi();
+
+ private slots:
+ void slotModelChanged();
+
+ private:
+ BtOpenWorkActionMenu *m_menu;
+};
+
+#endif // BTOPENWORKACTION_H
diff --git a/src/frontend/cdragdrop.cpp b/src/frontend/cdragdrop.cpp
index d595162..657c83e 100644
--- a/src/frontend/cdragdrop.cpp
+++ b/src/frontend/cdragdrop.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 2007 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,6 +44,9 @@ const BookmarkItem& BTMimeData::bookmark() const {
return m_bookmarkList.first();
}
-/** Creates a new bookmark item. */
-BookmarkItem::BookmarkItem(QString module, QString key, QString description)
- : m_moduleName(module), m_key(key), m_description(description) {}
+BookmarkItem::BookmarkItem(const QString &module, const QString &key,
+ const QString &description)
+ : m_moduleName(module), m_key(key), m_description(description)
+{
+ // Intentionally empty
+}
diff --git a/src/frontend/cdragdrop.h b/src/frontend/cdragdrop.h
index 3c4481f..37b2052 100644
--- a/src/frontend/cdragdrop.h
+++ b/src/frontend/cdragdrop.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 2007 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,30 +15,36 @@
#include <QStringList>
-/** Class which represents a bookmark.
-* Includes key, module name and description, all QStrings which have getter methods.
-* Can be created only through BTMimeData object.
+/**
+ Class which represents a bookmark. Includes key, module name and description,
+ all QStrings which have getter methods. Can be created only through
+ BTMimeData object.
*/
class BookmarkItem {
+ friend class BTMimeData;
public:
/** Returns the key */
- const QString& key() const {
+ inline const QString &key() const {
return m_key;
}
/** Returns the module name */
- const QString& module() const {
+ inline const QString &module() const {
return m_moduleName;
- } ;
+ }
/** Returns the bookmark description */
- const QString& description() const {
+ inline const QString &description() const {
return m_description;
- };
+ }
+
+ protected:
+ /** Creates a new bookmark item. */
+ BookmarkItem(const QString &module, const QString &key,
+ const QString &description);
+
protected:
- friend class BTMimeData;
- BookmarkItem(QString, QString, QString);
- QString m_moduleName; //the module which is used by this item
- QString m_key; //the key of a bookmark
- QString m_description; //the description of a bookmark
+ QString m_moduleName; /**< The module which is used by this item. */
+ QString m_key; /**< The key of a bookmark. */
+ QString m_description; /**< The description of a bookmark. */
};
diff --git a/src/frontend/cexportmanager.cpp b/src/frontend/cexportmanager.cpp
index 008963a..eaa0894 100644
--- a/src/frontend/cexportmanager.cpp
+++ b/src/frontend/cexportmanager.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/cexportmanager.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QApplication>
#include <QClipboard>
#include <QFileDialog>
@@ -35,7 +35,12 @@
using namespace Rendering;
using namespace Printing;
-CExportManager::CExportManager(const QString& caption, const bool showProgress, const QString& progressLabel, const CSwordBackend::FilterOptions filterOptions, const CSwordBackend::DisplayOptions displayOptions) {
+CExportManager::CExportManager(const QString &caption,
+ const bool showProgress,
+ const QString &progressLabel,
+ const FilterOptions &filterOptions,
+ const DisplayOptions &displayOptions)
+{
m_caption = !caption.isEmpty() ? caption : QString::fromLatin1("BibleTime");
m_progressLabel = progressLabel;
m_filterOptions = filterOptions;
@@ -56,7 +61,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
return false;
}
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -65,7 +70,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -75,7 +80,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
QString startKey;
QString stopKey;
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
modules.append(key->module());
CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
@@ -94,8 +99,14 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
return false;
}
-bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) {
- if (!list->Count())
+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())
return false;
const QString filename = getSaveFileName(format);
@@ -103,7 +114,7 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module,
return false;
}
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -112,7 +123,7 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module,
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -120,16 +131,16 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module,
CTextRendering::KeyTree tree;
- setProgressRange(list->Count());
+ setProgressRange(list.Count());
CTextRendering::KeyTreeItem::Settings itemSettings;
itemSettings.highlight = false;
- *list = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
+ list.setPosition(sword::TOP);
+ while (!list.Error() && !progressWasCancelled()) {
+ tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
incProgress();
- (*list)++;
+ list.increment();
}
const QString text = render->renderKeyTree(tree);
@@ -142,7 +153,10 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module,
return false;
}
-bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) {
+bool CExportManager::saveKeyList(const QList<CSwordKey*> &list,
+ Format format,
+ bool addText)
+{
if (!list.count())
return false;
@@ -151,7 +165,7 @@ bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, c
return false;
}
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -160,7 +174,7 @@ bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, c
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -197,7 +211,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
return false;
}
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -206,7 +220,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -216,7 +230,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
QString startKey;
QString stopKey;
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
modules.append(key->module());
CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
@@ -235,11 +249,16 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
return true;
}
-bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) {
- if (!list->Count())
+bool CExportManager::copyKeyList(const sword::ListKey &l,
+ const CSwordModuleInfo *module,
+ Format format,
+ bool addText)
+{
+ sword::ListKey list = l;
+ if (!list.Count())
return false;
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -248,7 +267,7 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module,
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -258,11 +277,11 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module,
CTextRendering::KeyTreeItem::Settings itemSettings;
itemSettings.highlight = false;
- *list = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) );
+ list.setPosition(sword::TOP);
+ while (!list.Error() && !progressWasCancelled()) {
+ tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
- (*list)++;
+ list.increment();
}
const QString text = render->renderKeyTree(tree);
@@ -271,11 +290,14 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module,
}
-bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) {
+bool CExportManager::copyKeyList(const QList<CSwordKey*> &list,
+ Format format,
+ bool addText)
+{
if (!list.count())
return false;
- CSwordBackend::FilterOptions filterOptions = m_filterOptions;
+ FilterOptions filterOptions = m_filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -284,7 +306,7 @@ bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, c
filterOptions.textualVariants = false;
CHTMLExportRendering::Settings settings(addText);
- boost::scoped_ptr<CTextRendering> render (
+ QSharedPointer<CTextRendering> render (
(format == HTML)
? new CHTMLExportRendering(settings, m_displayOptions, filterOptions)
: new CPlainTextExportRendering(settings, m_displayOptions, filterOptions)
@@ -310,31 +332,42 @@ bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, c
return true;
}
-bool CExportManager::printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+bool CExportManager::printKeyList(const sword::ListKey &l,
+ 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;
QString startKey, stopKey;
- setProgressRange(list->Count());
-
- (*list) = sword::TOP;
- while (!list->Error() && !progressWasCancelled()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(list);
- if (vk) {
- startKey = QString::fromUtf8((const char*)(vk->LowerBound()) );
- stopKey = QString::fromUtf8((const char*)(vk->UpperBound()) );
- tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
+ setProgressRange(list.Count());
+
+ list.setPosition(sword::TOP);
+ while (!list.Error() && !progressWasCancelled()) {
+ if (dynamic_cast<const sword::VerseKey&>(l) != 0) {
+ const sword::VerseKey &vk = static_cast<const sword::VerseKey&>(l);
+ startKey = QString::fromUtf8((const char*) vk.LowerBound());
+ stopKey = QString::fromUtf8((const char*) vk.UpperBound());
+ tree.append(new CTextRendering::KeyTreeItem(startKey,
+ stopKey,
+ module,
+ settings));
}
else {
startKey = QString::fromUtf8((const char*) * list);
- tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
+ tree.append(new CTextRendering::KeyTreeItem(startKey,
+ module,
+ settings));
}
- (*list)++;
+ list.increment();
incProgress();
}
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
if (!progressWasCancelled()) {
printer->printKeyTree(tree);
@@ -345,7 +378,12 @@ bool CExportManager::printKeyList(sword::ListKey* list, CSwordModuleInfo* module
return false;
}
-bool CExportManager::printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) {
+bool CExportManager::printKey(const CSwordModuleInfo *module,
+ const QString &startKey,
+ const QString &stopKey,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
CPrinter::KeyTreeItem::Settings settings;
settings.keyRenderingFace =
displayOptions.verseNumbers
@@ -360,12 +398,15 @@ bool CExportManager::printKey( CSwordModuleInfo* module, const QString& startKey
tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) );
}
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
printer->printKeyTree(tree);
return true;
}
-bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+bool CExportManager::printKey(const CSwordKey *key,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
CPrinter::KeyTreeItem::Settings settings;
settings.keyRenderingFace =
displayOptions.verseNumbers
@@ -375,13 +416,15 @@ bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions dis
CPrinter::KeyTree tree;
tree.append( new CPrinter::KeyTreeItem(key->key(), key->module(), settings) );
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
printer->printKeyTree(tree);
return true;
}
-/** Prints a key using the hyperlink created by CReferenceManager. */
-bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) {
+bool CExportManager::printByHyperlink(const QString &hyperlink,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
QString moduleName;
QString keyName;
ReferenceManager::Type type;
@@ -398,7 +441,7 @@ bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::
? CPrinter::KeyTreeItem::Settings::SimpleKey
: CPrinter::KeyTreeItem::Settings::NoKey;
- CSwordModuleInfo* module = backend()->findModuleByName(moduleName);
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(moduleName);
Q_ASSERT(module);
if (module) {
@@ -426,12 +469,16 @@ bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::
}
}
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
printer->printKeyTree(tree);
return true;
}
-bool CExportManager::printKeyList(const QStringList& list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+bool CExportManager::printKeyList(const QStringList &list,
+ const CSwordModuleInfo *module,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
CPrinter::KeyTreeItem::Settings settings;
settings.keyRenderingFace =
displayOptions.verseNumbers
@@ -447,7 +494,7 @@ bool CExportManager::printKeyList(const QStringList& list, CSwordModuleInfo* mod
incProgress();
}
- boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
+ QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions));
if (!progressWasCancelled()) {
printer->printKeyTree(tree);
@@ -475,14 +522,6 @@ const QString CExportManager::getSaveFileName(const Format format) {
return QFileDialog::getSaveFileName(0, QObject::tr("Save file"), "", filterString(format), 0);
}
-/** Returns a string containing the linebreak for the current format. */
-const QString CExportManager::lineBreak(const Format format) {
- if (static_cast<bool>(m_displayOptions.lineBreaks))
- return (format == HTML) ? QString::fromLatin1("<br/>\n") : QString::fromLatin1("\n");
-
- return QString::null;
-}
-
/** No descriptions */
void CExportManager::setProgressRange( const int items ) {
if (QProgressDialog* dlg = progressDialog()) {
diff --git a/src/frontend/cexportmanager.h b/src/frontend/cexportmanager.h
index ee8c2c4..d2a185d 100644
--- a/src/frontend/cexportmanager.h
+++ b/src/frontend/cexportmanager.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,13 +10,10 @@
#ifndef CEXPORTMANAGER_H
#define CEXPORTMANAGER_H
-#include "util/cpointers.h"
-
#include <QList>
#include <QString>
#include "backend/config/cbtconfig.h"
-#include "backend/managers/cswordbackend.h"
-
+#include "btglobal.h"
class CSwordKey;
class CSwordModuleInfo;
@@ -26,7 +23,7 @@ class QProgressDialog;
/** Contains the functions to export text to disk, clipboard or printer.
* @author The BibleTime team
*/
-class CExportManager : CPointers {
+class CExportManager {
public:
/** The format the export actions should have
*/
@@ -35,21 +32,60 @@ class CExportManager : CPointers {
Text
};
- CExportManager(const QString& caption, const bool showProgress = true, const QString& progressLabel = QString::null, const CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults(), const CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults());
+ CExportManager(const QString &caption,
+ const bool showProgress = true,
+ const QString &progressLabel = QString::null,
+ const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults(),
+ const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults());
bool saveKey(CSwordKey* key, const Format format, const bool addText);
- bool saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
- bool saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
+
+ bool saveKeyList(const sword::ListKey &list,
+ const CSwordModuleInfo *module,
+ Format format,
+ bool addText);
+
+ bool saveKeyList(const QList<CSwordKey*> &list,
+ Format format,
+ const bool addText );
bool copyKey(CSwordKey* key, const Format format, const bool addText);
- bool copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText);
- bool copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText );
- bool printKey(CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
- bool printByHyperlink(const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- bool printKeyList(const QStringList& list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ bool copyKeyList(const sword::ListKey &list,
+ const CSwordModuleInfo *module,
+ Format format,
+ bool addText);
+
+ bool copyKeyList(const QList<CSwordKey*> &list,
+ Format format,
+ bool addText);
+
+ bool printKey(const CSwordKey *key,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ bool printKey(const CSwordModuleInfo *module,
+ const QString &startKey,
+ const QString &stopKey,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ /**
+ Prints a key using the hyperlink created by CReferenceManager.
+ */
+ bool printByHyperlink(const QString &hyperlink,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ bool printKeyList(const sword::ListKey &list,
+ const CSwordModuleInfo *module,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ bool printKeyList(const QStringList &list,
+ const CSwordModuleInfo *module,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
protected: // Protected methods
/**
@@ -60,17 +96,13 @@ class CExportManager : CPointers {
* Returns a filename to save a file.
*/
const QString getSaveFileName(const Format format);
- /**
- * Returns a string containing the linebreak for the current format.
- */
- const QString lineBreak( const Format format );
private:
QString m_caption; ///< \todo Useless field
QString m_progressLabel;
bool m_showProgress;
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
+ FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
QProgressDialog* m_progressDialog;
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index 474eacd..19323fc 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/cinfodisplay.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QAction>
#include <QDebug>
#include <QLabel>
@@ -18,6 +18,7 @@
#include <QSize>
#include <QVBoxLayout>
#include <QtAlgorithms>
+#include <QMenu>
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
@@ -47,9 +48,18 @@ CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
m_htmlPart->setMouseTracking(false); //we don't want strong/lemma/note mouse infos
m_htmlPart->view()->setAcceptDrops(false);
- m_copyAction = new QAction(tr("Copy"), this);
- m_copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
- QObject::connect(m_copyAction, SIGNAL(triggered()), m_htmlPart->connectionsProxy(), SLOT(copySelection()) );
+ QAction* selectAllAction = new QAction(QIcon(), tr("Select all"), this);
+ selectAllAction->setShortcut(QKeySequence::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()) );
+
+ QMenu* menu = new QMenu();
+ menu->addAction(selectAllAction);
+ menu->addAction(copyAction);
+ m_htmlPart->installPopup(menu);
connect(
m_htmlPart->connectionsProxy(),
@@ -59,7 +69,7 @@ CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
layout->addWidget(m_htmlPart->view());
- CDisplayTemplateMgr *mgr(CPointers::displayTemplateManager());
+ CDisplayTemplateMgr *mgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
QString divText("<div class=\"infodisplay\">%1</div>");
@@ -78,20 +88,19 @@ CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
CInfoDisplay::~CInfoDisplay() {
- delete m_copyAction;
}
void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) {
qDebug() << "CInfoDisplay::lookup";
qDebug() << mod_name << key_text;
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName(mod_name);
+ CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName(mod_name);
Q_ASSERT(m);
if (!m)
return;
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(m) );
- key->key( key_text );
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(m) );
+ key->setKey(key_text);
- CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *mgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
@@ -163,7 +172,7 @@ void CInfoDisplay::setInfo(const ListInfoData& list) {
};
}
- CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *mgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
// settings.langAbbrev = "";
@@ -175,6 +184,9 @@ void CInfoDisplay::setInfo(const ListInfoData& list) {
m_htmlPart->setText(content);
}
+void CInfoDisplay::selectAll() {
+ m_htmlPart->selectAll();
+}
const QString CInfoDisplay::decodeAbbreviation( const QString& data ) {
// QStringList strongs = QStringList::split("|", data);
@@ -199,11 +211,11 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
// qWarning("setting crossref %s", data.latin1());
- CSwordBackend::DisplayOptions dispOpts;
+ DisplayOptions dispOpts;
dispOpts.lineBreaks = false;
dispOpts.verseNumbers = true;
- CSwordBackend::FilterOptions filterOpts;
+ FilterOptions filterOpts;
filterOpts.headings = false;
filterOpts.strongNumbers = false;
filterOpts.morphTags = false;
@@ -228,7 +240,7 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
if (pos > 0) {
const QString moduleName = data.left(pos);
// qWarning("found module %s", moduleName.latin1());
- module = CPointers::backend()->findModuleByName(moduleName);
+ module = CSwordBackend::instance()->findModuleByName(moduleName);
if (!module) {
module = CBTConfig::get(CBTConfig::standardBible);
}
@@ -300,8 +312,8 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
}
/*!
- \fn CInfoDisplay::decodeFootnote( const QString& data )
- */
+ \fn CInfoDisplay::decodeFootnote( const QString& data )
+ */
const QString CInfoDisplay::decodeFootnote( const QString& data ) {
QStringList list = data.split("/");
Q_ASSERT(list.count() >= 3);
@@ -309,7 +321,7 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
return QString::null;
}
- CSwordBackend::FilterOptions filterOpts;
+ FilterOptions filterOpts;
filterOpts.headings = false;
filterOpts.strongNumbers = false;
filterOpts.morphTags = false;
@@ -318,7 +330,7 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
// turn scripRefs off, so that they do not show up as footnotes in the OSIS filter's EntryAttributes
filterOpts.scriptureReferences = false;
- CPointers::backend()->setFilterOptions(filterOpts);
+ CSwordBackend::instance()->setFilterOptions(filterOpts);
const QString modulename = list.first();
const QString swordFootnote = list.last();
@@ -328,13 +340,13 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
list.pop_front();
const QString keyname = list.join("/");
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(modulename);
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(modulename);
if (!module) {
return QString::null;
}
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key(keyname);
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey(keyname);
key->renderedText(CSwordKey::ProcessEntryAttributesOnly); //force entryAttributes
const char* note =
@@ -369,8 +381,8 @@ const QString CInfoDisplay::decodeStrongs( const QString& data ) {
QString text;
if (module) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( (*it).mid(1) ); //skip H or G (language sign), will have to change later if we have better modules
+ 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();
}
//if the module could not be found just display an empty lemma info
@@ -405,7 +417,7 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
if (valStart > -1) {
valueClass = morph.mid(0, valStart);
//qDebug() << "valueClass: " << valueClass;
- module = CPointers::backend()->findModuleByName( valueClass );
+ module = CSwordBackend::instance()->findModuleByName( valueClass );
}
value = morph.mid(valStart + 1); //works for prepended module and without (-1 +1 == 0).
@@ -443,15 +455,15 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
QString text;
//Q_ASSERT(module);
if (module) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
//skip H or G (language sign) if we have to skip it
- const bool isOk = key->key( skipFirstChar ? value.mid(1) : value );
+ 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->module(CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon));
- key->key( skipFirstChar ? value.mid(1) : value );
+ key->setModule(CBTConfig::get
+ (CBTConfig::standardHebrewMorphLexicon));
+ key->setKey(skipFirstChar ? value.mid(1) : value);
}
text = key->renderedText();
@@ -479,8 +491,8 @@ const QString CInfoDisplay::getWordTranslation( const QString& data ) {
return QString::null;
}
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( data );
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey(data);
if (key->key().toUpper() != data.toUpper()) { //key not present in the lexicon
return QString::null;
}
@@ -494,12 +506,8 @@ const QString CInfoDisplay::getWordTranslation( const QString& data ) {
return ret;
}
-
-/*!
- \fn CInfoDisplay::clearInfo()
- */
void CInfoDisplay::clearInfo() {
- CDisplayTemplateMgr* tmgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *tmgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
diff --git a/src/frontend/cinfodisplay.h b/src/frontend/cinfodisplay.h
index 61c9eaf..17c36a5 100644
--- a/src/frontend/cinfodisplay.h
+++ b/src/frontend/cinfodisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -58,10 +58,10 @@ class CInfoDisplay : public QWidget {
protected slots:
void lookupInfo(const QString &, const QString &);
+ void selectAll();
private:
CReadDisplay* m_htmlPart;
- QAction* m_copyAction;
};
} //end of InfoDisplay namespace
diff --git a/src/frontend/cinputdialog.cpp b/src/frontend/cinputdialog.cpp
deleted file mode 100644
index 5833965..0000000
--- a/src/frontend/cinputdialog.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/cinputdialog.h"
-
-#include <QDebug>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QVBoxLayout>
-#include <QWidget>
-#include "util/dialogutil.h"
-
-
-CInputDialog::CInputDialog
-(const QString& caption, const QString& description, const QString& text, QWidget *parent, Qt::WindowFlags wflags )
- : QDialog(parent, wflags) {
- QVBoxLayout *vboxLayout;
- QLabel *label;
- QHBoxLayout *hboxLayout;
- QPushButton *clearButton;
- QSpacerItem *spacerItem;
- QDialogButtonBox *buttonBox;
-
- setWindowTitle(caption);
-
- resize(400, 300);
- vboxLayout = new QVBoxLayout(this);
- label = new QLabel(description, this);
- vboxLayout->addWidget(label);
-
- m_textEdit = new QTextEdit(this);
- vboxLayout->addWidget(m_textEdit);
- m_textEdit->setWordWrapMode( QTextOption::WordWrap );
- m_textEdit->setText(text);
- if (!text.isEmpty())
- m_textEdit->selectAll();
-
- hboxLayout = new QHBoxLayout();
- clearButton = new QPushButton(this);
- clearButton->setText(tr("Clear"));
- hboxLayout->addWidget(clearButton);
- spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hboxLayout->addItem(spacerItem);
- buttonBox = new QDialogButtonBox(this);
- buttonBox->setOrientation(Qt::Horizontal);
- buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
- hboxLayout->addWidget(buttonBox);
-
- vboxLayout->addLayout(hboxLayout);
-
- QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- QObject::connect(clearButton, SIGNAL(clicked()), m_textEdit, SLOT(clear()));
-
- m_textEdit->setFocus();
-}
-
-/** Returns the text entered at the moment. */
-const QString CInputDialog::text() {
- return m_textEdit->toPlainText();
-}
-
-/** A static function to get some using CInputDialog. */
-const QString CInputDialog::getText
-( const QString& caption, const QString& description, const QString& text, bool* ok, QWidget* parent, Qt::WindowFlags wflags) {
- CInputDialog* dlg = new CInputDialog(caption, description, text, parent, wflags);
-
- QString ret = QString::null;
- *ok = (dlg->exec() == QDialog::Accepted) ? true : false;
- if (*ok) {
- //qDebug() << "dialog was accepted, return text: " << dlg->text();
- ret = dlg->text();
- }
-
- delete dlg;
- return ret;
-}
diff --git a/src/frontend/cinputdialog.h b/src/frontend/cinputdialog.h
deleted file mode 100644
index 153c14e..0000000
--- a/src/frontend/cinputdialog.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CINPUTDIALOG_H
-#define CINPUTDIALOG_H
-
-#include <QDialog>
-
-
-class QTextEdit;
-class QWidget;
-
-/** This is a small input dialog with
- * a multiline edit for the text input.
- * @author The BibleTime team
- */
-class CInputDialog : public QDialog {
- Q_OBJECT
- public:
- CInputDialog(const QString& caption, const QString& description, const QString& text, QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- /**
- * A static function to get some using CInputDialog.
- */
- static const QString getText( const QString& caption, const QString& description, const QString& text = QString::null, bool* ok = 0, QWidget* parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- /**
- * Returns the text entered at the moment.
- */
- const QString text();
- // ~CInputDialog();
-
- private:
- QTextEdit* m_textEdit;
-};
-
-#endif
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index c499962..cfdb6ee 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -2,25 +2,39 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bibletime.h"
#include "frontend/cmdiarea.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include <QEvent>
#include <QMdiSubWindow>
#include <QTimer>
+#include <QToolBar>
#include <QWindowStateChangeEvent>
#include <QMenu>
CMDIArea::CMDIArea(BibleTime *parent)
- : QMdiArea(parent), m_mdiArrangementMode(ArrangementModeManual) {
+ : QMdiArea(parent), m_mdiArrangementMode(ArrangementModeManual), m_activeWindow(0), m_bibleTime(parent) {
Q_ASSERT(parent != 0);
+ #if QT_VERSION >= 0x040500
+ // Set document-style tabs (for Mac):
+ setDocumentMode(true);
+ #endif
+
+ /*
+ Activate windows based on the history of activation, e.g. when one has window A
+ activated, and activates window B and then closes window B, then window A is activated.
+ */
+ setActivationOrder(QMdiArea::ActivationHistoryOrder);
+
+ // Show scrollbars only when needed:
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@@ -30,21 +44,24 @@ CMDIArea::CMDIArea(BibleTime *parent)
static const int moveSize = 30;
-QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
- QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
- subWindow->installEventFilter(this);
-
- // Change Qt QMdiSubWindow Close action to have no shortcut
+void CMDIArea::fixSystemMenu(QMdiSubWindow* subWindow) {
+ // Change Qt QMdiSubWindow Close action to have no shortcuts
// This makes our closeWindow actions with Ctrl-W work correctly
QList<QAction*> actions = subWindow->systemMenu()->actions();
for (int i=0; i<actions.count(); i++) {
QAction* action = actions.at(i);
QString text = action->text();
if (text.contains("Close")) {
- action->setShortcut(QKeySequence());
+ action->setShortcuts(QList<QKeySequence>());
break;
}
}
+}
+
+QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
+ QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
+ subWindow->installEventFilter(this);
+ fixSystemMenu(subWindow);
// Manual arrangement mode
enableWindowMinMaxFlags(true);
@@ -84,13 +101,29 @@ QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFl
void CMDIArea::setMDIArrangementMode( const MDIArrangementMode newArrangementMode ) {
m_mdiArrangementMode = newArrangementMode;
- triggerWindowUpdate();
+ switch (m_mdiArrangementMode) {
+ case ArrangementModeManual:
+ setViewMode(QMdiArea::SubWindowView);
+ break;
+ case ArrangementModeTile:
+ setViewMode(QMdiArea::SubWindowView);
+ tileSubWindows();
+ break;
+ case ArrangementModeTabbed:
+ setViewMode(QMdiArea::TabbedView);
+ break;
+ default:
+ setViewMode(QMdiArea::SubWindowView);
+ triggerWindowUpdate();
+ break;
+ }
}
void CMDIArea::myTileVertical() {
if (!updatesEnabled() || !usableWindowList().count() ) {
return;
}
+ setViewMode(QMdiArea::SubWindowView);
QList<QMdiSubWindow*> windows = usableWindowList();
setUpdatesEnabled(false);
@@ -117,6 +150,7 @@ void CMDIArea::myTileHorizontal() {
if (!updatesEnabled() || !usableWindowList().count() ) {
return;
}
+ setViewMode(QMdiArea::SubWindowView);
QList<QMdiSubWindow*> windows = usableWindowList();
setUpdatesEnabled(false);
@@ -138,10 +172,12 @@ void CMDIArea::myTileHorizontal() {
emitWindowCaptionChanged();
}
+// Tile the windows, tiling implemented by Qt
void CMDIArea::myTile() {
if (!updatesEnabled() || !usableWindowList().count() ) {
return;
}
+ setViewMode(QMdiArea::SubWindowView);
tileSubWindows();
emitWindowCaptionChanged();
}
@@ -150,6 +186,7 @@ void CMDIArea::myCascade() {
if (!updatesEnabled() || !usableWindowList().count() ) {
return;
}
+ setViewMode(QMdiArea::SubWindowView);
QList<QMdiSubWindow*> windows = usableWindowList();
@@ -193,7 +230,7 @@ void CMDIArea::emitWindowCaptionChanged() {
emit sigSetToplevelCaption(activeSubWindow()->windowTitle());
}
else {
- emit sigSetToplevelCaption(QString());
+ emit sigSetToplevelCaption(QString::null);
}
}
@@ -211,22 +248,34 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() {
}
void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
- if (!client || !updatesEnabled()) {
+ if (subWindowList().count() == 0)
+ m_bibleTime->clearMdiToolBars();
+
+ if (!client) {
return;
}
emit sigSetToplevelCaption( client->windowTitle().trimmed() );
+
+ // Notify child window it is active
+ CDisplayWindow* activeWindow = qobject_cast<CDisplayWindow*>(client->widget());
+ if (activeWindow != 0 && activeWindow != m_activeWindow) {
+ m_activeWindow = activeWindow;
+ activeWindow->windowActivated();
+ }
}
void CMDIArea::resizeEvent(QResizeEvent* e) {
/*
- Do not call QMdiArea::resizeEvent(e) unless we are in manual arrangement
- mode, since this would mess up our layout. The manual arrangement mode
- should be handled exactly as in QMdiArea.
+ Do not call QMdiArea::resizeEvent(e) if we are in manual arrangement
+ mode, since this would mess up our layout. Also, don't call it for the
+ automatic arrangement modes that we implement. Call it only for those
+ modes implemented by Qt
*/
- if (m_mdiArrangementMode == ArrangementModeManual) {
+ if (m_mdiArrangementMode == ArrangementModeTabbed) {
QMdiArea::resizeEvent(e);
}
else if (updatesEnabled()) {
+ // Handle resize for automatic modes that we implement
triggerWindowUpdate();
}
}
@@ -236,7 +285,8 @@ bool CMDIArea::eventFilter(QObject *o, QEvent *e) {
QMdiSubWindow *w(qobject_cast<QMdiSubWindow*>(o));
// Let the event be handled by other filters:
- if (w == 0) return QMdiArea::eventFilter(o, e);
+ if (w == 0)
+ return QMdiArea::eventFilter(o, e);
switch (e->type()) {
case QEvent::WindowStateChange: {
@@ -268,6 +318,7 @@ bool CMDIArea::eventFilter(QObject *o, QEvent *e) {
if (o == activeSubWindow()) {
emit sigSetToplevelCaption(w->windowTitle());
}
+ return QMdiArea::eventFilter(o, e);
break;
default:
break;
@@ -285,12 +336,12 @@ void CMDIArea::triggerWindowUpdate() {
case ArrangementModeTileHorizontal:
QTimer::singleShot(0, this, SLOT(myTileHorizontal()));
break;
- case ArrangementModeCascade:
- QTimer::singleShot(0, this, SLOT(myCascade()));
- break;
case ArrangementModeTile:
QTimer::singleShot(0, this, SLOT(myTile()));
break;
+ case ArrangementModeCascade:
+ QTimer::singleShot(0, this, SLOT(myCascade()));
+ break;
default:
break;
}
@@ -310,8 +361,6 @@ void CMDIArea::enableWindowMinMaxFlags(bool enable)
flags &= ~Qt::WindowMaximizeButtonHint;
}
subWindow->setWindowFlags(flags);
- subWindow->hide();
- subWindow->show();
}
}
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 858d0d4..9a62370 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +16,7 @@
class BibleTime;
class CSwordModuleInfo;
+class CDisplayWindow;
/**
A custom MDI area widget.
@@ -33,7 +34,8 @@ class CMDIArea: public QMdiArea {
ArrangementModeTileHorizontal = 2,
ArrangementModeCascade = 3,
ArrangementModeManual = 4,
- ArrangementModeTile = 5
+ ArrangementModeTile = 5,
+ ArrangementModeTabbed = 6
};
/**
@@ -69,7 +71,7 @@ class CMDIArea: public QMdiArea {
*/
QList<QMdiSubWindow*> usableWindowList();
- /**
+ /**
Show or hide the sub-window min/max buttons.
*/
void enableWindowMinMaxFlags(bool enable);
@@ -82,6 +84,7 @@ class CMDIArea: public QMdiArea {
arranging the subwindows into a tile automatically.
*/
void myTile();
+
/**
Our own cascade version which, if only one subwindow is left, shows it
maximized.
@@ -111,7 +114,7 @@ class CMDIArea: public QMdiArea {
signals:
/**
- * Emits a signal to set the acption of the toplevel widget.
+ * Emits a signal to set the caption of the toplevel widget.
*/
void sigSetToplevelCaption(const QString&);
@@ -129,6 +132,7 @@ class CMDIArea: public QMdiArea {
bool eventFilter(QObject *o, QEvent *e);
void emitWindowCaptionChanged();
+ void fixSystemMenu(QMdiSubWindow* subWindow);
protected slots:
/**
@@ -138,6 +142,10 @@ class CMDIArea: public QMdiArea {
protected:
MDIArrangementMode m_mdiArrangementMode;
+
+ private:
+ CDisplayWindow* m_activeWindow;
+ BibleTime* m_bibleTime;
};
#endif
diff --git a/src/frontend/cmodulechooserdialog.cpp b/src/frontend/cmodulechooserdialog.cpp
deleted file mode 100644
index d2d7505..0000000
--- a/src/frontend/cmodulechooserdialog.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/cmodulechooserdialog.h"
-
-#include <QButtonGroup>
-#include <QDebug>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QSpacerItem>
-#include <QStringList>
-#include <QTreeWidget>
-#include <QVBoxLayout>
-#include "backend/btmoduletreeitem.h"
-#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/tool.h"
-#include "util/dialogutil.h"
-#include "util/directory.h"
-
-
-CModuleChooserDialog::CModuleChooserDialog( QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules)
- : QDialog(parent),
- m_title(title),
- m_labelText(label) {
- m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
- m_filters = QList<BTModuleTreeItem::Filter*>();
- if (!allModules) {
- m_moduleList = CPointers::backend()->moduleList();
- }
- else m_moduleList = *allModules;
-}
-
-/**
-* Call init() after the constructor, either in the end of your own constructor or from outside.
-*/
-void CModuleChooserDialog::init() {
- //Set the flag to destroy when closed - otherwise eats memory
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(m_title);
- initView();
- initTree();
-}
-
-/** Initializes the view of this dialog */
-void CModuleChooserDialog::initView() {
- /// \todo choose the button text?
-
- QVBoxLayout *vboxLayout;
- QHBoxLayout *hboxLayout;
- QSpacerItem *spacerItem;
-
- vboxLayout = new QVBoxLayout(this);
-
- QLabel* label = util::tool::explanationLabel(this, QString::null, m_labelText);
- vboxLayout->addWidget(label);
-
- m_moduleChooser = new QTreeWidget(this);
- m_moduleChooser->header()->hide();
-
- vboxLayout->addWidget(m_moduleChooser);
-
- hboxLayout = new QHBoxLayout();
-
- spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hboxLayout->addItem(spacerItem);
-
- m_buttonBox = new QDialogButtonBox(this);
- m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
- util::prepareDialogBox(m_buttonBox);
- hboxLayout->addWidget(m_buttonBox);
-
- vboxLayout->addLayout(hboxLayout);
-
- QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()) );
- //The QDialog doc is a bit unclear but calling reject also destroys the dialog
- // in this situation.
- QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
-}
-
-
-void CModuleChooserDialog::initTree() {
- //qDebug() << "CModuleChooserDialog::initTree";
-
- // See BTModuleTreeItem documentation.
- BTModuleTreeItem root(m_filters, m_grouping, &m_moduleList);
- createModuleTree(&root, m_moduleChooser->invisibleRootItem());
-
-}
-
-void CModuleChooserDialog::createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
- foreach (BTModuleTreeItem* i, item->children()) {
- createModuleTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- initModuleItem(item, widgetItem);
- }
- }
-}
-
-
-/** Emits the signal with the list of the selected modules. */
-void CModuleChooserDialog::slotOk() {
- Q_ASSERT(m_moduleChooser);
- //create the list of selected modules
- QList<CSwordModuleInfo*> mods;
- QTreeWidgetItemIterator it( m_moduleChooser );
- for ( ; *it; ++it ) {
- //add the module to list if the box is checked
- if ((*it)->checkState(0) == Qt::Checked) {
- qDebug() << "was checked";
- for (QList<CSwordModuleInfo*>::iterator all_iter(m_moduleList.begin()); all_iter != m_moduleList.end(); ++all_iter) {
- if ((*all_iter)->name() == (*it)->text(0)) {
- qDebug() << "append";
- mods.append(*all_iter);
- break;
- }
- }
-
- }
- }
-
- // The selection is handled first, then the dialog is closed and destroyed.
- emit modulesChanged(mods, m_moduleChooser);
- QDialog::done(QDialog::Accepted);
-}
-
-QPushButton* CModuleChooserDialog::okButton() {
- return m_buttonBox->button(QDialogButtonBox::Ok);
-}
diff --git a/src/frontend/cmodulechooserdialog.h b/src/frontend/cmodulechooserdialog.h
deleted file mode 100644
index e74d743..0000000
--- a/src/frontend/cmodulechooserdialog.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2007 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CMODULECHOOSERDIALOG_H
-#define CMODULECHOOSERDIALOG_H
-
-#include <QDialog>
-
-#include "backend/btmoduletreeitem.h"
-#include <QList>
-#include <QTreeWidget>
-
-
-class CSwordModuleInfo;
-class QDialogButtonBox;
-
-/**
-* Abstract dialog which lets the user select modules with checkboxes.
-* The dialog will be destroyed after closing. Connect the modulesChanged() signal
-* to handle the selection before the dialog is destroyed.
-*/
-class CModuleChooserDialog : public QDialog {
- Q_OBJECT
- public:
-
- /**
- * Use your own constructor to set extra members.
- * Filters list is given to the module tree creator, see BTModuleTreeItem.
- * For module list see BTModuleTreeItem constructor documentation.
- * Call init() after the constructor, either in the end of your own constructor or from outside.
- */
- CModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules = 0);
-
- virtual ~CModuleChooserDialog() {}
-
- /** Call this after/from the constructor.*/
- void init();
-
- /** Set the module tree grouping.
- * Initially it's taken from the CBTConfig so it needs to be set only if that default is not adequate.
- * This must be called before the tree is initialized, i.e. before init().
- */
- void setGrouping(BTModuleTreeItem::Grouping grouping) {
- m_grouping = grouping;
- }
-
- /** Set the module tree filters. See setGrouping() for the calling convention and
- * BTModuleTreeItem for the filters. By default the filters list is empty.
- */
- void setFilters(QList<BTModuleTreeItem::Filter*> filters) {
- m_filters = filters;
- }
-
- QTreeWidget* treeWidget() {
- return m_moduleChooser;
- }
-
- QPushButton* okButton();
-
- signals:
-
- /** The signal is sent when the OK button is clicked. The list includes the selected (checked) modules. The tree widget can be used through the pointer for more complicated actions. */
- void modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*);
-
- protected:
-
- /**
- * Initialize one tree widget item.
- * To be overridden. This is called for each QTreeWidgetItem when it is created.
- * Here you can set for example the checked status of the item.
- */
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) = 0;
-
-
-
- private slots:
-
- /** Emits the signal modulesChanged() with the list of the selected modules. */
- void slotOk();
-
- private:
- /** Initialize the module tree. */
- void initTree();
-
- /** Initializes the view of this dialog.*/
- void initView();
-
- /** Call this from initTree(). */
- void createModuleTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
-
- QTreeWidget *m_moduleChooser;
- QDialogButtonBox *m_buttonBox;
- QString m_title;
- QString m_labelText;
- QList<BTModuleTreeItem::Filter*> m_filters;
- BTModuleTreeItem::Grouping m_grouping;
- QList<CSwordModuleInfo*> m_moduleList;
-};
-
-
-#endif
diff --git a/src/frontend/cmoduleindexdialog.cpp b/src/frontend/cmoduleindexdialog.cpp
deleted file mode 100644
index a32d1ea..0000000
--- a/src/frontend/cmoduleindexdialog.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/cmoduleindexdialog.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QProgressDialog>
-#include <QString>
-#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-#include "util/dialogutil.h"
-
-
-CModuleIndexDialog* CModuleIndexDialog::getInstance() {
- qDebug() << "CModuleIndexDialog::getInstance";
- static CModuleIndexDialog* instance = 0;
- if (instance == 0) {
- instance = new CModuleIndexDialog();
- }
- qDebug() << "CModuleIndexDialog::getInstance end";
- return instance;
-}
-
-void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& modules ) {
- static bool indexing = false;
- if (!indexing) {
- indexing = true;
- if (modules.count() < 1) return;
-
- m_currentModuleIndex = 0;
- m_progress = new QProgressDialog(QString(""), tr("Cancel"), 0, modules.count()*100);
- m_progress->setWindowModality(Qt::WindowModal); // not useful actually, should have parent for this
- m_progress->setWindowTitle(tr("Creating indices"));
- m_progress->show();
- m_progress->raise();
-
- foreach (CSwordModuleInfo* info, modules) {
- /// \todo how to cancel
- //QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged()), this, SLOT(swordSetupChanged()));
- connect(this, SIGNAL(sigCancel()), info, SLOT(cancelIndexing()) );
- connect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
- connect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
- connect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
- QString modname(info->name());
- const QString labelText = tr("Creating index for work: %1").arg(modname);
- m_progress->setLabelText(labelText);
- /// \todo if we want to cancel indexing from
- info->buildIndex(); //waits until this module is finished
-
- m_currentModuleIndex++;
- disconnect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
- disconnect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
- disconnect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
- if (m_progress->wasCanceled()) break;
- }
-
- delete m_progress;
- m_progress = 0;
- indexing = false;
- }
-}
-
-void CModuleIndexDialog::indexUnindexedModules( const QList<CSwordModuleInfo*>& modules ) {
- QList<CSwordModuleInfo*> unindexedMods;
-
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for ( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
- if ((*it)->hasIndex()) {
- continue;
- }
-
- unindexedMods << (*it);
- }
- indexAllModules(unindexedMods);
-}
-
-void CModuleIndexDialog::slotModuleProgress( int percentage ) {
- m_progress->setValue(m_currentModuleIndex * 100 + percentage);
- qApp->processEvents();
-}
-
-void CModuleIndexDialog::slotFinished( ) {
- m_progress->setValue(m_currentModuleIndex * 100 + 100);
- qApp->processEvents();
-}
-
-// Modules may be removed
-void CModuleIndexDialog::slotSwordSetupChanged() {
- qDebug() << "CModuleIndexDialog::slotSwordSetupChanged"; /// \todo cancel if modules are removed
- util::showInformation(0, tr("Indexing Is Cancelled"), tr("Indexing is cancelled because modules are removed."));
- emit sigCancel();
-}
diff --git a/src/frontend/cmoduleindexdialog.h b/src/frontend/cmoduleindexdialog.h
deleted file mode 100644
index b27b161..0000000
--- a/src/frontend/cmoduleindexdialog.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CMODULEINDEXDIALOG_H
-#define CMODULEINDEXDIALOG_H
-
-#include <QObject>
-
-
-class CSwordModuleInfo;
-class QProgressDialog;
-
-/**
- * This dialog is used to index a list of modules and to show progress for that.\
- * While the indexing is in progress it creates a blocking, top level dialog which shows the progress
- * while the indexing is done.
- *
- * @author The BibleTime team <info@bibletime.info>
-*/
-class CModuleIndexDialog : public QObject {
- Q_OBJECT
- public:
- /** Get the singleton instance.
- *
- */
- static CModuleIndexDialog* getInstance();
-
- /** Starts the actual indexing. It shows the dialog with progress information.
- */
- void indexAllModules( const QList<CSwordModuleInfo*>& modules );
-
- /** Indexes all modules in the list which don't have an index yet.
- */
- void indexUnindexedModules( const QList<CSwordModuleInfo*>& modules );
-
- signals:
- /** Indexing is cancelled programmatically. */
- void sigCancel();
-
- private:
- QProgressDialog* m_progress;
- int m_currentModuleIndex;
-
- protected slots:
- void slotModuleProgress( int percentage );
- void slotFinished();
- void slotSwordSetupChanged();
-};
-
-#endif
diff --git a/src/frontend/cprinter.cpp b/src/frontend/cprinter.cpp
index 11988a9..99d1daf 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,15 +15,18 @@
#include <QWebPage>
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "util/cpointers.h"
namespace Printing {
-CPrinter::CPrinter(QObject*, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
- : QObject(0),
- CDisplayRendering(displayOptions, filterOptions),
- m_htmlPage(new QWebPage()) {
+/// \todo WHY IS parent NOT USED!?
+CPrinter::CPrinter(QObject *,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+ : QObject(0),
+ CDisplayRendering(displayOptions, filterOptions),
+ m_htmlPage(new QWebPage())
+{
m_htmlPage->setParent(this);
//override the filteroptions set in the c-tor of CDisplayRendering
@@ -49,11 +52,13 @@ void CPrinter::printKeyTree( KeyTree& tree ) {
}
}
-const QString CPrinter::entryLink(const KeyTreeItem& item, CSwordModuleInfo* module) {
+const QString CPrinter::entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module)
+{
Q_ASSERT(module);
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
- vk.key(item.key());
+ vk.setKey(item.key());
switch (item.settings().keyRenderingFace) {
case KeyTreeItem::Settings::CompleteShort:
return QString::fromUtf8(vk.getShortText());
@@ -94,7 +99,7 @@ const QString CPrinter::renderEntry( const KeyTreeItem& i, CSwordKey* ) {
}
const QString CPrinter::finishText(const QString& text, KeyTree& tree) {
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ QList<const CSwordModuleInfo*> modules = collectModules(&tree);
Q_ASSERT(modules.count() > 0);
const CLanguageMgr::Language* const lang = modules.first()->language();
@@ -114,7 +119,7 @@ const QString CPrinter::finishText(const QString& text, KeyTree& tree) {
settings.pageDirection = ( modules.first()->textDirection() == CSwordModuleInfo::LeftToRight ) ? "ltr" : "rtl";
}
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *tMgr = CDisplayTemplateMgr::instance();
return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), text, settings);
}
diff --git a/src/frontend/cprinter.h b/src/frontend/cprinter.h
index f119ec3..2252786 100644
--- a/src/frontend/cprinter.h
+++ b/src/frontend/cprinter.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,12 +26,17 @@ namespace Printing {
class CPrinter : public QObject, public Rendering::CDisplayRendering {
Q_OBJECT
public:
- CPrinter(QObject* parent, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ CPrinter(QObject *parent,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
virtual ~CPrinter();
void printKeyTree( KeyTree& );
protected:
- virtual const QString entryLink(const KeyTreeItem& item, CSwordModuleInfo* const module);
+ virtual const QString entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module);
+
virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
virtual const QString finishText(const QString& arg1, KeyTree& tree);
diff --git a/src/frontend/crossrefrendering.cpp b/src/frontend/crossrefrendering.cpp
index 1d7ff63..616766c 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,23 +16,27 @@
namespace InfoDisplay {
-CrossRefRendering::CrossRefRendering( CSwordBackend::DisplayOptions displayOptions,
- CSwordBackend::FilterOptions filterOptions
- )
- : CHTMLExportRendering(Settings(), displayOptions, filterOptions) {}
+CrossRefRendering::CrossRefRendering(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+ : CHTMLExportRendering(Settings(), displayOptions, filterOptions)
+{
+ // Intentionally empty
+}
const QString CrossRefRendering::finishText( const QString& text, KeyTree& ) {
// qDebug() << "CrossRefRendering::finishText";
return text;
}
-const QString CrossRefRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) {
+const QString CrossRefRendering::entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module)
+{
QString linkText;
const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
if (isBible) {
- vk.key(item.key());
+ vk.setKey(item.key());
}
switch (item.settings().keyRenderingFace) {
diff --git a/src/frontend/crossrefrendering.h b/src/frontend/crossrefrendering.h
index 561fd3e..1e65d06 100644
--- a/src/frontend/crossrefrendering.h
+++ b/src/frontend/crossrefrendering.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,11 +20,13 @@ class CrossRefRendering : public Rendering::CHTMLExportRendering {
friend class CInfoDisplay;
CrossRefRendering(
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
);
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
+ virtual const QString entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module);
+
virtual const QString finishText( const QString&, KeyTree& tree );
};
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index 37bea2d..0d09259 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 0d8e8ad..5cc0f56 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,10 +22,11 @@ class BtColorWidget : public QFrame {
BtColorWidget(QWidget* parent = 0);
~BtColorWidget();
QSize sizeHint() const;
+
+ public slots:
void setColor(const QColor& color);
protected:
-// void paintEvent( QPaintEvent* );
void mouseReleaseEvent(QMouseEvent* event);
private:
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index 116d0d7..b302fed 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -1,9 +1,9 @@
/*********
*
-* This file is part of BtFontSizeWidget's source code, http://www.bibletime.info/.
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BtFontSizeWidget developers.
-* The BtFontSizeWidget source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index 3db867d..c2d7198 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,9 +19,11 @@ class BtFontSizeWidget : public QComboBox {
public:
BtFontSizeWidget(QWidget* parent = 0);
~BtFontSizeWidget();
- void setFontSize(int size);
int fontSize() const;
+ public slots:
+ void setFontSize(int size);
+
private slots:
virtual void changed(const QString& text);
diff --git a/src/frontend/display/bthtml.js b/src/frontend/display/bthtml.js
index d64215d..689ba55 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
index 70e8a5d..1b15b11 100644
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ b/src/frontend/display/bthtmlfindtext.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -49,10 +49,6 @@ void BtHtmlFindText::findNext() {
}
}
-void BtHtmlFindText::doHide() {
- hide();
-}
-
void BtHtmlFindText::findPrevious() {
QWebView* webView = getActiveWindowWebView();
if (webView != 0) {
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
index 3c24489..1d941c1 100644
--- a/src/frontend/display/bthtmlfindtext.h
+++ b/src/frontend/display/bthtmlfindtext.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,7 +26,6 @@ class BtHtmlFindText : public QDialog {
public slots:
void findNext();
void findPrevious();
- void doHide();
private:
QWebView* getActiveWindowWebView();
Ui_findTextDialog ui;
diff --git a/src/frontend/display/bthtmlfindtext.ui b/src/frontend/display/bthtmlfindtext.ui
index 97c373e..c04de0c 100644
--- a/src/frontend/display/bthtmlfindtext.ui
+++ b/src/frontend/display/bthtmlfindtext.ui
@@ -48,7 +48,7 @@
<item>
<widget class="QCheckBox" name="caseBox" >
<property name="toolTip" >
- <string>Seach with case sensitivity</string>
+ <string>Search with case sensitivity</string>
</property>
<property name="text" >
<string>Case &amp;sensitive</string>
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index 195564e..119c2a8 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/display/bthtmljsobject.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QObject>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.h"
@@ -18,6 +18,7 @@
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
#include "frontend/display/bthtmlreaddisplay.h"
+#include "bibletime.h"
using namespace InfoDisplay;
@@ -28,7 +29,10 @@ using namespace InfoDisplay;
// Access to DOM objects is implemented in Javascript and is communicated back to c++ through this class
BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display)
- : m_display(display) {
+ : m_display(display)
+{
+ m_dndData.isDragging = false;
+ m_dndData.mousePressed = false;
}
void BtHtmlJsObject::moveToAnchor(const QString& anchor) {
@@ -36,13 +40,6 @@ void BtHtmlJsObject::moveToAnchor(const QString& anchor) {
emit gotoAnchor(anchor);
}
-void BtHtmlJsObject::setBodyEditable(bool editable) {
- if (editable)
- emit setDocumentEditable();
- else
- emit setDocumentNotEditable();
-}
-
void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int& y) {
m_dndData.mousePressed = true;
m_dndData.isDragging = false;
@@ -75,7 +72,6 @@ void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma) {
// The mouse move event starts in the javascript function "mouseMoveHandler" in bthtml.js. It calls this function
void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey) {
- /// \bug Valgrind reports uninitialized m_dndData or m_dndData member:
if (!m_dndData.isDragging && m_dndData.mousePressed) {
// If we have not started dragging, but the mouse button is down, create a the mime data
QPoint current(x, y);
@@ -92,9 +88,9 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null);
drag->setMimeData(mimedata);
//add real Bible text from module/key
- if (CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName)) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
+ if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) {
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey(keyName);
mimedata->setText(key->strippedText()); // This works across applications!
}
}
@@ -149,7 +145,7 @@ void BtHtmlJsObject::timeOutEvent(const QString& attributes) {
}
// Update the mag if valid attributes were found
if (!(infoList.isEmpty())) {
- CPointers::infoDisplay()->setInfo(infoList);
+ BibleTime::instance()->infoDisplay()->setInfo(infoList);
}
}
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index c3536ff..c49dc83 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,7 +24,6 @@ class BtHtmlJsObject: public QObject {
BtHtmlJsObject(BtHtmlReadDisplay* display);
~BtHtmlJsObject() {}
void moveToAnchor(const QString& anchor);
- void setBodyEditable(bool editable);
void clearPrevAttribute();
public slots:
@@ -39,8 +38,6 @@ class BtHtmlJsObject: public QObject {
void mouseMoveAttribute(const QString& attrName, const QString& attrValue);
void gotoAnchor(const QString& anchor);
void selectAll();
- void setDocumentEditable();
- void setDocumentNotEditable();
private:
int m_int;
@@ -56,7 +53,7 @@ class BtHtmlJsObject: public QObject {
Link,
Text
} dragType;
- } m_dndData;
+ } m_dndData;
};
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index dd2132f..2d95c38 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/display/bthtmlreaddisplay.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QMenu>
#include <QString>
#include "backend/config/cbtconfig.h"
@@ -19,9 +19,9 @@
#include "frontend/cinfodisplay.h"
#include "frontend/display/bthtmljsobject.h"
#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/cdisplaywindowfactory.h"
#include "frontend/displaywindow/creadwindow.h"
#include "util/directory.h"
-#include "util/cpointers.h"
using namespace InfoDisplay;
@@ -35,7 +35,7 @@ BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWid
{
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
- m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow);
+ m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow, readWindow);
m_view->setAcceptDrops(true);
m_view->setPage(this);
setParent(m_view);
@@ -87,7 +87,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
else {
CDisplayWindow* window = parentWindow();
CSwordKey* const key = window->key();
- CSwordModuleInfo* module = key->module();
+ const CSwordModuleInfo *module = key->module();
//This is never used for Bibles, so it is not implemented for
//them. If it should be, see CReadDisplay::print() for example
//code.
@@ -98,7 +98,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
module->type() == CSwordModuleInfo::Commentary ||
module->type() == CSwordModuleInfo::GenericBook) {
/// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now
- CSwordBackend::FilterOptions filterOptions;
+ FilterOptions filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -106,7 +106,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
filterOptions.scriptureReferences = false;
filterOptions.textualVariants = false;
- CPointers::backend()->setFilterOptions(filterOptions);
+ CSwordBackend::instance()->setFilterOptions(filterOptions);
return QString(key->strippedText()).append("\n(")
.append(key->key())
@@ -122,7 +122,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
return QString::null;
}
else if (format == HTMLText) {
- // \todo It does not appear this is ever called
+ // \todo It does not appear this is ever called
}
else { //plain text requested
return selectedText();
@@ -144,9 +144,9 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
ReferenceManager::Type type;
ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
- if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
+ if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) {
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey(keyName);
return key->strippedText();
}
@@ -159,12 +159,12 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
ReferenceManager::Type type;
ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
- if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
+ if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) {
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey(keyName);
/// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now
- CSwordBackend::FilterOptions filterOptions;
+ FilterOptions filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
filterOptions.morphTags = false;
@@ -172,7 +172,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
filterOptions.scriptureReferences = false;
filterOptions.textualVariants = false;
- CPointers::backend()->setFilterOptions(filterOptions);
+ CSwordBackend::instance()->setFilterOptions(filterOptions);
return QString(key->strippedText()).append("\n(")
.append(key->key())
@@ -180,16 +180,16 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
.append(key->module()->name())
.append(")");
/* ("%1\n(%2, %3)")
- .arg()
- .arg(key->key())
- .arg(key->module()->name());*/
+ .arg()
+ .arg(key->key())
+ .arg(key->module()->name());*/
}
return QString::null;
}
default:
return QString::null;
}
- return QString();
+ return QString::null;
}
// Puts html text and javascript into QWebView
@@ -198,11 +198,11 @@ void BtHtmlReadDisplay::setText( const QString& newText ) {
QString jsText = newText;
jsText.replace(
- QString("</body>"),
- QString("<script type=\"text/javascript\">").append(javascript).append("</script></body>")
- );
+ QString("</body>"),
+ QString("<script type=\"text/javascript\">").append(javascript).append("</script></body>")
+ );
- // Disconnect any previous connect and connect to slot that loads the javascript object
+ // Disconnect any previous connections and connect to slot that loads the javascript object
QWebFrame* frame = mainFrame();
disconnect(frame, SIGNAL(javaScriptWindowObjectCleared()), 0, 0);
bool ok = connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(loadJSObject()));
@@ -211,11 +211,11 @@ void BtHtmlReadDisplay::setText( const QString& newText ) {
// Send text to the html viewer
m_view->setHtml(jsText);
- this->currentSource = jsText;
+ this->currentSource = jsText;
}
QString BtHtmlReadDisplay::getCurrentSource( ) {
- return this->currentSource;
+ return this->currentSource;
}
// See if any text is selected
@@ -233,10 +233,7 @@ QWidget* BtHtmlReadDisplay::view() {
// Select all text in the viewer
void BtHtmlReadDisplay::selectAll() {
- m_jsObject->setBodyEditable(true);
- m_view->triggerPageAction( QWebPage::MoveToStartOfDocument, true );
- m_view->triggerPageAction( QWebPage::SelectEndOfDocument, true );
- m_jsObject->setBodyEditable(false);
+ m_view->triggerPageAction( QWebPage::SelectAll, true );
}
// Scroll QWebView to the correct location as specified by the anchor
@@ -276,8 +273,8 @@ void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int li
// ----------------- BtHtmlReadDisplayView -------------------------------------
-BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent)
- : QWebView(parent), m_display(displayWidget) {
+BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent, CReadWindow* readWindow)
+ : QWebView(parent), m_display(displayWidget), m_readWindow(readWindow) {
}
BtHtmlReadDisplayView::~BtHtmlReadDisplayView() {
@@ -307,17 +304,48 @@ void BtHtmlReadDisplayView::dropEvent( QDropEvent* e ) {
}
};
//don't accept the action!
- e->ignore();
+// e->ignore();
}
// Reimplementation from QWebView
void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e ) {
- if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
- e->acceptProposedAction();
+ if ( ! e->mimeData()->hasFormat("BibleTime/Bookmark"))
+ return;
+
+ const QMimeData* mimedata = e->mimeData();
+ if (mimedata == 0)
+ return;
+
+ const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata);
+ if (btmimedata == 0)
+ return;
+
+ BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark();
+ QString moduleName = item.module();
+ CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(moduleName);
+ Q_ASSERT(m);
+ if (m == 0)
return;
+
+ CSwordModuleInfo::ModuleType bookmarkType = m->type();
+ CSwordModuleInfo::ModuleType windowType = CDisplayWindowFactory::getModuleType(m_readWindow);
+
+ // Is bible reference bookmark compatible with the window type?
+ if ((bookmarkType == CSwordModuleInfo::Bible ||
+ bookmarkType == CSwordModuleInfo::Commentary)) {
+ if (windowType == CSwordModuleInfo::Bible ||
+ windowType == CSwordModuleInfo::Commentary)
+ e->acceptProposedAction();
+ return;
}
- //don't accept the action!
- e->ignore();
+
+ // Is reference type compatible with window type
+ if (bookmarkType == windowType) {
+ e->acceptProposedAction();
+ return;
+ }
+
+ return;
}
// Reimplementation from QWebView
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index e4011d0..21724b9 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -104,17 +104,18 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
};
-class BtHtmlReadDisplayView : public QWebView, public CPointers {
+class BtHtmlReadDisplayView : public QWebView {
Q_OBJECT
protected:
friend class BtHtmlReadDisplay;
void contextMenuEvent(QContextMenuEvent* event);
- BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent);
+ BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent, CReadWindow* readWindow);
~BtHtmlReadDisplayView();
bool event(QEvent* e);
private:
BtHtmlReadDisplay* m_display;
+ CReadWindow* m_readWindow;
void dropEvent( QDropEvent* e );
void dragEnterEvent( QDragEnterEvent* e );
void dragMoveEvent( QDragMoveEvent* e );
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 8135d03..78d9038 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -59,15 +59,18 @@ void CDisplayConnections::copyAll() {
/** No descriptions */
void CDisplayConnections::copySelection() {
- qWarning("copyign the selected text");
m_display->copy(CDisplay::PlainText, CDisplay::SelectedText);
}
-void CDisplayConnections::printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+void CDisplayConnections::printAll(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
m_display->print(CDisplay::Document, displayOptions, filterOptions);
}
-void CDisplayConnections::printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+void CDisplayConnections::printAnchorWithText(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions);
}
@@ -177,7 +180,7 @@ void CDisplay::emitReferenceDropped( const QString& reference ) {
m_connections->emitReferenceDropped(key);
}
-/** Returns the connections obect used for signas and slots. */
+/** Returns the connections object used for signals and slots. */
CDisplayConnections* CDisplay::connectionsProxy() const {
return m_connections;
}
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index a7d6a03..af49178 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,8 +10,6 @@
#ifndef CDISPLAY_H
#define CDISPLAY_H
-#include "util/cpointers.h"
-
#include <QMap>
#include "backend/managers/cswordbackend.h"
@@ -27,7 +25,7 @@ class QMenu;
/** The base class for all display widgets.
* @author The BibleTime team
*/
-class CDisplay : public CPointers {
+class CDisplay {
public:
enum WriteDisplayType {
HTMLDisplay = 0,
@@ -84,15 +82,17 @@ class CDisplay : public CPointers {
*/
virtual void selectAll() = 0;
/**
- * Returns the connections obect used for signas and slots.
+ * Returns the connections object used for signals and slots.
*/
virtual CDisplayConnections* connectionsProxy() const;
/**
* Returns the parent window used for this display widget.
*/
CDisplayWindow* parentWindow() const;
- virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions,
- CSwordBackend::FilterOptions filterOptions) = 0;
+
+ virtual void print(const CDisplay::TextPart,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions) = 0;
/**
* Installs the popup which should be opened when the right mouse button was pressed.
*/
@@ -151,9 +151,11 @@ class CDisplayConnections : public QObject {
void saveAsHTML();
void saveAnchorWithText();
- void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions,
- CSwordBackend::FilterOptions filterOptions);
+ void printAll(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ void printAnchorWithText(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
void copySelection();
void copyAll();
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index 4d08666..ce7b94c 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,13 +25,70 @@
class BtActionCollection;
CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
- : CPlainWriteDisplay(parentWindow, parent), m_fontFamilyChooser(0),
- m_fontSizeChooser(0), m_colorChooser(0) {
+: CPlainWriteDisplay(parentWindow, parent) {
m_actions.bold = 0;
m_actions.italic = 0;
m_actions.underline = 0;
m_actions.selectAll = 0;
+ //--------------------bold toggle-------------------------
+ namespace DU = util::directory;
+ m_actions.bold = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ tr("Bold"),
+ this);
+ m_actions.bold->setCheckable(true);
+ 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)));
+
+ //--------------------italic toggle-------------------------
+ m_actions.italic = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ tr("Italic"),
+ this );
+ m_actions.italic->setCheckable(true);
+ m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
+ connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
+ m_actions.italic->setToolTip( tr("Italic") );
+
+ //--------------------underline toggle-------------------------
+ m_actions.underline = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ tr("Underline"),
+ this );
+ m_actions.underline->setCheckable(true);
+ m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
+ connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
+ m_actions.underline->setToolTip( tr("Underline") );
+
+ //--------------------align left toggle-------------------------
+ m_actions.alignLeft = new QAction(
+ DU::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)));
+ m_actions.alignLeft->setToolTip( tr("Align left") );
+
+ //--------------------align center toggle-------------------------
+ m_actions.alignCenter = new QAction(
+ DU::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)));
+ m_actions.alignCenter->setToolTip( tr("Center") );
+
+ //--------------------align right toggle-------------------------
+ m_actions.alignRight = new QAction(
+ DU::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)));
+ m_actions.alignRight->setToolTip( tr("Align right") );
+
setAcceptRichText(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
@@ -118,12 +175,12 @@ void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
/** Is called when a text with another color was selected. */
void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
- m_colorChooser->setColor(c);
+ emit setColor(c);
}
void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
- m_fontFamilyChooser->setCurrentFont(font);
- m_fontSizeChooser->setFontSize( font.pointSize() );
+ emit fontChanged(font);
+ emit fontSizeChanged(font.pointSize());
m_actions.bold->setChecked( font.bold() );
m_actions.italic->setChecked( font.italic() );
@@ -135,104 +192,46 @@ void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
}
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
- namespace DU = util::directory;
//--------------------font chooser-------------------------
- m_fontFamilyChooser = new QFontComboBox(this);
- actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser);
- m_fontFamilyChooser->setToolTip( tr("Font") );
- bar->addWidget(m_fontFamilyChooser);
- bool ok = connect(m_fontFamilyChooser, SIGNAL(currentFontChanged(const QFont&)),
+ QFontComboBox* fontFamilyCombo = new QFontComboBox(this);
+ fontFamilyCombo->setToolTip( tr("Font") );
+ bar->addWidget(fontFamilyCombo);
+ bool ok = connect(fontFamilyCombo, SIGNAL(currentFontChanged(const QFont&)),
this, SLOT(slotFontFamilyChoosen(const QFont&)));
Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(fontChanged(const QFont&)), fontFamilyCombo, SLOT(setCurrentFont(const QFont&)));
+ Q_ASSERT(ok);
//--------------------font size chooser-------------------------
- m_fontSizeChooser = new BtFontSizeWidget(this);
- m_fontSizeChooser->setToolTip( tr("Font size") );
- bar->addWidget(m_fontSizeChooser);
- ok = connect(m_fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ BtFontSizeWidget* fontSizeChooser = new BtFontSizeWidget(this);
+ fontSizeChooser->setToolTip( tr("Font size") );
+ bar->addWidget(fontSizeChooser);
+ ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(fontSizeChanged(int)), fontSizeChooser, SLOT(setFontSize(int)));
Q_ASSERT(ok);
//--------------------color button-------------------------
- m_colorChooser = new BtColorWidget();
- m_colorChooser->setToolTip(tr("Font color"));
- bar->addWidget(m_colorChooser);
- ok = connect(m_colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ BtColorWidget* colorChooser = new BtColorWidget();
+ colorChooser->setToolTip(tr("Font color"));
+ bar->addWidget(colorChooser);
+ ok = connect(colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(setColor(const QColor&)), colorChooser, SLOT(setColor(const QColor&)));
Q_ASSERT(ok);
bar->addSeparator();
- //--------------------bold toggle-------------------------
- m_actions.bold = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
- tr("Bold"),
- actions);
- m_actions.bold->setCheckable(true);
- m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::boldText::actionName, m_actions.bold);
- m_actions.bold->setToolTip( tr("Bold") );
- connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
-
bar->addAction(m_actions.bold);
-
- //--------------------italic toggle-------------------------
- m_actions.italic = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
- tr("Italic"),
- actions );
- m_actions.italic->setCheckable(true);
- m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::italicText::actionName, m_actions.italic);
- connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
- m_actions.italic->setToolTip( tr("Italic") );
bar->addAction(m_actions.italic);
-
- //--------------------underline toggle-------------------------
- m_actions.underline = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
- tr("Underline"),
- actions );
- m_actions.underline->setCheckable(true);
- m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::underlinedText::actionName, m_actions.underline);
- connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
- m_actions.underline->setToolTip( tr("Underline") );
bar->addAction(m_actions.underline);
//seperate formatting from alignment buttons
bar->addSeparator();
- //--------------------align left toggle-------------------------
- m_actions.alignLeft = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
- tr("Left"), actions);
- m_actions.alignLeft->setCheckable(true);
- m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignLeft::actionName, m_actions.alignLeft);
- connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
- m_actions.alignLeft->setToolTip( tr("Align left") );
bar->addAction(m_actions.alignLeft);
-
- //--------------------align center toggle-------------------------
- m_actions.alignCenter = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
- tr("Center"), actions);
- m_actions.alignCenter->setCheckable(true);
- m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignCenter::actionName, m_actions.alignCenter);
- connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
- m_actions.alignCenter->setToolTip( tr("Center") );
bar->addAction(m_actions.alignCenter);
-
- //--------------------align right toggle-------------------------
- m_actions.alignRight = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
- tr("Right"), actions);
- m_actions.alignRight->setCheckable(true);
- m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
- actions->addAction(CResMgr::displaywindows::writeWindow::alignRight::actionName, m_actions.alignRight);
- connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
- m_actions.alignRight->setToolTip( tr("Align right") );
bar->addAction(m_actions.alignRight);
connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
@@ -244,16 +243,3 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
slotAlignmentChanged( alignment() );
slotColorChanged( textColor() );
}
-
-/** Reimplementation to show a popup menu if the right mouse button was clicked. */
-QMenu* CHTMLWriteDisplay::createPopupMenu( const QPoint& ) {
- if (!m_actions.selectAll) {
- m_actions.selectAll = new QAction(tr("Select all"), this);
- connect(m_actions.selectAll, SIGNAL(triggered(bool)), SLOT(selectAll()));
- }
-
- QMenu* popup = new QMenu(this);
- popup->setTitle(tr("HTML editor window"));
- popup->addAction(m_actions.selectAll);
- return popup;
-}
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index 56f3f53..e8e4e7c 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,11 +48,6 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
friend class CDisplay;
CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
~CHTMLWriteDisplay();
- /**
- * Reimplementation to show a popup menu if the right mouse button was clicked.
- * (CPlainWriteDisplay)
- */
- virtual QMenu* createPopupMenu( const QPoint& pos );
protected slots:
void toggleBold(bool);
@@ -81,6 +76,11 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
*/
void slotColorChanged( const QColor& );
+ signals:
+ void fontChanged(const QFont& font);
+ void fontSizeChanged(int);
+ void setColor(const QColor&);
+
private:
struct {
QAction* bold;
@@ -95,10 +95,6 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
QAction* selectAll;
}
m_actions;
-
- QFontComboBox* m_fontFamilyChooser;
- BtFontSizeWidget* m_fontSizeChooser;
- BtColorWidget* m_colorChooser;
};
#endif
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index 720aa72..bfcbe0b 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/display/cplainwritedisplay.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
@@ -42,7 +42,7 @@ void CPlainWriteDisplay::selectAll() {
void CPlainWriteDisplay::setText( const QString& newText ) {
//make sure the text has been converted to show \n instead of <br/>
QString text = newText;
-// text.replace("\n<br /><!-- BT newline -->\n", "\n");
+// text.replace("\n<br /><!-- BT newline -->\n", "\n");
text.replace("<br />", "\n"); //inserted by BT or the Qt textedit widget
QTextEdit::setText(text);
@@ -62,9 +62,6 @@ const QString CPlainWriteDisplay::text( const CDisplay::TextType /*format*/, con
return QString::null;
}
-void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::DisplayOptions, CSwordBackend::FilterOptions) {
-}
-
/** Sets the current status of the edit widget. */
void CPlainWriteDisplay::setModified( const bool modified ) {
document()->setModified(modified);
@@ -86,16 +83,6 @@ const QString CPlainWriteDisplay::plainText() {
return ret;
}
-/** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
-QMenu* CPlainWriteDisplay::createPopupMenu( const QPoint& /*pos*/ ) {
- return installedPopup();
-}
-//
-///** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
-//QMenu* CPlainWriteDisplay::createPopupMenu( ) {
-// return installedPopup();
-//}
-
/** Creates the necessary action objects and puts them on the toolbar. */
void CPlainWriteDisplay::setupToolbar(QToolBar*, BtActionCollection*) {}
@@ -138,9 +125,9 @@ void CPlainWriteDisplay::dropEvent( QDropEvent* e ) {
BTMimeData::ItemList::iterator it;
for (it = items.begin(); it != items.end(); ++it) {
- CSwordModuleInfo* module = backend()->findModuleByName((*it).module());
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( (*it).key() );
+ CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName((*it).module());
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->setKey((*it).key());
QString moduleText = key->strippedText();
const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module());
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index 30efc72..2c7e1be 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,7 +44,14 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
*/
virtual QWidget* view();
virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document );
- virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions );
+
+ /**
+ Reimplemented from CDisplay.
+ */
+ virtual inline void print(const CDisplay::TextPart,
+ const DisplayOptions &,
+ const FilterOptions &) {}
+
/**
* Reimplementation (CWriteDisplay).
*/
@@ -68,14 +75,7 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
virtual ~CPlainWriteDisplay();
- /**
- * Reimplementation from QTextEdit. Provides an popup menu for the given position.
- */
- virtual QMenu* createPopupMenu( const QPoint& pos );
-// /**
-// * Reimplementation from QTextEdit. Provides an popup menu.
-// */
-// virtual QMenu* createPopupMenu();
+
/**
* Reimplementation from QTextEdit to manage drops of our drag and drop objects.
*/
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index 90175d4..690ee57 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -46,10 +46,14 @@ bool CReadDisplay::hasActiveAnchor() {
}
-void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
+void CReadDisplay::print(const CDisplay::TextPart type,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
+ typedef CSwordBibleModuleInfo CSBiMI;
CDisplayWindow* window = parentWindow();
CSwordKey* const key = window->key();
- CSwordModuleInfo* module = key->module();
+ const CSwordModuleInfo *module = key->module();
const CDisplayWindow *displayWindow = parentWindow();
CExportManager mgr(QObject::tr("Print keys"), false, QString::null, displayWindow->filterOptions(), displayWindow->displayOptions());
@@ -64,7 +68,7 @@ void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOp
CSwordVerseKey stopKey(*vk);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
+ const CSBiMI *bible = dynamic_cast<const CSBiMI*>(module);
if (bible) {
stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) );
}
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index b766f5b..d1e81c4 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -33,8 +33,10 @@ class CReadDisplay : public CDisplay {
* Moves the widget to the given anchor.
*/
virtual void moveToAnchor( const QString& ) = 0;
- virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions,
- CSwordBackend::FilterOptions filterOptions);
+
+ virtual void print(const CDisplay::TextPart,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
void setMouseTracking(const bool trackingEnabled) {
m_useMouseTracking = trackingEnabled;
diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp
index f30d217..47a3302 100644
--- a/src/frontend/display/cwritedisplay.cpp
+++ b/src/frontend/display/cwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
index 33ef5a5..3591efe 100644
--- a/src/frontend/display/cwritedisplay.h
+++ b/src/frontend/display/cwritedisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index f1956d5..9c26143 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,8 +21,10 @@
class BtActionItem : public QObject {
public:
- BtActionItem(QObject* parent)
- : QObject(parent) {
+ BtActionItem(QAction *action, QObject *parent = 0)
+ : QObject(parent), defaultKeys(action->shortcut()), action(action)
+ {
+ // Intentionally empty
}
QKeySequence defaultKeys;
QAction* action;
@@ -56,13 +58,11 @@ QAction* BtActionCollection::action(const QString& name) {
QAction* BtActionCollection::addAction(const QString& name, QAction* action) {
Q_ASSERT(action != 0);
- Q_ASSERT(m_actions[name] == 0); /// \todo replacing actions is ok???
- int count;
- count = m_actions.count();
- BtActionItem* item = new BtActionItem(this);
- item->action = action;
- item->defaultKeys = action->shortcut();
- m_actions[name] = item;
+ if (m_actions.contains(name)) {
+ delete m_actions[name];
+ }
+ BtActionItem* item = new BtActionItem(action, this);
+ m_actions.insert(name, item);
return action;
}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index 9a02958..2ce273d 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
index e809efc..2fa1d2d 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +15,6 @@
#include <QToolTip>
#include <QToolButton>
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
@@ -37,7 +36,8 @@ BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent)
}
void BtDisplaySettingsButton::setDisplayOptions(
- const CSwordBackend::DisplayOptions &displaySettings, bool repopulate)
+ const DisplayOptions &displaySettings,
+ bool repopulate)
{
m_displayOptions = displaySettings;
if (repopulate) {
@@ -46,7 +46,7 @@ void BtDisplaySettingsButton::setDisplayOptions(
}
void BtDisplaySettingsButton::setFilterOptions(
- const CSwordBackend::FilterOptions &moduleSettings,
+ const FilterOptions &moduleSettings,
bool repopulate)
{
m_filterOptions = moduleSettings;
@@ -55,7 +55,9 @@ void BtDisplaySettingsButton::setFilterOptions(
}
}
-void BtDisplaySettingsButton::setModules(const QList<CSwordModuleInfo*> &modules) {
+void BtDisplaySettingsButton::setModules(
+ const QList<const CSwordModuleInfo*> &modules)
+{
m_modules = modules;
repopulateMenu();
}
@@ -225,7 +227,7 @@ void BtDisplaySettingsButton::addMenuEntry(QAction *action, bool checked) {
}
bool BtDisplaySettingsButton::isOptionAvailable(const CSwordModuleInfo::FilterTypes option) {
- foreach (CSwordModuleInfo *module, m_modules) {
+ Q_FOREACH (const CSwordModuleInfo *module, m_modules) {
if (module->has(option)) return true;
}
return false;
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.h b/src/frontend/displaywindow/btdisplaysettingsbutton.h
index e947e83..489395e 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.h
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,6 +13,7 @@
#include <QToolButton>
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
class CSwordModuleInfo;
@@ -27,15 +28,18 @@ class BtDisplaySettingsButton: public QToolButton {
public:
BtDisplaySettingsButton(QWidget *parent = 0);
- void setDisplayOptions(const CSwordBackend::DisplayOptions &displaySettings,
+ public slots:
+ void setDisplayOptions(const DisplayOptions &displaySettings,
bool repopulate = true);
- void setFilterOptions(const CSwordBackend::FilterOptions &moduleSettings,
+ void setFilterOptions(const FilterOptions &moduleSettings,
bool repopulate = true);
- void setModules(const QList<CSwordModuleInfo*> &modules);
+
+ void setModules(const QList<const CSwordModuleInfo*> &modules);
signals:
- void sigFilterOptionsChanged(CSwordBackend::FilterOptions filterOptions);
- void sigDisplayOptionsChanged(CSwordBackend::DisplayOptions displayOptions);
+ void sigFilterOptionsChanged(FilterOptions filterOptions);
+ void sigDisplayOptionsChanged(DisplayOptions displayOptions);
+ void sigModulesChanged(const QList<CSwordModuleInfo*> &modules);
void sigChanged(void);
protected slots:
@@ -51,9 +55,9 @@ class BtDisplaySettingsButton: public QToolButton {
void addMenuEntry(QAction *action, bool checked);
private:
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
- QList<CSwordModuleInfo*> m_modules;
+ FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
+ QList<const CSwordModuleInfo*> m_modules;
QMenu *m_popup;
QAction *m_lineBreakAction;
diff --git a/src/frontend/displaywindow/btmodulechooserbar.cpp b/src/frontend/displaywindow/btmodulechooserbar.cpp
index e07e739..29be862 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,24 +17,18 @@
#include <QToolBar>
-BtModuleChooserBar::BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow *parent)
+BtModuleChooserBar::BtModuleChooserBar(QWidget *parent)
: QToolBar(parent),
- BtWindowModuleChooser(parent, type),
- m_idCounter(0) {
+ BtWindowModuleChooser(CSwordModuleInfo::Unknown, 0),
+ m_idCounter(0),
+ m_window(0) {
qDebug() << "BtModuleChooserBar::BtModuleChooserBar";
setAllowedAreas(Qt::TopToolBarArea);
setFloatable(false);
- setModules(useModules);
- connect(parent, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
- connect(parent, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
}
void BtModuleChooserBar::slotBackendModulesChanged() {
- backendModulesChanged();
-}
-
-void BtModuleChooserBar::backendModulesChanged() {
m_modules = m_window->getModuleList();
adjustButtonCount();
@@ -48,10 +42,6 @@ void BtModuleChooserBar::backendModulesChanged() {
}
}
-void BtModuleChooserBar::slotWindowModulesChanged() {
- windowModulesChanged();
-}
-
void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
//qDebug() << "BtModuleChooserBar::ajustButtonCount";
int buttonCountDifference = 0;
@@ -67,11 +57,7 @@ void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
//if there are more buttons than modules, delete buttons
if (buttonCountDifference > 0) {
for (int j = 0; j < buttonCountDifference; j++) {
- //qDebug() << "delete first button, " << j;
- // it should be safe to delete the button later
- BtModuleChooserButton* b = m_buttonList.takeFirst();
- b->setParent(0);
- b->deleteLater();
+ delete m_buttonList.takeFirst();
}
}
// if there are more modules than buttons, add buttons
@@ -82,7 +68,7 @@ void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
}
}
-void BtModuleChooserBar::windowModulesChanged() {
+void BtModuleChooserBar::slotWindowModulesChanged() {
//qDebug() << "BtModuleChooserBar::windowModulesChanged";
m_modules = m_window->getModuleList();
adjustButtonCount();
@@ -105,10 +91,16 @@ BtModuleChooserButton* BtModuleChooserBar::addButton() {
return b;
}
+
/** Sets the modules which are chosen in this module chooser bar. */
-void BtModuleChooserBar::setModules( QStringList useModules ) {
+void BtModuleChooserBar::setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window) {
qDebug() << "BtModuleChooserBar::setModules";
m_modules = useModules;
+ m_window = window;
+ m_moduleType = type;
+
+ clear();
+
adjustButtonCount(true);
//if (!useModules.count()) return;
@@ -120,6 +112,9 @@ void BtModuleChooserBar::setModules( QStringList useModules ) {
}
updateButtonMenus();
qDebug() << "BtModuleChooserBar::setModules end";
+
+ connect(m_window, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
+ connect(m_window, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
}
void BtModuleChooserBar::updateButtonMenus() {
diff --git a/src/frontend/displaywindow/btmodulechooserbar.h b/src/frontend/displaywindow/btmodulechooserbar.h
index 7ae903c..977d3c0 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.h
+++ b/src/frontend/displaywindow/btmodulechooserbar.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,31 +21,26 @@ class BtModuleChooserButton;
class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
Q_OBJECT
public:
- BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow* parent);
+ BtModuleChooserBar(QWidget* parent);
+ /** Initialize with module list.*/
+ void setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window);
public slots:
- /** The backend module list was updated, module list and widgets must be updated*/
- void slotBackendModulesChanged();
- void slotWindowModulesChanged();
-
- protected:
/**
* The backend module list was updated, module list and widgets must be updated.
* The signal comes from the window, not from the backend. The new list can
* be shorter but not longer than the old list.
*/
- virtual void backendModulesChanged();
+ void slotBackendModulesChanged();
+
/**
* The window module list was changed, i.e. 1 module added, removed or replaced.
*/
- virtual void windowModulesChanged();
+ void slotWindowModulesChanged();
private:
/** Adds an empty button to the toolbar.*/
BtModuleChooserButton* addButton();
- /** Initialize with module list.*/
- void setModules( QStringList useModules );
-
/** Updates every button's menu without recreating it.*/
void updateButtonMenus();
/**
@@ -56,6 +51,8 @@ class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
private:
int m_idCounter;
+ CReadWindow* m_window;
+ CSwordModuleInfo::ModuleType m_moduleType;
QList<BtModuleChooserButton*> m_buttonList;
};
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.cpp b/src/frontend/displaywindow/btmodulechooserbutton.cpp
index 549123f..9c8ad2f 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,7 +20,6 @@
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/cpointers.h"
BtModuleChooserButton::BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype)
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.h b/src/frontend/displaywindow/btmodulechooserbutton.h
index 9835eb0..270603b 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.h
+++ b/src/frontend/displaywindow/btmodulechooserbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.cpp b/src/frontend/displaywindow/bttextwindowheader.cpp
index cd5392f..5bacf2b 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,9 +22,12 @@
#include <QAction>
#include <QDebug>
-BtTextWindowHeader::BtTextWindowHeader ( CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules )
- : QWidget ( window ),
- BtWindowModuleChooser(window, modtype) {
+BtTextWindowHeader::BtTextWindowHeader(CSwordModuleInfo::ModuleType modtype,
+ QStringList modules,
+ CDisplayWindow *window)
+ : QWidget(window),
+ BtWindowModuleChooser(modtype, window)
+{
QHBoxLayout* layout = new QHBoxLayout ( this );
layout->setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -37,10 +40,6 @@ BtTextWindowHeader::BtTextWindowHeader ( CDisplayWindow* window, CSwordModuleInf
BtTextWindowHeader::~BtTextWindowHeader() {}
void BtTextWindowHeader::slotBackendModulesChanged() {
- backendModulesChanged();
-}
-
-void BtTextWindowHeader::backendModulesChanged() {
m_modules = m_window->getModuleList();
adjustWidgetCount();
@@ -55,10 +54,6 @@ void BtTextWindowHeader::backendModulesChanged() {
}
void BtTextWindowHeader::slotWindowModulesChanged() {
- windowModulesChanged();
-}
-
-void BtTextWindowHeader::windowModulesChanged() {
m_modules = m_window->getModuleList();
adjustWidgetCount();
updateWidgets();
diff --git a/src/frontend/displaywindow/bttextwindowheader.h b/src/frontend/displaywindow/bttextwindowheader.h
index a3e6b6b..1ea86b4 100644
--- a/src/frontend/displaywindow/bttextwindowheader.h
+++ b/src/frontend/displaywindow/bttextwindowheader.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,19 +22,20 @@ class BtTextWindowHeaderWidget;
class BtTextWindowHeader: public QWidget, public BtWindowModuleChooser {
Q_OBJECT
public:
- BtTextWindowHeader(CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules);
+ BtTextWindowHeader(CSwordModuleInfo::ModuleType modtype, QStringList modules, CDisplayWindow *window);
virtual ~BtTextWindowHeader();
public slots:
+ /**
+ The backend module list was updated, module list and widgets must be updated from
+ scratch.
+ */
void slotBackendModulesChanged();
- void slotWindowModulesChanged();
-
- protected:
- /** The backend module list was updated, module list and widgets must be updated from scratch.*/
- void backendModulesChanged();
- /** The window module list was updated, module list and widgets must be updated.*/
- void windowModulesChanged();
+ /**
+ The window module list was updated, module list and widgets must be updated.
+ */
+ void slotWindowModulesChanged();
signals:
/** User selected a module from menu to replace another module*/
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
index 3858efb..f0829bc 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,7 +24,6 @@
#include "frontend/displaywindow/bttextwindowheader.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/cpointers.h"
const char* ActionType = "ActionType";
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.h b/src/frontend/displaywindow/bttextwindowheaderwidget.h
index 2b5379e..d2bbe40 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.h
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 49b145e..1a5593b 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,15 +15,18 @@
#include <QToolButton>
-class BtToolButton : public QToolButton {
+namespace {
+
+class BtToolButton: public QToolButton {
public:
- BtToolButton(QWidget* parent = 0) : QToolButton(parent) {
- }
+ inline BtToolButton(QWidget *parent = 0)
+ : QToolButton(parent) {}
private:
- void nextCheckState() {
- }
+ virtual inline void nextCheckState() {}
};
+} // anonymous namespace
+
// This class provides a toolbar widget that has a icon plus a right side down arrow
// The icon is typically set to a back or forward arrow and the down arrow has a popup
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index 202a006..ebbc848 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -32,9 +32,6 @@ class BtToolBarPopupAction : public QWidgetAction {
// Function to catch the Shortcut event and emit the triggered signal
virtual bool event(QEvent* e);
- signals:
- void triggered();
-
protected:
QWidget* createWidget(QWidget* parent);
diff --git a/src/frontend/displaywindow/btwindowmodulechooser.h b/src/frontend/displaywindow/btwindowmodulechooser.h
index c30c284..1cf3fd1 100644
--- a/src/frontend/displaywindow/btwindowmodulechooser.h
+++ b/src/frontend/displaywindow/btwindowmodulechooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -35,20 +35,20 @@ class CDisplayWindow;
*/
class BtWindowModuleChooser {
public:
- BtWindowModuleChooser ( CDisplayWindow* parentWindow, CSwordModuleInfo::ModuleType moduleType )
- : m_window ( parentWindow ), m_moduleType ( moduleType ) {}
+ BtWindowModuleChooser(CSwordModuleInfo::ModuleType moduleType,
+ CDisplayWindow *parentWindow)
+ : m_window(parentWindow), m_moduleType (moduleType) {}
virtual ~BtWindowModuleChooser() {}
- protected:
/**
* The backend module list was updated, module list and widgets must be updated.
* This expects that the window module list has already been updated, so
* the corresponding slot should be connected to the window, not to the backend.
*/
- virtual void backendModulesChanged() = 0;
+ virtual void slotBackendModulesChanged() = 0;
/** Modules have been added, replaced or removed in the window without backend changing.*/
- virtual void windowModulesChanged() = 0;
+ virtual void slotWindowModulesChanged() = 0;
protected:
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 70dbd35..868dd8d 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -46,8 +46,8 @@ CBibleReadWindow::~CBibleReadWindow() {
void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
/**
- \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
- around with bits.
+ \todo Make CProfileWindow properly handle these things so we wouldn't have
+ to mess around with bits.
*/
CLexiconReadWindow::applyProfileSettings(settings);
@@ -68,14 +68,17 @@ void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
displayOptions().lineBreaks = (result & 0x1000) != 0;
displayOptions().verseNumbers = (result & 0x2000) != 0;
- displaySettingsButton()->setFilterOptions(filterOptions(), false);
- displaySettingsButton()->setDisplayOptions(displayOptions());
+ emit sigFilterOptionsChanged(filterOptions());
+ emit sigDisplayOptionsChanged(displayOptions());
+
+ // Apply settings to display:
+ lookup();
}
void CBibleReadWindow::storeProfileSettings( CProfileWindow * const settings) {
/**
- \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
- around with bits.
+ \todo Make CProfileWindow properly handle these things so we wouldn't have
+ to mess around with bits.
*/
int result = 0x0000;
@@ -142,13 +145,13 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
qaction->setShortcut(QKeySequence::Print);
a->addAction("printChapter", qaction);
-// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
-// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
-// qaction->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
-// a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
+// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
+// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+// qaction->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
+// a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
-// qaction = new QAction(tr("Reference only"), a );
-// a->addAction("copyReferenceOnly", qaction);
+// qaction = new QAction(tr("Reference only"), a );
+// a->addAction("copyReferenceOnly", qaction);
qaction = new QAction(tr("Text of reference"), a);
a->addAction("copyTextOfReference", qaction);
@@ -364,7 +367,7 @@ void CBibleReadWindow::previousVerse() {
}
}
-/** rapper around key() to return the right type of key. */
+/** wrapper around key() to return the right type of key. */
CSwordVerseKey* CBibleReadWindow::verseKey() {
CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
Q_ASSERT(k);
@@ -380,7 +383,7 @@ void CBibleReadWindow::copyDisplayedText() {
CSwordVerseKey vk(*verseKey());
vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
vk.UpperBound(dummy);
@@ -391,10 +394,8 @@ void CBibleReadWindow::copyDisplayedText() {
/** Saves the chapter as valid HTML page. */
void CBibleReadWindow::saveChapterHTML() {
//saves the complete chapter to disk
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
- Q_ASSERT(bible);
- if (!bible) //shouldn't happen
- return;
+ Q_ASSERT(dynamic_cast<const CSwordBibleModuleInfo*>(modules().first()) != 0);
+ const CSwordBibleModuleInfo *bible = static_cast<const CSwordBibleModuleInfo*>(modules().first());
CSwordVerseKey dummy(*verseKey());
dummy.Verse(1);
@@ -419,7 +420,7 @@ void CBibleReadWindow::saveChapterPlain() {
dummy.Verse(1);
vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
vk.UpperBound(dummy);
@@ -436,7 +437,7 @@ void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
}
//refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
@@ -477,3 +478,7 @@ void CBibleReadWindow::syncWindows() {
}
}
}
+
+void CBibleReadWindow::setupMainWindowToolBars() {
+ CLexiconReadWindow::setupMainWindowToolBars();
+}
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 11f0275..117c778 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,6 +48,8 @@ class CBibleReadWindow : public CLexiconReadWindow {
virtual void initToolbars();
virtual void initConnections();
virtual void initView();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
/**
* Reimplementation.
*/
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 062d42d..3aba333 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,6 +13,7 @@
#include <QMenu>
#include <QSplitter>
#include <QToolBar>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/display/cdisplay.h"
@@ -91,29 +92,27 @@ void CBookReadWindow::initConnections() {
/** Init the view */
void CBookReadWindow::initView() {
QSplitter* splitter = new QSplitter(this);
+ m_treeChooser = new CBookTreeChooser(modules(), history(), key(), splitter);
+ setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+ m_treeChooser->hide();
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
mainToolBar()->setFloatable(false);
-
addToolBar(mainToolBar());
+ setKeyChooser( CKeyChooser::createInstance(modules(), history(), key(), mainToolBar()) );
- m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
- setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
-
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
-
- setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
+ // Create the Works toolbar
+ setModuleChooserBar( new BtModuleChooserBar(this));
+ moduleChooserBar()->setModules(getModuleList(), modules().first()->type(), this);
addToolBar(moduleChooserBar());
+ // Create the Tools toolbar
setButtonsToolBar( new QToolBar(this) );
buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
buttonsToolBar()->setFloatable(false);
-
- setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
-
addToolBar(buttonsToolBar());
- m_treeChooser->hide();
setCentralWidget( splitter );
setWindowIcon(util::tool::getIconForModule(modules().first()));
@@ -125,18 +124,44 @@ void CBookReadWindow::initToolbars() {
mainToolBar()->addAction(m_actions.backInHistory);
mainToolBar()->addAction(m_actions.forwardInHistory);
-
mainToolBar()->addWidget(keyChooser());
- buttonsToolBar()->addAction(m_treeAction);
+ // Tools toolbar
+ buttonsToolBar()->addAction(m_treeAction); // Tree
m_treeAction->setChecked(false);
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ buttonsToolBar()->addWidget(button); // Display settings
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName ));
+ if (action) {
+ buttonsToolBar()->addAction(action); // Search
+ }
+}
- buttonsToolBar()->addWidget(displaySettingsButton());
-
+void CBookReadWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
+ btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(sigKeyChanged(CSwordKey*)), keyChooser, SLOT(updateKey(CSwordKey*)) );
+ Q_ASSERT(ok);
+
+ // Works toolbar
+ btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
+
+ // Tools toolbar
+ btMainWindow()->toolsToolBar()->addAction(m_treeAction); // Tree
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ btMainWindow()->toolsToolBar()->addWidget(button); // Display settings
QAction* action = qobject_cast<QAction*>(actionCollection()->action(
CResMgr::displaywindows::general::search::actionName ));
if (action) {
- buttonsToolBar()->addAction(action);
+ btMainWindow()->toolsToolBar()->addAction(action); // Search
}
}
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index b059aff..8b85504 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,6 +48,8 @@ class CBookReadWindow : public CLexiconReadWindow {
virtual void initToolbars();
virtual void initConnections();
virtual void initView();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
virtual void setupPopupMenu();
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index 4b4d3c2..b1a291f 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,9 +15,11 @@
#include <QToolBar>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletime.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"
@@ -29,6 +31,7 @@ CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, C
}
void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
+ namespace DU = util::directory;
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -54,6 +57,13 @@ void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
qaction = new QAction(tr("Previous verse"), a);
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
+
+ qaction = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ tr("Synchronize"), a);
+ qaction->setCheckable(true);
+ qaction->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ qaction->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
+ a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, qaction);
}
void CCommentaryReadWindow::initActions() {
@@ -91,6 +101,10 @@ void CCommentaryReadWindow::initActions() {
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
addAction(qaction);
+ qaction = ac->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ m_syncButton = qaction;
+ addAction(qaction);
+
CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
@@ -107,28 +121,21 @@ void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow
}
void CCommentaryReadWindow::initToolbars() {
- namespace DU = util::directory;
-
CLexiconReadWindow::initToolbars();
-
- m_syncButton = new QAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
- tr("Synchronize"),
- actionCollection()
- );
- m_syncButton->setCheckable(true);
- m_syncButton->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_syncButton->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_syncButton);
buttonsToolBar()->addAction(m_syncButton);
}
+void CCommentaryReadWindow::setupMainWindowToolBars() {
+ CLexiconReadWindow::setupMainWindowToolBars();
+ btMainWindow()->toolsToolBar()->addAction(m_syncButton);
+}
+
/** Reimplementation to handle the keychooser refresh. */
void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
CLexiconReadWindow::reload(reason);
//refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index d75da67..679906c 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -54,6 +54,8 @@ class CCommentaryReadWindow : public CLexiconReadWindow {
protected:
virtual void initActions();
virtual void initToolbars();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
private:
QAction* m_syncButton;
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 3900a92..2b712c7 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -35,30 +35,34 @@ using namespace Profile;
CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
: QMainWindow(parent),
+ m_actionCollection(0),
m_mdi(parent),
- m_displaySettingsButton(0),
m_keyChooser(0),
m_swordKey(0),
m_isReady(false),
m_moduleChooserBar(0),
m_mainToolBar(0),
+ m_buttonsToolBar(0),
+ m_formatToolBar(0),
+ m_headerBar(0),
m_popupMenu(0),
- m_displayWidget(0) {
+ m_displayWidget(0),
+ m_history(0) {
qDebug() << "CDisplayWindow::CDisplayWindow";
setAttribute(Qt::WA_DeleteOnClose); //we want to destroy this window when it is closed
- parent->addSubWindow(this);
m_actionCollection = new BtActionCollection(this);
setModules(modules);
// Connect this to the backend module list changes
- connect(CPointers::backend(),
+ connect(CSwordBackend::instance(),
SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
SLOT(reload(CSwordBackend::SetupChangedReason)));
- BibleTime* mainwindow = dynamic_cast<BibleTime*>(m_mdi->parent());
+ BibleTime* mainwindow = btMainWindow();
connect(mainwindow, SIGNAL(toggledTextWindowHeader(bool)), SLOT(slotShowHeader(bool)) );
connect(mainwindow, SIGNAL(toggledTextWindowNavigator(bool)), SLOT(slotShowNavigator(bool)) );
connect(mainwindow, SIGNAL(toggledTextWindowToolButtons(bool)), SLOT(slotShowToolButtons(bool)) );
connect(mainwindow, SIGNAL(toggledTextWindowModuleChooser(bool)), SLOT(slotShowModuleChooser(bool)) );
+ connect(mainwindow, SIGNAL(toggledTextWindowFormatToolbar(bool)), SLOT(slotShowFormatToolBar(bool)) );
}
CDisplayWindow::~CDisplayWindow() {
@@ -66,6 +70,33 @@ CDisplayWindow::~CDisplayWindow() {
m_swordKey = 0;
}
+BibleTime* CDisplayWindow::btMainWindow() {
+ return dynamic_cast<BibleTime*>(m_mdi->parent());
+}
+
+void CDisplayWindow::setToolBarsHidden() {
+ // Hide current window toolbars
+ if (mainToolBar())
+ mainToolBar()->setHidden(true);
+ if (buttonsToolBar())
+ buttonsToolBar()->setHidden(true);
+ if (moduleChooserBar())
+ moduleChooserBar()->setHidden(true);
+ if (formatToolBar())
+ formatToolBar()->setHidden(true);
+}
+void CDisplayWindow::clearMainWindowToolBars() {
+ // Clear main window toolbars, except for works toolbar
+ btMainWindow()->navToolBar()->clear();
+ btMainWindow()->toolsToolBar()->clear();
+ btMainWindow()->formatToolBar()->clear();
+}
+
+void CDisplayWindow::windowActivated() {
+ clearMainWindowToolBars();
+ setupMainWindowToolBars();
+}
+
/** Returns the right window caption. */
const QString CDisplayWindow::windowCaption() {
if (!m_modules.count()) {
@@ -76,10 +107,10 @@ const QString CDisplayWindow::windowCaption() {
}
/** Returns the used modules as a pointer list */
-QList<CSwordModuleInfo*> CDisplayWindow::modules() {
+const QList<const CSwordModuleInfo*> CDisplayWindow::modules() const {
//qDebug() << "CDisplayWindow::modules";
- return CPointers::backend()->getPointerList(m_modules);
+ return CSwordBackend::instance()->getConstPointerList(m_modules);
}
void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
@@ -188,7 +219,7 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
//first make sure all used Sword modules are still present
QMutableStringListIterator it(m_modules);
while (it.hasNext()) {
- if (!backend()->findModuleByName(it.next())) {
+ if (!CSwordBackend::instance()->findModuleByName(it.next())) {
it.remove();
}
}
@@ -234,13 +265,15 @@ void CDisplayWindow::slotRemoveModule(int index) {
}
/** Sets the new display options for this window. */
-void CDisplayWindow::setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions) {
+void CDisplayWindow::setDisplayOptions(const DisplayOptions &displayOptions) {
m_displayOptions = displayOptions;
+ emit sigDisplayOptionsChanged(m_displayOptions);
}
/** Sets the new filter options of this window. */
-void CDisplayWindow::setFilterOptions(const CSwordBackend::FilterOptions &filterOptions) {
+void CDisplayWindow::setFilterOptions(const FilterOptions &filterOptions) {
m_filterOptions = filterOptions;
+ emit sigFilterOptionsChanged(m_filterOptions);
}
/** Set the ready status */
@@ -264,6 +297,12 @@ void CDisplayWindow::setKey( CSwordKey* key ) {
m_swordKey = key;
}
+BTHistory* CDisplayWindow::history() {
+ if (m_history == 0)
+ m_history = new BTHistory(this);
+ return m_history;
+}
+
void CDisplayWindow::modulesChanged() {
// this would only set the stringlist again
//if (moduleChooserBar()) { //necessary for write windows
@@ -273,11 +312,8 @@ void CDisplayWindow::modulesChanged() {
close();
}
else {
- if (displaySettingsButton()) {
- displaySettingsButton()->setModules(modules());
- }
-
- key()->module(modules().first());
+ emit sigModulesChanged(modules());
+ key()->setModule(modules().first());
keyChooser()->setModules(modules());
}
}
@@ -298,7 +334,7 @@ void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
}
}
-/** Sets the module header of text area. */
+/** Setup the module header of text area. */
void CDisplayWindow::setHeaderBar( QToolBar* header ) {
m_headerBar = header;
header->setMovable(false);
@@ -328,73 +364,92 @@ bool CDisplayWindow::init() {
parentWidget()->setFocusPolicy(Qt::ClickFocus);
initActions();
initToolbars();
+ if ( ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ setToolBarsHidden();
+ btMainWindow()->clearMdiToolBars();
+ clearMainWindowToolBars();
initConnections();
setupPopupMenu();
m_filterOptions = CBTConfig::getFilterOptionDefaults();
m_displayOptions = CBTConfig::getDisplayOptionDefaults();
- if (displaySettingsButton()) {
- displaySettingsButton()->setFilterOptions(m_filterOptions, false);
- displaySettingsButton()->setDisplayOptions(m_displayOptions, false);
- displaySettingsButton()->setModules(modules());
- }
+ emit sigDisplayOptionsChanged(m_displayOptions);
+ emit sigFilterOptionsChanged(m_filterOptions);
+ emit sigModulesChanged(modules());
setReady(true);
return true;
}
-/** Sets the main toolbar. */
-void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
- m_mainToolBar = bar;
+static void prepareToolBar(QToolBar* bar, const QString& title, bool visible) {
bar->setAllowedAreas(Qt::TopToolBarArea);
bar->setFloatable(false);
- bar->setWindowTitle(tr("Navigation"));
- bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ bar->setWindowTitle(title);
+ bar->setVisible(visible);
}
-/** Sets the main toolbar. */
+/** Setup the Navigation toolbar. */
+void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Navigation"), CBTConfig::get(CBTConfig::showTextWindowNavigator) );
+ m_mainToolBar = bar;
+}
+
+/** Setup the Tools toolbar. */
void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Tool"), CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
m_buttonsToolBar = bar;
- bar->setAllowedAreas(Qt::TopToolBarArea);
- bar->setFloatable(false);
- bar->setWindowTitle(tr("Tools"));
- bar->setVisible( CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
}
-/** Sets the display settings button. */
-void CDisplayWindow::setDisplaySettingsButton( BtDisplaySettingsButton* button ) {
- if (m_displaySettingsButton) {
- m_displaySettingsButton->disconnect(this);
- }
+/** Setup the Format toolbar. */
+void CDisplayWindow::setFormatToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Format"), true );
+ m_formatToolBar = bar;
+}
- m_displaySettingsButton = button;
+/** Sets the display settings button. */
+void CDisplayWindow::setDisplaySettingsButton(BtDisplaySettingsButton *button) {
+ connect(this, SIGNAL(sigDisplayOptionsChanged(const DisplayOptions&)),
+ button, SLOT(setDisplayOptions(const DisplayOptions&)));
+ connect(this, SIGNAL(sigFilterOptionsChanged(const FilterOptions&)),
+ button, SLOT(setFilterOptions(const FilterOptions&)));
+ connect(this, SIGNAL(sigModulesChanged(const QList<const CSwordModuleInfo*>&)),
+ button, SLOT(setModules(const QList<const CSwordModuleInfo*>&)));
button->setDisplayOptions(displayOptions(), false);
button->setFilterOptions(filterOptions(), false);
button->setModules(modules());
- connect(button, SIGNAL(sigFilterOptionsChanged(CSwordBackend::FilterOptions)),
- this, SLOT(setFilterOptions(CSwordBackend::FilterOptions)));
- connect(button, SIGNAL(sigDisplayOptionsChanged(CSwordBackend::DisplayOptions)),
- this, SLOT(setDisplayOptions(CSwordBackend::DisplayOptions)));
+ connect(button, SIGNAL(sigFilterOptionsChanged(const FilterOptions&)),
+ this, SLOT(setFilterOptions(const FilterOptions&)));
+ connect(button, SIGNAL(sigDisplayOptionsChanged(const DisplayOptions&)),
+ this, SLOT(setDisplayOptions(const DisplayOptions&)));
connect(button, SIGNAL(sigChanged()),
this, SLOT(lookup()));
}
void CDisplayWindow::slotShowHeader(bool show) {
- headerBar()->setVisible(show);
+ if (headerBar())
+ headerBar()->setVisible(show);
}
void CDisplayWindow::slotShowNavigator(bool show) {
- mainToolBar()->setVisible(show);
+ if (mainToolBar())
+ mainToolBar()->setVisible(show);
}
void CDisplayWindow::slotShowToolButtons(bool show) {
- buttonsToolBar()->setVisible(show);
+ if (buttonsToolBar())
+ buttonsToolBar()->setVisible(show);
}
void CDisplayWindow::slotShowModuleChooser(bool show) {
- moduleChooserBar()->setVisible(show);
+ if (moduleChooserBar())
+ moduleChooserBar()->setVisible(show);
+}
+
+void CDisplayWindow::slotShowFormatToolBar(bool show) {
+ if (formatToolBar())
+ formatToolBar()->setVisible(show);
}
/** Lookup the current key. Used to refresh the display. */
@@ -407,25 +462,25 @@ void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& key
return;
}
- CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
- Q_ASSERT(m);
+ CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(moduleName);
if (!m) {
- return;
+ return; /// \todo check if this is correct behavior
}
/// \todo check for containsRef compat
if (m && modules().contains(m)) {
- key()->key(keyName);
+ key()->setKey(keyName);
keyChooser()->setKey(key()); //the key chooser does send an update signal
+ emit sigKeyChanged(key());
}
- else { //given module not displayed in this window
+ else { //given module not displayed in this window
//if the module is displayed in another display window we assume a wrong drop
//create a new window for the given module
QList<CSwordModuleInfo*> mList;
mList.append(m);
- Q_ASSERT(qobject_cast<BibleTime*>(mdi()->parent()) != 0);
- BibleTime *mainWindow(static_cast<BibleTime*>(mdi()->parent()));
+ BibleTime *mainWindow = btMainWindow();
+ Q_ASSERT(mainWindow != 0);
mainWindow->createReadDisplayWindow(mList, keyName);
}
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index b23d856..c54aab0 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,10 +11,10 @@
#define CDISPLAYWINDOW_H
#include <QMainWindow>
-#include "util/cpointers.h"
#include <QStringList>
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
#include "frontend/profile/cprofilewindow.h"
@@ -23,29 +23,30 @@ class CDisplay;
class BtDisplaySettingsButton;
class CKeyChooser;
class CMDIArea;
-//class CModuleChooserBar;
class BtModuleChooserBar;
-class CReadWindow;
class CSwordModuleInfo;
-class CWriteWindow;
class QCloseEvent;
class QMenu;
class QToolBar;
-
-/** The base class for all display windows of BibleTime.
+class BTHistory;
+class BibleTime;
+
+/** The base class for all display windows of BibleTime.
+ *
+ * Inherits QMainWindow.
+ *
+ * Inherited by CReadWindow and CWriteWindow.
+ *
* @author The BibleTime team
*/
-class CDisplayWindow : public QMainWindow, public CPointers {
+class CDisplayWindow : public QMainWindow {
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 );
+ /** Returns pointer to the mdi area object.*/
inline CMDIArea *mdi() const {
return m_mdi;
}
@@ -54,7 +55,7 @@ class CDisplayWindow : public QMainWindow, public CPointers {
const QString windowCaption();
/** Returns the used modules as a pointer list.*/
- QList<CSwordModuleInfo*> modules();
+ const QList<const CSwordModuleInfo*> modules() const;
/** Returns the used modules as a string list. */
inline const QStringList &getModuleList() const {
@@ -64,16 +65,16 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Store the settings of this window in the given CProfileWindow object.*/
virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- /** Store the settings of this window in the given profile window.*/
+ /** Load the settings the given CProfileWindow object into this window.*/
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
/** Returns the display options used by this display window. */
- inline const CSwordBackend::DisplayOptions &displayOptions() const {
+ inline const DisplayOptions &displayOptions() const {
return m_displayOptions;
}
/** Returns the filter options used by this window. */
- inline const CSwordBackend::FilterOptions &filterOptions() const {
+ inline const FilterOptions &filterOptions() const {
return m_filterOptions;
}
@@ -88,6 +89,9 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Returns true if the window may be closed.*/
virtual bool queryClose();
+ /** Returns history for this window */
+ BTHistory* history();
+
/** Returns the keychooser widget of this display window. */
inline CKeyChooser *keyChooser() const {
return m_keyChooser;
@@ -114,6 +118,9 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Sets and inits the properties of the tool buttons toolbar.*/
void setButtonsToolBar( QToolBar* bar );
+ /** Sets and inits the properties of the format toolbar.*/
+ void setFormatToolBar( QToolBar* bar );
+
/** Returns the main navigation toolbar. */
inline QToolBar *mainToolBar() const {
return m_mainToolBar;
@@ -124,14 +131,14 @@ class CDisplayWindow : public QMainWindow, public CPointers {
return m_buttonsToolBar;
}
+ /** Returns the format toolbar. */
+ inline QToolBar *formatToolBar() const {
+ return m_formatToolBar;
+ }
+
/** Initialize the toolbars.*/
virtual void initToolbars() = 0;
- /** Returns the display settings button. */
- inline BtDisplaySettingsButton *displaySettingsButton() const {
- return m_displaySettingsButton;
- }
-
/** Sets the display settings button.*/
void setDisplaySettingsButton( BtDisplaySettingsButton* button );
@@ -154,6 +161,15 @@ class CDisplayWindow : public QMainWindow, public CPointers {
return false;
};
+ /**
+ * Return pointer to the BibleTime main window
+ */
+ BibleTime* btMainWindow();
+ /**
+ * Called when this window is activated
+ */
+ void windowActivated();
+
inline BtActionCollection *actionCollection() const {
return m_actionCollection;
}
@@ -167,6 +183,23 @@ class CDisplayWindow : public QMainWindow, public CPointers {
void sigModuleRemoved(int index);
/** The module list of window changed but backend list didn't.*/
void sigModuleListChanged();
+
+ /**
+ Signal emitted when display options are changed.
+ */
+ void sigDisplayOptionsChanged(const DisplayOptions &displayOptions);
+
+ /**
+ Signal emitted when display options are changed.
+ */
+ void sigFilterOptionsChanged(const FilterOptions &filterOptions);
+
+ /** signal for change of modules */
+ void sigModulesChanged(const QList<const CSwordModuleInfo*> &modules);
+
+ /** signal for sword key change */
+ void sigKeyChanged(CSwordKey* key);
+
public slots:
/** Receives a signal telling that a module should be added.*/
void slotAddModule(int index, QString module);
@@ -188,6 +221,7 @@ class CDisplayWindow : public QMainWindow, public CPointers {
void slotShowNavigator(bool show);
void slotShowToolButtons(bool show);
void slotShowModuleChooser(bool show);
+ void slotShowFormatToolBar(bool show);
void slotShowHeader(bool show);
protected:
@@ -197,13 +231,17 @@ class CDisplayWindow : public QMainWindow, public CPointers {
CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CDisplayWindow();
- /** Returns the display options used by this display window. */
- inline CSwordBackend::DisplayOptions &displayOptions() {
+ /**
+ \returns the display options used by this display window.
+ */
+ inline DisplayOptions &displayOptions() {
return m_displayOptions;
}
- /** Returns the filter options used by this window. */
- inline CSwordBackend::FilterOptions &filterOptions() {
+ /**
+ \returns the filter options used by this window.
+ */
+ inline FilterOptions &filterOptions() {
return m_filterOptions;
}
@@ -242,18 +280,31 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Returns the installed RMB popup menu.*/
QMenu* popup();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars() = 0;
+
virtual void closeEvent(QCloseEvent* e);
+ void setToolBarsHidden();
+ void clearMainWindowToolBars();
+
protected slots:
- /** Sets the new filter options of this window.*/
- void setFilterOptions(const CSwordBackend::FilterOptions &filterOptions);
+ /**
+ Sets the new filter options of this window.
+ */
+ void setFilterOptions(const FilterOptions &filterOptions);
- /** Sets the new display options for this window.*/
- void setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions);
+ /**
+ Sets the new display options for this window.
+ */
+ void setDisplayOptions(const DisplayOptions &displayOptions);
virtual void modulesChanged();
- /** Lookup the current key. Used to refresh the display.*/
+ /**
+ Lookup the current key. Used to refresh the display. This also needs to be called
+ after programmatically changing filter/display options.
+ */
void lookup();
virtual void updatePopupMenu();
@@ -270,22 +321,23 @@ class CDisplayWindow : public QMainWindow, public CPointers {
BtActionCollection* m_actionCollection;
CMDIArea* m_mdi;
- //we may only cache the module names bacause after a backend relaod the pointers are invalid!
+ //we may only cache the module names bacause after a backend reload the pointers are invalid!
QStringList m_modules;
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
+ FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
- BtDisplaySettingsButton* m_displaySettingsButton;
CKeyChooser* m_keyChooser;
CSwordKey* m_swordKey;
bool m_isReady;
BtModuleChooserBar* m_moduleChooserBar;
QToolBar* m_mainToolBar;
QToolBar* m_buttonsToolBar;
+ QToolBar* m_formatToolBar;
QToolBar* m_headerBar;
QMenu* m_popupMenu;
CDisplay* m_displayWidget;
+ BTHistory* m_history;
};
#endif
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index 05fa963..9e1b5f6 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,24 +25,29 @@
CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent) {
qDebug() << "CDisplayWindowFactory::createReadInstance";
+ CReadWindow* win = 0;
switch (modules.first()->type()) {
case CSwordModuleInfo::Bible:
- return new CBibleReadWindow(modules, parent);
+ win = new CBibleReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::Commentary:
- return new CCommentaryReadWindow(modules, parent);
+ win = new CCommentaryReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::Lexicon:
- return new CLexiconReadWindow(modules, parent);
+ win = new CLexiconReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::GenericBook:
- return new CBookReadWindow(modules, parent);
+ win = new CBookReadWindow(modules, parent);
+ break;
default:
qWarning("unknown module type");
break;
}
- return 0;
+ return win;
}
-CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type) {
- if (type == CDisplayWindow::HTMLWindow) {
+CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type) {
+ if (type == CWriteWindow::HTMLWindow) {
return new CHTMLWriteWindow(modules, parent);
}
else {
@@ -50,3 +55,15 @@ CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*
}
return 0;
}
+
+const CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
+ if (qobject_cast<CBibleReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Bible;
+ if (qobject_cast<CCommentaryReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Commentary;
+ if (qobject_cast<CBookReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::GenericBook;
+ if (qobject_cast<CLexiconReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Lexicon;
+ return CSwordModuleInfo::Unknown;
+}
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index b4d856a..06d9aa4 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +11,7 @@
#define CDISPLAYWINDOWFACTORY_H
#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/cwritewindow.h"
class CMDIArea;
@@ -22,7 +23,8 @@ class CWriteWindow;
class CDisplayWindowFactory {
public:
static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type = CDisplayWindow::HTMLWindow);
+ static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type = CWriteWindow::HTMLWindow);
+ static const CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
private:
CDisplayWindowFactory();
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index 31cb92b..df36080 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,10 +11,12 @@
#include <QAction>
#include <QToolBar>
+#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 "util/directory.h"
@@ -35,13 +37,25 @@ void CHTMLWriteWindow::initView() {
setDisplayWidget( writeDisplay );
setCentralWidget( displayWidget()->view() );
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ // Create the Tools toolbar
+ setButtonsToolBar( new QToolBar(this) );
+ addToolBar(buttonsToolBar());
+
+ // Create the Format toolbar
+ setFormatToolBar( new QToolBar(this) );
+ addToolBar(formatToolBar());
+}
+
+void CHTMLWriteWindow::initActions() {
+ insertKeyboardActions(actionCollection());
+ CPlainWriteWindow::initActions();
+}
+
+void CHTMLWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
}
void CHTMLWriteWindow::initConnections() {
@@ -54,76 +68,32 @@ void CHTMLWriteWindow::initConnections() {
void CHTMLWriteWindow::initToolbars() {
namespace DU = util::directory;
- //setup the main toolbar
- m_actions.syncWindow = new QAction(
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
- mainToolBar()->addAction(m_actions.syncWindow);
-
- m_actions.saveText = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- m_actions.saveText->setToolTip( tr("Save text") );
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT( saveCurrentText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT( deleteEntry() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
-
- m_actions.restoreText = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT( restoreText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
-
- //html formatting toolbar
- QToolBar* bar = new QToolBar(this);
- bar->setAllowedAreas(Qt::TopToolBarArea);
- bar->setFloatable(false);
- ((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
- addToolBar(bar);
+ CPlainWriteWindow::initToolbars();
+
+ //Formatting toolbar
+ ((CWriteDisplay*)displayWidget())->setupToolbar( formatToolBar(), actionCollection() );
}
void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ profileWindow->setWindowSettings( action->isChecked() );
}
void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::applyProfileSettings(profileWindow);
if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ action->setChecked(true);
}
}
/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Loads the original text from the module. */
@@ -134,7 +104,8 @@ void CHTMLWriteWindow::restoreText() {
}
bool CHTMLWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ return action->isChecked();
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
@@ -148,8 +119,8 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
+ const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
+ this->key()->setKey(oldKey);
((CWriteDisplay*)displayWidget())->setModified(false);
textChanged();
@@ -161,3 +132,9 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
.arg( tr("Either the module may not be edited, or you do not have write permission.") ) );
}
}
+
+void CHTMLWriteWindow::setupMainWindowToolBars() {
+ CPlainWriteWindow::setupMainWindowToolBars();
+ //Formatting toolbar
+ ((CWriteDisplay*)displayWidget())->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
+}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 4d140cf..b669f94 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +15,11 @@
class QAction;
-/** The WYSIWYG implementation of the editor.
+/**
+ * The write window class which offers a WYSIWYG text editor for creating a personal commentary.
+ *
+ * Inherits CPlainWriteWindow.
+ *
* @author The BibleTime team
*/
class CHTMLWriteWindow : public CPlainWriteWindow {
@@ -28,11 +32,15 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Store the settings of this window in the given CProfileWindow object.
*/
virtual void storeProfileSettings( Profile::CProfileWindow* );
+
/**
* Store the settings of this window in the given profile window.
*/
virtual void applyProfileSettings( Profile::CProfileWindow* );
+ /**
+ * Returns true if the sync toolbar is enabled.
+ */
virtual bool syncAllowed() const;
protected:
@@ -42,9 +50,20 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::HTMLWindow;
+ 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;
}
+ /**
+ * Called to add actions to mainWindow toolbars
+ */
+ virtual void setupMainWindowToolBars();
protected slots:
/**
@@ -59,14 +78,6 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Saves the text for the current key. Directly writes the changed text into the module.
*/
virtual void saveCurrentText( const QString& );
- private:
- struct {
- QAction* saveText;
- QAction* restoreText;
- QAction* deleteEntry;
- QAction* syncWindow;
- }
- m_actions;
};
#endif
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 894c787..dae85e3 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +16,7 @@
#include <QMenu>
#include <QDebug>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordkey.h"
@@ -154,7 +155,7 @@ void CLexiconReadWindow::initConnections() {
Q_ASSERT(keyChooser());
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(keyChooser()->history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
+ connect(history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
//connect the history actions to the right slots
bool ok = connect(
@@ -182,42 +183,81 @@ void CLexiconReadWindow::initConnections() {
void CLexiconReadWindow::initView() {
qDebug() << "CLexiconReadWindow::initView";
+
+ // Create display widget for this window
setDisplayWidget( CDisplay::createReadInstance(this) );
+ setCentralWidget( displayWidget()->view() );
+ setWindowIcon(util::tool::getIconForModule(modules().first()));
+
+ // Create the Navigation toolbar
setMainToolBar( new QToolBar(this) );
addToolBar(mainToolBar());
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
- setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
+
+ // Create keychooser
+ setKeyChooser( CKeyChooser::createInstance(modules(), history(), key(), mainToolBar()) );
+
+ // Create the Works toolbar
+ setModuleChooserBar( new BtModuleChooserBar(this));
+ moduleChooserBar()->setModules(getModuleList(), modules().first()->type(), this);
addToolBar(moduleChooserBar());
+
+ // Create the Tools toolbar
setButtonsToolBar( new QToolBar(this) );
addToolBar(buttonsToolBar());
+
+ // Create the Text Header toolbar
addToolBarBreak();
setHeaderBar(new QToolBar(this));
addToolBar(headerBar());
- BtTextWindowHeader* h = new BtTextWindowHeader(this, modules().first()->type(), getModuleList());
- headerBar()->addWidget(h);
- setWindowIcon(util::tool::getIconForModule(modules().first()));
- setCentralWidget( displayWidget()->view() );
}
void CLexiconReadWindow::initToolbars() {
- //main toolbar
+ //Navigation toolbar
Q_ASSERT(m_actions.backInHistory);
+ mainToolBar()->addWidget(keyChooser());
mainToolBar()->addAction(m_actions.backInHistory); //1st button
mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
- //buttons toolbar
+ //Tools toolbar
QAction* action = qobject_cast<QAction*>(actionCollection()->action(
CResMgr::displaywindows::general::search::actionName));
Q_ASSERT( action );
if (action) {
buttonsToolBar()->addAction(action);
}
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ buttonsToolBar()->addWidget(button);
- setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
+ // Text Header toolbar
+ BtTextWindowHeader *h = new BtTextWindowHeader(modules().first()->type(), getModuleList(), this);
+ headerBar()->addWidget(h);
+}
- /// \todo find the right place for the button
- buttonsToolBar()->addWidget(displaySettingsButton());
+void CLexiconReadWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(sigKeyChanged(CSwordKey*)), keyChooser, SLOT(updateKey(CSwordKey*)) );
+ Q_ASSERT(ok);
+ btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
+ btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+
+ // Works toolbar
+ btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
+
+ // Tools toolbar
+ QAction* action = actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName);
+ Q_ASSERT( action );
+ if (action) {
+ btMainWindow()->toolsToolBar()->addAction(action);
+ }
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ btMainWindow()->toolsToolBar()->addWidget(button);
}
void CLexiconReadWindow::setupPopupMenu() {
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index 2a32cec..36b47db 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,26 +22,21 @@ class CSwordKey;
class QAction;
class QMenu;
-/**
- *@author The BibleTime team
+/** The class used to display lexicons. It is also used as the class that other display window types are derived from.
+ *
+ * Inherits CReadWindow.
+ *
+ * Inherited by CBibleReadWindow, CBookReadWindow, and CCommentaryReadWindow.
+ *
+ * @author The BibleTime team
*/
class CLexiconReadWindow : public CReadWindow {
Q_OBJECT
public:
CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CLexiconReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- // virtual void storeProfileSettings( CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- // virtual void applyProfileSettings( CProfileWindow* profileWindow );
- /**
- * Reimplementation.
- */
- // static void insertKeyboardActions( KAccel* a );
+
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
public slots:
@@ -58,6 +53,8 @@ class CLexiconReadWindow : public CReadWindow {
virtual void updatePopupMenu();
virtual void setupPopupMenu();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
struct ActionsStruct {
BtToolBarPopupAction* backInHistory;
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index 6394998..ad3b978 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,12 @@
#include <QDebug>
#include <QRegExp>
#include <QToolBar>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.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 "util/cresmgr.h"
@@ -40,69 +42,52 @@ void CPlainWriteWindow::initView() {
setDisplayWidget( CDisplay::createWriteInstance(this) );
setCentralWidget( displayWidget()->view() );
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
- addToolBarBreak();
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ // Create the Tools toolbar
+ setButtonsToolBar( new QToolBar(this) );
+ addToolBar(buttonsToolBar());
}
void CPlainWriteWindow::initToolbars() {
namespace DU = util::directory;
- m_actions.syncWindow = new QAction(
- //KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- mainToolBar()->addAction(m_actions.syncWindow);
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
-
-
- m_actions.saveText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
- m_actions.saveText->setToolTip( tr("Save text") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
+ // Navigation toolbar
+ setKeyChooser( CKeyChooser::createInstance(modules(),
+ history(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+ // Tools toolbar
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ buttonsToolBar()->addAction(action);
+}
- m_actions.restoreText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT(restoreText()) );
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
+void CPlainWriteWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(keyChooser, SIGNAL(beforeKeyChange(const QString&)), this, SLOT(beforeKeyChange(const QString&)));
+ Q_ASSERT(ok);
+
+ // Tools toolbar
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
}
void CPlainWriteWindow::initConnections() {
@@ -113,13 +98,15 @@ void CPlainWriteWindow::initConnections() {
void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ profileWindow->setWindowSettings( action->isChecked() );
}
void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::applyProfileSettings(profileWindow);
if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ action->setChecked(true);
}
}
@@ -134,8 +121,8 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
+ const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
+ this->key()->setKey(oldKey);
((CWriteDisplay*)displayWidget())->setModified(false);
textChanged();
@@ -158,13 +145,15 @@ void CPlainWriteWindow::restoreText() {
/** Is called when the current text was changed. */
void CPlainWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Deletes the module entry and clears the edit widget, */
void CPlainWriteWindow::deleteEntry() {
- modules().first()->deleteEntry( key() );
+ const_cast<CSwordModuleInfo*>(modules().first())->deleteEntry(key());
lookupSwordKey( key() );
((CWriteDisplay*)displayWidget())->setModified(false);
}
@@ -173,11 +162,68 @@ void CPlainWriteWindow::deleteEntry() {
void CPlainWriteWindow::setupPopupMenu() {}
bool CPlainWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ return action->isChecked();
}
void CPlainWriteWindow::initActions() {
+ insertKeyboardActions(actionCollection());
+
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ bool ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(restoreText()) );
+ Q_ASSERT(ok);
}
-void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const ) {
+void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
+
+ namespace DU = util::directory;
+
+ QAction* action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ tr("Sync with active Bible"),
+ a
+ );
+ action->setCheckable(true);
+ action->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ action->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
+ a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ tr("Save text"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
+ action->setToolTip( tr("Save text") );
+ a->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ tr("Delete current entry"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
+ action->setToolTip( tr("Delete current entry (no undo)") );
+ a->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ tr("Restore original text"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
+ action->setToolTip( tr("Restore original text, new text will be lost") );
+ a->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, action);
}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index ec9fe5e..9d3f29c 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,7 +17,12 @@ class BtActionCollection;
class QAction;
class QString;
-/** The write window class which offers a plain editor for source code editing.
+/** The write window class which offers a plain text editor for creating a personal commentary.
+ *
+ * Inherits CWriteWindow.
+ *
+ * Inherited by CHTMLWriteWindow.
+ *
* @author The BibleTime team
*/
class CPlainWriteWindow : public CWriteWindow {
@@ -39,6 +44,10 @@ class CPlainWriteWindow : public CWriteWindow {
* Setups the popup menu of this display widget.
*/
virtual void setupPopupMenu();
+
+ /**
+ * Returns true if the sync toolbar is enabled.
+ */
virtual bool syncAllowed() const;
protected: // Protected methods
@@ -48,10 +57,12 @@ class CPlainWriteWindow : public CWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::PlainTextWindow;
+ virtual CWriteWindow::WriteWindowType writeWindowType() {
+ return CWriteWindow::PlainTextWindow;
};
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
/**
* Initializes the intern keyboard actions.
*/
@@ -61,15 +72,6 @@ class CPlainWriteWindow : public CWriteWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
- private:
- struct {
- QAction* saveText;
- QAction* deleteEntry;
- QAction* restoreText;
- QAction* syncWindow;
- }
- m_actions;
-
protected slots: // Protected slots
/**
* Saves the text for the current key. Directly writes the changed text into the module.
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index 07c0abb..4c18b0b 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -83,13 +83,13 @@ void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
using namespace Rendering;
-// Q_ASSERT(isReady() && newKey && modules().first());
+// Q_ASSERT(isReady() && newKey && modules().first());
if (!isReady() || !newKey || modules().empty() || !modules().first()) {
return;
}
if (key() != newKey) {
- key()->key(newKey->key());
+ key()->setKey(newKey->key());
}
/// \todo next-TODO how about options?
@@ -146,11 +146,8 @@ void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
}
QStringList mods;
-
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
+ Q_FOREACH (const CSwordModuleInfo *module, modules()) {
+ mods.append(module->name());
}
settings->setModules(mods);
}
@@ -191,7 +188,7 @@ void CReadWindow::resizeEvent(QResizeEvent* /*e*/) {
}
void CReadWindow::openSearchStrongsDialog() {
-// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
+// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
QString searchText = QString::null;
if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index 7a529b8..855baa2 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,12 +20,18 @@ 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 {
Q_OBJECT
public:
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
@@ -35,7 +41,7 @@ class CReadWindow : public CDisplayWindow {
*/
virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
/**
- * Store the settings of this window in the given CProfileWindow object.
+ * Load the settings the given CProfileWindow object into this window.
*/
virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
@@ -45,9 +51,13 @@ class CReadWindow : public CDisplayWindow {
*/
virtual void setDisplayWidget( CDisplay* newDisplay );
/**
+ * Reimplemented Qt function for resize of window.
*/
virtual void resizeEvent(QResizeEvent* e);
+ /** Called to add actions to mainWindow toolbars.*/
+ virtual void setupMainWindowToolBars() = 0;
+
protected slots:
/**
* Load the text using the key
@@ -62,8 +72,8 @@ 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.
- *
+ /**
+ * 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
index 7496dd7..3369d8a 100644
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ b/src/frontend/displaywindow/cwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -65,10 +65,8 @@ void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
}
QStringList mods;
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
+ Q_FOREACH(const CSwordModuleInfo *m, modules()) {
+ mods.append(m->name());
}
settings->setModules(mods);
}
@@ -103,7 +101,7 @@ void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
return;
if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
- key()->key(newKey->key());
+ key()->setKey(newKey->key());
}
if ( modules().count() ) {
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
index 5d6a316..7a5a524 100644
--- a/src/frontend/displaywindow/cwritewindow.h
+++ b/src/frontend/displaywindow/cwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,11 +18,22 @@ 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);
@@ -32,10 +43,14 @@ class CWriteWindow : public CDisplayWindow {
*/
virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
/**
- * Store the settings of this window in the given CProfileWindow object.
+ * 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:
@@ -47,14 +62,22 @@ class CWriteWindow : public CDisplayWindow {
protected: // Protected methods
/**
- * Saves the given text as text of the given key. Use this function
- * as backend in each write window implementation.
+ * Set the displayWidget which is a subclass of QWebPage.
*/
void setDisplayWidget( CDisplay* display );
- virtual CDisplayWindow::WriteWindowType writeWindowType() = 0;
+
+ /** 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
*/
diff --git a/src/frontend/htmldialogs/btaboutdialog.cpp b/src/frontend/htmldialogs/btaboutdialog.cpp
deleted file mode 100644
index 528d9d5..0000000
--- a/src/frontend/htmldialogs/btaboutdialog.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/htmldialogs/btaboutdialog.h"
-
-#include "util/directory.h"
-
-// Sword includes:
-#include <swversion.h>
-
-
-// Forwards
-static QString make_body(const QString& content);
-static QString make_bold(const QString& content);
-static QString make_br();
-static QString make_center(const QString& content);
-static QString make_head(const QString& content);
-static QString make_html(const QString& content);
-static QString make_file_icon(const QString& icon);
-static QString make_link(const QString& link, const QString& text);
-
-
-// Implements the Help > About dialog box
-
-BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags )
- : BtTabHtmlDialog (tr("About BibleTime"), 5, parent, wflags) {
- resize(550, 340);
- init_lic_tab();
- init_sword_tab();
- init_qt_tab();
- init_contributors_tab();
- init_bt_tab();
-}
-
-BtAboutDialog::~BtAboutDialog() {
-}
-
-void BtAboutDialog::init_bt_tab() {
- selectTab(0);
- setTabText("BibleTime" );
- QString content;
- content = make_file_icon("bibletime");
- content += "&nbsp;&nbsp;";
- content += make_bold("BibleTime " BT_VERSION);
- content = make_center(content) + make_br();
- content += tr("BibleTime is an easy to use but powerful Bible study tool.");
- content += make_br() + make_br();
- content += tr("We are looking for developers and translators.");
- content += " ";
- content += tr("If you would like to join our team, please send an email to info@bibletime.info.");
- content += make_br() + make_br();
- content += tr("(c)1999-2009, The BibleTime Team");
- content += make_br();
- content += make_link("http://www.bibletime.info", "http://www.bibletime.info");
- QString bibletime = make_html(make_head("") + make_body(content));
- setHtml(bibletime);
-}
-
-void BtAboutDialog::init_contributors_tab() {
- selectTab(1);
- setTabText(tr("Contributors"));
- QString content;
- content += make_bold(tr("The following people contributed to BibleTime:")) + make_br();
-
- /****************************************************************************************
- *** NB!!! Credits are sorted alphabetically by last name! ***
- ****************************************************************************************/
- content += "<ul>";
- content += "<li>Thomas Abthorpe (" + tr("documentation and translation manager") + ")</li>";
- content += "<li>Joachim Ansorg (" + tr("project founder, developer") + ")</li>";
- content += "<li>David Blue (" + tr("designer") + ")</li>";
- content += "<li>Tim Brodie (" + tr("developer") + ")</li>";
- content += "<li>Timothy R. Butler (" + tr("designer") + ")</li>";
- content += "<li>Jim Campbell (" + tr("developer") + ")</li>";
- content += "<li>Lee Carpenter (" + tr("developer") + ")</li>";
- content += "<li>Jeremy Erickson (" + tr("packager") + ")</li>";
- content += "<li>Troy A. Griffitts (" + tr("creator of The Sword Project") + ")</li>";
- content += "<li>Martin Gruner (" + tr("project manager, developer") + ")</li>";
- content += "<li>Thomas Hagedorn (" + tr("domain sponsor") + ")</li>";
- content += "<li>Bob Harman (" + tr("howto") + ")</li>";
- content += "<li>Gary Holmlund (" + tr("developer") + ")</li>";
- content += "<li>Nikolay Igotti (" + tr("developer") + ")</li>";
- content += "<li>Eeli Kaikkonnen (" + tr("developer") + ")</li>";
- content += "<li>Chris Kujawa (" + tr("developer") + ")</li>";
- content += "<li>Mark Lybarger (" + tr("developer") + ")</li>";
- content += "<li>Luke Mauldin (" + tr("developer") + ")</li>";
- content += "<li>James Ots (" + tr("designer") + ")</li>";
- /** \todo BibleTime 2.6: Add tr("artist"): */
- content += "<li>Andrus Raag</li>";
- content += "<li>Jaak Ristioja (" + tr("developer") + ")</li>";
- content += "<li>Fred Saalbach (" + tr("documentation") + ")</li>";
- content += "<li>Gary Sims (" + tr("developer") + ")</li>";
- content += "<li>Wolfgang Stradner (" + tr("tester, usability expert") + ")</li>";
- content += "<li>Kang Sun (" + tr("developer") + ")</li>";
- content += "<li>Thorsten Uhlmann (" + tr("developer") + ")</li>";
- content += "<li>David White (" + tr("developer") + ")</li>";
- content += "<li>Mark Zealey (" + tr("developer") + ")</li>";
- content += "</ul>";
-
- content += make_bold(tr("The following people translated BibleTime into their language:")) + make_br();
-
- /****************************************************************************************
- *** NB!!! Credits are sorted alphabetically by last name! ***
- ****************************************************************************************/
- content += "<ul>";
- content += "<li>Horatiu Alexe</li>";
- content += "<li>Luis Barron</li>";
- content += "<li>Jan B&#x11B;lohoubek</li>";
- content += "<li>Chun-shek Chan</li>";
- content += "<li>Nouhoun Y. Diarra</li>";
- content += "<li>Rafael Fagundes</li>";
- content += "<li>Ilpo Kantonen</li>";
- content += "<li>Pavel Laukko</li>";
- content += "<li>Piotr Markiewicz</li>";
- content += "<li>G&eacute;za Nov&aacute;k</li>";
- content += "<li>Gabriel P&eacute;rez</li>";
- content += "<li>Igor Plisco</li>";
- content += "<li>Zdenko Podobn&yacute;</li>";
- content += "<li>Jaak Ristioja</li>";
- content += "<li>Igor Rykhlin</li>";
- content += "<li>Vlad Savitsky</li>";
- content += "<li>Henrik Sonesson</li>";
- content += "<li>Johan van der Lingen</li>";
- content += "<li>Jean Van Schaftingen</li>";
- content += "<li>Roland Teschner</li>";
- content += "<li>Giovanni Tedaldi</li>";
- content += "<li>Dmitry Yurevich</li>";
- content += "<li>Esteban Zeller</li>";
- content += "</ul>";
- content += make_br();
- content += tr("Some names may be missing, please email bibletime-translations@lists.sourceforge.net if you notice errors or omissions.");
-
- QString contributors = make_html(make_head("") + make_body(content));
- setHtml(contributors);
-}
-
-
-void BtAboutDialog::init_sword_tab() {
- selectTab(2);
- setTabText("Sword" );
-
- QString version( sword::SWVersion::currentVersion.getText());
- QString content = make_br() + make_br();
- content += make_center(make_bold(tr("SWORD library version %1").arg(version)));
- content += make_br();
-
- content += tr("BibleTime makes use of the SWORD Project. The SWORD Project is the CrossWire Bible Society's free Bible software project. Its purpose is to create cross-platform open-source tools-- covered by the GNU General Public License-- that allow programmers and Bible societies to write new Bible software more quickly and easily.");
- content += make_br() + make_br();
- content += tr("The SWORD Project") + make_br();
- content += make_link("http://www.crosswire.org/sword/index.jsp", "www.crosswire.org/sword/index.jsp");
-
- setHtml(content);
-
-}
-
-void BtAboutDialog::init_qt_tab() {
- selectTab(3);
- setTabText("Qt");
- QString content;
- content += make_br() + make_br();
- content += make_center(make_bold("Qt"));
- content += make_br();
- content += tr("This program uses Qt version %1.").arg(qVersion());
- content += make_br() + make_br();
- content += tr("Qt is a cross-platform application and UI framework, created with C++ language. It has been released under the LGPL license.");
- content += make_br() + make_br();
- content += make_link("http://qt.nokia.com/", "http://qt.nokia.com/");
- //content += tr("Please see ");
- //content += make_link("http://qtsoftware.com/company/model/", "qtsoftware.com/company/model");
- //content += tr(" for an overview of Qt licensing.");
- QString qt = make_html(make_head("") + make_body(content));
- setHtml(qt);
-}
-
-void BtAboutDialog::init_lic_tab() {
- namespace DU = util::directory;
-
- selectTab(4);
- setTabText(tr("License"));
-
- QByteArray text;
- text += tr("BibleTime is released under the GPL license.");
- text += " ";
- text += tr("You can download and use (but not distribute) the program for personal, private, public or commercial purposes without restrictions.");
- text += " ";
- text += tr("You can give away or distribute the program if you also distribute the corresponding source code.");
- text += "<br/><br/>";
- //text += tr("It is allowed to distribute software under GPL for a small fee, but it must be accompanied with the complete source code, and the fact that it is freely available with no cost must not be hidden.");
- //text += "<br/><br/>";
- text += tr("The complete legally binding license is below.");
-
- QFile licFile(DU::getLicenseDir().path() + "/license.html");
- if (licFile.open(QFile::ReadOnly)) {
- QByteArray html;
- while (!licFile.atEnd()) {
- QByteArray line = licFile.readLine();
- html = html + line;
- }
- licFile.close();
- html.replace("TRANSLATED TEXT", text);
- setHtml(QString(html));
- }
-}
-
-
-
-// Helper functions
-
-static QString make_center(const QString& content) {
- return "<center>" + content + "</center>";
-}
-
-static QString make_br() {
- return "<br/>";
-}
-
-static QString make_bold(const QString& content) {
- return "<b>" + content + "</b>";
-}
-
-static QString make_html(const QString& content) {
- return "<html>" + content + "</html>";
-}
-
-static QString make_head(const QString& content) {
- return "<head>" + content + "</head>";
-}
-
-static QString make_body(const QString& content) {
- return "<body>" + content + "</body>";
-}
-
-static QString make_link(const QString& link, const QString& text) {
- return "<a href=\"" + link + "\">" + text + "</a>";
-}
-
-static QString make_file_icon(const QString& icon) {
- namespace DU = util::directory;
- QUrl url = QUrl::fromLocalFile( DU::getIconDir().path() + "/" + icon + ".svg");
- QString html = "<img src=\"" + url.toString() + "\">";
- return html;
-}
-
diff --git a/src/frontend/htmldialogs/btaboutdialog.h b/src/frontend/htmldialogs/btaboutdialog.h
deleted file mode 100644
index 2fed22a..0000000
--- a/src/frontend/htmldialogs/btaboutdialog.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTABOUTDIALOG_H
-#define BTABOUTDIALOG_H
-
-#include "frontend/htmldialogs/bttabhtmldialog.h"
-
-
-class BtAboutDialog : public BtTabHtmlDialog {
- Q_OBJECT
- public:
- BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtAboutDialog();
-
- void init_bt_tab();
- void init_contributors_tab();
- void init_sword_tab();
- void init_qt_tab();
- void init_lic_tab();
-};
-
-#endif
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.cpp b/src/frontend/htmldialogs/bttabhtmldialog.cpp
deleted file mode 100644
index bd52464..0000000
--- a/src/frontend/htmldialogs/bttabhtmldialog.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/htmldialogs/bttabhtmldialog.h"
-
-#include <QContextMenuEvent>
-#include <QDesktopServices>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QMenu>
-#include <QTabWidget>
-#include <QVBoxLayout>
-#include <QWebView>
-#include "util/dialogutil.h"
-#include "util/directory.h"
-
-
-BtTabHtmlDialog::BtTabHtmlDialog
-(const QString& title, int tabs, QWidget *parent, Qt::WindowFlags wflags )
- : QDialog(parent, wflags), m_webView(0), m_tabWidget(0), m_tabs(tabs) {
- //Set the flag to destroy when closed
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(title);
- resize(400, 300);
-
- QVBoxLayout *vboxLayout = new QVBoxLayout(this);
- if (tabs == 0) {
- m_webView = new BtWebView(this);
- init_connections(m_webView);
- vboxLayout->addWidget(m_webView);
- m_webView->setHtml("Hi");
- }
- else {
- m_tabWidget = new QTabWidget(this);
- vboxLayout->addWidget(m_tabWidget);
- for (int i = 0; i < tabs; i++) {
- QWebView* webView = new BtWebView(this);
- init_connections(webView);
- webView->setObjectName("View" + QString::number(i));
- webView->setHtml(" ");
- m_tabWidget->addTab(webView, "Tab" + QString::number(i));
- m_tabWidget->show();
- }
- }
-
- QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
- vboxLayout->addWidget(buttonBox);
-
- bool ok;
- ok = connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- Q_ASSERT(ok);
- ok = connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- Q_ASSERT(ok);
-}
-
-BtTabHtmlDialog::~BtTabHtmlDialog() {
-}
-
-void BtTabHtmlDialog::init_connections(QWebView* webView) {
- webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
- bool ok = connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
- Q_ASSERT(ok);
-}
-
-void BtTabHtmlDialog::linkClicked(const QUrl url) {
- QDesktopServices::openUrl(url);
-}
-
-void BtTabHtmlDialog::selectTab(int tab) {
- Q_ASSERT(tab >= 0 && tab < m_tabWidget->count());
- m_tabWidget->setCurrentIndex(tab);
-}
-
-QWebView* BtTabHtmlDialog::webView() {
- QWebView* webview = 0;
- if (m_tabs == 0)
- webview = m_webView;
- else {
- QWidget* widget = m_tabWidget->currentWidget();
- QString name = widget->objectName();
- webview = qobject_cast<QWebView*>(widget);
- }
- Q_ASSERT(webview != 0);
- return webview;
-}
-
-void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl) {
- namespace DU = util::directory;
- QUrl url = baseUrl;
- if (url == QUrl()) {
- QUrl url = QUrl::fromLocalFile(DU::getIconDir().path());
- }
- webView()->setHtml(html, url);
-}
-
-void BtTabHtmlDialog::setUrl(const QUrl& url) {
- webView()->setUrl(url);
-}
-
-void BtTabHtmlDialog::setTabText(const QString& tabName) {
- Q_ASSERT(m_tabs != 0); // There are no tabs to name
- int index = m_tabWidget->currentIndex();
- m_tabWidget->setTabText(index, tabName);
-}
-
-// ******************* BtWebView *******************
-
-BtWebView::BtWebView(QWidget* parent)
- : QWebView(parent), m_popup(0) {
- m_popup = new QMenu(this);
- QAction* copyAction = pageAction(QWebPage::Copy);
- m_popup->addAction(copyAction);
-}
-
-void BtWebView::contextMenuEvent(QContextMenuEvent* event) {
- m_popup->exec(event->globalPos());
-}
-
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.h b/src/frontend/htmldialogs/bttabhtmldialog.h
deleted file mode 100644
index 6e5ed20..0000000
--- a/src/frontend/htmldialogs/bttabhtmldialog.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTTABDIALOG_H
-#define BTTABDIALOG_H
-
-#include <QDialog>
-
-#include <QString>
-#include <QUrl>
-#include <QWebView>
-
-
-class QTabWidget;
-class QMenu;
-
-// This class creates a dialog with zero or more tabs. For zero tabs it is
-// just a single QWebView inside the dialog. For 1 or more tabs, each tab
-// contains a separate QWebView. Each QWebView can have either plain text or
-// html text. The class will automatically delete itself when closed.
-// The class can either be directly called or subclassed. The dialog is not modal.
-
-// Typical direct usage:
-//
-// Zero tabs
-// BtTabHtmlDialog* dlg = new BtTabHtmlDialog("My Title", 0, parent);
-// dlg->setHtml(htmlText);
-// dlg->show();
-//
-// or
-//
-// Two tabs
-// BtTabHtmlDialog* dlg = new BtTabHtmlDialog("My Title", 2, parent);
-// dlg->selectTab(0);
-// dlg->setTabText(nameOfTab0);
-// dlg->setHtml(htmlText0);
-// dlg->selectTab(1);
-// dlg->setTabText(nameOfTab1);
-// dlg->setHtml(htmlText1);
-// dlg->show();
-
-
-class BtTabHtmlDialog : public QDialog {
- Q_OBJECT
- public:
- BtTabHtmlDialog(const QString& title, int numberTabs, QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtTabHtmlDialog();
- void selectTab(int tab);
- void setTabText(const QString& tabName);
-
-// See QWebView::setHtml()
- void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
-
-// See QWebView::setUrl()
- void setUrl(const QUrl& url);
-
- private slots:
- void linkClicked(const QUrl url);
-
- private:
- void init_connections(QWebView* webView);
- QWebView* webView();
-
- QWebView* m_webView;
- QTabWidget* m_tabWidget;
- int m_tabs;
-};
-
-
-class BtWebView : public QWebView {
- public:
- BtWebView(QWidget* parent = 0);
-
- protected:
- void contextMenuEvent(QContextMenuEvent* event);
-
- private:
- QMenu* m_popup;
-};
-
-#endif
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 60d2a7b..329ce78 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,7 +28,7 @@ void BTHistory::add(CSwordKey* newKey) {
Q_ASSERT(newKey);
// Add new key Action after current index if we were not using the history functions,
// if it's not a duplicate and if it's not empty.
- if (!m_inHistoryFunction && ((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->text()) )) {
+ if (!m_inHistoryFunction && ((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->text()) )) {
if (!newKey->key().isEmpty()) {
m_historyList.insert(++m_index, new QAction(newKey->key(), this));
}
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index df674d0..2a374b6 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index 21216e4..1c7fccb 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,8 +21,11 @@
QMap<QObject*, int> boxes;
-CBookKeyChooser::CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, key, parent), m_layout(0) {
+CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *historyPtr, CSwordKey *key,
+ QWidget *parent)
+ : CKeyChooser(modules, historyPtr, key, parent), m_layout(0)
+{
setModules(modules, false);
m_key = dynamic_cast<CSwordTreeKey*>(key);
@@ -37,8 +40,6 @@ CBookKeyChooser::CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *ke
connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
-CBookKeyChooser::~CBookKeyChooser() {}
-
void CBookKeyChooser::setKey(CSwordKey* newKey) {
setKey(newKey, true);
}
@@ -83,7 +84,7 @@ void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
if (found)
key = m_key->key(); //found: change key to this level
else
- m_key->key(key); //not found: restore old key
+ m_key->setKey(key); //not found: restore old key
setupCombo(key, depth, index);
@@ -119,14 +120,17 @@ CSwordKey* CBookKeyChooser::key() {
}
/** Sets another module to this keychooser */
-void CBookKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
+void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh)
+{
+ typedef CSwordBookModuleInfo CSBMI;
m_modules.clear();
// for (modules.first(); modules.current(); modules.next()) {
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- if ( (*it)->type() == CSwordModuleInfo::GenericBook ) {
- if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
+ Q_FOREACH(const CSwordModuleInfo *m, modules) {
+ if (m->type() == CSwordModuleInfo::GenericBook ) {
+ const CSBMI *book = dynamic_cast<const CSBMI*>(m);
+ if (book != 0) {
m_modules.append(book);
}
}
@@ -214,8 +218,8 @@ void CBookKeyChooser::setupCombo(const QString key, const int depth, const int c
CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
CSwordTreeKey tmpKey(*m_key);
- tmpKey.key(key);
- tmpKey.parent();
+ tmpKey.setKey(key);
+ tmpKey.sword::TreeKeyIdx::parent();
tmpKey.firstChild();
QStringList items;
@@ -250,7 +254,7 @@ void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
QString newKey("/");
newKey.append(items.join("/"));
- m_key->key(newKey);
+ m_key->setKey(newKey);
setKey(m_key);
}
@@ -260,6 +264,6 @@ void CBookKeyChooser::updateKey(CSwordKey* key) {
}
void CBookKeyChooser::setKey(QString& newKey) {
- m_key->key(newKey);
+ m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index f1ac69f..3b32d48 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -30,16 +30,20 @@ class TreeKeyIdx;
class CBookKeyChooser : public CKeyChooser {
Q_OBJECT
public:
- CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
- ~CBookKeyChooser();
+ CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *history, CSwordKey *key = 0,
+ QWidget *parent = 0);
+
/**
- * Refreshes the content.
+ Reimplemented from CKeyChooser.
*/
virtual void refreshContent();
+
/**
* Sets another module to this keychooser
*/
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = false);
+ virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh = false);
/**
* Returns the key of this keychooser
*/
@@ -78,7 +82,7 @@ class CBookKeyChooser : public CKeyChooser {
private:
QList<CKeyChooserWidget*> m_chooserWidgets;
- QList<CSwordBookModuleInfo*> m_modules;
+ QList<const CSwordBookModuleInfo*> m_modules;
CSwordTreeKey *m_key;
QHBoxLayout* m_layout;
};
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index db55dca..1b0edd4 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,6 @@
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
-#include <QHeaderView>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "backend/config/cbtconfig.h"
@@ -21,8 +20,9 @@
#include "frontend/keychooser/bthistory.h"
-CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, key, parent),
+CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory* historyPtr, CSwordKey *key, QWidget *parent)
+ : CKeyChooser(modules, historyPtr, key, parent),
m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
setModules(modules, false);
@@ -40,7 +40,7 @@ CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_treeView);
- m_treeView->header()->hide();
+ m_treeView->setHeaderHidden(true);
//when user selects the item whe must react
connect(m_treeView, SIGNAL(currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(itemActivated(QTreeWidgetItem*)));
@@ -50,8 +50,6 @@ CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *
connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
}
-CBookTreeChooser::~CBookTreeChooser() {}
-
/** Sets a new key to this keychooser. Inherited from ckeychooser. */
void CBookTreeChooser::setKey(CSwordKey* key) {
setKey(key, false);
@@ -86,20 +84,16 @@ void CBookTreeChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
}
}
-/** Returns the key of this keychooser. Inherited from ckeychooser.*/
-CSwordKey* CBookTreeChooser::key() {
- return m_key;
-}
-
-/** Sets another module to this keychooser. Inherited from ckeychooser (therefore
-the list of modules instead of one). */
-void CBookTreeChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
+void CBookTreeChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh)
+{
+ typedef CSwordBookModuleInfo CSBMI;
//Add given modules into private list
m_modules.clear();
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) {
+ Q_FOREACH (const CSwordModuleInfo *m, modules) {
+ const CSBMI *book = dynamic_cast<const CSBMI*>(m);
+ if (book != 0) {
m_modules.append(book);
}
}
@@ -139,7 +133,7 @@ void CBookTreeChooser::itemActivated( QTreeWidgetItem* item ) {
qDebug() << "CBookTreeChooser::itemActivated";
//Sometimes Qt calls this function with a null pointer.
if (item) {
- m_key->key(item->text(1));
+ m_key->setKey(item->text(1));
//tell possible listeners about the change
emit keyChanged(m_key);
}
@@ -193,6 +187,6 @@ void CBookTreeChooser::addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item)
}
void CBookTreeChooser::setKey(QString& newKey) {
- m_key->key(newKey);
+ m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 01fd369..409038e 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,6 +12,7 @@
#include "frontend/keychooser/ckeychooser.h"
+#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/ckeychooserwidget.h"
@@ -20,9 +21,9 @@ class TreeKeyIdx;
}
class CSwordBookModuleInfo;
class CSwordKey;
-class CSwordTreeKey;
class QTreeWidget;
class QTreeWidgetItem;
+class BTHistory;
/** The keychooser implementation for books.
* @author The BibleTime team
@@ -30,24 +31,34 @@ class QTreeWidgetItem;
class CBookTreeChooser : public CKeyChooser {
Q_OBJECT
public:
- CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
- ~CBookTreeChooser();
+ CBookTreeChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *history, CSwordKey *key = 0,
+ QWidget *parent = 0);
+
/**
- * Refreshes the content.
+ Reimplemented from CKeyChooser::refreshContent().
*/
virtual void refreshContent();
+
/**
- * Sets another module to this keychooser
+ Reimplemented from CKeyChooser::setModules().
*/
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
+ virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh = true);
+
/**
- * Returns the key of this keychooser.
+ Reimplemented from CKeyChooser::key().
*/
- virtual CSwordKey* key();
+ virtual inline CSwordKey *key() {
+ return m_key;
+ }
+
/**
- * Sets a new key to this keychooser
+ Reimplemented from CKeyChooser::setKey().
*/
- virtual void setKey(CSwordKey*);
+ virtual void setKey(CSwordKey *key);
+
+
void setKey(CSwordKey*, const bool emitSinal);
public slots: // Public slots
@@ -71,7 +82,7 @@ class CBookTreeChooser : public CKeyChooser {
void setKey(QString& newKey);
private:
- QList<CSwordBookModuleInfo*> m_modules;
+ QList<const CSwordBookModuleInfo*> m_modules;
CSwordTreeKey* m_key;
QTreeWidget* m_treeView;
};
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index 905e125..4d58298 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,37 +22,49 @@
#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-CKeyChooser::CKeyChooser(QList<CSwordModuleInfo*>, CSwordKey *, QWidget *parent)
+CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo*> &, BTHistory* historyPtr,
+ CSwordKey *, QWidget *parent)
: QWidget(parent),
- m_history(0) {
+ m_history(historyPtr) {
//qDebug() << "CKeyChooser::CKeyChooser";
- m_history = new BTHistory(this);
- QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+ bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+ Q_ASSERT(ok);
}
-CKeyChooser::~CKeyChooser() {}
-
-CKeyChooser* CKeyChooser::createInstance(QList<CSwordModuleInfo*> modules, 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;
}
- switch ( modules.first()->type() ) {
- case CSwordModuleInfo::Commentary: //Bibles and commentaries use the same key chooser
+ 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, key, parent);
- break;
+ return new CBibleKeyChooser(modules, historyPtr, key, parent);
case CSwordModuleInfo::Lexicon:
- return new CLexiconKeyChooser(modules, key, parent);
+ return new CLexiconKeyChooser(modules, historyPtr, key, parent);
case CSwordModuleInfo::GenericBook:
- return new CBookKeyChooser(modules, key, parent);
+ 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;
}
}
-
-
-BTHistory* CKeyChooser::history() {
- return m_history;
-}
-
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index 4441df0..2a52de3 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -32,46 +32,50 @@ class CKeyChooser : public QWidget {
/**
* Creates a proper Instance, either
- *
- @ref CLexiconKeyChooser or
+ * @ref CLexiconKeyChooser or
* @ref CBibleKeyChooser
* @param info the @ref CModuleInfo to be represented by the KeyChooser
* @param key if not NULL, the @ref CKey the KeyChooser should be set to
* @param parent the parent of the widget to create
*/
- static CKeyChooser* createInstance(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent);
+ static CKeyChooser *createInstance(
+ const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *history, CSwordKey *key, QWidget *parent);
public slots:
/**
- * sets the @ref CKey
- * @param key the key which the widget should be set to
+ Sets the CKey
+ \param key the key which the widget should be set to.
*/
virtual void setKey(CSwordKey* key) = 0;
+
/**
- * sets the @ref CKey
- * @param key the key which the widget should be set to
+ Updates the CKey.
+ \param key the key which the widget should be set to.
*/
- virtual void updateKey(CSwordKey* key) = 0;
+ virtual void updateKey(CSwordKey *key) = 0;
+
/**
- * gets the current @ref CKey
- *
- * @return the current @ref CKey
+ \returns the current CKey.
*/
- virtual CSwordKey* key() = 0;
+ virtual CSwordKey *key() = 0;
+
/**
- * Sets the module of this keychooser and refreshes the comboboxes
+ Sets the module of this keychooser and refreshes the comboboxes
*/
- virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true ) = 0;
+ virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh = true) = 0;
+
/**
- * Freshes the content of the different key chooser parts.
+ Refreshes the content of the different key chooser parts.
*/
virtual void refreshContent() = 0;
/**
- * Returns the history object of this keychooser.
+ \returns the history object of this keychooser.
*/
- BTHistory* history();
+ inline BTHistory *history() const { return m_history; }
signals:
@@ -86,21 +90,22 @@ class CKeyChooser : public QWidget {
protected:
+ CKeyChooser(const QList<const CSwordModuleInfo*> &info,
+ BTHistory *history, CSwordKey *key = 0,
+ QWidget *parent = 0);
+
+ virtual inline ~CKeyChooser() {}
+
/**
- * the constructor - DO NOT USE! -- use @ref #createInstance instead!
- */
- CKeyChooser(QList<CSwordModuleInfo*> info, CSwordKey *key = 0, QWidget *parent = 0);
- virtual ~CKeyChooser();
- /**
- * Set the appropriate font do display the modules
+ Resets the appropriate font to for the modules.
*/
virtual void adjustFont() = 0;
protected slots:
- virtual void setKey(QString& newKey) = 0;
+ virtual void setKey(QString &newKey) = 0;
private:
- BTHistory* m_history;
+ BTHistory *m_history;
};
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index a11bd6f..1c8cc4d 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -127,7 +127,7 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
- // return;
+ // return;
m_list.clear();
for (int i = 1; i <= count; i++) { /// \todo CHECK
@@ -137,18 +137,18 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(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())
- // return;
+ // return;
m_list = list;
reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit) {
//if (isResetting || !updatesEnabled())
if (isResetting)
return;
@@ -239,7 +239,7 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
QString text = comboBox()->lineEdit()->text();
for (int index = 0; index < comboBox()->count(); ++index) {
if (comboBox()->itemText(index) == text) {
-// emit changed(index);
+// emit changed(index);
emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
break;
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 1dab8b3..384b19a 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -63,15 +63,15 @@ class CKCComboBox : public QComboBox {
*/
class CKeyChooserWidget : public QWidget {
Q_OBJECT
+
public:
- /**
- * the constructor
- */
- CKeyChooserWidget(QStringList *list = 0, const bool useNextPrevSignals = false, QWidget *parent = 0 );
- /**
- * the constructor
- */
- CKeyChooserWidget(int count = 0, const bool useNextPrevSignals = false, QWidget *parent = 0 );
+ 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
@@ -82,8 +82,9 @@ class CKeyChooserWidget : public QWidget {
* @param do_emit should we emit @ref #changed(int)
*/
void reset(const int count, int index, bool do_emit);
- void reset(QStringList& list, int index, bool do_emit);
- void reset(QStringList *list, int index, bool do_emit);
+ 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.
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index eca19d4..e09efb1 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,8 +10,6 @@
#include "frontend/keychooser/clexiconkeychooser.h"
#include <algorithm>
-#include <iterator>
-#include <map>
#include <QHBoxLayout>
#include <QDebug>
#include "backend/config/cbtconfig.h"
@@ -23,9 +21,12 @@
#include "util/cresmgr.h"
-CLexiconKeyChooser::CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, key, parent),
- m_key(dynamic_cast<CSwordLDKey*>(key)) {
+CLexiconKeyChooser::CLexiconKeyChooser(
+ const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
+ : CKeyChooser(modules, historyPtr, key, parent),
+ m_key(dynamic_cast<CSwordLDKey*>(key))
+{
setModules(modules, false);
//we use a layout because the key chooser should be resized to full size
@@ -64,9 +65,8 @@ CSwordKey* CLexiconKeyChooser::key() {
return m_key;
}
-void CLexiconKeyChooser::setKey(CSwordKey* key) {
- qDebug() << "CLexiconKeyChooser::setKey";
-
+/** Update key display without emiting a signal */
+void CLexiconKeyChooser::updateKey(CSwordKey* key) {
if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) {
return;
}
@@ -74,6 +74,16 @@ void CLexiconKeyChooser::setKey(CSwordKey* key) {
QString newKey = m_key->key();
const int index = m_widget->comboBox()->findText(newKey);
m_widget->comboBox()->setCurrentIndex(index);
+}
+
+void CLexiconKeyChooser::setKey(CSwordKey* key) {
+ qDebug() << "CLexiconKeyChooser::setKey";
+
+ if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) {
+ return;
+ }
+
+ updateKey(key);
// qWarning("setKey end");
emit keyChanged( m_key);
@@ -85,7 +95,7 @@ void CLexiconKeyChooser::activated(int index) {
// To prevent from eternal loop, because activated() is emitted again
if (m_key && m_key->key() != text) {
- m_key->key(text);
+ m_key->setKey(text);
setKey(m_key);
}
// qWarning("activated end");
@@ -98,24 +108,24 @@ inline bool my_cmpEntries(const QString& a, const QString& b) {
/** Reimplementation. */
void CLexiconKeyChooser::refreshContent() {
if (m_modules.count() == 1) {
- m_widget->reset(m_modules.first()->entries(), 0, true);
+ m_widget->reset(&m_modules.first()->entries(), 0, true);
// qWarning("resetted");
}
else {
- typedef std::multimap<unsigned int, QStringList*> EntryMap;
+ typedef std::multimap<unsigned int, const QStringList*> EntryMap;
EntryMap entryMap;
- QStringList* entries = 0;
- QListIterator<CSwordLexiconModuleInfo*> mit(m_modules);
+
+ QListIterator<const CSwordLexiconModuleInfo*> mit(m_modules);
while (mit.hasNext()) {
- entries = mit.next()->entries();
- entryMap.insert( std::make_pair(entries->count(), entries) );
+ const QStringList &entries = mit.next()->entries();
+ entryMap.insert( std::make_pair(entries.count(), &entries) );
}
QStringList goodEntries; //The string list which contains the entries which are available in all modules
EntryMap::iterator it = entryMap.begin(); //iterator to go thoigh all selected modules
QStringList refEntries = *(it->second); //copy the items for the first time
- QStringList* cmpEntries = ( ++it )->second; //list for comparision, starts with the second module in the map
+ const QStringList *cmpEntries = (++it)->second; //list for comparision, starts with the second module in the map
// Testing for refEntries being empty is not needed for the set union
// of all keys, but is a good idea since it is being updated in the
@@ -142,21 +152,17 @@ void CLexiconKeyChooser::refreshContent() {
}
-/** No descriptions */
-void CLexiconKeyChooser::adjustFont() {
-
-}
-
-/** Sets the module and refreshes the combo boxes */
-void CLexiconKeyChooser::setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh ) {
+void CLexiconKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh)
+{
+ typedef CSwordLexiconModuleInfo CSLMI;
while (!m_modules.isEmpty())
m_modules.takeFirst(); // not deleting the pointer
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
- CSwordLexiconModuleInfo* lexicon = dynamic_cast<CSwordLexiconModuleInfo*>(*it);
- if (lexicon) {
+ Q_FOREACH(const CSwordModuleInfo *m, modules) {
+ const CSLMI *lexicon = dynamic_cast<const CSLMI*>(m);
+ if (lexicon != 0) {
m_modules.append(lexicon);
}
}
@@ -167,10 +173,7 @@ void CLexiconKeyChooser::setModules( const QList<CSwordModuleInfo*>& modules, co
}
}
-/** No descriptions */
-void CLexiconKeyChooser::updateKey(CSwordKey*) {}
-
void CLexiconKeyChooser::setKey(QString& newKey) {
- m_key->key(newKey);
+ m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index f93a148..e014448 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -30,46 +30,48 @@ class QWidget;
*/
class CLexiconKeyChooser : public CKeyChooser {
Q_OBJECT
+
public:
- /**
- * The constructor
- *
- * you should not need to use this, use @ref CKeyChooser::createInstance instead
- */
- CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+ CLexiconKeyChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *history, CSwordKey *key = 0,
+ QWidget *parent = 0);
public slots:
/**
- * see @ref CKeyChooser::getKey
- * @return Return the key object we use.
+ Reimplemented from CKeyChooser::key().
*/
- virtual CSwordKey* key();
+ virtual CSwordKey *key();
+
/**
- * see @ref CKeyChooser::setKey
+ Reimplemented from CKeyChooser::setKey().
*/
virtual void setKey(CSwordKey* key);
+
/**
* used to react to changes in the @ref CKeyChooserWidget
*
* @param index not used
**/
virtual void activated(int index);
+
/**
- * Reimplementation.
+ Reimplemented from CKeyChooser::refreshContent().
*/
virtual void refreshContent();
+
/**
- * Sets the module and refreshes the combo boxes of this keychooser.
+ Reimplemented from CKeyChooser::setModules().
*/
- virtual void setModules( const QList<CSwordModuleInfo*>& modules, const bool refresh = true );
+ virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh = true);
protected:
CKeyChooserWidget *m_widget;
CSwordLDKey* m_key;
- QList<CSwordLexiconModuleInfo*> m_modules;
+ QList<const CSwordLexiconModuleInfo*> m_modules;
QHBoxLayout *m_layout;
- virtual void adjustFont();
+ virtual inline void adjustFont() {}
public slots: // Public slots
virtual void updateKey(CSwordKey* key);
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 5154241..df1c35d 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index f795b24..2c298b3 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -61,8 +61,8 @@ class CScrollButton: public QToolButton {
virtual void mouseReleaseEvent(QMouseEvent *e);
/**
- * \brief Reimplementation from \ref QWidget#mouseMoveEvent - processes
- * the mouse move events
+ * \brief Reimplementation of QWidget::mouseMoveEvent() to process mouse
+ move events.
*/
virtual void mouseMoveEvent(QMouseEvent *e);
@@ -72,7 +72,7 @@ class CScrollButton: public QToolButton {
*
* If the button is in the locked state, this means the mouse is grabbed
* and any mouse move events invoke calculation about whether to emit the
- * \ref CScrollButton#change_requested signal.
+ * change_requested() signal.
*/
bool m_isLocked;
};
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 7c987cc..4ad8750 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index ae81636..8645efc 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,11 +26,10 @@ class QVBoxLayout;
*/
class CScrollerWidgetSet : public QWidget {
Q_OBJECT
+
public:
- /**
- * the constructor
- */
CScrollerWidgetSet(QWidget *parent = 0);
+
/**
* Sets the tooltips for the given entries using the parameters as text.
*/
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
index e5cf4ff..b74752e 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
@@ -2,12 +2,12 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
+#include "frontend/keychooser/versekeychooser/btbiblekeywidget.h"
#include <QApplication>
#include <QDebug>
@@ -24,6 +24,7 @@
#include "backend/keys/cswordversekey.h"
#include "frontend/keychooser/cscrollerwidgetset.h"
#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
+#include "util/btsignal.h"
#include "util/cresmgr.h"
#include "util/directory.h"
@@ -45,12 +46,16 @@ class BtLineEdit : public QLineEdit {
};
-CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
- QWidget(parent),
- m_key(key),
- m_dropDownHoverTimer(this) {
+BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
+ CSwordVerseKey *key, QWidget *parent,
+ const char *name)
+ : QWidget(parent), m_key(key), m_dropDownHoverTimer(this)
+{
+ Q_UNUSED(name);
+
namespace DU = util::directory;
+
updatelock = false;
m_module = mod;
@@ -68,9 +73,6 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
setFocusProxy(m_textbox);
m_textbox->setContentsMargins(0, 0, 0, 0);
- setKey(key); // The order of these two functions is important.
- setModule();
-
m_chapterScroller = new CScrollerWidgetSet(this);
m_verseScroller = new CScrollerWidgetSet(this);
@@ -137,20 +139,25 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
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()));
+ Q_ASSERT(ok);
+
+ setKey(key); // The order of these two functions is important.
+ setModule();
}
-CKeyReferenceWidget::~CKeyReferenceWidget() {
+BtBibleKeyWidget::~BtBibleKeyWidget() {
delete m_dropDownButtons;
}
-void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m) {
+void BtBibleKeyWidget::setModule(const CSwordBibleModuleInfo *m) {
if (m) { //can be null
m_module = m;
- m_key->module(m);
+ m_key->setModule(m);
}
}
-bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
+bool BtBibleKeyWidget::eventFilter(QObject *o, QEvent *e) {
if (o != m_dropDownButtons) return false;
switch (e->type()) {
case QEvent::Enter:
@@ -164,7 +171,7 @@ bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
}
}
-void CKeyReferenceWidget::enterEvent(QEvent *) {
+void BtBibleKeyWidget::enterEvent(QEvent *) {
m_dropDownHoverTimer.stop();
resetDropDownButtons();
@@ -173,31 +180,32 @@ void CKeyReferenceWidget::enterEvent(QEvent *) {
m_dropDownButtons->show();
}
-void CKeyReferenceWidget::leaveEvent(QEvent *) {
+void BtBibleKeyWidget::leaveEvent(QEvent *) {
m_dropDownHoverTimer.start();
}
-void CKeyReferenceWidget::resizeEvent(QResizeEvent *event) {
+void BtBibleKeyWidget::resizeEvent(QResizeEvent *event) {
if (m_dropDownButtons->isVisible()) {
resetDropDownButtons();
}
QWidget::resizeEvent(event);
}
-void CKeyReferenceWidget::resetDropDownButtons() {
+void BtBibleKeyWidget::resetDropDownButtons() {
m_dropDownButtons->setParent(window());
int h(m_dropDownButtons->layout()->minimumSize().height());
- QPoint topLeft(mapTo(window(), QPoint(m_textbox->x(), height())));
+ QPoint topLeft(mapTo(window(),
+ QPoint(m_textbox->x(), m_textbox->y() + m_textbox->height())));
m_dropDownButtons->setGeometry(topLeft.x(), topLeft.y(),
m_textbox->width(), h);
}
-void CKeyReferenceWidget::slotClearRef( ) {
+void BtBibleKeyWidget::slotClearRef( ) {
m_textbox->setText("");
m_textbox->setFocus();
}
-void CKeyReferenceWidget::updateText() {
+void BtBibleKeyWidget::updateText() {
QString text(m_key->key());
m_textbox->setText(text);
QFontMetrics fm(m_textbox->font());
@@ -208,89 +216,77 @@ void CKeyReferenceWidget::updateText() {
}
}
-bool CKeyReferenceWidget::setKey(CSwordVerseKey *key) {
+bool BtBibleKeyWidget::setKey(CSwordVerseKey *key) {
if (!key) return false;
- m_key->key(key->key());
- updateText();
+ m_key->setKey(key->key());
return true;
}
-QLineEdit* CKeyReferenceWidget::textbox() {
- return m_textbox;
-}
-
-void CKeyReferenceWidget::slotReturnPressed() {
- m_key->key(m_textbox->text());
- updateText();
+void BtBibleKeyWidget::slotReturnPressed() {
+ m_key->setKey(m_textbox->text());
emit changed(m_key);
}
/* Handlers for the various scroller widgetsets. Do we really want a verse scroller? */
-void CKeyReferenceWidget::slotUpdateLock() {
+void BtBibleKeyWidget::slotUpdateLock() {
updatelock = true;
oldKey = m_key->key();
}
-void CKeyReferenceWidget::slotUpdateUnlock() {
+void BtBibleKeyWidget::slotUpdateUnlock() {
updatelock = false;
if (oldKey != m_key->key())
emit changed(m_key);
}
-void CKeyReferenceWidget::slotStepBook(int n) {
+void BtBibleKeyWidget::slotStepBook(int n) {
emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseBook ) : m_key->previous( CSwordVerseKey::UseBook );
if (!updatelock)
emit changed(m_key);
- updateText();
}
-void CKeyReferenceWidget::slotStepChapter(int n) {
+void BtBibleKeyWidget::slotStepChapter(int n) {
emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseChapter ) : m_key->previous( CSwordVerseKey::UseChapter );
if (!updatelock)
emit changed(m_key);
- updateText();
}
-void CKeyReferenceWidget::slotStepVerse(int n) {
+void BtBibleKeyWidget::slotStepVerse(int n) {
emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseVerse ) : m_key->previous( CSwordVerseKey::UseVerse );
if (!updatelock)
emit changed(m_key);
- updateText();
}
-void CKeyReferenceWidget::slotChangeVerse(int n) {
+void BtBibleKeyWidget::slotChangeVerse(int n) {
if (m_key->Verse() != n) {
emit beforeChange(m_key);
m_key->Verse( n );
setKey( m_key );
}
- updateText();
if (!updatelock) emit changed(m_key);
}
-void CKeyReferenceWidget::slotChangeChapter(int n) {
+void BtBibleKeyWidget::slotChangeChapter(int n) {
if (m_key->Chapter() != n) {
emit beforeChange(m_key);
m_key->Chapter( n );
setKey( m_key );
}
- updateText();
if (!updatelock)
emit changed(m_key);
}
-void CKeyReferenceWidget::slotChangeBook(QString bookname) {
+void BtBibleKeyWidget::slotChangeBook(QString bookname) {
if (m_key->book() != bookname) {
emit beforeChange(m_key);
m_key->book( bookname );
setKey( m_key );
}
- updateText();
if (!updatelock)
emit changed(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
index df2c9d2..29633fd 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
@@ -2,13 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#ifndef CKEYREFERENCEWIDGET_H
-#define CKEYREFERENCEWIDGET_H
+#ifndef BTBIBLEKEYWIDGET_H
+#define BTBIBLEKEYWIDGET_H
#include <QWidget>
@@ -22,17 +22,17 @@ class CLexiconKeyChooser;
class CSwordVerseKey;
class QLineEdit;
-class CKeyReferenceWidget : public QWidget {
+class BtBibleKeyWidget : public QWidget {
Q_OBJECT
+
public:
- /**
- * the constructor
- */
- CKeyReferenceWidget(CSwordBibleModuleInfo *, CSwordVerseKey*, QWidget *parent = 0, const char *name = 0);
- ~CKeyReferenceWidget();
+ BtBibleKeyWidget(const CSwordBibleModuleInfo *module,
+ CSwordVerseKey *key, QWidget *parent = 0,
+ const char *name = 0);
+
+ ~BtBibleKeyWidget();
bool setKey(CSwordVerseKey* key);
- QLineEdit* textbox();
- void setModule(CSwordBibleModuleInfo *m = 0);
+ void setModule(const CSwordBibleModuleInfo *m = 0);
bool eventFilter(QObject *o, QEvent *e);
signals:
@@ -44,7 +44,6 @@ class CKeyReferenceWidget : public QWidget {
void leaveEvent(QEvent *event);
void resizeEvent(QResizeEvent *event);
void resetDropDownButtons();
- void updateText();
protected slots: // Protected slots
/**
@@ -63,6 +62,9 @@ class CKeyReferenceWidget : public QWidget {
void slotChangeChapter(int chapter);
void slotChangeVerse(int verse);
+ public slots:
+ void updateText();
+
private:
friend class CLexiconKeyChooser;
friend class BtDropdownChooserButton;
@@ -86,7 +88,7 @@ class CKeyReferenceWidget : public QWidget {
bool updatelock;
QString oldKey;
- CSwordBibleModuleInfo *m_module;
+ const CSwordBibleModuleInfo *m_module;
};
#endif
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index 1e8c292..512a0f3 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,12 +12,12 @@
#include <QDebug>
#include <QWheelEvent>
#include "frontend/keychooser/versekeychooser/btversekeymenu.h"
-#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
+#include "frontend/keychooser/versekeychooser/btbiblekeywidget.h"
const unsigned int ARROW_HEIGHT = 15;
-BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref)
+BtDropdownChooserButton::BtDropdownChooserButton(BtBibleKeyWidget* ref)
: QToolButton(),
m_ref(ref) {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -30,7 +30,7 @@ BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref)
setStyleSheet("QToolButton{margin:0px;}QToolButton::menu-indicator{subcontrol-position: center center;}");
BtVerseKeyMenu* m = new BtVerseKeyMenu(this);
-// KAcceleratorManager::setNoAccel(m);
+// KAcceleratorManager::setNoAccel(m);
setMenu(m);
QObject::connect(m, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuTriggered(QAction*)));
}
@@ -61,7 +61,7 @@ void BtDropdownChooserButton::wheelEvent(QWheelEvent* e) {
//******************Book dropdown button*************************************/
-BtBookDropdownChooserButton::BtBookDropdownChooserButton(CKeyReferenceWidget* ref)
+BtBookDropdownChooserButton::BtBookDropdownChooserButton(BtBibleKeyWidget* ref)
: BtDropdownChooserButton(ref) {
setToolTip(tr("Select book"));
QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepBook(int)));
@@ -83,7 +83,7 @@ void BtBookDropdownChooserButton::slotMenuTriggered(QAction* action) {
//****************** Chapter dropdown button *************************************/
-BtChapterDropdownChooserButton::BtChapterDropdownChooserButton(CKeyReferenceWidget* ref)
+BtChapterDropdownChooserButton::BtChapterDropdownChooserButton(BtBibleKeyWidget* ref)
: BtDropdownChooserButton(ref) {
setToolTip(tr("Select chapter"));
QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepChapter(int)));
@@ -104,7 +104,7 @@ void BtChapterDropdownChooserButton::slotMenuTriggered(QAction* action) {
//****************** Verse dropdown button *************************************/
-BtVerseDropdownChooserButton::BtVerseDropdownChooserButton(CKeyReferenceWidget* ref)
+BtVerseDropdownChooserButton::BtVerseDropdownChooserButton(BtBibleKeyWidget* ref)
: BtDropdownChooserButton(ref) {
setToolTip(tr("Select verse"));
QObject::connect(this, SIGNAL(stepItem(int)), m_ref, SLOT(slotStepVerse(int)));
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index e9dbdc2..04b7000 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,7 +13,7 @@
#include <QToolButton>
-class CKeyReferenceWidget;
+class BtBibleKeyWidget;
/**
* Base class for book/ch/v dropdown list chooser buttons.
@@ -21,7 +21,7 @@ class CKeyReferenceWidget;
class BtDropdownChooserButton : public QToolButton {
Q_OBJECT
public:
- BtDropdownChooserButton(CKeyReferenceWidget* ref);
+ BtDropdownChooserButton(BtBibleKeyWidget* ref);
virtual ~BtDropdownChooserButton() {}
/** The item list is constructed here just before the menu is shown.*/
@@ -29,14 +29,14 @@ class BtDropdownChooserButton : public QToolButton {
/** Recreates the menu list.*/
virtual void newList() = 0;
/** Returns the verse reference widget which this button belongs to.*/
- CKeyReferenceWidget* ref() {
+ BtBibleKeyWidget* ref() {
return m_ref;
}
public slots:
/** When a menu item is selected the key will be changed.*/
virtual void slotMenuTriggered(QAction* action) = 0;
protected:
- CKeyReferenceWidget* m_ref;
+ BtBibleKeyWidget* m_ref;
void wheelEvent(QWheelEvent* event);
signals:
void stepItem(int step);
@@ -46,7 +46,7 @@ class BtDropdownChooserButton : public QToolButton {
class BtBookDropdownChooserButton : public BtDropdownChooserButton {
Q_OBJECT
public:
- BtBookDropdownChooserButton(CKeyReferenceWidget* ref);
+ BtBookDropdownChooserButton(BtBibleKeyWidget* ref);
~BtBookDropdownChooserButton() {}
virtual void newList();
public slots:
@@ -57,7 +57,7 @@ class BtBookDropdownChooserButton : public BtDropdownChooserButton {
class BtChapterDropdownChooserButton : public BtDropdownChooserButton {
Q_OBJECT
public:
- BtChapterDropdownChooserButton(CKeyReferenceWidget* ref);
+ BtChapterDropdownChooserButton(BtBibleKeyWidget* ref);
~BtChapterDropdownChooserButton() {}
virtual void newList();
public slots:
@@ -68,7 +68,7 @@ class BtChapterDropdownChooserButton : public BtDropdownChooserButton {
class BtVerseDropdownChooserButton : public BtDropdownChooserButton {
Q_OBJECT
public:
- BtVerseDropdownChooserButton(CKeyReferenceWidget* ref);
+ BtVerseDropdownChooserButton(BtBibleKeyWidget* ref);
~BtVerseDropdownChooserButton() {}
virtual void newList();
public slots:
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index c06a18d..9c6e77f 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index f47d0f5..7f5b333 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 2488668..6a16d8d 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,13 +16,18 @@
#include "backend/keys/cswordversekey.h"
#include "frontend/keychooser/bthistory.h"
#include "frontend/keychooser/cscrollbutton.h"
-#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
+#include "frontend/keychooser/versekeychooser/btbiblekeywidget.h"
#include "util/cresmgr.h"
-CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) :
- CKeyChooser(modules, key, parent),
- m_key(dynamic_cast<CSwordVerseKey*>(key)) {
+CBibleKeyChooser::CBibleKeyChooser(
+ const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
+ : CKeyChooser(modules, historyPtr, key, parent),
+ m_key(dynamic_cast<CSwordVerseKey*>(key))
+{
+ typedef CSwordBibleModuleInfo CSBMI;
+
w_ref = 0;
setModules(modules, false);
if (!m_modules.count()) {
@@ -35,16 +40,19 @@ CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *
layout->setContentsMargins(0, 0, 0, 0);
layout->setDirection( QBoxLayout::LeftToRight );
- w_ref = new CKeyReferenceWidget(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()), m_key, this);
+ w_ref = new BtBibleKeyWidget(dynamic_cast<const CSBMI*>(m_modules.first()),
+ m_key, this);
setFocusProxy(w_ref);
layout->addWidget(w_ref);
- connect(w_ref, SIGNAL(beforeChange(CSwordVerseKey *)), SLOT(beforeRefChange(CSwordVerseKey *)));
+ bool ok = connect(w_ref, SIGNAL(beforeChange(CSwordVerseKey *)), SLOT(beforeRefChange(CSwordVerseKey *)));
connect(w_ref, SIGNAL(changed(CSwordVerseKey *)), SLOT(refChanged(CSwordVerseKey *)));
+ Q_ASSERT(ok);
setKey(m_key); //set the key without changing it, setKey(key()) would change it
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ ok = connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ Q_ASSERT(ok);
}
CSwordKey* CBibleKeyChooser::key() {
@@ -62,7 +70,7 @@ void CBibleKeyChooser::setKey(CSwordKey* key) {
}
void CBibleKeyChooser::beforeRefChange(CSwordVerseKey* key) {
- Q_UNUSED(key); /// \todo Is this correct?
+ Q_UNUSED(key);
Q_ASSERT(m_key);
@@ -88,17 +96,26 @@ void CBibleKeyChooser::refChanged(CSwordVerseKey* key) {
setUpdatesEnabled(true);
}
-void CBibleKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) {
+void CBibleKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh)
+{
+ typedef CSwordBibleModuleInfo CSBMI;
+
m_modules.clear();
- foreach (CSwordModuleInfo* mod, modules) {
- if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
- if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(mod)) m_modules.append(bible);
+ Q_FOREACH (const CSwordModuleInfo *mod, modules) {
+ if (mod->type() == CSwordModuleInfo::Bible
+ || mod->type() == CSwordModuleInfo::Commentary)
+ {
+ const CSBMI* bible = dynamic_cast<const CSBMI*>(mod);
+ if (bible != 0) {
+ m_modules.append(bible);
+ }
}
}
// First time this is called we havnt set up w_ref.
- if (w_ref) w_ref->setModule(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()));
+ if (w_ref) w_ref->setModule(dynamic_cast<const CSwordBibleModuleInfo*>(m_modules.first()));
if (refresh) refreshContent();
}
@@ -106,11 +123,13 @@ void CBibleKeyChooser::refreshContent() {
setKey(m_key);
}
-void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {}
+void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {
+ w_ref->updateText();
+}
void CBibleKeyChooser::adjustFont() {}
void CBibleKeyChooser::setKey(QString& newKey) {
- m_key->key(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 9501099..d2c5363 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,7 +18,7 @@
class QWidget;
-class CKeyReferenceWidget;
+class BtBibleKeyWidget;
class CSwordVerseKey;
class CSwordBibleModuleInfo;
@@ -26,7 +26,7 @@ class CSwordBibleModuleInfo;
*
* it inhertits @ref CKeyChooser
*
- * it uses a CKeyReferenceWidget 's to represent the bible keys
+ * it uses a BtBibleKeyWidget to represent the bible keys
*
* @author The BibleTime team
*/
@@ -35,25 +35,27 @@ class CBibleKeyChooser : public CKeyChooser {
Q_OBJECT
public:
- /**
- * the constructor
- * you should not need to use this, use @ref CKeyChooser::createInstance instead
- */
- CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
+ CBibleKeyChooser(const QList<const CSwordModuleInfo*> &modules,
+ BTHistory *history, CSwordKey *key = 0,
+ QWidget *parent = 0);
public slots:
/**
- * see @ref CKeyChooser::getKey
+ Reimplemented from CKeyChooser::key().
*/
CSwordKey* key();
+
/**
- * see @ref CKeyChooser::setKey
+ Reimplemented from CKeyChooser::setKey().
*/
virtual void setKey(CSwordKey *key);
+
/**
- * Sets the module
+ Reimplemented from CKeyChooser::setModules().
*/
- virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
+ virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
+ bool refresh = true);
+
/**
* used to do actions before key changes
*/
@@ -68,11 +70,14 @@ class CBibleKeyChooser : public CKeyChooser {
void refreshContent();
protected slots:
+ /**
+ Reimplemented from CKeyChooser::setModules().
+ */
virtual void setKey(QString& newKey);
private:
- CKeyReferenceWidget* w_ref;
- QList<CSwordBibleModuleInfo*> m_modules;
+ BtBibleKeyWidget* w_ref;
+ QList<const CSwordBibleModuleInfo*> m_modules;
CSwordVerseKey *m_key;
};
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
deleted file mode 100644
index 40dc79e..0000000
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-
-#include <boost/scoped_ptr.hpp>
-#include <QDebug>
-#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
-#include "frontend/cinputdialog.h"
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/directory.h"
-
-
-BtBookmarkItem::BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description)
- : m_description(description),
- m_moduleName(module ? module->name() : QString::null) {
- if (((module && (module->type() == CSwordModuleInfo::Bible)) || (module->type() == CSwordModuleInfo::Commentary)) ) {
- CSwordVerseKey vk(0);
- vk.key(key);
- vk.setLocale("en");
- m_key = vk.key(); //the m_key member is always the english key!
- }
- else {
- m_key = key;
- };
-
- update();
-}
-
-BtBookmarkItem::BtBookmarkItem(QTreeWidgetItem* parent)
- : BtBookmarkItemBase(parent) {}
-
-BtBookmarkItem::BtBookmarkItem(const BtBookmarkItem& other)
- : BtBookmarkItemBase(0),
- m_key(other.m_key),
- m_description(other.m_description),
- m_moduleName(other.m_moduleName) {
- update();
-}
-
-CSwordModuleInfo* BtBookmarkItem::module() {
- CSwordModuleInfo* const m = CPointers::backend()->findModuleByName(m_moduleName);
- return m;
-}
-
-QString BtBookmarkItem::key() {
- const QString englishKeyName = englishKey();
- if (!module()) {
- return englishKeyName;
- }
-
- QString returnKeyName = englishKeyName;
- if ((module()->type() == CSwordModuleInfo::Bible) || (module()->type() == CSwordModuleInfo::Commentary)) {
- CSwordVerseKey vk(0);
- vk.key(englishKeyName);
- vk.setLocale(CPointers::backend()->booknameLanguage().toLatin1() );
-
- returnKeyName = vk.key(); //the returned key is always in the currently set bookname language
- }
-
- return returnKeyName;
-}
-
-const QString& BtBookmarkItem::description() {
- return m_description;
-}
-
-void BtBookmarkItem::setDescription(QString text) {
- m_description = text;
-}
-
-QString BtBookmarkItem::toolTip() {
- if (!module()) {
- return QString::null;
- }
-
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
- filterOptions.footnotes = false;
- filterOptions.scriptureReferences = false;
- CPointers::backend()->setFilterOptions(filterOptions);
-
- QString ret;
- boost::scoped_ptr<CSwordKey> k( CSwordKey::createInstance(module()) );
- k->key(this->key());
-
- const CLanguageMgr::Language* lang = module()->language();
- CBTConfig::FontSettingsPair fontPair = CBTConfig::get
- (lang);
-
- Q_ASSERT(k.get());
- if (fontPair.first) { //use a special font
- ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
- .arg(key())
- .arg(module()->name())
- .arg(description())
- ;
- }
- else {
- ret = QString::fromLatin1("<b>%1 (%2)</b><hr>%3")
- .arg(key())
- .arg(module()->name())
- .arg(description())
- ;
- }
-
- return ret;
-}
-
-bool BtBookmarkItem::enableAction(MenuAction action) {
- if (action == ChangeBookmark || (module() && (action == PrintBookmarks)) || action == DeleteEntries)
- return true;
-
- return false;
-}
-
-void BtBookmarkItem::rename() {
- bool ok = false;
- const QString newDescription = CInputDialog::getText(QObject::tr("Change description ..."), QObject::tr("Enter a new description for the chosen bookmark."), description(), &ok, treeWidget());
-
- if (ok) {
- m_description = newDescription;
- update();
- }
-}
-
-QString BtBookmarkItem::englishKey() const {
- return m_key;
-}
-
-void BtBookmarkItem::update() {
- namespace DU = util::directory;
-
- qDebug() << "BtBookmarkItem::update";
- setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
-
- const QString title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
- setText(0, title);
- setToolTip(0, toolTip());
-}
-
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
deleted file mode 100644
index 82241ce..0000000
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-
-#include <QDropEvent>
-#include <QTreeWidgetItem>
-#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
-
-
-BtBookmarkItemBase::BtBookmarkItemBase() {}
-
-BtBookmarkItemBase::BtBookmarkItemBase(QTreeWidgetItem* parent)
- : QTreeWidgetItem(parent) {}
-
-CBookmarkIndex* BtBookmarkItemBase::bookmarkWidget() const {
- return dynamic_cast<CBookmarkIndex*>(treeWidget());
-}
-
-// void BtBookmarkItemBase::dropped(QDropEvent* e)
-// {
-//
-// }
-//
-// void BtBookmarkItemBase::addPreviousSibling(BtBookmarkItemBase* item)
-// {
-//
-// }
-//
-// void BtBookmarkItemBase::addNextSibling(BtBookmarkItemBase* item)
-// {
-//
-// }
diff --git a/src/frontend/profile/cprofile.cpp b/src/frontend/profile/cprofile.cpp
index 34f397b..e36c227 100644
--- a/src/frontend/profile/cprofile.cpp
+++ b/src/frontend/profile/cprofile.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/profile/cprofile.h b/src/frontend/profile/cprofile.h
index 621167e..8acffd3 100644
--- a/src/frontend/profile/cprofile.h
+++ b/src/frontend/profile/cprofile.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/profile/cprofilemgr.cpp b/src/frontend/profile/cprofilemgr.cpp
index 279a562..99e7823 100644
--- a/src/frontend/profile/cprofilemgr.cpp
+++ b/src/frontend/profile/cprofilemgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,7 +48,7 @@ const QList<CProfile*>& CProfileMgr::profiles() {
}
/** Creates a new profile with the name "name" (first parameter). @return The profile object */
-CProfile* CProfileMgr::create( const QString name ) {
+CProfile *CProfileMgr::create(const QString &name) {
CProfile* p = new CProfile(QString::null, name);
m_profiles.append(p);
diff --git a/src/frontend/profile/cprofilemgr.h b/src/frontend/profile/cprofilemgr.h
index 462ce93..7f5edcf 100644
--- a/src/frontend/profile/cprofilemgr.h
+++ b/src/frontend/profile/cprofilemgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,7 +28,7 @@ class CProfileMgr {
/** Creates a new profile with the name "name" (first parameter).
* @return The profile object
*/
- CProfile* create( const QString name );
+ CProfile *create(const QString &name);
/**
* @return a list of available profiles
*/
diff --git a/src/frontend/profile/cprofilewindow.cpp b/src/frontend/profile/cprofilewindow.cpp
index bfeabc8..4f8fab9 100644
--- a/src/frontend/profile/cprofilewindow.cpp
+++ b/src/frontend/profile/cprofilewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/profile/cprofilewindow.h b/src/frontend/profile/cprofilewindow.h
index 74294f7..f9c144f 100644
--- a/src/frontend/profile/cprofilewindow.h
+++ b/src/frontend/profile/cprofilewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index e638130..ece0ced 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,11 +26,14 @@ namespace Search {
static const int DIALOG_HEIGHT = 400;
static const int DIALOG_BORDER = 30;
-CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules, QWidget* parentDialog )
- : QDialog(parentDialog) {
+CSearchAnalysisDialog::CSearchAnalysisDialog(
+ const CSwordModuleSearch::Results &results,
+ QWidget *parentDialog)
+ : QDialog(parentDialog)
+{
initView();
m_analysis->reset();
- m_analysis->analyse(modules);
+ m_analysis->analyse(results);
// Set initial width based on the search data, but limit to the
// width of the desktop
@@ -39,7 +42,6 @@ CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules,
if (width > desktopWidth)
width = desktopWidth;
resize(width, DIALOG_HEIGHT);
-
}
/** Initializes this dialog. */
@@ -49,7 +51,7 @@ void CSearchAnalysisDialog::initView() {
m_analysis = new CSearchAnalysisScene(this);
m_analysisView = new CSearchAnalysisView(m_analysis, this);
-//// m_analysisView->show();
+//// m_analysisView->show();
vboxLayout->addWidget(m_analysisView);
m_buttonBox = new QDialogButtonBox(this);
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index 4bff4a0..b4edcad 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,10 @@
#include <QDialog>
-#include <QObject>
+#include "backend/cswordmodulesearch.h"
+
+// Sword includes
+#include <listkey.h>
class CSwordModuleInfo;
@@ -25,13 +28,13 @@ class CSearchAnalysisView;
class CSearchAnalysisScene;
/**
- @author The BibleTime team <info@bibletime.info>
+ @author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisDialog : public QDialog {
Q_OBJECT
public:
- CSearchAnalysisDialog(QList<CSwordModuleInfo*> modules, QWidget* parentDialog);
- ~CSearchAnalysisDialog() {}
+ CSearchAnalysisDialog(const CSwordModuleSearch::Results &results,
+ QWidget *parentDialog = 0);
protected: // Protected methods
/**
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index b2fc1ad..23b2962 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -41,13 +41,17 @@ const int LEGEND_INNER_BORDER = 5;
const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;
-CSearchAnalysisItem::CSearchAnalysisItem(const int moduleCount, const QString &bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules)
- : QGraphicsRectItem(),
- m_moduleList( modules ),
- m_scaleFactor(scaleFactor),
- m_bookName(bookname),
- m_moduleCount(moduleCount),
- m_bufferPixmap(0) {
+CSearchAnalysisItem::CSearchAnalysisItem(
+ const int moduleCount,
+ const QString &bookname,
+ double *scaleFactor,
+ const CSwordModuleSearch::Results &results)
+ : m_results(results),
+ m_scaleFactor(scaleFactor),
+ m_bookName(bookname),
+ m_moduleCount(moduleCount),
+ m_bufferPixmap(0)
+{
m_resultCountArray.resize(m_moduleCount);
int index = 0;
for (index = 0; index < m_moduleCount; ++index) m_resultCountArray[index] = 0;
@@ -137,23 +141,27 @@ int CSearchAnalysisItem::width() {
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
/// \todo Fix that loop
int i = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
+ for (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());
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
- CSwordModuleInfo* info = (*it);
const QColor c = CSearchAnalysisScene::getColor(i);
toolTipString.append(
- QString("<tr bgcolor=\"white\"><td><b><font color=\"#%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
- .arg(QString().sprintf("%02X%02X%02X", c.red(), c.green(), c.blue()))
+ 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)info->searchResult().Count())*(double)100 : 0.0, 0, 'g', 2)
+ .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)results.Count())*(double)100 : 0.0, 0, 'g', 2)
);
++i;
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index d5a46a9..7db96a9 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,19 +13,19 @@
#include <QGraphicsRectItem>
#include <QGraphicsScene>
+#include "backend/cswordmodulesearch.h"
class CSwordModuleInfo;
namespace Search {
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
class CSearchAnalysisItem : public QGraphicsRectItem {
public:
+ CSearchAnalysisItem(const int moduleCount, const QString &bookname,
+ double *scaleFactor,
+ const CSwordModuleSearch::Results &results);
- CSearchAnalysisItem(const int moduleCount, const QString& bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules);
~CSearchAnalysisItem();
/**
* Sets the resultcount of this item
@@ -52,7 +52,8 @@ class CSearchAnalysisItem : public QGraphicsRectItem {
private:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
+ private: /* Fields: */
+ CSwordModuleSearch::Results m_results;
double *m_scaleFactor;
QString m_bookName;
int m_moduleCount;
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index 38b6552..c5b9d02 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -39,12 +39,6 @@ const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;
-CSearchAnalysisLegendItem::CSearchAnalysisLegendItem(QList<CSwordModuleInfo*> *list )
- : QGraphicsRectItem() {
- m_moduleList = list;
-}
-
-/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
painter->save();
@@ -61,8 +55,7 @@ void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraph
// for (unsigned int index=0; index < m_moduleList->count(); index++){
int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
+ Q_FOREACH(const CSwordModuleInfo *m, m_moduleList) {
// the module color indicators
QPoint p1( (int)(rect().x()) + LEGEND_INNER_BORDER, (int)(rect().y()) + LEGEND_INNER_BORDER + moduleIndex*(LEGEND_DELTAY + ITEM_TEXT_SIZE) );
QPoint p2(p1.x() + ITEM_TEXT_SIZE, p1.y() + ITEM_TEXT_SIZE);
@@ -72,7 +65,7 @@ void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraph
painter->drawRect(r);
QPoint p3( p2.x() + LEGEND_INNER_BORDER, p2.y() );
- painter->drawText(p3, (*it)->name() );
+ painter->drawText(p3, m->name() );
++moduleIndex;
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index b3110eb..232fe64 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,19 +17,20 @@ class CSwordModuleInfo;
namespace Search {
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
class CSearchAnalysisLegendItem : public QGraphicsRectItem {
- public:
- CSearchAnalysisLegendItem(QList<CSwordModuleInfo*>* list );
+ public: /* Methods: */
+ inline CSearchAnalysisLegendItem(const QList<const CSwordModuleInfo*> &modules)
+ : m_moduleList(modules) {}
- private:
+ private: /* Methods: */
+ /** Reimplementation of QGraphicsItem::paint. */
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
+
+ private: /* Fields: */
+ QList<const CSwordModuleInfo*> m_moduleList;
};
-}
+} // namespace Search
#endif
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index 6d486a8..e4165ab 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -51,14 +51,12 @@ CSearchAnalysisScene::CSearchAnalysisScene(QObject *parent )
setSceneRect(0, 0, 1, 1);
}
-
-QHash<QString, CSearchAnalysisItem*>* CSearchAnalysisScene::getSearchAnalysisItemList() {
- // Returns pointer to the search analysis items
- return &m_itemList;
-}
-
/** Starts the analysis of the search result. This should be called only once because QCanvas handles the updates automatically. */
-void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
+void CSearchAnalysisScene::analyse(
+ const CSwordModuleSearch::Results &results)
+{
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
/**
* Steps of analysing our search result;
* -Create the items for all available books ("Genesis" - "Revelation")
@@ -67,13 +65,13 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
* -Find out how many times we found the book
* -Set the count to the items which belongs to the book
*/
- setModules(modules);
+ setResults(results);
m_lastPosList.clear();
- const int numberOfModules = m_moduleList.count();
+ const int numberOfModules = m_results.count();
if (!numberOfModules)
return;
- m_legend = new CSearchAnalysisLegendItem(&m_moduleList);
+ m_legend = new CSearchAnalysisLegendItem(m_results.keys());
addItem(m_legend);
m_legend->setRect(LEFT_BORDER, UPPER_BORDER,
LEGEND_WIDTH, LEGEND_INNER_BORDER*2 + ITEM_TEXT_SIZE*numberOfModules + LEGEND_DELTAY*(numberOfModules - 1) );
@@ -84,20 +82,19 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
m_maxCount = 0;
int count = 0;
CSwordVerseKey key(0);
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
CSearchAnalysisItem* analysisItem = m_itemList[key.book()];
bool ok = true;
while (ok && analysisItem) {
moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ for (RCI it = m_results.begin(); it != m_results.end(); it++) {
qApp->processEvents( QEventLoop::AllEvents );
- if (!m_lastPosList.contains(*it)) {
- m_lastPosList.insert(*it, 0);
+ if (!m_lastPosList.contains(it.key())) {
+ m_lastPosList.insert(it.key(), 0);
}
- analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), *it)));
+ analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), it.key())));
m_maxCount = (count > m_maxCount) ? count : m_maxCount;
++moduleIndex;
@@ -112,25 +109,30 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
ok = key.next(CSwordVerseKey::UseBook);
analysisItem = m_itemList[key.book()];
}
- setSceneRect(0, 0, xPos + BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX + RIGHT_BORDER, height() );
+ setSceneRect(0, 0, xPos + BAR_WIDTH + (m_results.count() - 1)*BAR_DELTAX + RIGHT_BORDER, height() );
slotResized();
}
/** Sets the module list used for the analysis. */
-void CSearchAnalysisScene::setModules(QList<CSwordModuleInfo*> modules) {
- m_moduleList.clear();
- foreach (CSwordModuleInfo * mod, modules) {
- if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
- m_moduleList.append(mod);
+void CSearchAnalysisScene::setResults(
+ const CSwordModuleSearch::Results &results)
+{
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
+ m_results.clear();
+ 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());
}
}
m_itemList.clear();
CSearchAnalysisItem* analysisItem = 0;
CSwordVerseKey key(0);
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
do {
- analysisItem = new CSearchAnalysisItem(m_moduleList.count(), key.book(), &m_scaleFactor, &m_moduleList);
+ analysisItem = new CSearchAnalysisItem(m_results.count(), key.book(), &m_scaleFactor, m_results);
addItem(analysisItem);
analysisItem->hide();
m_itemList.insert(key.book(), analysisItem);
@@ -160,13 +162,13 @@ void CSearchAnalysisScene::reset() {
/** No descriptions */
void CSearchAnalysisScene::slotResized() {
- m_scaleFactor = (double)( (double)(height() - UPPER_BORDER - LOWER_BORDER - BAR_LOWER_BORDER - 100 - (m_moduleList.count() - 1) * BAR_DELTAY)
+ m_scaleFactor = (double)( (double)(height() - UPPER_BORDER - LOWER_BORDER - BAR_LOWER_BORDER - 100 - (m_results.count() - 1) * BAR_DELTAY)
/ (double)m_maxCount);
QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList );
while ( it.hasNext() ) {
it.next();
if (it.value()) {
- it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX, height() - LOWER_BORDER - BAR_LOWER_BORDER);
+ it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_results.count() - 1)*BAR_DELTAX, height() - LOWER_BORDER - BAR_LOWER_BORDER);
}
}
update();
@@ -200,9 +202,12 @@ QColor CSearchAnalysisScene::getColor(int index) {
}
}
-/** Returns the count of the book in the module */
-unsigned int CSearchAnalysisScene::getCount( const QString book, CSwordModuleInfo* module ) {
- sword::ListKey& result = module->searchResult();
+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 int length = book.length();
unsigned int i = m_lastPosList[module];
unsigned int count = 0;
@@ -218,6 +223,8 @@ unsigned int CSearchAnalysisScene::getCount( const QString book, CSwordModuleInf
}
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;
@@ -230,9 +237,8 @@ void CSearchAnalysisScene::saveAsHTML() {
const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
CSwordVerseKey key(0);
- sword::ListKey searchResult;
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
@@ -242,9 +248,12 @@ void CSearchAnalysisScene::saveAsHTML() {
tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
- foreach (CSwordModuleInfo* mod, m_moduleList) {
+ 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>");
- searchResult = mod->searchResult();
+
+ /// \warning This is a workaround for sword constness
+ sword::ListKey searchResult = it.value();
countStr.setNum(searchResult.Count());
tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
@@ -259,8 +268,7 @@ void CSearchAnalysisScene::saveAsHTML() {
analysisItem = m_itemList.value( key.book() );
int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ 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>");
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index 2a4f171..a3a1832 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,8 +15,12 @@
#include <QColor>
#include <QHash>
#include <QMap>
+#include "backend/cswordmodulesearch.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"
+// Sword includes
+#include <listkey.h>
+
class CSwordModuleInfo;
@@ -39,16 +43,14 @@ class CSearchAnalysisScene : public QGraphicsScene {
* This should be called only once because
* QCanvas handles the updates automatically.
*/
- void analyse(QList<CSwordModuleInfo*> modules);
+ void analyse(const CSwordModuleSearch::Results &results);
+
/**
* This function returns a color for each module
* @return The color at position index in the list
*/
static QColor getColor(int index);
- /**
- * This function returns a pointer to the list of AnalysisItems
- */
- QHash<QString, CSearchAnalysisItem*>* getSearchAnalysisItemList();
+
void reset();
/**
* resize the height of the scene
@@ -65,17 +67,17 @@ class CSearchAnalysisScene : public QGraphicsScene {
void slotResized();
protected:
- void setModules(QList<CSwordModuleInfo*> modules);
+ void setResults(const CSwordModuleSearch::Results &results);
private:
/**
* Returns the count of the book in the module
*/
- unsigned int getCount( const QString book, CSwordModuleInfo* module );
+ unsigned int getCount(const QString &book, const CSwordModuleInfo *module);
- QList<CSwordModuleInfo*> m_moduleList;
+ CSwordModuleSearch::Results m_results;
QHash<QString, CSearchAnalysisItem*> m_itemList;
- QMap<CSwordModuleInfo*, unsigned int> m_lastPosList;
+ QMap<const CSwordModuleInfo*, unsigned int> m_lastPosList;
int m_maxCount;
double m_scaleFactor;
CSearchAnalysisLegendItem* m_legend;
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index 7efa604..d177f63 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index e66fc57..8d8c5f3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +22,7 @@ namespace Search {
class CSearchAnalysisScene;
/**
- @author The BibleTime team <info@bibletime.info>
+ @author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisView : public QGraphicsView {
public:
@@ -31,10 +31,10 @@ class CSearchAnalysisView : public QGraphicsView {
~CSearchAnalysisView() {}
/**
- * Returns the sizeHint for this view
- * We give back the size of the parent widgetas default.
- * This is a reimplementation from QCanvasView::sizeHint().
- */
+ * Returns the sizeHint for this view
+ * We give back the size of the parent widgetas default.
+ * This is a reimplementation from QCanvasView::sizeHint().
+ */
virtual QSize sizeHint() const;
/**
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
new file mode 100644
index 0000000..1d5f556
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
@@ -0,0 +1,58 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
+
+#include <QAction>
+#include <QToolButton>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/managers/cswordbackend.h"
+#include "util/tool.h"
+
+
+namespace {
+const QString groupingOrderKey("GUI/SearchDialog/ModuleChooserDialog/grouping");
+}
+
+BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
+ Qt::WindowFlags flags)
+ : BtModuleChooserDialog(parent, flags)
+{
+ // Initialize the tree model:
+ BtBookshelfTreeModel::Grouping grouping(groupingOrderKey);
+ BtBookshelfTreeModel *treeModel = new BtBookshelfTreeModel(grouping, this);
+ treeModel->setCheckable(true);
+ connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+
+ // Initialize the bookshelf widget:
+ bookshelfWidget()->showHideAction()->setVisible(false);
+ bookshelfWidget()->showHideButton()->hide();
+ bookshelfWidget()->setTreeModel(treeModel);
+ bookshelfWidget()->setSourceModel(CSwordBackend::instance()->model());
+
+ retranslateUi();
+}
+
+BtSearchModuleChooserDialog::~BtSearchModuleChooserDialog() {
+ // Intentionally empty
+}
+
+void BtSearchModuleChooserDialog::retranslateUi() {
+ setWindowTitle(tr("Works to Search in"));
+ util::tool::initExplanationLabel(label(), QString::null,
+ tr("Select the works which should be searched."));
+}
+
+void BtSearchModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ g.saveTo(groupingOrderKey);
+}
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.h b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
new file mode 100644
index 0000000..103682c
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
@@ -0,0 +1,45 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTSEARCHMODULECHOOSERDIALOG_H
+#define BTSEARCHMODULECHOOSERDIALOG_H
+
+#include "frontend/btmodulechooserdialog.h"
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+
+class BtBookshelfTreeModel;
+class CSwordModuleInfo;
+
+class BtSearchModuleChooserDialog: public BtModuleChooserDialog {
+ Q_OBJECT
+ public:
+ BtSearchModuleChooserDialog(QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
+ ~BtSearchModuleChooserDialog();
+
+ inline void setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
+ bookshelfWidget()->treeModel()->setCheckedModules(modules);
+ }
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return bookshelfWidget()->treeModel()->checkedModules();
+ }
+
+ protected slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
+
+ protected:
+ void retranslateUi();
+};
+
+#endif // BTSEARCHMODULECHOOSERDIALOG_H
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index 95c9218..9f76b6b 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,12 +19,12 @@
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/htmldialogs/bttabhtmldialog.h"
+#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
+#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
#include "frontend/searchdialog/crangechooserdialog.h"
-#include "frontend/searchdialog/csearchmodulechooserdialog.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
@@ -204,15 +204,15 @@ void BtSearchOptionsArea::initConnections() {
}
/** Sets the modules used by the search. */
-void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules ) {
+void BtSearchOptionsArea::setModules(const QList<const CSwordModuleInfo*> &modules) {
qDebug() << "BtSearchOptionsArea::setModules";
qDebug() << modules;
QString t;
m_modules.clear(); //remove old modules
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+ QList<const CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ for (QList<const CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
/// \todo Check for containsRef compat
if (*it == 0) { //don't operate on null modules.
continue;
@@ -256,24 +256,30 @@ void BtSearchOptionsArea::moduleListTextSelected(int index) {
QString text = m_modulesCombo->itemText(index);
qDebug() << text;
QStringList moduleNamesList = text.split(", ");
- QList<CSwordModuleInfo*> moduleList;
+ QList<const CSwordModuleInfo*> moduleList;
foreach(QString name, moduleNamesList) {
- moduleList.append(CPointers::backend()->findModuleByName(name));
+ moduleList.append(CSwordBackend::instance()->findModuleByName(name));
}
//set the list and the combobox list and text
setModules(moduleList);
}
void BtSearchOptionsArea::chooseModules() {
- QString title(tr("Works to Search in"));
- QString label(tr("Select the works which should be searched."));
- CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
- dlg->exec();
-}
+ BtSearchModuleChooserDialog* dlg = new BtSearchModuleChooserDialog(this);
+ QSet<CSwordModuleInfo*> ms;
+ Q_FOREACH (const CSwordModuleInfo *module, modules()) {
+ ms.insert(const_cast<CSwordModuleInfo*>(module));
+ }
-QList<CSwordModuleInfo*> BtSearchOptionsArea::modules() const {
- return m_modules;
+ dlg->setCheckedModules(ms);
+ if (dlg->exec() == QDialog::Accepted) {
+ QList<const CSwordModuleInfo*> ms;
+ Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
+ ms.append(m);
+ }
+ setModules(ms);
+ }
+ delete dlg;
}
void BtSearchOptionsArea::reset() {
@@ -333,108 +339,8 @@ void BtSearchOptionsArea::setupRanges() {
}
void BtSearchOptionsArea::syntaxHelp() {
-
- QString style = QString(
- "<style type='text/css'>"
- "h1 a {font-size: medium}"
- "table {margin-left: 20px}"
- "td {"
- " border-width: 3px 3px 3px 3px;"
- " border-style: solid solid solid solid;"
- " border-color: white white white white;"
- " background-color: #faf0e6;"
- "}"
- "p#links {margin-left: 20px}"
- "</style>");
-
- //: Don't translate words inside <> tags!
- //: Translate 'All words' etc. indentically to the Search dialog options.
- QString intro = tr(
- "<p>"
- "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
- "</p>");
-
- QString links = tr(
- "<p id='links'>"
- "<A href='#allsome'>Which words to find</A><br />"
- "<A href='#grouping'>Grouping and order</A><br />"
- "<A href='#wildcards'>Wildcards (partial words)</A><br />"
- "<A href='#fields'>Text fields (different parts of text)</A><br/>"
- "<A href='#lucene'>Other syntax features</A><br/>"
- "</p>");
-
- //: Syntax words (AND, OR...) must not be translated.
- QString whichwords = tr(
- "<h1><A name='allsome'>Which words to find</A></h1>"
- "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
-
- //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
- QString whichwordstable = tr(
- "<p><table><tr>"
- "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
- "</tr><tr>"
- "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
- "</tr><tr>"
- "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr><tr>"
- "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr></table></p>");
-
- QString grouping = tr(
- "<h1><A name='grouping'>Grouping and order</A></h1>"
- "<p>Words can be grouped with <strong>parenthesis</strong>. "
- "Strict word order can be defined with <strong>quotes</strong>.</p>");
-
- QString groupingtable = tr(
- "<p><table><tr>"
- "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
- "</tr><tr>"
- "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
- "</tr><tr>"
- "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
- "</tr></table></p>");
-
- QString wildcards = tr(
- "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
- "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
-
- QString wildcardstable = tr(
- "<p><table><tr>"
- "<td>a*</td><td>All words beginning with 'a'</td>"
- "</tr><tr>"
- "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
- "</tr><tr>"
- "<td>a?</td><td>'at' and 'an'</td>"
- "</tr><tr>"
- "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
- "</tr></table></p>");
-
- QString fields = tr(
- "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
- "<p>Available text fields:<br /><table>"
- "<tr><td>heading:</td><td>Searches headings</td></tr>"
- "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
- "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
- "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
-
- QString fieldstable = tr(
- "<p>Examples:<br /><table>"
- "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
- "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
- "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
- "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
- "</tr></table></p>");
-
- QString lucene = tr(
- "<h1><A name='lucene'>Other syntax features</A></h1>"
- "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
-
- QString syntax = style + intro + links + whichwords + whichwordstable +
- grouping + groupingtable + wildcards + wildcardstable +
- fields + fieldstable + lucene;
-
- BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
- dlg->setHtml(syntax);
+ // The dialog is deleted on close:
+ BtSearchSyntaxHelpDialog *dlg = new BtSearchSyntaxHelpDialog(this);
dlg->show();
}
@@ -490,28 +396,28 @@ bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event) {
}
void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
-// static const QRegExp re("\\b(AND|OR)\\b");
-// qDebug() << "new text:" << newText;
-// qDebug() << "contains:" << (newText.contains(re));
-// if (newText.isEmpty() || !newText.contains(re) ) {
-// qDebug()<< "no AND/OR";
-// if (!m_typeAndButton->isEnabled()) {
-// m_typeOrButton->setEnabled(true);
-// m_typeAndButton->setEnabled(true);
-// m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
-// m_typeOrButton->setToolTip(tr("Some of the words"));
-// }
-// }
-// else {
-// qDebug() << "AND/OR!";
-// if (m_typeAndButton->isEnabled()) {
-// m_typeOrButton->setChecked(true);
-// m_typeOrButton->setEnabled(false);
-// m_typeAndButton->setEnabled(false);
-// m_typeAndButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
-// m_typeOrButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
-// }
-// }
+// static const QRegExp re("\\b(AND|OR)\\b");
+// qDebug() << "new text:" << newText;
+// qDebug() << "contains:" << (newText.contains(re));
+// if (newText.isEmpty() || !newText.contains(re) ) {
+// qDebug()<< "no AND/OR";
+// if (!m_typeAndButton->isEnabled()) {
+// m_typeOrButton->setEnabled(true);
+// m_typeAndButton->setEnabled(true);
+// m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
+// m_typeOrButton->setToolTip(tr("Some of the words"));
+// }
+// }
+// else {
+// qDebug() << "AND/OR!";
+// if (m_typeAndButton->isEnabled()) {
+// m_typeOrButton->setChecked(true);
+// m_typeOrButton->setEnabled(false);
+// m_typeAndButton->setEnabled(false);
+// m_typeAndButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
+// m_typeOrButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
+// }
+// }
}
//bool BtSearchOptionsArea::isAndSearchType()
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index c7c1b1c..afc73ca 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -57,9 +57,11 @@ class BtSearchOptionsArea : public QWidget {
QPushButton* searchButton() const;
/**
- * Returns the list of used modules.
+ Returns the list of used modules.
*/
- QList<CSwordModuleInfo*> modules() const;
+ inline QList<const CSwordModuleInfo*> modules() const {
+ return m_modules;
+ }
/**
* Sets all options back to the default.
@@ -88,11 +90,12 @@ class BtSearchOptionsArea : public QWidget {
*/
void saveSettings();
bool eventFilter(QObject* obj, QEvent* event);
+
public slots:
/**
- * Sets the modules used by the search.
+ Sets the modules used by the search.
*/
- void setModules( QList<CSwordModuleInfo*> modules );
+ void setModules(const QList<const CSwordModuleInfo*> &modules);
/** Sets the modules when user selects them from the combobox.*/
void moduleListTextSelected(int index);
@@ -121,7 +124,7 @@ class BtSearchOptionsArea : public QWidget {
void sigStartSearch();
private:
- QList<CSwordModuleInfo*> m_modules;
+ QList<const CSwordModuleInfo*> m_modules;
QHBoxLayout *hboxLayout;
QGroupBox *searchGroupBox;
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 4b33f80..623de0e 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,6 +12,7 @@
#include <QApplication>
#include <QDebug>
#include <QFrame>
+#include <QMenu>
#include <QProgressDialog>
#include <QPushButton>
#include <QSize>
@@ -22,8 +23,6 @@
#include "backend/keys/cswordversekey.h"
#include "backend/rendering/cdisplayrendering.h"
#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "frontend/searchdialog/analysis/csearchanalysisdialog.h"
#include "frontend/searchdialog/cmoduleresultview.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/searchdialog/csearchresultview.h"
@@ -40,10 +39,6 @@ BtSearchResultArea::BtSearchResultArea(QWidget *parent)
qDebug() << "BtSearchResultArea::BtSearchResultArea end";
}
-BtSearchResultArea::~BtSearchResultArea() {
- saveDialogSettings();
-}
-
void BtSearchResultArea::initView() {
QVBoxLayout *mainLayout;
QWidget *resultListsWidget;
@@ -54,32 +49,32 @@ void BtSearchResultArea::initView() {
int mWidth = util::tool::mWidth(this, 1);
this->setMinimumSize(QSize(mWidth*40, mWidth*15));
mainLayout = new QVBoxLayout(this);
- mainSplitter = new QSplitter(this);
- mainSplitter->setOrientation(Qt::Horizontal);
+ m_mainSplitter = new QSplitter(this);
+ m_mainSplitter->setOrientation(Qt::Horizontal);
- resultListsWidget = new QWidget(mainSplitter);
+ resultListsWidget = new QWidget(m_mainSplitter);
resultListsWidgetLayout = new QVBoxLayout(resultListsWidget);
resultListsWidgetLayout->setContentsMargins(0, 0, 0, 0);
//Splitter for two result lists
- resultListSplitter = new QSplitter(resultListsWidget);
- resultListSplitter->setOrientation(Qt::Vertical);
- m_moduleListBox = new CModuleResultView(resultListSplitter);
- resultListSplitter->addWidget(m_moduleListBox);
- m_resultListBox = new CSearchResultView(resultListSplitter);
- resultListSplitter->addWidget(m_resultListBox);
- resultListsWidgetLayout->addWidget(resultListSplitter);
+ m_resultListSplitter = new QSplitter(resultListsWidget);
+ m_resultListSplitter->setOrientation(Qt::Vertical);
+ m_moduleListBox = new CModuleResultView(m_resultListSplitter);
+ m_resultListSplitter->addWidget(m_moduleListBox);
+ m_resultListBox = new CSearchResultView(m_resultListSplitter);
+ m_resultListSplitter->addWidget(m_resultListBox);
+ resultListsWidgetLayout->addWidget(m_resultListSplitter);
- mainSplitter->addWidget(resultListsWidget);
+ m_mainSplitter->addWidget(resultListsWidget);
//Preview ("info") area
- m_displayFrame = new QFrame(mainSplitter);
+ m_displayFrame = new QFrame(m_mainSplitter);
m_displayFrame->setFrameShape(QFrame::NoFrame);
m_displayFrame->setFrameShadow(QFrame::Plain);
- mainSplitter->addWidget(m_displayFrame);
+ m_mainSplitter->addWidget(m_displayFrame);
- mainLayout->addWidget(mainSplitter);
+ mainLayout->addWidget(m_mainSplitter);
QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
frameLayout->setContentsMargins(0, 0, 0, 0);
@@ -87,20 +82,38 @@ void BtSearchResultArea::initView() {
m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
frameLayout->addWidget(m_previewDisplay->view());
+ QAction* selectAllAction = new QAction(QIcon(), tr("Select all"), this);
+ selectAllAction->setShortcut(QKeySequence::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()), this, SLOT(copySelection()) );
+
+ QMenu* menu = new QMenu();
+ menu->addAction(selectAllAction);
+ menu->addAction(copyAction);
+ m_previewDisplay->installPopup(menu);
+
loadDialogSettings();
}
-void BtSearchResultArea::setSearchResult(QList<CSwordModuleInfo*> modules) {
+void BtSearchResultArea::setSearchResult(
+ const CSwordModuleSearch::Results &results)
+{
const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
reset(); //clear current modules
- m_modules = modules;
- //pre-select the first module in the list
- //this will pre-select and display the first hit of that module
- m_moduleListBox->setupTree(modules, searchedText);
+ m_results = results;
+
+ // Populate listbox:
+ m_moduleListBox->setupTree(results, searchedText);
+
+ // Pre-select the first module in the list:
m_moduleListBox->setCurrentItem(m_moduleListBox->topLevelItem(0), 0);
- qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
+ Q_ASSERT(qobject_cast<CSearchDialog*>(parent()) != 0);
+ static_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
}
void BtSearchResultArea::reset() {
@@ -108,7 +121,6 @@ void BtSearchResultArea::reset() {
m_resultListBox->clear();
m_previewDisplay->setText("<html><head/><body></body></html>");
qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(false);
- m_modules.clear();
}
void BtSearchResultArea::clearPreview() {
@@ -125,7 +137,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
QString text;
CDisplayRendering render;
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
modules.append(module);
CTextRendering::KeyTreeItem::Settings settings;
@@ -134,7 +146,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
vk.Headings(1);
- vk.key(key);
+ vk.setKey(key);
((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
@@ -152,7 +164,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
const QString startKey = vk.key();
- vk.key(key);
+ vk.setKey(key);
vk.next(CSwordVerseKey::UseVerse);
vk.next(CSwordVerseKey::UseVerse);
@@ -165,7 +177,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
else if (module->type() == CSwordModuleInfo::Commentary) {
CSwordVerseKey vk(module);
vk.Headings(1);
- vk.key(key);
+ vk.setKey(key);
((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
@@ -178,7 +190,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
}
const QString startKey = vk.key();
- vk.key(key);
+ vk.setKey(key);
const QString endKey = vk.key();
settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::NoKey;
@@ -193,7 +205,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
}
}
-QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
+QStringList BtSearchResultArea::queryParser(const QString& queryString) {
QString token;
QStringList tokenList;
int cnt, pos;
@@ -226,13 +238,13 @@ QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
}
// 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++;
+ // 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] == '!') {
@@ -423,20 +435,20 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
//char buf8[1000];
//standard::WhitespaceAnalyzer analyzer;
//lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //boost::scoped_ptr<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
+ //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);
+ // 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);
+ QStringList words = queryParser(newSearchText);
qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
foreach (QString word, words) { //search for every word in the list
QRegExp findExp;
@@ -481,18 +493,15 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
void BtSearchResultArea::initConnections() {
connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
connect(m_resultListBox, SIGNAL(keyDeselected()), this, SLOT(clearPreview()));
- connect(m_moduleListBox, SIGNAL(moduleSelected(CSwordModuleInfo*)), m_resultListBox, SLOT(setupTree(CSwordModuleInfo*)));
+ connect(m_moduleListBox,
+ SIGNAL(moduleSelected(const CSwordModuleInfo*, const sword::ListKey&)),
+ m_resultListBox,
+ SLOT(setupTree(const CSwordModuleInfo*, const sword::ListKey&)));
connect(m_moduleListBox, SIGNAL(moduleChanged()), m_previewDisplay->connectionsProxy(), SLOT(clear()));
// connect the strongs list
- connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, QStringList*)),
- m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, QStringList*)));
-}
-
-/** Shows a dialog with the search analysis of the current search. */
-void BtSearchResultArea::showAnalysis() {
- CSearchAnalysisDialog dlg(m_modules, this);
- dlg.exec();
+ connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, const QStringList&)),
+ m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, const QStringList&)));
}
/**
@@ -501,127 +510,97 @@ void BtSearchResultArea::showAnalysis() {
void BtSearchResultArea::loadDialogSettings() {
QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
if (mainSplitterSizes.count() > 0) {
- mainSplitter->setSizes(mainSplitterSizes);
+ m_mainSplitter->setSizes(mainSplitterSizes);
}
else {
int w = this->size().width();
int w2 = m_moduleListBox->sizeHint().width();
mainSplitterSizes << w2 << w - w2;
- mainSplitter->setSizes(mainSplitterSizes);
+ m_mainSplitter->setSizes(mainSplitterSizes);
}
QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) resultListSplitter->setSizes(resultSplitterSizes);
+ if (resultSplitterSizes.count() > 0) m_resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
void BtSearchResultArea::saveDialogSettings() {
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, resultListSplitter->sizes());
-}
-
-StrongsResult::StrongsResult() {
-}
-
-StrongsResult::StrongsResult(const QString& text, const QString &keyName)
- : text(text) {
- //keyNameList.clear();
- keyNameList.append(keyName);
-}
-
-QString StrongsResult::keyText() const {
- return text;
-}
-
-int StrongsResult::keyCount() const {
- return keyNameList.count();
-}
-
-void StrongsResult::addKeyName(const QString& keyName) {
- if (keyNameList.indexOf(keyName) == -1)
- keyNameList.append(keyName);
-}
-
-QStringList* StrongsResult::getKeyList() {
- return & keyNameList;
+ CBTConfig::set(CBTConfig::searchMainSplitterSizes, m_mainSplitter->sizes());
+ CBTConfig::set(CBTConfig::searchResultSplitterSizes, m_resultListSplitter->sizes());
}
+/******************************************************************************
+* StrongsResultList:
+******************************************************************************/
-
-/********************************************
-************ StrongsResultClass *************
-********************************************/
-void StrongsResultClass::initStrongsResults(void) {
+StrongsResultList::StrongsResultList(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ const QString &strongsNumber)
+{
using namespace Rendering;
- CDisplayRendering render;
- QList<CSwordModuleInfo*> modules;
- CTextRendering::KeyTreeItem::Settings settings;
- QString rText, lText, key;
- bool found;
- int sIndex;
- int count;
- int index;
- QString text;
-
- modules.append(srModule);
- sword::ListKey& result = srModule->searchResult();
+ /// \warning This is a workaround for Sword constness
+ sword::ListKey result = results;
- count = result.Count();
+ int count = result.Count();
if (!count)
return;
- qApp->processEvents( QEventLoop::AllEvents, 1 ); //1 ms only
- srList.clear();
+
+ CTextRendering::KeyTreeItem::Settings settings;
+ QList<const CSwordModuleInfo*> modules;
+ modules.append(module);
+ clear();
+
// for whatever reason the text "Parsing...translations." does not appear.
// this is not critical but the text is necessary to get the dialog box
// to be wide enough.
- QProgressDialog* progress = new QProgressDialog(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
+ QProgressDialog progress(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
//0, "progressDialog", tr("Parsing Strong's Numbers"), tr("Parsing Strong's numbers for translations."), true);
-
//progress->setAllowCancel(false);
//progress->setMinimumDuration(0);
- progress->show();
- progress->raise();
- for (index = 0; index < count; index++) {
- progress->setValue( index );
- qApp->processEvents(QEventLoop::AllEvents, 1 ); //1 ms only
-
- key = QString::fromUtf8(result.GetElement(index)->getText());
- text = render.renderSingleKey(key, modules, settings);
- sIndex = 0;
- while ((rText = getStrongsNumberText(text, &sIndex)) != "") {
- StrongsResultList::iterator it;
- found = FALSE;
- for ( it = srList.begin(); it != srList.end(); ++it ) {
- lText = (*it).keyText();
- if (lText == rText) {
- found = TRUE;
+ progress.show();
+ progress.raise();
+
+ qApp->processEvents(QEventLoop::AllEvents, 1); //1 ms only
+
+ for (int index = 0; index < count; index++) {
+ progress.setValue(index);
+ qApp->processEvents(QEventLoop::AllEvents, 1); //1 ms only
+
+ QString key = QString::fromUtf8(result.GetElement(index)->getText());
+ QString text = CDisplayRendering().renderSingleKey(key, modules, settings);
+ for (int sIndex = 0;;) {
+ continueloop:
+ QString rText = getStrongsNumberText(text, sIndex, strongsNumber);
+ if (rText.isEmpty()) break;
+
+ for (iterator it = begin(); it != end(); ++it) {
+ if ((*it).keyText() == rText) {
(*it).addKeyName(key);
- break;
+ goto continueloop; // break, then continue
}
}
- if (found == FALSE)
- srList.append( StrongsResult(rText, key) );
+ append(StrongsResult(rText, key));
}
}
- delete progress;
- progress = 0;
- //qHeapSort(srList);
}
-QString StrongsResultClass::getStrongsNumberText(const QString& verseContent, int *startIndex) {
+QString StrongsResultList::getStrongsNumberText(const QString &verseContent,
+ int &startIndex,
+ const QString &lemmaText)
+{
// get the strongs text
int idx1, idx2, index;
QString sNumber, strongsText;
//const bool cs = CSwordModuleSearch::caseSensitive;
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
- if (*startIndex == 0) {
+ if (startIndex == 0) {
index = verseContent.indexOf("<body");
}
else {
- index = *startIndex;
+ index = startIndex;
}
// find all the "lemma=" inside the the content
@@ -639,7 +618,7 @@ QString StrongsResultClass::getStrongsNumberText(const QString& verseContent, in
idx2 = verseContent.indexOf("<", index, cs);
strongsText = verseContent.mid(index, idx2 - index);
index = idx2;
- *startIndex = index;
+ startIndex = index;
return(strongsText);
}
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index f0e3d6e..f7ef8d8 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,13 +16,14 @@
#include <QWidget>
#include "backend/managers/cswordbackend.h"
#include "backend/cswordmodulesearch.h"
+#include "frontend/display/creaddisplay.h"
+#include "frontend/searchdialog/analysis/csearchanalysisdialog.h"
namespace Search {
class CModuleResultView;
class CSearchResultView;
}
-class CReadDisplay;
class CSwordModuleInfo;
class QFrame;
class QHBoxLayout;
@@ -44,73 +45,45 @@ namespace Search {
* To add a new verse to a strongs text result use addKeyName.
*/
class StrongsResult {
- public:
- StrongsResult();
- StrongsResult(const QString& text, const QString &keyName);
-
- QString keyText() const;
- int keyCount() const;
- void addKeyName(const QString& keyName);
- QStringList* getKeyList();
+ public: /* Methods: */
+ inline StrongsResult() {}
+ inline StrongsResult(const QString &text,
+ const QString &keyName)
+ : m_text(text)
+ {
+ m_keyNameList.append(keyName);
+ }
- /* ????
- bool operator==(const StrongsResult &l, const StrongsResult &r)
- { return (l.keyText() == r.keyText()); }
+ const QString &keyText() const { return m_text; }
+ inline int keyCount() const { return m_keyNameList.count(); }
+ inline void addKeyName(const QString &keyName) {
+ if (m_keyNameList.contains(keyName)) return;
+ m_keyNameList.append(keyName);
+ }
- bool operator<(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() < r->keyText()); }
+ inline const QStringList &getKeyList() const { return m_keyNameList; }
- bool operator>(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() > r->keyText()); }
- */
- private:
- QString text;
- QStringList keyNameList;
+ private: /* Fields: */
+ QString m_text;
+ QStringList m_keyNameList;
};
-typedef QList<StrongsResult> StrongsResultList;
-
/**
+* \todo Fix comment!
* This class is used to keep track of the text strongs results.
* It keeps track of all instances of all strongs text results.
* This class makes use of the above class StrongsResult.
-*
-* The functions of the class are:
-* - Store an instance of a strongs text result.
-* - Each strongs text result will contain a list of verses (keyNames).
-* - The number of verses (keyNames) is returned by keyCount().
-* - The text for the strongs text result is returned by keyText().
-* - The list of verses (keyNames) is returned by getKeyList() [as QStringList].
-*
-* To add a new verse to a strongs text result use addKeyName.
*/
-class StrongsResultClass {
- public:
- StrongsResultClass(CSwordModuleInfo* module, const QString& strongsNumber)
- : srModule(module), lemmaText(strongsNumber) {
- initStrongsResults();
- }
-
- QString keyText(int index) const {
- return srList[index].keyText();
- }
- int keyCount(int index) const {
- return srList[index].keyCount();
- }
- QStringList* getKeyList(int index) {
- return srList[index].getKeyList();
- }
- int Count() const {
- return srList.count();
- }
-
- private:
- void initStrongsResults(void);
- QString getStrongsNumberText(const QString& verseContent, int *startIndex);
-
- StrongsResultList srList;
- CSwordModuleInfo* srModule;
- QString lemmaText;
+class StrongsResultList: public QList<StrongsResult> {
+ public: /* Methods: */
+ StrongsResultList(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ const QString &strongsNumber);
+
+ private: /* Methods: */
+ QString getStrongsNumberText(const QString &verseContent,
+ int &startIndex,
+ const QString &lemmaText);
};
@@ -119,18 +92,27 @@ class StrongsResultClass {
*/
class BtSearchResultArea : public QWidget {
Q_OBJECT
- public:
+ public: /* Methods: */
BtSearchResultArea(QWidget *parent = 0);
- ~BtSearchResultArea();
+ inline ~BtSearchResultArea() { saveDialogSettings(); }
+
/**
* Sets the modules which contain the result of each.
*/
- void setSearchResult(QList<CSwordModuleInfo*> modules);
+ void setSearchResult(
+ const CSwordModuleSearch::Results &results);
- QSize sizeHint() const {
+ /**
+ Reimplemented from QWidget::sizeHint().
+ */
+ virtual QSize sizeHint() const {
return baseSize();
}
- QSize minimumSizeHint() const {
+
+ /**
+ Reimplemented from QWidget::minimumSizeHint().
+ */
+ virtual QSize minimumSizeHint() const {
return minimumSize();
}
@@ -140,19 +122,22 @@ class BtSearchResultArea : public QWidget {
*/
void reset();
- protected:
+ protected: /* Methods: */
/**
* Initializes the view of this widget.
*/
void initView();
+
/**
* Initializes the signal slot conections of the child widgets
*/
void initConnections();
+
/**
* This function breakes the queryString into clucene tokens
*/
- QStringList QueryParser(const QString& queryString);
+ QStringList queryParser(const QString& queryString);
+
/**
* This function highlights the searched text in the content using the search type given by search flags
*/
@@ -162,6 +147,7 @@ class BtSearchResultArea : public QWidget {
* Load the settings from the resource file
*/
void loadDialogSettings();
+
/**
* Save the settings to the resource file
*/
@@ -172,16 +158,33 @@ class BtSearchResultArea : public QWidget {
* Update the preview of the selected key.
*/
void updatePreview(const QString& key);
+
/**
* Clear the preview of the selected key.
*/
void clearPreview();
+
/**
* Shows a dialog with the search analysis of the current search.
*/
- void showAnalysis();
+ inline void showAnalysis() {
+ CSearchAnalysisDialog(m_results, this).exec();
+ }
+
+ /**
+ * Select all text
+ */
+ inline void selectAll() { m_previewDisplay->selectAll(); }
- private:
+ /**
+ * Copy selected text
+ */
+ inline void copySelection() {
+ m_previewDisplay->connectionsProxy()->copySelection();
+ }
+
+ private: /* Fields: */
+ CSwordModuleSearch::Results m_results;
CModuleResultView* m_moduleListBox;
CSearchResultView* m_resultListBox;
@@ -189,10 +192,8 @@ class BtSearchResultArea : public QWidget {
QFrame *m_displayFrame;
CReadDisplay* m_previewDisplay;
- QList<CSwordModuleInfo*> m_modules;
-
- QSplitter *mainSplitter;
- QSplitter *resultListSplitter;
+ QSplitter *m_mainSplitter;
+ QSplitter *m_resultListSplitter;
};
} //namespace Search
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
new file mode 100644
index 0000000..a1debc3
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
@@ -0,0 +1,229 @@
+/*********
+*
+* 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/searchdialog/btsearchsyntaxhelpdialog.h"
+
+#include <QDesktopServices>
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QWebView>
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
+
+namespace Search {
+
+BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFlags wflags)
+ : QDialog(parent, wflags)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+ resize(550, 340);
+
+ QVBoxLayout *l = new QVBoxLayout;
+
+ m_webView = new QWebView(this);
+ m_webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
+ connect(m_webView, SIGNAL(linkClicked(QUrl)),
+ this, SLOT(linkClicked(QUrl)));
+ l->addWidget(m_webView);
+
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ l->addWidget(m_buttons);
+
+ setLayout(l);
+
+ retranslateUi();
+}
+
+BtSearchSyntaxHelpDialog::~BtSearchSyntaxHelpDialog() {
+ // Intentionally empty
+}
+
+void BtSearchSyntaxHelpDialog::retranslateUi() {
+ namespace DU = util::directory;
+
+ QString theTitle(tr("Search Syntax Help"));
+ setWindowTitle(theTitle);
+
+ QString html("<html><head><title>");
+ html += theTitle;
+ html += "</title><style type=\"text/css\">"
+ "body{"
+ "background-color:";
+ html += palette().color(QPalette::Window).name();
+ html += ";"
+ "color:";
+ html += palette().color(QPalette::WindowText).name();
+ html +=
+ "}h3{"
+ "font-weight:bold;"
+ "text-align:center"
+ "}a{"
+ "text-decoration:underline"
+ "}a:link{"
+ "color:";
+ html += palette().color(QPalette::Link).name();
+ html +=
+ "}a:visited{"
+ "color:";
+ html += palette().color(QPalette::LinkVisited).name();
+ html +=
+ "}h1 a{"
+ "font-size:medium"
+ "}table{"
+ "margin-left:2em;"
+ "border-collapse:collapse"
+ "}td{"
+ "padding:0.2em 0.3em;"
+ "border:3px solid ";
+ html += palette().color(QPalette::Foreground).name();
+ html += ";"
+ "color:";
+ html += palette().color(QPalette::Text).name();
+ html += ";"
+ "background-color:";
+ html += palette().color(QPalette::Base).name();
+ html +=
+ "}ul#links{"
+ "list-style-type:none"
+ "}"
+ "</style></head><body><p>";
+
+ html += tr("This help is mainly for 'Full syntax' option. 'All words' and 'Some words' "
+ "options have more limited syntax; <a href='#wildcards'>wildcards</a> and "
+ "<a href='#fields'>text fields</a> are supported for them. Some other syntax "
+ "features may give strange or wrong results with All words/Some words.");
+ html += "</p><p><ul id='links'><li><a href='#allsome'>";
+ html += tr("Which words to find");
+ html += "</a></li><li><a href='#grouping'>";
+ html += tr("Grouping and order");
+ html += "</a></li><li><a href='#wildcards'>";
+ html += tr("Wildcards (partial words)");
+ html += "</a></li><li><a href='#fields'>";
+ html += tr("Text fields (different parts of text)");
+ html += "</a></li><li><a href='#lucene'>";
+ html += tr("Other syntax features");
+
+ html += "</a></li></ul></p><h1><a name='allsome'>";
+ html += tr("Which words to find");
+ html += "</a></h1><p>";
+ html += tr("Search terms are separated by spaces. <strong>AND</strong> (all words), "
+ "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) "
+ "can be added between the words. If none is added explicitly OR is used "
+ "automatically. '<strong>+</strong>word' means the word must be in the results, "
+ "'<strong>-</strong>word' means it must not be in the results.",
+ "Do not translate \"AND\", \"OR\" or \"NOT\".");
+ html += "</p><p><table><tr><td>";
+ html += tr("jesus AND god", "Do not translate \"AND\".");
+ html += "</td><td>";
+ html += tr("Finds verses with both 'Jesus' and 'God'");
+ html += "</td></tr><tr><td>";
+ html += tr("jesus OR god", "Do not translate \"OR\".");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' or 'God' or both");
+ html += "</td></tr><tr><td>";
+ html += tr("jesus NOT god", "Do not translate \"NOT\".");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' but with no 'God'");
+ html += "</td></tr><tr><td>";
+ html += tr("+jesus -god");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' but with no 'God'");
+
+ html += "</td></tr></table></p><h1><a name='grouping'>";
+ html += tr("Grouping and order");
+ html += "</a></h1><p>";
+ html += tr("Words can be grouped with <strong>parenthesis</strong>. Strict word order "
+ "can be defined with <strong>quotes</strong>.");
+ html += "</p><p><table><tr><td>";
+ html += tr("(a AND b) OR c", "Do not translate \"AND\" or \"OR\".");
+ html += "</td><td>";
+ html += tr("Finds verses with both 'a' AND 'b', and verses with 'c'");
+ html += "</td></tr><tr><td>";
+ html += tr("\"says lord\"");
+ html += "</td><td>";
+ html += ("Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'");
+ html += "</td></tr><tr><td>";
+ html += tr("\"says the lord\"");
+ html += "</td><td>";
+ html += tr("Finds all verses with 'says the LORD'");
+
+ html += "</td></tr></table></p><h1><a name='wildcards'>";
+ html += tr("Wildcards (partial words)");
+ html += "</a></h1><p>";
+ html += tr("'<strong>*</strong>' matches any sequence of 0 or more characters, while "
+ "'<strong>?</strong>' matches any single character. A wildcard can not be used in "
+ "the beginning of a word.");
+ html += "</p><p><table><tr><td>";
+ html += tr("a*");
+ html += "</td><td>";
+ html += tr("All words beginning with 'a'");
+ html += "</td></tr><tr><td>";
+ html += tr("a*a");
+ html += "</td><td>";
+ html += tr("'Assyria', 'aroma', 'abba' etc.");
+ html += "</td></tr><tr><td>";
+ html += tr("a?");
+ html += "</td><td>";
+ html += tr("'at' and 'an'");
+ html += "</td></tr><tr><td>";
+ html += tr("a??a");
+ html += "</td><td>";
+ html += tr("'abba', 'area', 'Asia' etc.");
+
+ html += "</td></tr></table></p><h1><a name='fields'>";
+ html += tr("Text fields (different parts of text)");
+ html += "</a></h1><p>";
+ html += tr("Available text fields:" );
+ html += "<br/><table><tr><td>heading:</td><td>";
+ html += tr("Searches headings");
+ html += "</td></tr><tr><td>footnote:</td><td>";
+ html += tr("Searches footnotes");
+ html += "</td></tr><tr><td>strong:</td><td>";
+ html += tr("Searches Strong's numbers");
+ html += "</td></tr><tr><td>morph:</td><td>";
+ html += tr("Searches morphology codes");
+ html += "</td></tr></table></p><p>";
+ html += tr("Examples:" );
+ html += "<br/><table><tr><td>";
+ html += tr("heading:Jesus", "Do not translate \"heading:\".");
+ html += "</td><td>";
+ html += tr("Finds headings with 'Jesus'");
+ html += "</td></tr><tr><td>";
+ html += tr("footnote:Jesus AND footnote:said",
+ "Do not translate \"footnote:\" or \"AND\".");
+ html += "</td><td>";
+ html += tr("Finds footnotes with 'Jesus' and 'said'");
+ html += "</td></tr><tr><td>";
+ html += tr("strong:G846", "Do not translate \"strong:\".");
+ html += "</td><td>";
+ html += tr("Finds verses with Strong's Greek number 846");
+ html += "</td></tr><tr><td>";
+ html += tr("morph:\"N-NSF\"", "Do not translate \"morph:\".");
+ html += "</td><td>";
+ html += tr("Finds verses with morphology code 'N-NSF'");
+ html += "</td></tr></table></p><h1><a name='lucene'>";
+ html += tr("Other syntax features");
+ html += "</a></h1><p>";
+ html += tr("BibleTime uses the CLucene search engine. You can read more on the "
+ "<a href='%1'>lucene syntax web page</a> (in external browser).")
+ .arg("http://lucene.apache.org/java/1_4_3/queryparsersyntax.html");
+ html += "</p></body></html>";
+
+ m_webView->setHtml(html, QUrl::fromLocalFile(DU::getIconDir().path()));
+
+ util::prepareDialogBox(m_buttons);
+}
+
+void BtSearchSyntaxHelpDialog::linkClicked(const QUrl &url) {
+ QDesktopServices::openUrl(url);
+}
+
+} // namespace Search
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
new file mode 100644
index 0000000..89cc805
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
@@ -0,0 +1,40 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTTABDIALOG_H
+#define BTTABDIALOG_H
+
+#include <QDialog>
+
+class QDialogButtonBox;
+class QUrl;
+class QWebView;
+
+namespace Search {
+
+class BtSearchSyntaxHelpDialog: public QDialog {
+ Q_OBJECT
+ public:
+ BtSearchSyntaxHelpDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ ~BtSearchSyntaxHelpDialog();
+
+ protected:
+ void retranslateUi();
+
+ protected slots:
+ void linkClicked(const QUrl &url);
+
+ private:
+ QWebView *m_webView;
+ QDialogButtonBox *m_buttons;
+};
+
+} // namespace Search
+
+#endif
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index 355ed00..cf77627 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index d750e16..dffbcd8 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index ef23756..f37b4d9 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -38,8 +38,7 @@ CModuleResultView::CModuleResultView(QWidget* parent)
}
CModuleResultView::~CModuleResultView() {
- qDeleteAll(strongsResults);
- strongsResults.clear();
+ qDeleteAll(m_strongsResults);
}
@@ -98,32 +97,31 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-/** Setups the tree using the given list of modules. */
-void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText ) {
+void CModuleResultView::setupTree(
+ const CSwordModuleSearch::Results &results,
+ const QString &searchedText)
+{
clear();
+
+ m_results = results;
+
/// \todo this class is for sorting
//util::CSortListViewItem* item = 0;
//util::CSortListViewItem* oldItem = 0;
QTreeWidgetItem* item = 0;
- QTreeWidgetItem* oldItem = 0;
- sword::ListKey result;
-
- qDeleteAll(strongsResults);
- strongsResults.clear();
+ qDeleteAll(m_strongsResults);
+ m_strongsResults.clear();
bool strongsAvailable = false;
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- // for (modules.first(); modules.current(); modules.next()) {
- result = (*it)->searchResult();
+ Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
+ sword::ListKey result = results.value(m);
- item = new QTreeWidgetItem(this, QStringList((*it)->name()) << QString::number(result.Count()) );
+ item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
/// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
- item->setIcon(0, util::tool::getIconForModule(*it) );
- oldItem = item;
+ 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
@@ -142,7 +140,7 @@ void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QStri
sTokenIndex = searchedText.indexOf(" ", sstIndex);
sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
- setupStrongsResults((*it), item, sNumber);
+ setupStrongsResults(m, results[m], item, sNumber);
/// \todo item->setOpen(true);
strongsAvailable = true;
@@ -153,53 +151,50 @@ void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QStri
setRootIsDecorated( strongsAvailable );
}
-void CModuleResultView::setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent,
- const QString& sNumber) {
- QString lText;
- /// \todo
- //util::CSortListViewItem* item = 0;
- QTreeWidgetItem* item = 0;
-
- strongsResults[module] = new StrongsResultClass(module, sNumber);
-
- for (int cnt = 0; cnt < strongsResults[module]->Count(); ++cnt) {
- lText = strongsResults[module]->keyText(cnt);
-
- item = new QTreeWidgetItem(parent, QStringList(lText) << QString::number(strongsResults[module]->keyCount(cnt)));
- /// \todo
- //item->setColumnSorting(1, util::CSortListViewItem::Number);
+void CModuleResultView::setupStrongsResults(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ QTreeWidgetItem *parent,
+ const QString &sNumber)
+{
+ StrongsResultList *m = new StrongsResultList(module, results, sNumber);
+ m_strongsResults[module] = m;
+
+ for (int cnt = 0; cnt < m->count(); ++cnt) {
+ QStringList columns(m->at(cnt).keyText());
+ columns.append(QString::number(m->at(cnt).keyCount()));
+ new QTreeWidgetItem(parent, columns);
}
}
/// \todo
/** Is executed when an item was selected in the list. */
void CModuleResultView::executed( QTreeWidgetItem* i, QTreeWidgetItem*) {
- QString itemText, lText;
+ QString itemText;
if (!i) {
//Clear list
emit moduleChanged();
return;
}
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(i->text(0))) {
+ if (CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(i->text(0))) {
emit moduleChanged();
- emit moduleSelected(m);
+ emit moduleSelected(m, m_results.value(m));
return;
}
- StrongsResultClass* strongsResult = strongsResults[activeModule()];
+ StrongsResultList *strongsResult = m_strongsResults[activeModule()];
if (!strongsResult) {
return;
}
itemText = i->text(0);
- for (int cnt = 0; cnt < strongsResult->Count(); cnt++) {
- lText = strongsResult->keyText(cnt);
- if (lText == itemText) {
+ for (int cnt = 0; cnt < strongsResult->count(); cnt++) {
+ if (strongsResult->at(cnt).keyText() == itemText) {
//clear the verses list
emit moduleChanged();
- emit strongsSelected(activeModule(), strongsResult->getKeyList(cnt));
+ emit strongsSelected(activeModule(),
+ strongsResult->at(cnt).getKeyList());
return;
}
}
@@ -221,7 +216,7 @@ CSwordModuleInfo* CModuleResultView::activeModule() {
}
if (item) {
- return CPointers::backend()->findModuleByName(item->text(0));
+ return CSwordBackend::instance()->findModuleByName(item->text(0));
}
return 0;
@@ -236,46 +231,57 @@ void CModuleResultView::contextMenuEvent( QContextMenuEvent * event ) {
/** Copies the whole search result into the clipboard. */
void CModuleResultView::copyResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result, m, CExportManager::Text, false);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Copy search result..."), true,
+ tr("Copying search result"));
+
+ mgr.copyKeyList(m_results[m], m, CExportManager::Text, false);
};
}
/** Copies the whole search result with the text into the clipboard. */
void CModuleResultView::copyResultWithText() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result, m, CExportManager::Text, true);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Copy search result..."), true,
+ tr("Copying search result"));
+
+ mgr.copyKeyList(m_results[m], m, CExportManager::Text, true);
};
}
/** Saves the search result keys. */
void CModuleResultView::saveResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result, m, CExportManager::Text, false);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Save search result..."), true,
+ tr("Saving search result"));
+
+ mgr.saveKeyList(m_results[m], m, CExportManager::Text, false);
};
}
/** Saves the search result with it's text. */
void CModuleResultView::saveResultWithText() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result, m, CExportManager::Text, true);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Save search result..."), true,
+ tr("Saving search result"));
+
+ mgr.saveKeyList(m_results[m], m, CExportManager::Text, true);
};
}
/** Appends the whole search result to the printer queue. */
void CModuleResultView::printResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
- mgr.printKeyList(&result, m, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults());
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Print search result..."), true,
+ tr("Printing search result"));
+
+ mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
+ CBTConfig::getFilterOptionDefaults());
};
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index ab48f60..5940859 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +22,7 @@ class QContextMenuEvent;
class QMenu;
class QPoint;
class QStringList;
-class StrongsResultClass;
+class StrongsResultList;
namespace Search {
@@ -33,9 +33,11 @@ class CModuleResultView : public QTreeWidget {
~CModuleResultView();
/**
- * Setups the tree using the given list of modules.
+ Setups the tree using the given list of modules.
*/
- void setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText );
+ void setupTree(const CSwordModuleSearch::Results &results,
+ const QString &searchedText);
+
/**
* Returns the currently active module.
*/
@@ -56,7 +58,10 @@ class CModuleResultView : public QTreeWidget {
void initConnections();
- void setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent, const QString& searchedText);
+ void setupStrongsResults(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ QTreeWidgetItem *parent,
+ const QString &searchedText);
protected slots:
/**
@@ -89,9 +94,9 @@ class CModuleResultView : public QTreeWidget {
void saveResult();
signals:
- void moduleSelected(CSwordModuleInfo*);
+ void moduleSelected(const CSwordModuleInfo*, const sword::ListKey&);
void moduleChanged();
- void strongsSelected(CSwordModuleInfo*, QStringList*);
+ void strongsSelected(CSwordModuleInfo*, const QStringList&);
private:
struct {
@@ -119,7 +124,8 @@ class CModuleResultView : public QTreeWidget {
QMenu* m_popup;
- QHash<CSwordModuleInfo*, StrongsResultClass*> strongsResults;
+ CSwordModuleSearch::Results m_results;
+ QHash<const CSwordModuleInfo*, StrongsResultList*> m_strongsResults;
QSize m_size;
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 335fc5e..4fc2a3d 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index b665a8f..8a3a91e 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 6f8214c..5461732 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +11,7 @@
#include <QDebug>
#include <QDialogButtonBox>
+#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSettings>
@@ -24,7 +25,7 @@
#include "backend/cswordmodulesearch.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "frontend/cmoduleindexdialog.h"
+#include "frontend/btmoduleindexdialog.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "frontend/searchdialog/btsearchresultarea.h"
#include "util/cresmgr.h"
@@ -36,7 +37,9 @@ namespace Search {
static CSearchDialog* m_staticDialog = 0;
-void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText, QWidget* parentDialog) {
+void CSearchDialog::openDialog(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText, QWidget *parentDialog)
+{
if (!m_staticDialog) {
m_staticDialog = new CSearchDialog(parentDialog);
};
@@ -81,7 +84,7 @@ CSearchDialog::CSearchDialog(QWidget *parent)
setWindowIcon(DU::getIcon(CResMgr::searchdialog::icon));
setWindowTitle(tr("Search"));
setAttribute(Qt::WA_DeleteOnClose);
- m_searcher.connectFinished( this, SLOT(searchFinished()));
+
initView();
initConnections();
}
@@ -91,10 +94,9 @@ CSearchDialog::~CSearchDialog() {
m_staticDialog = 0;
}
-/** Starts the search with the set modules and the set search text. */
void CSearchDialog::startSearch() {
+ typedef QList<const CSwordModuleInfo*> ML;
QString originalSearchText(m_searchOptionsArea->searchText());
- QString searchText("");
// first check the search string for errors
{
@@ -104,50 +106,72 @@ void CSearchDialog::startSearch() {
return;
}
}
-
- searchText = prepareSearchText(originalSearchText);
+ QString searchText = prepareSearchText(originalSearchText);
// Insert search text into history list of combobox
m_searchOptionsArea->addToHistory(originalSearchText);
- // check that we have the indices we need for searching
- if (!m_searcher.modulesHaveIndices( modules() ) ) {
- int result = util::showQuestion(this, tr("Missing indices"),
- tr("One or more works need indexing before they can be searched.\n"
- "This could take a long time. Proceed with indexing?"),
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
- // In SuSE 10.0 the result is the logical or of the button type, just like it is
- // inputed into the QMessageBox.
- if ( (result == (QMessageBox::Yes | QMessageBox::Default)) ||
- (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) {
- CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance();
- dlg->indexUnindexedModules( modules() );
+ // Check that we have the indices we need for searching
+ ML unindexedModules = CSwordModuleSearch::unindexedModules(modules());
+ if (unindexedModules.size() > 0) {
+ // Build the list of module names:
+ QStringList moduleNameList;
+ Q_FOREACH (const CSwordModuleInfo *m, unindexedModules) {
+ moduleNameList.append(m->name());
}
- else {
+ QString moduleNames("<br><center>");
+ moduleNames.append(moduleNameList.join(", "));
+ moduleNames.append("</center><br>");
+
+ // Ask the user about unindexed modules:
+ int result = util::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"
+ "ong time. Click \"Yes\" to index the modules and start the "
+ "search, or \"No\" to cancel the search."),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+ // User didn't press "Yes":
+ if ((result & (QMessageBox::Yes | QMessageBox::Default)) == 0x0) {
+ return;
+ }
+
+ // Show indexing dialog, and index the modules:
+ if (!BtModuleIndexDialog::indexAllModules(unindexedModules)) {
+ // Failed or user cancelled.
return;
}
}
+ // Set the search options:
+ m_searcher.setSearchedText(searchText);
+ m_searcher.setModules(modules());
if (m_searchOptionsArea->hasSearchScope()) {
- m_searcher.setSearchScope( m_searchOptionsArea->searchScope() );
- }
- else {
+ m_searcher.setSearchScope(m_searchOptionsArea->searchScope());
+ } else {
m_searcher.resetSearchScope();
}
- m_searcher.setModules( modules() );
- m_searcher.setSearchedText(searchText);
-
-
- //Just to be sure that it can't be clicked again, if the search happens to be a bit slow.
- m_searchOptionsArea->searchButton()->setEnabled(false);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(false);
+ // Disable the dialog:
+ setEnabled(false);
+ setCursor(Qt::WaitCursor);
+ // Execute search:
m_searcher.startSearch();
- m_searchOptionsArea->searchButton()->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setFocus();
+ // Display the search results:
+ if (m_searcher.foundItems() > 0) {
+ m_searchResultArea->setSearchResult(m_searcher.results());
+ } else {
+ m_searchResultArea->reset();
+ }
+ m_staticDialog->raise();
+ m_staticDialog->activateWindow();
+
+ // Re-enable the dialog:
+ setEnabled(true);
+ setCursor(Qt::ArrowCursor);
}
QString CSearchDialog::prepareSearchText(const QString& orig) {
@@ -179,8 +203,9 @@ QString CSearchDialog::prepareSearchText(const QString& orig) {
return text;
}
-/** Starts the search with the given module list and given search text. */
-void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText) {
+void CSearchDialog::startSearch(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText)
+{
m_searchResultArea->reset();
m_searchOptionsArea->reset();
setModules(modules);
@@ -189,27 +214,8 @@ void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const Q
startSearch();
}
-/** Returns the list of used modules. */
-QList<CSwordModuleInfo*> CSearchDialog::modules() const {
- return m_searchOptionsArea->modules();
-}
-
-/** Sets the list of modules for the search. */
-void CSearchDialog::setModules( const QList<CSwordModuleInfo*> modules ) {
- m_searchOptionsArea->setModules(modules);
-}
-
-/** Returns the search text which is set currently. */
-QString CSearchDialog::searchText() const {
- return m_searchOptionsArea->searchText();
-}
-
-sword::ListKey CSearchDialog::searchScope() {
- return m_searchOptionsArea->searchScope();
-}
-
/** Sets the search text which is used for the search. */
-void CSearchDialog::setSearchText( const QString searchText ) {
+void CSearchDialog::setSearchText( const QString &searchText ) {
m_searchOptionsArea->setSearchText(searchText);
}
@@ -224,12 +230,16 @@ void CSearchDialog::initView() {
verticalLayout->addWidget(m_searchOptionsArea);
m_searchResultArea = new BtSearchResultArea(this);
+ m_searchResultArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
verticalLayout->addWidget(m_searchResultArea);
+ QLabel* hint = new QLabel(tr("Drag any verse reference onto an open Bible window"), this);
+ verticalLayout->addWidget(hint);
+
QHBoxLayout* horizontalLayout = new QHBoxLayout();
m_analyseButton = new QPushButton(tr("&Analyze results..."), 0);
- m_analyseButton->setToolTip(tr("Show a graphical analyzis of the search result"));
+ m_analyseButton->setToolTip(tr("Show a graphical analysis of the search result"));
QSpacerItem* spacerItem = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addWidget(m_analyseButton);
horizontalLayout->addItem(spacerItem);
@@ -244,17 +254,6 @@ void CSearchDialog::initView() {
loadDialogSettings();
}
-void CSearchDialog::searchFinished() {
- if ( m_searcher.foundItems() ) {
- m_searchResultArea->setSearchResult(modules());
- }
- else {
- m_searchResultArea->reset();
- }
- m_staticDialog->raise();
- m_staticDialog->activateWindow();
-}
-
void CSearchDialog::showModulesSelector() {
m_searchOptionsArea->chooseModules();
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index 55bded4..b8c097f 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,12 +15,10 @@
#include <QString>
#include "backend/cswordmodulesearch.h"
#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-
+#include "frontend/searchdialog/btsearchoptionsarea.h"
namespace Search {
class BtSearchResultArea;
-class BtSearchOptionsArea;
}
class QPushButton;
class QWidget;
@@ -28,12 +26,15 @@ class QWidget;
namespace Search {
/**
- *@author The BibleTime team
- */
+ \note destroys itself on close
+*/
class CSearchDialog : public QDialog {
Q_OBJECT
public:
- static void openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText = QString::null, QWidget* parentDialog = 0);
+ static void openDialog(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText = QString::null,
+ QWidget *parentDialog = 0);
+
static void closeDialog();
protected:
@@ -47,10 +48,6 @@ class CSearchDialog : public QDialog {
*/
static CSearchDialog* getSearchDialog();
- /**
- * The constructor of the dialog. It's protected because you should use the static public function openDialog.
- * The dialog destroys itself if it was closed.
- */
CSearchDialog(QWidget *parent);
~CSearchDialog();
@@ -58,33 +55,48 @@ class CSearchDialog : public QDialog {
* Initializes this object.
*/
void initView();
+
/**
- * Starts the search with the given module list and given search text.
- * Doesn't wait for the start button press, starts immediately
+ Starts the search with the given module list and given search text.
*/
- void startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText);
+ void startSearch(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText);
+
/**Prepares the search string given by user for a specific search type */
QString prepareSearchText(const QString& orig);
+
/**
- * Sets the list of modules for the search.
+ Sets the list of modules for the search.
*/
- void setModules( const QList<CSwordModuleInfo*> modules );
+ void setModules(const QList<const CSwordModuleInfo*> modules) {
+ m_searchOptionsArea->setModules(modules);
+ }
+
/**
- * Returns the list of used modules.
+ Returns the list of used modules.
*/
- QList<CSwordModuleInfo*> modules() const;
+ inline QList<const CSwordModuleInfo*> modules() const {
+ return m_searchOptionsArea->modules();
+ }
+
/**
* Sets the search text which is used for the search.
*/
- void setSearchText( const QString searchText );
+ void setSearchText( const QString &searchText );
+
/**
- * Returns the search text which is set currently.
+ \returns the search text which is set currently.
*/
- QString searchText() const;
+ QString searchText() const {
+ return m_searchOptionsArea->searchText();
+ }
+
/**
- * Returns the used search scope as a list key
+ \returns the used search scope as a list key
*/
- sword::ListKey searchScope();
+ inline sword::ListKey searchScope() const {
+ return m_searchOptionsArea->searchScope();
+ }
/**
* Resets the parts to the default.
@@ -101,10 +113,10 @@ class CSearchDialog : public QDialog {
protected slots:
/**
- * Starts the search with the set modules and the set search text.
+ Starts the search with the set modules and the set search text.
*/
void startSearch();
- void searchFinished();
+
void showModulesSelector();
/**
* Initializes the signal slot connections
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp b/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
deleted file mode 100644
index d09ae2a..0000000
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2007 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/searchdialog/csearchmodulechooserdialog.h"
-
-#include <QButtonGroup>
-#include <QDebug>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QSpacerItem>
-#include <QStringList>
-#include <QTreeWidget>
-#include <QVBoxLayout>
-#include "backend/btmoduletreeitem.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/directory.h"
-
-
-namespace Search {
-
-CSearchModuleChooserDialog::CSearchModuleChooserDialog( QWidget* parent, QString title, QString label,
- QList<CSwordModuleInfo*> selectedModules)
- : CModuleChooserDialog(parent, title, label),
- m_selectedModules(selectedModules) {
- m_hiddenFilter = new BTModuleTreeItem::HiddenOff();
- QList<BTModuleTreeItem::Filter*> filters;
- filters.append(m_hiddenFilter);
- setFilters(filters);
- init();
-}
-
-CSearchModuleChooserDialog::~CSearchModuleChooserDialog() {
- //see the ctor
- delete m_hiddenFilter;
-}
-
-void CSearchModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) {
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- if (m_selectedModules.contains(btItem->moduleInfo()))
- widgetItem->setCheckState(0, Qt::Checked);
- else
- widgetItem->setCheckState(0, Qt::Unchecked);
-}
-
-} //end of namespace Search
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.h b/src/frontend/searchdialog/csearchmodulechooserdialog.h
deleted file mode 100644
index bfa6126..0000000
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CSEARCHMODULECHOOSERDIALOG_H
-#define CSEARCHMODULECHOOSERDIALOG_H
-
-#include "frontend/cmodulechooserdialog.h"
-
-
-class BTModuleTreeItem;
-class CSwordModuleInfo;
-class QTreeWidgetItem;
-
-namespace Search {
-
-class CSearchModuleChooserDialog : public CModuleChooserDialog {
- Q_OBJECT
- public:
- CSearchModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*> selectedModules);
- ~CSearchModuleChooserDialog();
-
- protected: // Protected methods
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
-
- private:
- QList<CSwordModuleInfo*> m_selectedModules;
- BTModuleTreeItem::HiddenOff* m_hiddenFilter;
-};
-
-} //end of namespace Search
-
-#endif
diff --git a/src/frontend/searchdialog/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index fc137e2..6f15b62 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -93,13 +93,16 @@ void CSearchResultView::initConnections() {
}
/** Setups the list with the given module. */
-void CSearchResultView::setupTree(CSwordModuleInfo* m) {
+void CSearchResultView::setupTree(const CSwordModuleInfo *m,
+ const sword::ListKey &results)
+{
clear();
if (!m) return;
m_module = m;
- sword::ListKey& result = m->searchResult();
+ /// \warning This is a workaround for Sword constness
+ sword::ListKey &result = const_cast<sword::ListKey&>(results);
const int count = result.Count();
if (!count) return;
@@ -118,24 +121,20 @@ void CSearchResultView::setupTree(CSwordModuleInfo* m) {
this->setCurrentItem(this->topLevelItem(0), 0);
}
-void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, QStringList* vList) {
+void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, const QStringList &vList) {
clear();
- if (!m) {
- return;
- }
+ if (!m) return;
m_module = m;
- if (vList->count() <= 0) {
- return;
- }
+ if (vList.empty()) return;
setUpdatesEnabled(false);
QTreeWidgetItem* oldItem = 0;
QTreeWidgetItem* item = 0;
- foreach (QString s, *vList) {
+ foreach (QString s, vList) {
item = new QTreeWidgetItem(this, oldItem);
item->setText(0, (s));
oldItem = item;
@@ -180,13 +179,13 @@ void CSearchResultView::printItems() {
void CSearchResultView::saveItems() {
CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
}
mgr.saveKeyList( keys, CExportManager::Text, false);
@@ -198,13 +197,13 @@ void CSearchResultView::saveItems() {
void CSearchResultView::saveItemsWithText() {
CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.saveKeyList( keys, CExportManager::Text, true);
@@ -216,13 +215,13 @@ void CSearchResultView::saveItemsWithText() {
void CSearchResultView::copyItems() {
CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.copyKeyList( keys, CExportManager::Text, false);
@@ -234,13 +233,13 @@ void CSearchResultView::copyItems() {
void CSearchResultView::copyItemsWithText() {
CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.copyKeyList( keys, CExportManager::Text, true);
@@ -249,25 +248,21 @@ void CSearchResultView::copyItemsWithText() {
keys.clear(); //delete all the keys we created
}
-CSwordModuleInfo* CSearchResultView::module() {
- return m_module;
-}
-
/// \todo port this to the new d'n'd
// Q3DragObject* CSearchResultView::dragObject() {
-// //return a valid DragObject to make DnD possible!
+// //return a valid DragObject to make DnD possible!
//
-// /*
-// * First get all selected items and fill with them the dndItems list. The return the QDragObject we got from CDRagDropMgr
-// */
-// CDragDropMgr::ItemList dndItems;
+// /*
+// * First get all selected items and fill with them the dndItems list. The return the QDragObject we got from CDRagDropMgr
+// */
+// CDragDropMgr::ItemList dndItems;
//
-// Q3PtrList<Q3ListViewItem> items = selectedItems();
-// for (items.first(); items.current(); items.next()) {
-// dndItems.append( CDragDropMgr::Item(m_module->name(), items.current()->text(0), QString::null) ); //no description
-// };
+// Q3PtrList<Q3ListViewItem> items = selectedItems();
+// for (items.first(); items.current(); items.next()) {
+// dndItems.append( CDragDropMgr::Item(m_module->name(), items.current()->text(0), QString::null) ); //no description
+// };
//
-// return CDragDropMgr::dragObject(dndItems, viewport());
+// return CDragDropMgr::dragObject(dndItems, viewport());
// }
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 52e6929..b3a09ee 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,11 +10,13 @@
#ifndef CSEARCHRESULTSVIEW_H
#define CSEARCHRESULTSVIEW_H
-class CSwordModuleInfo;
-
#include <QTreeWidget>
+// Sword includes
+#include <listkey.h>
+
+class CSwordModuleInfo;
class CReadDisplay;
class QAction;
class QMenu;
@@ -26,8 +28,13 @@ class CSearchResultView : public QTreeWidget {
public:
CSearchResultView(QWidget* parent);
virtual ~CSearchResultView();
- /** Returns the module which is currently used. */
- CSwordModuleInfo* module();
+
+ /**
+ \returns the module which is currently used.
+ */
+ inline const CSwordModuleInfo *module() const {
+ return m_module;
+ }
protected: // Protected methods
/**
@@ -42,11 +49,13 @@ class CSearchResultView : public QTreeWidget {
public slots: // Public slots
void saveItems();
+
/**
- * Setups the list with the given module.
+ Setups the list with the given module.
*/
- void setupTree(CSwordModuleInfo*);
- void setupStrongsTree(CSwordModuleInfo*, QStringList*);
+ void setupTree(const CSwordModuleInfo *m, const sword::ListKey &results);
+
+ void setupStrongsTree(CSwordModuleInfo*, const QStringList&);
void copyItemsWithText();
void copyItems();
void saveItemsWithText();
@@ -88,7 +97,7 @@ class CSearchResultView : public QTreeWidget {
m_actions;
QMenu* m_popup;
- CSwordModuleInfo* m_module;
+ const CSwordModuleInfo *m_module;
signals: // Signals
void keySelected(const QString&);
diff --git a/src/frontend/settingsdialogs/btfontsettings.cpp b/src/frontend/settingsdialogs/btfontsettings.cpp
new file mode 100644
index 0000000..7160e54
--- /dev/null
+++ b/src/frontend/settingsdialogs/btfontsettings.cpp
@@ -0,0 +1,164 @@
+/*********
+*
+* 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/settingsdialogs/btfontsettings.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QWidget>
+#include "frontend/settingsdialogs/cfontchooser.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
+#include "util/directory.h"
+
+// Sword includes:
+#include <localemgr.h>
+#include <swlocale.h>
+
+
+BtFontSettingsPage::BtFontSettingsPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ namespace DU = util::directory;
+
+ m_languageLabel = new QLabel(tr("&Language:"), this);
+
+ m_languageComboBox = new QComboBox(this);
+ m_languageComboBox->setToolTip(tr("The font selection below will apply to all texts in this language"));
+ m_languageLabel->setBuddy(m_languageComboBox);
+
+ m_languageCheckBox = new QCheckBox(tr("Use custom font"), this);
+ connect(m_languageCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(useOwnFontClicked(bool)) );
+
+
+ QHBoxLayout *hLayout = new QHBoxLayout;
+ hLayout->setContentsMargins(0, 0, 0, 0);
+ hLayout->addWidget(m_languageLabel, 0, Qt::AlignRight);
+ hLayout->addWidget(m_languageComboBox, 1);
+ hLayout->addWidget(m_languageCheckBox);
+
+ CLanguageMgr::LangMap langMap = CLanguageMgr::instance()->availableLanguages();
+
+ for (CLanguageMgr::LangMapIterator it = langMap.constBegin() ; it != langMap.constEnd(); ++it ) {
+ const QString name =
+ (*it)->translatedName().isEmpty()
+ ? (*it)->abbrev()
+ : (*it)->translatedName();
+
+ m_fontMap.insert(name, CBTConfig::get(*it) );
+ }
+
+ for ( QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
+ if ( m_fontMap[it.key()].first ) { //show font icon
+ m_languageComboBox->addItem(DU::getIcon("fonts.svg"), it.key() );
+ }
+ else { //don't show icon for font
+ m_languageComboBox->addItem(it.key());
+ }
+ }
+
+ /// \todo remember the last selected font and jump there.
+
+ m_fontChooser = new CFontChooser(this);
+
+ /// \todo Eeli's wishlist: why not show something relevant here, like a Bible verse in chosen (not tr()'ed!) language?
+ QString sampleText;
+ sampleText.append("1 In the beginning God created the heaven and the earth. ");
+ sampleText.append("2 And the earth was without form, and void; and darkness was on the face of the deep.");
+ sampleText.append(" And the Spirit of God moved on the face of the waters.");
+
+ m_fontChooser->setSampleText(sampleText);
+
+ connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)), SLOT(newDisplayWindowFontSelected(const QFont&)));
+ connect(m_languageComboBox, SIGNAL(activated(const QString&)), SLOT(newDisplayWindowFontAreaSelected(const QString&)));
+
+ m_fontChooser->setFont( m_fontMap[m_languageComboBox->currentText()].second );
+ useOwnFontClicked( m_fontMap[m_languageComboBox->currentText()].first );
+ m_languageCheckBox->setChecked( m_fontMap[m_languageComboBox->currentText()].first );
+ m_fontChooser->setMinimumSize(m_fontChooser->sizeHint());
+
+ QVBoxLayout *fLayout = new QVBoxLayout;
+ fLayout->setContentsMargins(0, 0, 0, 0);
+ fLayout->addLayout(hLayout);
+ fLayout->addWidget(m_fontChooser);
+
+ m_fontsGroupBox = new QGroupBox(tr("Optionally specify a custom font for each language:"), this);
+ m_fontsGroupBox->setFlat(true);
+ m_fontsGroupBox->setLayout(fLayout);
+
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ static_cast<QVBoxLayout*>(layout())->addWidget(m_fontsGroupBox);
+}
+
+
+BtFontSettingsPage::~BtFontSettingsPage() {
+}
+
+void BtFontSettingsPage::save() {
+ for (QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
+ const CLanguageMgr::Language * const lang = CLanguageMgr::instance()->languageForTranslatedName(it.key());
+ if (!lang->isValid()) { //we possibly use a language, for which we have only the abbrev
+ if (!lang->abbrev().isEmpty()) {
+ CLanguageMgr::Language l(it.key(), it.key(), it.key()); //create a temp language
+ CBTConfig::set(&l, it.value());
+ }
+ }
+ else {
+ CBTConfig::set(lang, it.value());
+ }
+ }
+}
+
+/** */
+void BtFontSettingsPage::newDisplayWindowFontSelected(const QFont &newFont) {
+ //belongs to the languages/fonts page
+ CBTConfig::FontSettingsPair oldSettings = m_fontMap[ m_languageComboBox->currentText() ];
+ m_fontMap.insert( m_languageComboBox->currentText(), CBTConfig::FontSettingsPair(oldSettings.first, newFont) );
+}
+
+/** Called when the combobox contents is changed */
+void BtFontSettingsPage::newDisplayWindowFontAreaSelected(const QString& usage) {
+ //belongs to fonts/languages
+ useOwnFontClicked( m_fontMap[usage].first );
+ m_languageCheckBox->setChecked( m_fontMap[usage].first );
+
+ m_fontChooser->setFont( m_fontMap[usage].second );
+}
+
+
+/** This slot is called when the "Use own font for language" bo was clicked. */
+void BtFontSettingsPage::useOwnFontClicked(bool isOn) {
+ namespace DU = util::directory;
+
+ //belongs to fonts/languages
+
+ m_fontChooser->setEnabled(isOn);
+ m_fontMap[ m_languageComboBox->currentText() ].first = isOn;
+
+ if (isOn) { //show font icon
+ m_languageComboBox->setItemIcon(m_languageComboBox->currentIndex(), DU::getIcon("fonts.svg"));
+ }
+ else { //don't show
+ m_languageComboBox->setItemText(m_languageComboBox->currentIndex(), m_languageComboBox->currentText() ); /// \todo should this change icon to empty?
+ }
+}
+
+
+const QIcon &BtFontSettingsPage::icon() const {
+ return util::directory::getIcon(CResMgr::settings::fonts::icon);
+}
+
+QString BtFontSettingsPage::header() const {
+ return tr("Fonts");
+}
diff --git a/src/frontend/settingsdialogs/clanguagesettings.h b/src/frontend/settingsdialogs/btfontsettings.h
index 4d55cda..9df4bc5 100644
--- a/src/frontend/settingsdialogs/clanguagesettings.h
+++ b/src/frontend/settingsdialogs/btfontsettings.h
@@ -2,16 +2,15 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#ifndef CLANGUAGESETTINGS_H
-#define CLANGUAGESETTINGS_H
+#ifndef BTFONTSETTINGS_H
+#define BTFONTSETTINGS_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "util/cpointers.h"
#include <QMap>
#include <QWidget>
@@ -21,19 +20,23 @@
class CFontChooser;
class QCheckBox;
class QComboBox;
+class QGroupBox;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CLanguageSettingsPage : public BtConfigPage, CPointers {
+class BtFontSettingsPage : public BtConfigPage {
Q_OBJECT
public:
- CLanguageSettingsPage(QWidget *parent);
- ~CLanguageSettingsPage();
+ BtFontSettingsPage(QWidget *parent = 0);
+ ~BtFontSettingsPage();
void save();
- QString iconName();
- QString label();
- QString header();
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
protected slots:
@@ -47,9 +50,10 @@ class CLanguageSettingsPage : public BtConfigPage, CPointers {
void newDisplayWindowFontAreaSelected(const QString&);
private:
- QComboBox* m_swordLocaleCombo;
- QComboBox* m_usageCombo;
- QCheckBox* m_useOwnFontCheck;
+ QGroupBox *m_fontsGroupBox;
+ QLabel *m_languageLabel;
+ QComboBox *m_languageComboBox;
+ QCheckBox *m_languageCheckBox;
CFontChooser* m_fontChooser;
QMap<QString, CBTConfig::FontSettingsPair> m_fontMap;
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.cpp b/src/frontend/settingsdialogs/btlanguagesettings.cpp
new file mode 100644
index 0000000..dc31d0b
--- /dev/null
+++ b/src/frontend/settingsdialogs/btlanguagesettings.cpp
@@ -0,0 +1,145 @@
+/*********
+*
+* 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/settingsdialogs/btlanguagesettings.h"
+
+#include <QComboBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include "util/cresmgr.h"
+#include "util/tool.h"
+#include "util/directory.h"
+
+// Sword includes:
+#include <localemgr.h>
+#include <swlocale.h>
+
+
+BtLanguageSettingsPage::BtLanguageSettingsPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ namespace DU = util::directory;
+
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
+
+ //Sword locales
+ m_swordLocaleCombo = new QComboBox(this);
+ QLabel* label = new QLabel( tr("Language for names of Bible books:"), this);
+ label->setBuddy(m_swordLocaleCombo);
+ m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
+
+
+ QHBoxLayout* hBoxLayout = new QHBoxLayout();
+ hBoxLayout->addWidget(label);
+ hBoxLayout->addWidget(m_swordLocaleCombo);
+ hBoxLayout->addStretch();
+ mainLayout->addLayout(hBoxLayout);
+
+ mainLayout->addSpacerItem(new QSpacerItem(1,1, QSizePolicy::Fixed, QSizePolicy::Expanding));
+
+ QStringList languageNames;
+ languageNames.append(CLanguageMgr::instance()->languageForAbbrev("en_US")->translatedName());
+
+ std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ for (std::list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++) {
+ // qWarning("working on %s", (*it).c_str());
+ const CLanguageMgr::Language * const l =
+ CLanguageMgr::instance()->languageForAbbrev( sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName() );
+
+ if (l->isValid()) {
+ languageNames.append( l->translatedName() );
+ }
+ else {
+ languageNames.append(
+ sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
+ );
+ }
+ } //for
+
+ languageNames.sort();
+ m_swordLocaleCombo->addItems( languageNames );
+
+ const CLanguageMgr::Language * const l =
+ CLanguageMgr::instance()->languageForAbbrev( CBTConfig::get(CBTConfig::language) );
+
+ QString currentLanguageName;
+ if ( l->isValid() && languageNames.contains(l->translatedName()) ) { //tranlated language name is in the box
+ currentLanguageName = l->translatedName();
+ }
+ else { //a language like "German Abbrevs" might be the language to set
+ sword::SWLocale* locale =
+ sword::LocaleMgr::getSystemLocaleMgr()->getLocale( CBTConfig::get(CBTConfig::language).toLocal8Bit() );
+ if (locale) {
+ currentLanguageName = QString::fromLatin1(locale->getDescription());
+ }
+ }
+
+ if (currentLanguageName.isEmpty()) { // set english as default if nothing was chosen
+ Q_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
+ currentLanguageName = CLanguageMgr::instance()->languageForAbbrev("en_US")->translatedName();
+ }
+
+ //now set the item with the right name as current item
+ for (int i = 0; i < m_swordLocaleCombo->count(); ++i) {
+ if (currentLanguageName == m_swordLocaleCombo->itemText(i)) {
+ m_swordLocaleCombo->setCurrentIndex(i);
+ break; //item found, finish the loop
+ }
+ }
+
+}
+
+
+BtLanguageSettingsPage::~BtLanguageSettingsPage() {
+}
+
+void BtLanguageSettingsPage::save() {
+
+ QString languageAbbrev;
+
+ const QString currentLanguageName = m_swordLocaleCombo->currentText();
+ const CLanguageMgr::Language * const l = CLanguageMgr::instance()->languageForTranslatedName( currentLanguageName );
+
+ if (l && l->isValid()) {
+ languageAbbrev = l->abbrev();
+ }
+ else { //it can be the lang abbrev like de_abbrev or the Sword description
+ std::list <sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+
+ for (std::list <sword::SWBuf>::iterator it = locales.begin(); it != locales.end(); it++) {
+ sword::SWLocale* locale = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str());
+ Q_ASSERT(locale);
+
+ if ( locale && (QString::fromLatin1(locale->getDescription()) == currentLanguageName) ) {
+ languageAbbrev = QString::fromLatin1(locale->getName()); //we found the abbrevation for the current language
+ break;
+ }
+ }
+
+ if (languageAbbrev.isEmpty()) {
+ languageAbbrev = currentLanguageName; //probably a non-standard locale name like de_abbrev
+ }
+ }
+
+ if (!languageAbbrev.isEmpty()) {
+ CBTConfig::set(CBTConfig::language, languageAbbrev);
+ }
+}
+
+const QIcon &BtLanguageSettingsPage::icon() const {
+ return util::directory::getIcon(CResMgr::settings::languages::icon);
+}
+
+QString BtLanguageSettingsPage::header() const {
+ return tr("Languages");
+}
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.h b/src/frontend/settingsdialogs/btlanguagesettings.h
new file mode 100644
index 0000000..911e466
--- /dev/null
+++ b/src/frontend/settingsdialogs/btlanguagesettings.h
@@ -0,0 +1,60 @@
+/*********
+*
+* 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 BTLANGUAGESETTINGS_H
+#define BTLANGUAGESETTINGS_H
+
+#include "frontend/bookshelfmanager/btconfigdialog.h"
+
+#include <QMap>
+#include <QWidget>
+#include "backend/config/cbtconfig.h"
+
+
+//class CFontChooser;
+//class QCheckBox;
+class QComboBox;
+
+/**
+ @author The BibleTime team <info@bibletime.info>
+*/
+class BtLanguageSettingsPage : public BtConfigPage {
+ Q_OBJECT
+ public:
+ BtLanguageSettingsPage(QWidget *parent = 0);
+ ~BtLanguageSettingsPage();
+ void save();
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
+
+ protected slots:
+
+ // This slot is called when the "Use own font for language" button was clicked.
+ //void useOwnFontClicked(bool);
+
+ // Called when a new font in the fonts page was selected.
+ //void newDisplayWindowFontSelected(const QFont &);
+
+ // Called when the combobox contents is changed
+ //void newDisplayWindowFontAreaSelected(const QString&);
+
+ private:
+ QComboBox* m_swordLocaleCombo;
+ //QComboBox* m_usageCombo;
+ //QCheckBox* m_useOwnFontCheck;
+ //CFontChooser* m_fontChooser;
+
+ //QMap<QString, CBTConfig::FontSettingsPair> m_fontMap;
+};
+
+#endif
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
index ec92855..a5d856d 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.cpp
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,7 +21,6 @@
// *************** BtShortcutsDialog ***************************************************************************
// A dialog to allow the user to input a shortcut for a primary and alternate key
-// dialog constructor
BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
: QDialog(parent), m_primaryLabel(0), m_alternateLabel(0), m_primaryButton(0), m_alternateButton(0) {
setWindowTitle(tr("Configure shortcuts"));
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
index 53f738c..f475ebd 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.h
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index f92a27e..d8fdfd8 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -157,10 +157,8 @@ void BtShortcutsEditor::commitChanges() {
void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title) {
Q_UNUSED(title); /// \todo Is this correct?
- QList<QAction*> actionList = collection->actions();
- int count;
- count = actionList.count();
foreach (QAction *action, collection->actions()) {
+ /// \todo Is the following check really necessary?
if (action) {
int count = m_table->rowCount();
m_table->insertRow(count);
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
index 93e2bfc..f9a812a 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.h
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -33,7 +33,7 @@ class BtShortcutsEditor : public QWidget {
void commitChanges();
// puts actions and shortcut keys into QTableWidget
- void addCollection(BtActionCollection* collection, const QString& title = QString());
+ void addCollection(BtActionCollection *collection, const QString &title = QString::null);
// clears any shortcut keys in the table matching the specified keys
void clearConflictWithKeys(const QString& keys);
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index 636b9cc..15394fb 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,12 +26,14 @@
#include "frontend/displaywindow/clexiconreadwindow.h"
#include "frontend/displaywindow/creadwindow.h"
#include "util/cresmgr.h"
+#include "util/directory.h"
-CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget* /* parent */ )
- : BtConfigPage() {
- QVBoxLayout* mainLayout = new QVBoxLayout(this);
- this->setLayout(mainLayout);
+CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
QHBoxLayout* layoutForWindowTypeChooser = new QHBoxLayout();
mainLayout->addLayout(layoutForWindowTypeChooser);
@@ -97,7 +99,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget* /* parent */ )
// ----- Commentary windows ------ //
m_commentary.actionCollection = new BtActionCollection(this);
CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
+ CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_commentary.keyChooser);
ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -108,7 +110,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(QWidget* /* parent */ )
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.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&)));
@@ -195,7 +197,7 @@ QString CAcceleratorSettingsPage::getTitleForEditor(BtShortcutsEditor* editor) {
return m_lexicon.title;
if (editor == m_book.keyChooser)
return m_book.title;
- return QString();
+ return QString::null;
}
// Gets list of shortcuts editors that can conflict with a key change in the current shortcut editor
@@ -230,12 +232,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
+ CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
+ CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
+ CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
+ CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
+ CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
+ CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
}
void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
@@ -246,15 +248,10 @@ void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
}
-QString CAcceleratorSettingsPage::iconName() {
- return CResMgr::settings::keys::icon;
+const QIcon &CAcceleratorSettingsPage::icon() const {
+ return util::directory::getIcon(CResMgr::settings::keys::icon);
}
-QString CAcceleratorSettingsPage::label() {
- //: Empty string, don't translate
- return tr("");
-}
-
-QString CAcceleratorSettingsPage::header() {
+QString CAcceleratorSettingsPage::header() const {
return tr("Shortcuts");
}
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
index 74401ab..999e3d0 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,6 @@
#define CACCELERATORSETTINGS_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "util/cpointers.h"
#include <QPointer>
#include <QWidget>
@@ -26,15 +25,18 @@ class QStackedWidget;
/**
@author The BibleTime team <info@bibletime.info>
*/
-class CAcceleratorSettingsPage : public BtConfigPage, CPointers {
+class CAcceleratorSettingsPage : public BtConfigPage {
Q_OBJECT
public:
- CAcceleratorSettingsPage(QWidget *parent);
+ CAcceleratorSettingsPage(QWidget *parent = 0);
~CAcceleratorSettingsPage();
void save();
- QString iconName();
- QString label();
- QString header();
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
protected slots:
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index f127883..e1d68ca 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,9 +16,9 @@
#include <QWidget>
#include "frontend/settingsdialogs/cacceleratorsettings.h"
#include "frontend/settingsdialogs/cdisplaysettings.h"
-#include "frontend/settingsdialogs/clanguagesettings.h"
+#include "frontend/settingsdialogs/btfontsettings.h"
+#include "frontend/settingsdialogs/btlanguagesettings.h"
#include "frontend/settingsdialogs/cswordsettings.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/directory.h"
#include "util/dialogutil.h"
@@ -30,6 +30,7 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_displayPage(0),
m_swordPage(0),
m_acceleratorsPage(0),
+ m_fontsPage(0),
m_languagesPage(0),
m_bbox(0) {
setWindowTitle(tr("Configure BibleTime"));
@@ -43,10 +44,14 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_swordPage = new CSwordSettingsPage(this);
addPage(m_swordPage);
- // Add "Languages" (fonts) page
- m_languagesPage = new CLanguageSettingsPage(this);
+ // Add "Languages" page
+ m_languagesPage = new BtLanguageSettingsPage(this);
addPage(m_languagesPage);
+ // Add "Fonts" page
+ m_fontsPage = new BtFontSettingsPage(this);
+ addPage(m_fontsPage);
+
// Add "Keyboard" (accelerators) page
m_acceleratorsPage = new CAcceleratorSettingsPage(this);
addPage(m_acceleratorsPage);
@@ -74,6 +79,7 @@ CConfigurationDialog::~CConfigurationDialog() {
void CConfigurationDialog::save() {
m_acceleratorsPage->save();
m_languagesPage->save();
+ m_fontsPage->save();
m_swordPage->save();
m_displayPage->save();
emit signalSettingsChanged( );
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index 6b423e4..e0fbf93 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +16,8 @@
class BtActionCollection;
class CAcceleratorSettingsPage;
class CDisplaySettingsPage;
-class CLanguageSettingsPage;
+class BtFontSettingsPage;
+class BtLanguageSettingsPage;
class CSwordSettingsPage;
class QAbstractButton;
class QDialogButtonBox;
@@ -37,7 +38,8 @@ class CConfigurationDialog : public BtConfigDialog {
CDisplaySettingsPage* m_displayPage;
CSwordSettingsPage* m_swordPage;
CAcceleratorSettingsPage* m_acceleratorsPage;
- CLanguageSettingsPage* m_languagesPage;
+ BtFontSettingsPage* m_fontsPage;
+ BtLanguageSettingsPage* m_languagesPage;
QDialogButtonBox* m_bbox;
// Load the settings from the resource file
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.cpp b/src/frontend/settingsdialogs/cdisplaysettings.cpp
index 9341632..dd390a6 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-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,8 +17,8 @@
#include "backend/config/cbtconfig.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/rendering/cdisplayrendering.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
+#include "util/directory.h"
#include "util/tool.h"
@@ -44,9 +44,11 @@ QSize CWebViewerWidget::sizeHint () const {
// ************************
/** Initializes the startup section of the OD. */
-CDisplaySettingsPage::CDisplaySettingsPage(QWidget* /*parent*/)
- : BtConfigPage() {
- QVBoxLayout* layout = new QVBoxLayout(this);
+CDisplaySettingsPage::CDisplaySettingsPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
{ //startup logo
m_showLogoCheck = new QCheckBox(this);
@@ -54,11 +56,11 @@ CDisplaySettingsPage::CDisplaySettingsPage(QWidget* /*parent*/)
m_showLogoCheck->setToolTip(tr("Show the BibleTime logo on startup"));
m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
- layout->addWidget(m_showLogoCheck);
+ mainLayout->addWidget(m_showLogoCheck);
}
- layout->addSpacing(20);
+ mainLayout->addSpacing(20);
- layout->addWidget(
+ mainLayout->addWidget(
util::tool::explanationLabel(
this,
tr("Display templates"),
@@ -77,7 +79,7 @@ CDisplaySettingsPage::CDisplaySettingsPage(QWidget* /*parent*/)
hboxlayout->addWidget(availableLabel);
hboxlayout->addWidget( m_styleChooserCombo );
hboxlayout->addStretch();
- layout->addLayout( hboxlayout );
+ mainLayout->addLayout( hboxlayout );
QWidget* webViewWidget = new CWebViewerWidget(this);
QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
@@ -87,10 +89,10 @@ CDisplaySettingsPage::CDisplaySettingsPage(QWidget* /*parent*/)
webViewLayout->addWidget(previewLabel);
webViewLayout->addWidget(m_stylePreviewViewer);
webViewWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- layout->addWidget(webViewWidget);
+ mainLayout->addWidget(webViewWidget);
m_styleChooserCombo->addItems(
- CPointers::displayTemplateManager()->availableTemplates()
+ CDisplayTemplateMgr::instance()->availableTemplates()
);
for (int i = 0; i < m_styleChooserCombo->count(); ++i) {
@@ -137,7 +139,7 @@ void CDisplaySettingsPage::updateStylePreview() {
tree.append( new CTextRendering::KeyTreeItem(
QString("\n<span class=\"entryname\"><a name=\"John319\" href=\"sword://Bible/WEB/John 3:19\">19</a></span>%1")
- .arg(tr("This is the judgment, that the light has come into the world, and men loved the darkness rather than the light; for their works were evil.")),
+ .arg(tr("This is the judgement, that the light has come into the world, and men loved the darkness rather than the light; for their works were evil.")),
settings));
tree.append( new CTextRendering::KeyTreeItem(
@@ -173,14 +175,11 @@ void CDisplaySettingsPage::save() {
// implement the BtConfigPage methods
-QString CDisplaySettingsPage::iconName() {
- return CResMgr::settings::startup::icon;
+const QIcon &CDisplaySettingsPage::icon() const {
+ return util::directory::getIcon(CResMgr::settings::startup::icon);
}
-QString CDisplaySettingsPage::label() {
- //: Empty string, don't translate
- return tr("");
-}
-QString CDisplaySettingsPage::header() {
+
+QString CDisplaySettingsPage::header() const {
return tr("Display");
}
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.h b/src/frontend/settingsdialogs/cdisplaysettings.h
index be9a359..fe46679 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.h
+++ b/src/frontend/settingsdialogs/cdisplaysettings.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,11 +22,14 @@ class QWebView;
class CDisplaySettingsPage : public BtConfigPage {
Q_OBJECT
public:
- CDisplaySettingsPage(QWidget* parent);
+ CDisplaySettingsPage(QWidget *parent = 0);
void save();
- QString iconName();
- QString label();
- QString header();
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
protected slots:
/** Update the style preview widget. */
diff --git a/src/frontend/settingsdialogs/cfontchooser.cpp b/src/frontend/settingsdialogs/cfontchooser.cpp
index 786847b..81a8868 100644
--- a/src/frontend/settingsdialogs/cfontchooser.cpp
+++ b/src/frontend/settingsdialogs/cfontchooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cfontchooser.h b/src/frontend/settingsdialogs/cfontchooser.h
index fc5b8dd..0ebed51 100644
--- a/src/frontend/settingsdialogs/cfontchooser.h
+++ b/src/frontend/settingsdialogs/cfontchooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/clanguagesettings.cpp b/src/frontend/settingsdialogs/clanguagesettings.cpp
deleted file mode 100644
index a54a023..0000000
--- a/src/frontend/settingsdialogs/clanguagesettings.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/settingsdialogs/clanguagesettings.h"
-
-#include <QCheckBox>
-#include <QComboBox>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QWidget>
-#include "frontend/settingsdialogs/cfontchooser.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/tool.h"
-#include "util/directory.h"
-
-// Sword includes:
-#include <localemgr.h>
-#include <swlocale.h>
-
-
-CLanguageSettingsPage::CLanguageSettingsPage(QWidget* /*parent*/)
- : BtConfigPage() {
- namespace DU = util::directory;
-
- QVBoxLayout* layout = new QVBoxLayout(this);
-
- //Sword locales
- layout->addWidget(
- util::tool::explanationLabel(
- this,
- tr(""),
- tr("Select the language in which the Biblical book names are displayed.")
- ));
-
- m_swordLocaleCombo = new QComboBox(this);
- QLabel* label = new QLabel( tr("Language for names of Bible books:"), this);
- label->setBuddy(m_swordLocaleCombo);
- m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
-
-
- QHBoxLayout* hBoxLayout = new QHBoxLayout();
- hBoxLayout->addWidget(label);
- hBoxLayout->addWidget(m_swordLocaleCombo);
- hBoxLayout->addStretch();
- layout->addLayout(hBoxLayout);
-
- QStringList languageNames;
- languageNames.append( languageMgr()->languageForAbbrev("en_US")->translatedName() );
-
- std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- for (std::list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++) {
- // qWarning("working on %s", (*it).c_str());
- const CLanguageMgr::Language* const l =
- CPointers::languageMgr()->languageForAbbrev( sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName() );
-
- if (l->isValid()) {
- languageNames.append( l->translatedName() );
- }
- else {
- languageNames.append(
- sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
- );
- }
- } //for
-
- languageNames.sort();
- m_swordLocaleCombo->addItems( languageNames );
-
- const CLanguageMgr::Language* const l =
- CPointers::languageMgr()->languageForAbbrev( CBTConfig::get(CBTConfig::language) );
-
- QString currentLanguageName;
- if ( l->isValid() && languageNames.contains(l->translatedName()) ) { //tranlated language name is in the box
- currentLanguageName = l->translatedName();
- }
- else { //a language like "German Abbrevs" might be the language to set
- sword::SWLocale* locale =
- sword::LocaleMgr::getSystemLocaleMgr()->getLocale( CBTConfig::get(CBTConfig::language).toLocal8Bit() );
- if (locale) {
- currentLanguageName = QString::fromLatin1(locale->getDescription());
- }
- }
-
- if (currentLanguageName.isEmpty()) { // set english as default if nothing was chosen
- Q_ASSERT(languageMgr()->languageForAbbrev("en_US"));
- currentLanguageName = languageMgr()->languageForAbbrev("en_US")->translatedName();
- }
-
- //now set the item with the right name as current item
- for (int i = 0; i < m_swordLocaleCombo->count(); ++i) {
- if (currentLanguageName == m_swordLocaleCombo->itemText(i)) {
- m_swordLocaleCombo->setCurrentIndex(i);
- break; //item found, finish the loop
- }
- }
-
- layout->addSpacing(20);
-
- //Font settings
-
- layout->addWidget(
- util::tool::explanationLabel(
- this,
- tr("Fonts"),
- tr("You can specify a custom font for each language.")
- )
- );
- QHBoxLayout* hLayout = new QHBoxLayout();
-
- m_usageCombo = new QComboBox(this);
- m_usageCombo->setToolTip(tr("The font selection below will apply to all texts in this language"));
-
- hLayout->addWidget(m_usageCombo);
-
- CLanguageMgr::LangMap langMap = languageMgr()->availableLanguages();
-
- for (CLanguageMgr::LangMapIterator it = langMap.constBegin() ; it != langMap.constEnd(); ++it ) {
- const QString name =
- (*it)->translatedName().isEmpty()
- ? (*it)->abbrev()
- : (*it)->translatedName();
-
- m_fontMap.insert(name, CBTConfig::get(*it) );
- }
-
- for ( QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
- if ( m_fontMap[it.key()].first ) { //show font icon
- m_usageCombo->addItem(DU::getIcon("fonts.svg"), it.key() );
- }
- else { //don't show icon for font
- m_usageCombo->addItem(it.key());
- }
- }
-
- m_useOwnFontCheck = new QCheckBox(tr("Use custom font"), this);
- m_useOwnFontCheck->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- connect(m_useOwnFontCheck, SIGNAL(toggled(bool)), SLOT(useOwnFontClicked(bool)) );
- hLayout->addWidget(m_useOwnFontCheck);
-
- layout->addLayout(hLayout);
- hLayout->setContentsMargins(0, 0, 0, 0);
- /// \todo remember the last selected font and jump there.
-
- m_fontChooser = new CFontChooser(this);
-
- /// \todo Eeli's wishlist: why not show something relevant here, like a Bible verse in chosen (not tr()'ed!) language?
- QString sampleText;
- sampleText.append("1 In the beginning God created the heaven and the earth. ");
- sampleText.append("2 And the earth was without form, and void; and darkness was on the face of the deep.");
- sampleText.append(" And the Spirit of God moved on the face of the waters.");
-
- m_fontChooser->setSampleText(sampleText);
- layout->addWidget(m_fontChooser);
-
- connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)), SLOT(newDisplayWindowFontSelected(const QFont&)));
- connect(m_usageCombo, SIGNAL(activated(const QString&)), SLOT(newDisplayWindowFontAreaSelected(const QString&)));
-
- m_fontChooser->setFont( m_fontMap[m_usageCombo->currentText()].second );
- useOwnFontClicked( m_fontMap[m_usageCombo->currentText()].first );
- m_useOwnFontCheck->setChecked( m_fontMap[m_usageCombo->currentText()].first );
- m_fontChooser->setMinimumSize(m_fontChooser->sizeHint());
-}
-
-
-CLanguageSettingsPage::~CLanguageSettingsPage() {
-}
-
-void CLanguageSettingsPage::save() {
- for (QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
- const CLanguageMgr::Language* const lang = languageMgr()->languageForTranslatedName(it.key());
- if (!lang->isValid()) { //we possibly use a language, for which we have only the abbrev
- if (!lang->abbrev().isEmpty()) {
- CLanguageMgr::Language l(it.key(), it.key(), it.key()); //create a temp language
- CBTConfig::set(&l, it.value());
- }
- }
- else {
- CBTConfig::set(lang, it.value());
- }
- }
-
-
- QString languageAbbrev;
-
- const QString currentLanguageName = m_swordLocaleCombo->currentText();
- const CLanguageMgr::Language* const l = CPointers::languageMgr()->languageForTranslatedName( currentLanguageName );
-
- if (l && l->isValid()) {
- languageAbbrev = l->abbrev();
- }
- else { //it can be the lang abbrev like de_abbrev or the Sword description
- std::list <sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
-
- for (std::list <sword::SWBuf>::iterator it = locales.begin(); it != locales.end(); it++) {
- sword::SWLocale* locale = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str());
- Q_ASSERT(locale);
-
- if ( locale && (QString::fromLatin1(locale->getDescription()) == currentLanguageName) ) {
- languageAbbrev = QString::fromLatin1(locale->getName()); //we found the abbrevation for the current language
- break;
- }
- }
-
- if (languageAbbrev.isEmpty()) {
- languageAbbrev = currentLanguageName; //probably a non-standard locale name like de_abbrev
- }
- }
-
- if (!languageAbbrev.isEmpty()) {
- CBTConfig::set(CBTConfig::language, languageAbbrev);
- }
-}
-
-/** */
-void CLanguageSettingsPage::newDisplayWindowFontSelected(const QFont &newFont) {
- //belongs to the languages/fonts page
- CBTConfig::FontSettingsPair oldSettings = m_fontMap[ m_usageCombo->currentText() ];
- m_fontMap.insert( m_usageCombo->currentText(), CBTConfig::FontSettingsPair(oldSettings.first, newFont) );
-}
-
-/** Called when the combobox contents is changed */
-void CLanguageSettingsPage::newDisplayWindowFontAreaSelected(const QString& usage) {
- //belongs to fonts/languages
- useOwnFontClicked( m_fontMap[usage].first );
- m_useOwnFontCheck->setChecked( m_fontMap[usage].first );
-
- m_fontChooser->setFont( m_fontMap[usage].second );
-}
-
-
-/** This slot is called when the "Use own font for language" bo was clicked. */
-void CLanguageSettingsPage::useOwnFontClicked(bool isOn) {
- namespace DU = util::directory;
-
- //belongs to fonts/languages
-
- m_fontChooser->setEnabled(isOn);
- m_fontMap[ m_usageCombo->currentText() ].first = isOn;
-
- if (isOn) { //show font icon
- m_usageCombo->setItemIcon(m_usageCombo->currentIndex(), DU::getIcon("fonts.svg"));
- }
- else { //don't show
- m_usageCombo->setItemText(m_usageCombo->currentIndex(), m_usageCombo->currentText() ); /// \todo should this change icon to empty?
- }
-}
-
-
-QString CLanguageSettingsPage::iconName() {
- return CResMgr::settings::fonts::icon;
-}
-QString CLanguageSettingsPage::label() {
- //: Empty string, don't translate
- return tr("");
-}
-QString CLanguageSettingsPage::header() {
- return tr("Languages");
-}
diff --git a/src/frontend/settingsdialogs/clistwidget.cpp b/src/frontend/settingsdialogs/clistwidget.cpp
index 44cc246..3a2a4c7 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/clistwidget.h b/src/frontend/settingsdialogs/clistwidget.h
index 0011f93..ecd5f98 100644
--- a/src/frontend/settingsdialogs/clistwidget.h
+++ b/src/frontend/settingsdialogs/clistwidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cswordsettings.cpp b/src/frontend/settingsdialogs/cswordsettings.cpp
index c6a5bcc..39e48e8 100644
--- a/src/frontend/settingsdialogs/cswordsettings.cpp
+++ b/src/frontend/settingsdialogs/cswordsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,16 +21,18 @@
#include <QWidget>
#include "backend/config/cbtconfig.h"
#include "util/cresmgr.h"
+#include "util/directory.h"
#include "util/tool.h"
-#include "util/cpointers.h"
-CSwordSettingsPage::CSwordSettingsPage(QWidget* /*parent*/)
- : BtConfigPage() {
- QVBoxLayout* vbox = new QVBoxLayout(this);
+CSwordSettingsPage::CSwordSettingsPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *vbox = static_cast<QVBoxLayout*>(layout());
+
QTabWidget* tabWidget = new QTabWidget();
vbox->addWidget(tabWidget);
- setLayout(vbox);
m_worksTab = new StandardWorksTab();
m_filtersTab = new TextFiltersTab();
@@ -50,10 +52,9 @@ StandardWorksTab::StandardWorksTab()
gridLayout->addWidget(
util::tool::explanationLabel(
- this,
- tr(""),
- tr("Standard works are used when no particular work is specified, \
- for example when a hyperlink into a Bible or lexicon was clicked .")),
+ this, "",
+ tr("Standard works are used when no particular work is specified, for example "
+ "when a hyperlink into a Bible or lexicon was clicked.")),
0, 0, 1, 2 /*fill the horizontal space*/
);
@@ -143,7 +144,7 @@ StandardWorksTab::StandardWorksTab()
//fill the comboboxes with the right modules
- const QList<CSwordModuleInfo*> &modules(backend()->moduleList());
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
QString modDescript;
for (MLCI it(modules.begin()); it != modules.end(); it++) {
modDescript = (*it)->config(CSwordModuleInfo::Description);
@@ -178,7 +179,7 @@ StandardWorksTab::StandardWorksTab()
inserted = true;
}
- if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
+ if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
m_standardLexiconCombo->addItem(modDescript);
}
break;
@@ -258,11 +259,10 @@ TextFiltersTab::TextFiltersTab() {
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(5);
QWidget* eLabel = util::tool::explanationLabel(
- this,
- tr(""),
- tr("Filters control the appearance of text. \
-Here you can specify default settings for all filters. \
-You can override these settings in each display window.")
+ this, "",
+ tr("Filters control the appearance of text. Here you can specify "
+ "default settings for all filters. You can override these "
+ "settings in each display window.")
);
eLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
eLabel->setMaximumHeight(50);
@@ -324,14 +324,11 @@ void CSwordSettingsPage::save() {
m_filtersTab->save();
}
-QString CSwordSettingsPage::iconName() {
- return CResMgr::settings::sword::icon;
-}
-QString CSwordSettingsPage::label() {
- //: Empty string, don't translate
- return tr("");
+const QIcon &CSwordSettingsPage::icon() const {
+ return util::directory::getIcon(CResMgr::settings::sword::icon);
}
-QString CSwordSettingsPage::header() {
+
+QString CSwordSettingsPage::header() const {
return tr("Desk");
}
@@ -369,9 +366,8 @@ void StandardWorksTab::save() {
qWarning("Unhandled module type.");
};
- CSwordModuleInfo* const module = backend()->findModuleByDescription(moduleDescription);
- CBTConfig::set
- (moduleType, module);
+ CSwordModuleInfo * const module = CSwordBackend::instance()->findModuleByDescription(moduleDescription);
+ CBTConfig::set(moduleType, module);
}
}
diff --git a/src/frontend/settingsdialogs/cswordsettings.h b/src/frontend/settingsdialogs/cswordsettings.h
index 9af4c70..b4684db 100644
--- a/src/frontend/settingsdialogs/cswordsettings.h
+++ b/src/frontend/settingsdialogs/cswordsettings.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,6 @@
#define CSWORDSETTINGS_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "util/cpointers.h"
#include <QWidget>
@@ -23,11 +22,15 @@ class TextFiltersTab;
class CSwordSettingsPage : public BtConfigPage {
Q_OBJECT
public:
- CSwordSettingsPage(QWidget* parent);
+ CSwordSettingsPage(QWidget *parent = 0);
+
void save();
- QString iconName();
- QString label();
- QString header();
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
private:
StandardWorksTab* m_worksTab;
@@ -36,7 +39,7 @@ class CSwordSettingsPage : public BtConfigPage {
//Tab pages. To be used only in Sword settings page.
-class StandardWorksTab : public QWidget, CPointers {
+class StandardWorksTab: public QWidget {
Q_OBJECT
public:
StandardWorksTab();
diff --git a/src/frontend/tips/bttipdialog.cpp b/src/frontend/tips/bttipdialog.cpp
new file mode 100644
index 0000000..ed0a409
--- /dev/null
+++ b/src/frontend/tips/bttipdialog.cpp
@@ -0,0 +1,193 @@
+/*********
+*
+* 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 "bttipdialog.h"
+
+#include "backend/config/cbtconfig.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+#include <QCheckBox>
+#include <QDesktopServices>
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWebView>
+
+
+namespace {
+
+inline QString vertical_align(const QString &text) {
+ return "<table height=\"100%\"><tr><td style=\"vertical-align:middle\" "
+ "height=\"100%\">" + text + "</td></tr></table>";
+}
+
+inline QString make_style(QWidget *widget) {
+ const QPalette &p = widget->palette();
+ return "<style type=\"text/css\">"
+ "body{"
+ "background-color:" + p.color(QPalette::Base).name() + ";"
+ "color:" + p.color(QPalette::Text).name() + "}"
+ "h3{font-weight:bold;text-align:center}"
+ "a{text-decoration:underline}"
+ "a:link{color:" + p.color(QPalette::Link).name() + "}"
+ "a:visited{color:" + p.color(QPalette::LinkVisited).name() + "}"
+ "</style>";
+}
+
+inline QString make_html(QWidget *widget, const QString &text) {
+ return "<html><head>" + make_style(widget) + "</head><body>"
+ + vertical_align(text) + "</body></html>";
+}
+
+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\" />";
+}
+
+} // 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));
+ resize(450, 240);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+
+ m_tipView = new QWebView;
+ m_tipView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_tipView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ mainLayout->addWidget(m_tipView);
+
+ QHBoxLayout* hLayout = new QHBoxLayout;
+
+ m_showTipsCheckBox = new QCheckBox;
+ m_showTipsCheckBox->setText(tr("Show tips at startup"));
+ bool showTips = CBTConfig::get(CBTConfig::showTipAtStartup);
+ m_showTipsCheckBox->setChecked(showTips);
+ hLayout->addWidget(m_showTipsCheckBox);
+
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close,
+ Qt::Horizontal,
+ this);
+ QPushButton *nextButton;
+ nextButton = m_buttonBox->addButton(tr("Next Tip"),
+ QDialogButtonBox::ActionRole);
+ hLayout->addWidget(m_buttonBox);
+
+ mainLayout->addLayout(hLayout);
+ setLayout(mainLayout);
+
+ bool ok;
+ ok = connect(m_showTipsCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(startupBoxChanged(bool)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_buttonBox, SIGNAL(rejected()),
+ this, SLOT(reject()));
+ Q_ASSERT(ok);
+
+ ok = connect(nextButton, SIGNAL(clicked()),
+ this, SLOT(nextTip()));
+ Q_ASSERT(ok);
+
+ ok = connect(m_tipView->page(), SIGNAL(linkClicked(const QUrl&)),
+ this, SLOT(linkClicked(const QUrl&)));
+ Q_ASSERT(ok);
+
+ m_tipNumber = CBTConfig::get(CBTConfig::tipNumber);
+ initTips();
+ displayTip();
+}
+
+void BtTipDialog::initTips() {
+ m_tips.clear();
+
+ m_tips << tr("To add multiple Bible works in parallel in your active Bible window"
+ " select this icon and choose another Bible work.")
+ + "<br><center>" + make_icon(CResMgr::modules::bible::icon_add) + "</center>";
+
+ m_tips << tr("To add multiple commentary works in parallel in your active commentary window"
+ " select this icon and choose another commentary work.")
+ + "<br><center>" + make_icon(CResMgr::modules::commentary::icon_add) + "</center>";
+
+ m_tips << tr("To learn more about the BibleTime project please go to our web site.")
+ + "<br><center><a href=\"http://www.bibletime.info\">www.bibletime.info</a></center>";
+
+ m_tips << tr("To synchronize a commentary window with the active Bible window, activate the"
+ " commentary window and select this icon.") + "<br><center>"
+ + make_icon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)
+ + "</center><br>" + tr("Select the icon again to stop the synchronization.");
+
+ m_tips << tr("To create a bookmark drag any verse reference from a Bible or commentary work"
+ " into the Bookmarks window. An arrow will indicate the position that the bookmark will"
+ " go when you release the cursor. Other works will have a reference in the upper left"
+ " corner that can be used to create a bookmark.");
+
+ m_tips << tr("To change a bookmark title or description, right click on the bookmark"
+ " and select the Edit Bookmark menu. After finishing the edit the description can be"
+ " seen by hovering over the bookmark.");
+
+ m_tips << tr("To load multiple installation sources for works, go to the Bookshelf Manager"
+ ", select the Add button, and then the Get List button.");
+
+ m_tips << tr("To find more information about a work, go the the Bookshelf window, right"
+ " click on the work, and select the About menu.");
+
+ m_tips << tr("The Bookshelf, Bookmark, and Mag windows can be moved to new locations by"
+ " dragging them from the title at the top of each window. They can be placed to the left,"
+ " right, above, or below the works windows. They can be placed on top of each other and"
+ " tabs will appear so each window can be selected. They can be resized by dragging the"
+ " border between the window and another window.");
+
+ m_tips << tr("You can search for Strong's numbers in a work. Start with a work that has Strong's"
+ " numbers and hover over a word. Right click the word and use the Strong's Search"
+ " menu. A search dialog will appear that allows you to see the use of the same"
+ " Strong's number in other locations of the work.");
+
+ m_tips << tr("You can save personal notes for specific verses references. You must install"
+ " the Personal commentary. Open the Bookshelf Manager, choose Crosswire as the"
+ " source and look under Commentary and English. Once installed, use the"
+ " Bookshelf window and right click the Personal commentary. Use either the"
+ " Edit Plain Text menu or the Edit HTML menu to open the work in write mode.");
+
+ m_tips << tr("You can view Strong's number information in the MAG window by hovering over"
+ " a word in a Bible work that has Strong's numbers. You should have the StrongsGreek"
+ " and StrongsHebrew lexicons from Crosswire installed.");
+}
+
+void BtTipDialog::displayTip() {
+ m_tipView->setHtml(make_html(this, m_tips[m_tipNumber]));
+}
+
+void BtTipDialog::startupBoxChanged(bool checked) {
+ CBTConfig::set(CBTConfig::showTipAtStartup, checked);
+}
+
+void BtTipDialog::nextTip() {
+ m_tipNumber++;
+ if (m_tipNumber >= m_tips.count()) {
+ m_tipNumber = 0;
+ }
+ CBTConfig::set(CBTConfig::tipNumber, m_tipNumber);
+ displayTip();
+}
+
+void BtTipDialog::linkClicked(const QUrl& url) {
+ QDesktopServices::openUrl(url);
+}
diff --git a/src/frontend/tips/bttipdialog.h b/src/frontend/tips/bttipdialog.h
new file mode 100644
index 0000000..cd00394
--- /dev/null
+++ b/src/frontend/tips/bttipdialog.h
@@ -0,0 +1,62 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTTIPDIALOG_H
+#define BTTIPDIALOG_H
+
+#include <QDialog>
+#include <QStringList>
+
+
+class QAbstractButton;
+class QCheckBox;
+class QDialogButtonBox;
+class QPushButton;
+class QUrl;
+class QWebView;
+
+/**
+ The Tip Of The Day dialog.
+*/
+class BtTipDialog: public QDialog {
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtTipDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+
+ private: /* Methods: */
+
+ /** Enter tips in this function */
+ void initTips();
+
+ /** Sends the current tip to the web view */
+ void displayTip();
+
+ private slots:
+
+ /** Called when the show tips at startup checkbox changes. */
+ void startupBoxChanged(bool checked);
+
+ /** Called when the next tip button is pressed. */
+ void nextTip();
+
+ /** Called when any link in a tip is clicked. */
+ void linkClicked(const QUrl& url);
+
+ private: /* Fields: */
+
+ QDialogButtonBox* m_buttonBox;
+ QWebView* m_tipView;
+ QCheckBox* m_showTipsCheckBox;
+ int m_tipNumber;
+ QStringList m_tips;
+};
+
+#endif