summaryrefslogtreecommitdiff
path: root/src/frontend/keychooser
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/keychooser')
-rw-r--r--src/frontend/keychooser/bthistory.cpp5
-rw-r--r--src/frontend/keychooser/bthistory.h6
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp163
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h142
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp20
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h6
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp56
-rw-r--r--src/frontend/keychooser/ckeychooser.h161
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp214
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h274
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp25
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h6
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp6
-rw-r--r--src/frontend/keychooser/cscrollbutton.h5
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp79
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h96
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp18
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp2
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp8
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp15
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h10
24 files changed, 682 insertions, 647 deletions
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 93651a5..22c9e69 100644
--- a/src/frontend/keychooser/bthistory.cpp
+++ b/src/frontend/keychooser/bthistory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,8 +44,7 @@ void BTHistory::move(QAction* historyItem) {
//find the action in the list
m_index = m_historyList.indexOf(historyItem);
//move to the selected item in the list, it will be the current item
- QString newKey = m_historyList.at(m_index)->text();
- emit historyMoved(newKey); // signal to "outsiders"; key has been changed
+ emit historyMoved(m_historyList.at(m_index)->text()); // signal to "outsiders"; key has been changed
sendChangedSignal();
m_inHistoryFunction = false;
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index a92a25e..6c65aca 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -60,7 +62,7 @@ class BTHistory: public QObject {
/**
* Signal will be sent when the current point in history has moved
*/
- void historyMoved(QString& newKey);
+ void historyMoved(QString newKey);
private:
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index 1c7fccb..9255980 100644
--- a/src/frontend/keychooser/cbookkeychooser.cpp
+++ b/src/frontend/keychooser/cbookkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,78 +13,76 @@
#include <QHBoxLayout>
#include <QList>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-QMap<QObject*, int> boxes;
+#define ID_PROPERTY_NAME "CBookKeyChooser_ID"
-CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key,
- QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent), m_layout(0)
+CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_layout(0)
{
-
setModules(modules, false);
- m_key = dynamic_cast<CSwordTreeKey*>(key);
- if (!m_modules.count()) {
+ m_key = dynamic_cast<CSwordTreeKey * >(key);
+ if (!m_modules.count())
m_key = 0;
- }
setModules(modules, true);
setKey(key);
adjustFont();
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ connect(this, SIGNAL(keyChanged(CSwordKey *)),
+ history(), SLOT(add(CSwordKey *)));
}
-void CBookKeyChooser::setKey(CSwordKey* newKey) {
+void CBookKeyChooser::setKey(CSwordKey * newKey) {
setKey(newKey, true);
}
/** Sets a new key to this keychooser */
-void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
- if (m_key != newKey) { //set the internal key to the new one
+void CBookKeyChooser::setKey(CSwordKey * newKey, const bool emitSignal) {
+ if (m_key != newKey) // Set the internal key to the new one
m_key = dynamic_cast<CSwordTreeKey*>(newKey);
- }
- QString oldKey = m_key->key(); //string backup of key
+ QString oldKey(m_key->key());
- if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ if (oldKey.isEmpty()) { // Don't set keys equal to "/", always use a key which may have content
m_key->firstChild();
oldKey = m_key->key();
}
- const int oldOffset = m_key->getOffset(); //backup key position
+ const int oldOffset = m_key->getOffset();
- QStringList siblings; //split up key
- if (m_key && !oldKey.isEmpty()) {
+ QStringList siblings; // Split up key
+ if (m_key && !oldKey.isEmpty())
siblings = oldKey.split('/', QString::SkipEmptyParts);
- }
int depth = 0;
- int index = 0;
m_key->root(); //start iteration at root node
- while ( m_key->firstChild() && (depth < siblings.count()) ) {
+ while (m_key->firstChild() && (depth < siblings.count())) {
QString key = m_key->key();
- index = (depth == 0) ? -1 : 0;
+ int index = (depth == 0) ? -1 : 0;
bool found = false;
do { //look for matching sibling
++index;
found = (m_key->getLocalNameUnicode() == siblings[depth]);
- }
- while (!found && m_key->nextSibling());
+ } while (!found && m_key->nextSibling());
- if (found)
+ if (found) {
key = m_key->key(); //found: change key to this level
- else
+ } else {
m_key->setKey(key); //not found: restore old key
+ }
setupCombo(key, depth, index);
@@ -98,41 +96,41 @@ void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
}
//clear the combos which were not filled
- for (; depth < m_modules.first()->depth(); ++depth) {
- CKeyChooserWidget* chooser = m_chooserWidgets.at(depth);
- if (chooser) chooser->reset(0, 0, false);
+ for (; depth < m_modules.first()->depth(); ++depth) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(depth);
+ if (chooser)
+ chooser->reset(0, 0, false);
}
if (oldKey.isEmpty()) {
m_key->root();
- }
- else {
+ } else {
//m_key->key(oldKey);
m_key->setOffset(oldOffset);
}
- if (emitSignal) emit keyChanged(m_key);
+ if (emitSignal)
+ emit keyChanged(m_key);
}
/** Returns the key of this kechooser. */
-CSwordKey* CBookKeyChooser::key() {
+CSwordKey * CBookKeyChooser::key() {
return m_key;
}
/** Sets another module to this keychooser */
-void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo *> & modules,
bool refresh)
{
typedef CSwordBookModuleInfo CSBMI;
m_modules.clear();
// for (modules.first(); modules.current(); modules.next()) {
- Q_FOREACH(const CSwordModuleInfo *m, modules) {
+ Q_FOREACH(const CSwordModuleInfo * m, modules) {
if (m->type() == CSwordModuleInfo::GenericBook ) {
- const CSBMI *book = dynamic_cast<const CSBMI*>(m);
- if (book != 0) {
+ const CSBMI * const book = dynamic_cast<const CSBMI *>(m);
+ if (book != 0)
m_modules.append(book);
- }
}
}
@@ -149,45 +147,43 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
for (int i = 0; i < m_modules.first()->depth(); ++i) {
// Create an empty keychooser, don't handle next/prev signals
- CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this);
- m_chooserWidgets.append( w );
+ CKeyChooserWidget * const w = new CKeyChooserWidget(0, this);
+ m_chooserWidgets.append(w);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
int totalWidth = 200; //only 1 level
if (m_modules.first()->depth() > 1) {
- if (m_modules.first()->depth() > 3)
+ if (m_modules.first()->depth() > 3) {
totalWidth = 400; //4+ levels
- else
+ } else {
totalWidth = 300; //2-3 levels
+ }
}
int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth());
- w->comboBox()->setMaximumWidth(maxWidth);
- w->comboBox()->setCurrentIndex(0);
+ w->comboBox().setMaximumWidth(maxWidth);
+ w->comboBox().setCurrentIndex(0);
- connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
+ connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int)));
m_layout->addWidget(w);
- boxes[w] = i;
-
+ w->setProperty(ID_PROPERTY_NAME, i+1);
w->show();
}
//set the tab order of the key chooser widgets
- CKeyChooserWidget* chooser = 0;
- CKeyChooserWidget* chooser_prev = 0;
+ CKeyChooserWidget * chooser = 0;
+ CKeyChooserWidget * chooser_prev = 0;
const int count = m_chooserWidgets.count();
- for (int i = 0; i < count; ++i) {
+ for (int i = 0; i < count; i++) {
chooser = m_chooserWidgets.at(i);
Q_ASSERT(chooser);
-
- if (chooser && chooser_prev) {
+ if (chooser_prev)
QWidget::setTabOrder(chooser_prev, chooser);
- }
chooser_prev = chooser;
}
@@ -201,21 +197,22 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** No descriptions */
void CBookKeyChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- QListIterator<CKeyChooserWidget*> it(m_chooserWidgets);
- while (it.hasNext()) {
- it.next()->comboBox()->setFont( CBTConfig::get( m_modules.first()->language() ).second );
- }
+ QListIterator<CKeyChooserWidget *> it(m_chooserWidgets);
+ while (it.hasNext())
+ it.next()->comboBox().setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
/** Refreshes the content. */
void CBookKeyChooser::refreshContent() {
- if (m_key) {
- updateKey( m_key ); //refresh with current key
- }
+ if (m_key)
+ updateKey(m_key); // Refresh with current key
}
-void CBookKeyChooser::setupCombo(const QString key, const int depth, const int currentItem) {
- CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
+void CBookKeyChooser::setupCombo(const QString & key,
+ const int depth,
+ const int currentItem)
+{
+ CKeyChooserWidget * const chooserWidget = m_chooserWidgets.at(depth);
CSwordTreeKey tmpKey(*m_key);
tmpKey.setKey(key);
@@ -223,32 +220,32 @@ void CBookKeyChooser::setupCombo(const QString key, const int depth, const int c
tmpKey.firstChild();
QStringList items;
- if (depth > 0) items << QString::null; //insert an empty item at the top
+ if (depth > 0)
+ items.append(QString::null); // Insert an empty item at the top
do {
- items << tmpKey.getLocalNameUnicode();
- }
- while (tmpKey.nextSibling());
+ items.append(tmpKey.getLocalNameUnicode());
+ } while (tmpKey.nextSibling());
- if (chooserWidget) chooserWidget->reset(items, currentItem, false);
+ if (chooserWidget)
+ chooserWidget->reset(items, currentItem, false);
}
/** A keychooser changed. Update and emit a signal if necessary. */
-void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
- const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code!
-
+void CBookKeyChooser::keyChooserChanged(int newIndex) {
+ Q_UNUSED(newIndex);
QStringList items;
- CKeyChooserWidget* chooser;
- for (int i = 0; i < m_chooserWidgets.count(); ++i) {
- chooser = m_chooserWidgets.at(i);
- const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null;
-
- if (currentText.isEmpty() || i > activeID) {
+ const int max = std::min(m_chooserWidgets.count(),
+ sender()->property(ID_PROPERTY_NAME).toInt());
+ for (int i = 0; i < max; i++) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(i);
+ Q_ASSERT(chooser);
+ const QString currentText = chooser->comboBox().currentText();
+ if (currentText.isEmpty())
break;
- }
- items << currentText;
+ items.append(currentText);
}
QString newKey("/");
@@ -259,11 +256,11 @@ void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
}
/** Updates the keychoosers for the given key but emit no signal. */
-void CBookKeyChooser::updateKey(CSwordKey* key) {
+void CBookKeyChooser::updateKey(CSwordKey * key) {
setKey(key, false);
}
-void CBookKeyChooser::setKey(QString& newKey) {
+void CBookKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index 3b32d48..c01e0e9 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,71 +22,79 @@ class CSwordBookModuleInfo;
class CSwordKey;
class CSwordTreeKey;
-namespace sword {
-class TreeKeyIdx;
-}
-
-/** The keychooser implementation for books.
- * @author The BibleTime team
- */
-class CBookKeyChooser : public CKeyChooser {
- Q_OBJECT
- public:
- CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Reimplemented from CKeyChooser.
- */
- virtual void refreshContent();
-
- /**
- * Sets another module to this keychooser
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = false);
- /**
- * Returns the key of this keychooser
- */
- virtual CSwordKey* key();
- /**
- * Sets a new key to this keychooser
- */
- virtual void setKey(CSwordKey*);
- /**
- * Sets a new key to this keychooser
- */
- void setKey(CSwordKey*, const bool emitSignal);
-
-
- public slots: // Public slots
- /**
- * Updates the keychoosers for the given key but emit no signal.
- */
- void updateKey(CSwordKey*);
-
- protected: // Protected methods
- /**
- * Fills the combo given by depth with the items from the key having depth "depth".
- * The parent sibling is given by key.
- */
- void setupCombo(const QString key, const int depth, const int currentItem);
- /** No descriptions */
- virtual void adjustFont();
-
- protected slots:
- /**
- * A keychooser changed. Update and emit a signal if necessary.
- */
- void keyChooserChanged(int);
- virtual void setKey(QString& newKey);
-
- private:
- QList<CKeyChooserWidget*> m_chooserWidgets;
- QList<const CSwordBookModuleInfo*> m_modules;
- CSwordTreeKey *m_key;
- QHBoxLayout* m_layout;
+/**
+ \brief The keychooser implementation for books.
+*/
+class CBookKeyChooser: public CKeyChooser {
+
+ Q_OBJECT
+
+public:
+
+ CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key = 0,
+ QWidget * parent = 0);
+
+ /**
+ Reimplemented from CKeyChooser.
+ */
+ virtual void refreshContent();
+
+ /**
+ * Sets another module to this keychooser
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = false);
+ /**
+ * Returns the key of this keychooser
+ */
+ virtual CSwordKey * key();
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ virtual void setKey(CSwordKey * key);
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ void setKey(CSwordKey * key, const bool emitSignal);
+
+public slots: // Public slots
+
+ /**
+ * Updates the keychoosers for the given key but emit no signal.
+ */
+ void updateKey(CSwordKey * key);
+
+protected: /* Methods: */
+
+ /**
+ * Fills the combo given by depth with the items from the key having depth "depth".
+ * The parent sibling is given by key.
+ */
+ void setupCombo(const QString & key, const int depth, const int currentItem);
+
+ /** No descriptions */
+ virtual void adjustFont();
+
+protected slots:
+
+ /**
+ * A keychooser changed. Update and emit a signal if necessary.
+ */
+ void keyChooserChanged(int);
+
+ virtual void setKey(const QString & newKey);
+
+private: /* Fields: */
+
+ QList<CKeyChooserWidget *> m_chooserWidgets;
+ QList<const CSwordBookModuleInfo *> m_modules;
+ CSwordTreeKey * m_key;
+ QHBoxLayout * m_layout;
+
};
#endif
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index a41922e..96917d8 100644
--- a/src/frontend/keychooser/cbooktreechooser.cpp
+++ b/src/frontend/keychooser/cbooktreechooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,16 +13,19 @@
#include <QHBoxLayout>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory* historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
+CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordTreeKey *>(key))
+{
setModules(modules, false);
@@ -109,8 +112,7 @@ void CBookTreeChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** From ckeychooser. */
void CBookTreeChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- m_treeView->setFont( CBTConfig::get(m_modules.first()->language()).second );
-
+ m_treeView->setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
@@ -183,7 +185,7 @@ void CBookTreeChooser::addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item)
}
}
-void CBookTreeChooser::setKey(QString& newKey) {
+void CBookTreeChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 409038e..17b5825 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -79,7 +81,7 @@ class CBookTreeChooser : public CKeyChooser {
protected slots: // Protected slots
void itemActivated( QTreeWidgetItem* item );
- void setKey(QString& newKey);
+ void setKey(const QString & newKey);
private:
QList<const CSwordBookModuleInfo*> m_modules;
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index b46ee51..96b5638 100644
--- a/src/frontend/keychooser/ckeychooser.cpp
+++ b/src/frontend/keychooser/ckeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,48 +21,44 @@
#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo*> &, BTHistory* historyPtr,
- CSwordKey *, QWidget *parent)
- : QWidget(parent),
- m_history(historyPtr) {
- bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo *> &,
+ BTHistory * historyPtr,
+ QWidget * parent)
+ : QWidget(parent)
+ , m_history(historyPtr)
+{
+ bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString)),
+ this, SLOT(setKey(const QString &)));
Q_ASSERT(ok);
}
-CKeyChooser* CKeyChooser::createInstance(
- const QList<const CSwordModuleInfo*> &modules, BTHistory *historyPtr,
- CSwordKey *key, QWidget *parent)
+CKeyChooser * CKeyChooser::createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
{
- if (!modules.count()) {
- /**
- \todo Verify and document that we need to return 0 here rather than
- fail with an assertion.
- */
- return 0;
- }
+ Q_ASSERT(!modules.empty());
+ Q_ASSERT(modules.first()->type() == CSwordModuleInfo::Commentary
+ || modules.first()->type() == CSwordModuleInfo::Bible
+ || modules.first()->type() == CSwordModuleInfo::Lexicon
+ || modules.first()->type() == CSwordModuleInfo::GenericBook);
+
+ switch (modules.first()->type()) {
- CSwordModuleInfo::ModuleType typeOfModules = modules.first()->type();
-/*
-#ifdef BT_DEBUG
- Q_FOREACH (const CSwordModuleInfo *module, modules) {
- Q_ASSERT(module->type() == typeOfModules);
- }
-#endif
-*/
- switch (typeOfModules) {
case CSwordModuleInfo::Commentary:
/* Fall thru - Bibles and commentaries use the same key chooser */
+
case CSwordModuleInfo::Bible:
return new CBibleKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::Lexicon:
return new CLexiconKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::GenericBook:
return new CBookKeyChooser(modules, historyPtr, key, parent);
+
default:
- /**
- \todo Verify and document that we need to return 0 here rather
- than fail with an assertion.
- */
- return 0;
+ abort();
+
}
}
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index 0ab9c5b..79706cc 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,83 +25,86 @@ class QAction;
* Do not use directly, create a KeyChooser with
* @ref #createInstance , this will create the proper one
* of the classes that inherit from @ref CKeyChooser
- *
- * @author The BibleTime team
- */
-class CKeyChooser : public QWidget {
- Q_OBJECT
- public:
-
- /**
- * Creates a proper Instance, either
- * @ref CLexiconKeyChooser or
- * @ref CBibleKeyChooser
- * @param info the @ref CModuleInfo to be represented by the KeyChooser
- * @param key if not NULL, the @ref CKey the KeyChooser should be set to
- * @param parent the parent of the widget to create
- */
- static CKeyChooser *createInstance(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key, QWidget *parent);
-
-
- public slots:
- /**
- Sets the CKey
- \param key the key which the widget should be set to.
- */
- virtual void setKey(CSwordKey* key) = 0;
-
- /**
- Updates the CKey.
- \param key the key which the widget should be set to.
- */
- virtual void updateKey(CSwordKey *key) = 0;
-
- /**
- \returns the current CKey.
- */
- virtual CSwordKey *key() = 0;
-
- /**
- Sets the module of this keychooser and refreshes the comboboxes
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = true) = 0;
-
- /**
- Refreshes the content of the different key chooser parts.
- */
- virtual void refreshContent() = 0;
-
- /**
- \returns the history object of this keychooser.
- */
- inline BTHistory *history() const { return m_history; }
-
- signals:
-
- /**
- * is emitted if the @ref CKey was changed by the user
- */
- void keyChanged(CSwordKey* newKey);
-
- protected:
-
- CKeyChooser(const QList<const CSwordModuleInfo*> &info,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Resets the appropriate font to for the modules.
- */
- virtual void adjustFont() = 0;
-
- protected slots:
- virtual void setKey(QString &newKey) = 0;
-
- private:
- BTHistory *m_history;
+ */
+class CKeyChooser: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ /**
+ \returns the history object of this keychooser.
+ */
+ inline BTHistory * history() const { return m_history; }
+
+ /**
+ * Creates a proper Instance, either
+ * @ref CLexiconKeyChooser or
+ * @ref CBibleKeyChooser
+ * @param info the @ref CModuleInfo to be represented by the KeyChooser
+ * @param key if not NULL, the @ref CKey the KeyChooser should be set to
+ * @param parent the parent of the widget to create
+ */
+ static CKeyChooser * createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key,
+ QWidget * parent);
+
+public slots:
+
+ /**
+ Sets the CKey
+ \param key the key which the widget should be set to.
+ */
+ virtual void setKey(CSwordKey * key) = 0;
+
+ /**
+ Updates the CKey.
+ \param key the key which the widget should be set to.
+ */
+ virtual void updateKey(CSwordKey * key) = 0;
+
+ /**
+ \returns the current CKey.
+ */
+ virtual CSwordKey * key() = 0;
+
+ /**
+ Sets the module of this keychooser and refreshes the comboboxes
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = true) = 0;
+
+ /**
+ Refreshes the content of the different key chooser parts.
+ */
+ virtual void refreshContent() = 0;
+
+signals:
+
+ /**
+ * is emitted if the @ref CKey was changed by the user
+ */
+ void keyChanged(CSwordKey * newKey);
+
+protected: /* Methods: */
+
+ CKeyChooser(const QList<const CSwordModuleInfo *> & info,
+ BTHistory * history,
+ QWidget * parent = 0);
+
+ /**
+ Resets the appropriate font to for the modules.
+ */
+ virtual void adjustFont() = 0;
+
+protected slots:
+
+ virtual void setKey(const QString & newKey) = 0;
+
+private: /* Fields: */
+
+ BTHistory * const m_history;
};
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index 36fc05b..ea3421e 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,58 +19,60 @@
class BtKeyLineEdit : public QLineEdit {
- public:
- BtKeyLineEdit(QWidget* parent)
- : QLineEdit(parent) {
- }
- protected:
- void focusInEvent(QFocusEvent* event) {
- Qt::FocusReason reason = event->reason();
- if (reason == Qt::OtherFocusReason) {
- selectAll();
- }
- QWidget::focusInEvent(event);
- }
-};
+public: /* Methods: */
+
+ BtKeyLineEdit(QWidget * parent)
+ : QLineEdit(parent) {}
+
+protected: /* Methods: */
+
+ virtual void focusInEvent(QFocusEvent * event) {
+ const Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason)
+ selectAll();
+ QWidget::focusInEvent(event);
+ }
+
+};
-CKCComboBox::CKCComboBox()
- : QComboBox() {
+CKCComboBox::CKCComboBox(QWidget * parent)
+ : QComboBox(parent)
+{
setFocusPolicy(Qt::WheelFocus);
setLineEdit(new BtKeyLineEdit(this));
- if (lineEdit()) {
- installEventFilter( lineEdit() );
- }
+ if (lineEdit())
+ installEventFilter(lineEdit());
}
-/** Reimplementation. */
-bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
+bool CKCComboBox::eventFilter(QObject * o, QEvent * e) {
if (e->type() == QEvent::FocusOut) {
- QFocusEvent* f = static_cast<QFocusEvent*>(e);
+ QFocusEvent * const f = static_cast<QFocusEvent *>(e);
if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
int index = findText(currentText());
- if (index == -1) {
- index = 0;// return 0 if not found
- }
- setCurrentIndex( index );
- emit focusOut( index );
-
+ if (index == -1)
+ index = 0; // return 0 if not found
+ setCurrentIndex(index);
+ emit focusOut(index);
return false;
}
- else if (f->reason() == Qt::PopupFocusReason) {
+
+ if (f->reason() == Qt::PopupFocusReason)
return false;
- }
- else if (f->reason() == Qt::ActiveWindowFocusReason) {
+
+ if (f->reason() == Qt::ActiveWindowFocusReason) {
emit activated(currentText());
return false;
}
- else if (f->reason() == Qt::MouseFocusReason) {
+
+ if (f->reason() == Qt::MouseFocusReason) {
emit activated(currentText());
return false;
}
- else if (o == this) {
+
+ if (o == this) {
emit activated(currentText());
return false;
}
@@ -80,8 +82,8 @@ bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
}
/** Scrolls in the list if the wheel of the mouse was used. */
-void CKCComboBox::wheelEvent( QWheelEvent* e ) {
- return QComboBox::wheelEvent(e);
+void CKCComboBox::wheelEvent(QWheelEvent * e) {
+ return QComboBox::wheelEvent(e); /// \bug rest method won't get executed.
const signed int change = (int)((float)e->delta() / (float)120);
int current = currentIndex();
@@ -89,18 +91,17 @@ void CKCComboBox::wheelEvent( QWheelEvent* e ) {
if ((current + change >= 0) && (current + change < count()) ) {
setCurrentIndex(current + change);
e->accept();
- emit activated( currentIndex() );
- }
- else {
+ emit activated(currentIndex());
+ } else {
e->ignore();
}
}
//**********************************************************************************/
-CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
+CKeyChooserWidget::CKeyChooserWidget(int count, QWidget * parent)
+ : QWidget(parent)
+{
for (int index = 1; index <= count; index++) {
m_list.append( QString::number(index) );
}
@@ -108,15 +109,11 @@ CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals,
reset(m_list, 0, false);
}
-CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
- if (list) {
- m_list = *list; //deep copy the items of list
- }
- else {
- m_list.clear();
- }
+CKeyChooserWidget::CKeyChooserWidget(QStringList * list, QWidget * parent )
+ : QWidget(parent)
+{
+ if (list)
+ m_list = *list;
init();
reset(m_list, 0, false);
@@ -129,14 +126,13 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
// return;
m_list.clear();
- for (int i = 1; i <= count; i++) { /// \todo CHECK
- m_list.append( QString::number(i) );
- }
+ for (int i = 1; i <= count; i++) /// \todo CHECK
+ m_list.append(QString::number(i));
reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList & list, int index, bool do_emit) {
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
@@ -147,37 +143,34 @@ void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit)
}
-void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList * list, int index, bool do_emit) {
//if (isResetting || !updatesEnabled())
- if (isResetting)
+ if (m_isResetting)
return;
// qWarning("starting insert");
- isResetting = true;
+ m_isResetting = true;
- oldKey = QString::null;
+ m_oldKey = QString::null;
// m_comboBox->setUpdatesEnabled(false);
//DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
m_comboBox->hide();
m_comboBox->clear();
- if (list) {
+ if (list)
m_comboBox->insertItems(-1, *list);
- }
- if (!list || (list && !list->count())) { //nothing in the combobox
+ if (!list || (list && !list->count())) { // nothing in the combobox
setEnabled(false);
- }
- else if (!isEnabled()) { //was disabled
+ } else if (!isEnabled()) { // was disabled
setEnabled(true);
}
- if (list->count()) {
+ if (list->count())
m_comboBox->setCurrentIndex(index);
- }
- if (do_emit) {
+
+ if (do_emit)
emit changed(m_comboBox->currentIndex());
- }
m_comboBox->sizeHint(); //without this function call the combo box won't be properly sized!
//DON'T REMOVE OR MOVE THE show()! Otherwise QComboBox's sizeHint() function won't work properly!
@@ -186,56 +179,56 @@ void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit)
// m_comboBox->setFont( m_comboBox->font() );
// m_comboBox->setUpdatesEnabled(true);
- isResetting = false;
+ m_isResetting = false;
// qWarning("inserted");
}
/** Initializes this widget. We need this function because we have more than one constructor. */
void CKeyChooserWidget::init() {
- oldKey = QString::null;
+ m_oldKey = QString::null;
setFocusPolicy(Qt::WheelFocus);
- m_comboBox = new CKCComboBox();
+ m_comboBox = new CKCComboBox(this);
setFocusProxy(m_comboBox);
- m_comboBox->setAutoCompletion( true );
+ m_comboBox->setAutoCompletion(true);
m_comboBox->setEditable(true);
m_comboBox->setInsertPolicy(QComboBox::NoInsert);
m_comboBox->setFocusPolicy(Qt::WheelFocus);
- m_mainLayout = new QHBoxLayout( this );
+ m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setSpacing(0);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
m_mainLayout->addWidget(m_comboBox);
m_scroller = new CScrollerWidgetSet(this);
- m_mainLayout->addWidget( m_scroller );
+ m_mainLayout->addWidget(m_scroller);
m_mainLayout->addSpacing(0);
setTabOrder(m_comboBox, 0);
setFocusProxy(m_comboBox);
- connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
+ connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
- connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)) );
-
- connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
+ connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)));
+ connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
// connect(m_comboBox, SIGNAL(activated(const QString&)), SLOT(slotReturnPressed(const QString&)));
- connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
+ connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()),
+ SLOT(slotReturnPressed()));
connect(m_comboBox, SIGNAL(focusOut(int)), SIGNAL(focusOut(int)));
updatelock = false;
- isResetting = false;
+ m_isResetting = false;
}
/** Is called when the return key was presed in the combobox. */
-void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
- Q_ASSERT(comboBox()->lineEdit());
+void CKeyChooserWidget::slotReturnPressed() {
+ Q_ASSERT(m_comboBox->lineEdit());
- QString text = comboBox()->lineEdit()->text();
- for (int index = 0; index < comboBox()->count(); ++index) {
- if (comboBox()->itemText(index) == text) {
+ const QString text(m_comboBox->lineEdit()->text());
+ for (int index = 0; index < m_comboBox->count(); ++index) {
+ if (m_comboBox->itemText(index) == text) {
// emit changed(index);
emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
break;
@@ -245,71 +238,74 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
/** Is called when the current item of the combo box was changed. */
void CKeyChooserWidget::slotComboChanged(int index) {
- if (!updatesEnabled()) {
+ if (!updatesEnabled())
return;
- }
setUpdatesEnabled(false);
- const QString key = comboBox()->itemText( index );
- if (oldKey.isNull() || (oldKey != key)) {
+ const QString key(m_comboBox->itemText(index));
+ if (m_oldKey.isNull() || (m_oldKey != key))
emit changed(index);
- }
- oldKey = key;
+ m_oldKey = key;
setUpdatesEnabled(true);
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- comboBox()->setToolTip(comboTip);
+void CKeyChooserWidget::setToolTips(const QString & comboTip,
+ const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_comboBox->setToolTip(comboTip);
m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
}
/** Sets the current item to the one with the given text */
-bool CKeyChooserWidget::setItem( const QString item ) {
+bool CKeyChooserWidget::setItem(const QString & item) {
bool ret = false;
- const int count = comboBox()->count();
+ const int count = m_comboBox->count();
for (int i = 0; i < count; ++i) {
- if (comboBox()->itemText(i) == item) {
- comboBox()->setCurrentIndex(i);
+ if (m_comboBox->itemText(i) == item) {
+ m_comboBox->setCurrentIndex(i);
ret = true;
break;
}
}
if (!ret)
- comboBox()->setCurrentIndex(-1);
+ m_comboBox->setCurrentIndex(-1);
return ret;
}
/* Handlers for the various scroller widgetset. */
void CKeyChooserWidget::lock() {
updatelock = true;
- comboBox()->setEditable(false);
- oldKey = comboBox()->currentText();
+ m_comboBox->setEditable(false);
+ m_oldKey = m_comboBox->currentText();
}
void CKeyChooserWidget::unlock() {
updatelock = false;
- comboBox()->setEditable(true);
- comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
- if (comboBox()->currentText() != oldKey) {
- emit changed(comboBox()->currentIndex());
- }
+ m_comboBox->setEditable(true);
+ m_comboBox->setEditText(m_comboBox->itemText(m_comboBox->currentIndex()));
+ if (m_comboBox->currentText() != m_oldKey)
+ emit changed(m_comboBox->currentIndex());
}
void CKeyChooserWidget::changeCombo(int n) {
- const int old_index = comboBox()->currentIndex();
+ const int old_index = m_comboBox->currentIndex();
int new_index = old_index + n;
//index of highest Item
- const int max = comboBox()->count() - 1;
- if (new_index > max) new_index = max;
- if (new_index < 0) new_index = 0;
+ const int max = m_comboBox->count() - 1;
+ if (new_index > max)
+ new_index = max;
+ if (new_index < 0)
+ new_index = 0;
if (new_index != old_index) {
- comboBox()->setCurrentIndex(new_index);
+ m_comboBox->setCurrentIndex(new_index);
if (!updatelock)
emit changed(new_index);
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 3121af8..a1fd31d 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,6 @@
#include <QComboBox>
-#include <QString>
#include <QStringList>
@@ -28,30 +29,27 @@ class QEvent;
* We use this class to control the focus move in the combobox
* This class is used in the key chooser widgets
*/
-class CKCComboBox : public QComboBox {
- Q_OBJECT
- public:
- CKCComboBox();
- /**
- * Returns the size this widget would like to have.
- */
- // virtual QSize sizeHint() const;
-
- protected:
- /**
- * Reimplementation.
- */
- virtual bool eventFilter( QObject *o, QEvent *e );
- /**
- * Scrolls in the list if the wheel of the mouse was used.
- */
- virtual void wheelEvent( QWheelEvent* e);
-
- signals:
- /**
- * Emitted when the user moves the focus away from the combo by pressing tab
- */
- void focusOut(int itemIndex);
+class CKCComboBox: public QComboBox {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKCComboBox(QWidget * parent = 0);
+
+protected: /* Methods: */
+
+ virtual bool eventFilter(QObject * o, QEvent * e);
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+signals:
+
+ /**
+ * Emitted when the user moves the focus away from the combo by pressing tab
+ */
+ void focusOut(int itemIndex);
+
};
/**
@@ -61,114 +59,122 @@ class CKCComboBox : public QComboBox {
*
* @author The BibleTime team
*/
-class CKeyChooserWidget : public QWidget {
- Q_OBJECT
-
- public:
- CKeyChooserWidget(QStringList *list = 0,
- const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- CKeyChooserWidget(int count = 0, const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- /**
- * This function does clear the combobox, then fill in
- * the StringList, set the ComboBox' current item to index
- * and if do_emit is true, it will emit @ref #changed
- *
- * @param list the stringlist to be inserted
- * @param index the index that the combobox is to jump to
- * @param do_emit should we emit @ref #changed(int)
- */
- void reset(const int count, int index, bool do_emit);
- void reset(const QStringList &list, int index, bool do_emit);
- void reset(const QStringList *list, int index, bool do_emit);
-
- /**
- * Initializes this widget. We need this function because
- * we have more than one constructor.
- */
- virtual void init();
- /**
- *
- */
- // virtual void adjustSize();
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString comboTip, const QString nextEntry, const QString scrollButton, const QString previousEntry);
- /**
- * Sets the current item to the one with the given text
- */
- bool setItem( const QString item);
- /**
- * Return the combobox of this key chooser widget.
- */
- QComboBox* comboBox() {
- return m_comboBox;
- };
-
- public slots:
- /**
- * is called to lock the combobox
- */
- void lock()
- ;
- /**
- * is called to unlock the combobox
- */
- void unlock();
- /**
- * is called to move the combobox to a certain index
- * @param index the index to jump to
- */
- void changeCombo(int index);
- void slotComboChanged(int index);
-
- signals:
- /**
- * Is emitted if the widget changed, but
- * only if it is not locked or being reset
- *
- * @param the current ComboBox index
- */
- void changed(int index);
- /**
- * Is emitted if the widget was left with a focus out event.
- * @param index The new index of the ComboBox
- */
- void focusOut(int index);
-
- protected:
- /**
- * indicates wheter we are resetting at the moment
- */
- bool isResetting;
- /**
- *
- */
- QString oldKey;
-
- protected slots: // Protected slots
- /**
- * Is called when the return key was presed in the combobox.
- */
- void slotReturnPressed( /*const QString&*/ );
-
-
- private:
-
- QStringList m_list;
- bool m_useNextPrevSignals;
- bool updatelock;
-
- /**
- * Members should never be public!!
- */
- CKCComboBox* m_comboBox;
- QHBoxLayout *m_mainLayout;
- CScrollerWidgetSet * m_scroller;
+class CKeyChooserWidget: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKeyChooserWidget(QStringList * list = 0,
+ QWidget * parent = 0);
+
+ CKeyChooserWidget(int count = 0,
+ QWidget * parent = 0);
+
+ /**
+ * This function does clear the combobox, then fill in
+ * the StringList, set the ComboBox' current item to index
+ * and if do_emit is true, it will emit @ref #changed
+ *
+ * @param list the stringlist to be inserted
+ * @param index the index that the combobox is to jump to
+ * @param do_emit should we emit @ref #changed(int)
+ */
+ void reset(const int count, int index, bool do_emit);
+
+ void reset(const QStringList & list, int index, bool do_emit);
+
+ void reset(const QStringList * list, int index, bool do_emit);
+
+ /**
+ * Initializes this widget. We need this function because
+ * we have more than one constructor.
+ */
+ virtual void init();
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & comboTip,
+ const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+ /**
+ * Sets the current item to the one with the given text
+ */
+ bool setItem(const QString & item);
+
+ /**
+ * Return the combobox of this key chooser widget.
+ */
+ QComboBox & comboBox() const {
+ Q_ASSERT(m_comboBox);
+ return *m_comboBox;
+ }
+
+public slots:
+
+ /**
+ * is called to lock the combobox
+ */
+ void lock();
+
+ /**
+ * is called to unlock the combobox
+ */
+ void unlock();
+
+ /**
+ * is called to move the combobox to a certain index
+ * @param index the index to jump to
+ */
+ void changeCombo(int index);
+
+ void slotComboChanged(int index);
+
+signals:
+
+ /**
+ * Is emitted if the widget changed, but
+ * only if it is not locked or being reset
+ *
+ * @param the current ComboBox index
+ */
+ void changed(int index);
+
+ /**
+ * Is emitted if the widget was left with a focus out event.
+ * @param index The new index of the ComboBox
+ */
+ void focusOut(int index);
+
+protected slots:
+
+ /**
+ * Is called when the return key was presed in the combobox.
+ */
+ void slotReturnPressed();
+
+private: /* Fields: */
+
+ QStringList m_list;
+ bool updatelock;
+
+ /**
+ * Members should never be public!!
+ */
+ CKCComboBox * m_comboBox;
+ QHBoxLayout * m_mainLayout;
+ CScrollerWidgetSet * m_scroller;
+
+ /**
+ * indicates wheter we are resetting at the moment
+ */
+ bool m_isResetting;
+
+ QString m_oldKey;
+
};
#endif
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 42fb4e8..2c6545a 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,11 +19,12 @@
#include "util/cresmgr.h"
-CLexiconKeyChooser::CLexiconKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordLDKey*>(key))
+CLexiconKeyChooser::CLexiconKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordLDKey *>(key))
{
setModules(modules, false);
@@ -34,12 +35,12 @@ CLexiconKeyChooser::CLexiconKeyChooser(
m_layout->setDirection(QBoxLayout::LeftToRight);
m_layout->setSizeConstraint(QLayout::SetNoConstraint);
- m_widget = new CKeyChooserWidget(0, false, this);
+ m_widget = new CKeyChooserWidget(0, this);
setFocusProxy(m_widget);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
- m_widget->comboBox()->setMaximumWidth(200);
+ m_widget->comboBox().setMaximumWidth(200);
m_widget->setToolTips(
tr("Entries of the current work"),
@@ -70,8 +71,8 @@ void CLexiconKeyChooser::updateKey(CSwordKey* key) {
}
QString newKey = m_key->key();
- const int index = m_widget->comboBox()->findText(newKey);
- m_widget->comboBox()->setCurrentIndex(index);
+ const int index = m_widget->comboBox().findText(newKey);
+ m_widget->comboBox().setCurrentIndex(index);
}
void CLexiconKeyChooser::setKey(CSwordKey* key) {
@@ -87,7 +88,7 @@ void CLexiconKeyChooser::setKey(CSwordKey* key) {
void CLexiconKeyChooser::activated(int index) {
// qWarning("activated");
- const QString text = m_widget->comboBox()->itemText(index);
+ const QString text = m_widget->comboBox().itemText(index);
// To prevent from eternal loop, because activated() is emitted again
if (m_key && m_key->key() != text) {
@@ -169,7 +170,7 @@ void CLexiconKeyChooser::setModules(const QList<const CSwordModuleInfo*> &module
}
}
-void CLexiconKeyChooser::setKey(QString& newKey) {
+void CLexiconKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index e014448..5f14747 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -77,7 +79,7 @@ class CLexiconKeyChooser : public CKeyChooser {
virtual void updateKey(CSwordKey* key);
protected slots:
- virtual void setKey(QString& newKey);
+ virtual void setKey(const QString & newKey);
};
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 9a92b5f..775d4db 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,10 +24,6 @@ CScrollButton::CScrollButton(QWidget *parent)
setCursor(Qt::SplitVCursor);
}
-CScrollButton::~CScrollButton() {
- // Intentionally empty
-}
-
void CScrollButton::mousePressEvent(QMouseEvent *e) {
if (m_isLocked) return;
if (e->button() != Qt::LeftButton) return;
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 06d272d..2b3f662 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +27,6 @@ class CScrollButton: public QToolButton {
Q_OBJECT
public:
CScrollButton(QWidget *parent = 0);
- virtual ~CScrollButton();
signals:
/**
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 4ad8750..e169ae9 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.cpp
+++ b/src/frontend/keychooser/cscrollerwidgetset.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,64 +16,69 @@
#include "frontend/keychooser/cscrollbutton.h"
-const unsigned int WIDTH = 16;
-const unsigned int ARROW_HEIGHT = 12;
-const unsigned int MOVER_HEIGHT = 6;
+#define WIDTH (static_cast<unsigned int>(16))
+#define ARROW_HEIGHT (static_cast<unsigned int>(12))
+#define MOVER_HEIGHT (static_cast<unsigned int>(6))
-CScrollerWidgetSet::CScrollerWidgetSet(QWidget *parent) : QWidget(parent) {
+
+CScrollerWidgetSet::CScrollerWidgetSet(QWidget * parent)
+ : QWidget(parent)
+{
m_layout = new QVBoxLayout(this);
m_layout->setSpacing(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);
- btn_up = new QToolButton(this);
- btn_up->setArrowType(Qt::UpArrow);
+ m_buttonUp = new QToolButton(this);
+ m_buttonUp->setArrowType(Qt::UpArrow);
- btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_up->setFocusPolicy(Qt::NoFocus);
- btn_up->setAutoRaise(true);
+ m_buttonUp->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonUp->setFocusPolicy(Qt::NoFocus);
+ m_buttonUp->setAutoRaise(true);
- btn_fx = new CScrollButton(this);
- btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
- btn_fx->setFocusPolicy(Qt::NoFocus);
+ m_scrollButton = new CScrollButton(this);
+ m_scrollButton->setFixedSize(WIDTH, MOVER_HEIGHT);
+ m_scrollButton->setFocusPolicy(Qt::NoFocus);
- btn_down = new QToolButton(this);
- btn_down->setArrowType(Qt::DownArrow);
- btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_down->setFocusPolicy(Qt::NoFocus);
- btn_down->setAutoRaise(true);
+ m_buttonDown = new QToolButton(this);
+ m_buttonDown->setArrowType(Qt::DownArrow);
+ m_buttonDown->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonDown->setFocusPolicy(Qt::NoFocus);
+ m_buttonDown->setAutoRaise(true);
- m_layout->addWidget( btn_up, 0 );
- m_layout->addWidget( btn_fx, 0 );
- m_layout->addWidget( btn_down, 0 );
+ m_layout->addWidget(m_buttonUp, 0);
+ m_layout->addWidget(m_scrollButton, 0);
+ m_layout->addWidget(m_buttonDown, 0);
setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.
- connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
- connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
- connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
- connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
- connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
+ connect(m_scrollButton, SIGNAL(lock()), SLOT(slotLock()));
+ connect(m_scrollButton, SIGNAL(unlock()), SLOT(slotUnlock()));
+ connect(m_scrollButton, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
+ connect(m_buttonUp, SIGNAL(clicked()), SLOT(slotUpClick()));
+ connect(m_buttonDown, SIGNAL(clicked()), SLOT(slotDownClick()));
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CScrollerWidgetSet::setToolTips( const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- btn_fx->setToolTip(scrollButtonTip);
- btn_down->setToolTip(nextEntryTip);
- btn_up->setToolTip(previousEntryTip);
+void CScrollerWidgetSet::setToolTips(const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_scrollButton->setToolTip(scrollButtonTip);
+ m_buttonDown->setToolTip(nextEntryTip);
+ m_buttonUp->setToolTip(previousEntryTip);
}
-void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
+void CScrollerWidgetSet::wheelEvent(QWheelEvent * e) {
/**
* The problem is, that wheel events do everytime have the delta value 120
*/
- const int vchange = ((e->delta() > 0) ? (-1) : (1));
+ const int vchange = ((e->delta() > 0) ? -1 : 1);
- if (vchange != 0) {//do not emit a change with value 0
+ if (vchange != 0) { // Do not emit a change with value 0
emit change(vchange);
e->accept();
- }
- else {
+ } else {
e->ignore();
}
}
@@ -81,15 +86,19 @@ void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
void CScrollerWidgetSet::slotLock() {
emit scroller_pressed();
}
+
void CScrollerWidgetSet::slotUnlock() {
emit scroller_released();
}
+
void CScrollerWidgetSet::slotScroller(int n) {
emit change(n);
}
+
void CScrollerWidgetSet::slotUpClick() {
slotScroller(-1);
}
+
void CScrollerWidgetSet::slotDownClick() {
slotScroller(1);
}
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index f2ae643..2894928 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,51 +23,53 @@ class QVBoxLayout;
/**
* This class implements the Scroller Widget-set, which
* consists of two normal ref @QToolButton and a enhanced @ref CScrollButton
- *
- * @author The BibleTime team
- */
-class CScrollerWidgetSet : public QWidget {
- Q_OBJECT
-
- public:
- CScrollerWidgetSet(QWidget *parent = 0);
-
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString nextEntry, const QString scrollButton, const QString previousEntry);
-
- signals:
- /**
- * Is emitted to proceed to some other entry relative to the
- * current, indicated by the int value.
- * \param count offset to change to
- */
- void change(int count);
-
- /**
- * These emit when the scroll button is pressed or released
- */
- void scroller_pressed();
- void scroller_released();
-
- protected:
-
- virtual void wheelEvent( QWheelEvent* e );
-
- QToolButton* btn_up;
- QToolButton* btn_down;
- CScrollButton* btn_fx;
-
- protected slots:
- void slotLock();
- void slotUnlock();
- void slotUpClick();
- void slotDownClick();
- void slotScroller(int);
-
- private:
- QVBoxLayout *m_layout;
+ */
+class CScrollerWidgetSet: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CScrollerWidgetSet(QWidget * parent = 0);
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+signals:
+
+ /**
+ * Is emitted to proceed to some other entry relative to the
+ * current, indicated by the int value.
+ * \param count offset to change to
+ */
+ void change(int count);
+
+ void scroller_pressed();
+
+ void scroller_released();
+
+protected: /* Methods: */
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+protected slots:
+
+ void slotLock();
+ void slotUnlock();
+ void slotUpClick();
+ void slotDownClick();
+ void slotScroller(int);
+
+private: /* Fields: */
+
+ QVBoxLayout * m_layout;
+ QToolButton * m_buttonUp;
+ QToolButton * m_buttonDown;
+ CScrollButton * m_scrollButton;
};
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
index 5feb371..2ac2574 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,11 +21,12 @@
#include <QStringList>
#include <QToolButton>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/keychooser/cscrollerwidgetset.h"
#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
#include "util/btsignal.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtLineEdit : public QLineEdit {
@@ -52,16 +53,13 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
{
Q_UNUSED(name);
- namespace DU = util::directory;
-
-
updatelock = false;
m_module = mod;
setFocusPolicy(Qt::WheelFocus);
QToolButton* clearRef = new QToolButton(this);
- clearRef->setIcon(DU::getIcon("edit_clear_locationbar"));
+ clearRef->setIcon(util::getIcon("edit_clear_locationbar"));
clearRef->setAutoRaise(true);
clearRef->setStyleSheet("QToolButton{margin:0px;}");
connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
@@ -138,7 +136,7 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
- bool ok = connect(m_key->signaler(), SIGNAL(changed()), this, SLOT(updateText()));
+ bool ok = connect(m_key->afterChangedSignaller(), SIGNAL(signal()), this, SLOT(updateText()));
Q_ASSERT(ok);
setKey(key); // The order of these two functions is important.
@@ -287,7 +285,7 @@ void BtBibleKeyWidget::slotChangeVerse(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setVerse(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock) emit changed(m_key);
@@ -298,7 +296,7 @@ void BtBibleKeyWidget::slotChangeChapter(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setChapter(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
@@ -310,7 +308,7 @@ void BtBibleKeyWidget::slotChangeBook(QString bookname) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->book( bookname );
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
index 644bc75..7d94c94 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index 8030aaf..70f800a 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index bdd56da..646b7ef 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index ac94299..9a8d35e 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,13 +25,15 @@ BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent)
void BtVerseKeyMenu::startFirstClickDelayTimer() {
m_firstClickLock = true;
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_timerId = startTimer(300);
}
void BtVerseKeyMenu::timerEvent(QTimerEvent* e) {
if (e->timerId() == m_timerId) {
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_firstClickLock = false;
}
else {
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index 343277c..18caab5 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 358c9c4..e481020 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,11 +20,12 @@
#include "util/cresmgr.h"
-CBibleKeyChooser::CBibleKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordVerseKey*>(key))
+CBibleKeyChooser::CBibleKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordVerseKey *>(key))
{
typedef CSwordBibleModuleInfo CSBMI;
@@ -126,7 +127,7 @@ void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {
void CBibleKeyChooser::adjustFont() {}
-void CBibleKeyChooser::setKey(QString& newKey) {
+void CBibleKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
index d2c5363..91ad265 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -70,10 +72,8 @@ class CBibleKeyChooser : public CKeyChooser {
void refreshContent();
protected slots:
- /**
- Reimplemented from CKeyChooser::setModules().
- */
- virtual void setKey(QString& newKey);
+
+ virtual void setKey(const QString & newKey);
private:
BtBibleKeyWidget* w_ref;