diff options
Diffstat (limited to 'src/frontend/keychooser')
24 files changed, 186 insertions, 224 deletions
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp index 8b14ded..60d2a7b 100644 --- a/src/frontend/keychooser/bthistory.cpp +++ b/src/frontend/keychooser/bthistory.cpp @@ -1,24 +1,18 @@ -// -// C++ Implementation: BTHistory -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2007 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#include "bthistory.h" - -#include "backend/keys/cswordkey.h" +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2009 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ +#include "frontend/keychooser/bthistory.h" #include <QAction> -#include <QList> - #include <QDebug> +#include <QList> +#include "backend/keys/cswordkey.h" BTHistory::BTHistory(QWidget* parent) @@ -30,7 +24,7 @@ BTHistory::BTHistory(QWidget* parent) } void BTHistory::add(CSwordKey* newKey) { - qDebug("BTHistory::add"); + qDebug() << "BTHistory::add"; Q_ASSERT(newKey); // Add new key Action after current index if we were not using the history functions, // if it's not a duplicate and if it's not empty. @@ -38,14 +32,14 @@ void BTHistory::add(CSwordKey* newKey) { if (!newKey->key().isEmpty()) { m_historyList.insert(++m_index, new QAction(newKey->key(), this)); } - // TODO: history limit? + // \todo history limit? sendChangedSignal(); } Q_ASSERT(class_invariant()); } void BTHistory::move(QAction* historyItem) { - qDebug("BTHistory::move"); + qDebug() << "BTHistory::move"; //Q_ASSERT(historyItem); Q_ASSERT(m_historyList.count()); @@ -62,7 +56,7 @@ void BTHistory::move(QAction* historyItem) { } void BTHistory::back() { - qDebug("BTHistory::back"); + qDebug() << "BTHistory::back"; if ( m_index >= 1) { move(m_historyList.at(m_index - 1)); } @@ -70,7 +64,7 @@ void BTHistory::back() { } void BTHistory::fw() { - qDebug("BTHistory::fw"); + qDebug() << "BTHistory::fw"; if (m_index < (m_historyList.size() - 1)) { move(m_historyList.at(m_index + 1)); } @@ -78,7 +72,7 @@ void BTHistory::fw() { } QList<QAction*> BTHistory::getBackList() { - qDebug("BTHistory::getBackList"); + qDebug() << "BTHistory::getBackList"; QList<QAction*> list; for (int i = m_index - 1; i >= 0; --i) { @@ -91,7 +85,7 @@ QList<QAction*> BTHistory::getBackList() { } QList<QAction*> BTHistory::getFwList() { - qDebug("BTHistory::getFwList"); + qDebug() << "BTHistory::getFwList"; QList<QAction*> list; //qDebug() << "historyList.size:" << m_historyList.size(); diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h index 9c09e10..df674d0 100644 --- a/src/frontend/keychooser/bthistory.h +++ b/src/frontend/keychooser/bthistory.h @@ -1,21 +1,19 @@ -// -// C++ Interface: BTHistory -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2007 -// -// Copyright: See COPYING file that comes with this distribution -// -// +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2008 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ #ifndef BTHISTORY_H #define BTHISTORY_H -#include <QList> #include <QObject> +#include <QList> + class CSwordKey; class QAction; @@ -23,10 +21,9 @@ class QWidget; class BTHistory: public QObject { Q_OBJECT - public: BTHistory(QWidget* parent); - ~BTHistory() {}; + ~BTHistory() {} /** * Return a list of Actions behind the current point, the first of the history list will be the diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp index ca13baa..21216e4 100644 --- a/src/frontend/keychooser/cbookkeychooser.cpp +++ b/src/frontend/keychooser/cbookkeychooser.cpp @@ -6,19 +6,18 @@ * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ -#include "cbookkeychooser.h" -#include "bthistory.h" +#include "frontend/keychooser/cbookkeychooser.h" -#include "backend/keys/cswordtreekey.h" -#include "backend/drivers/cswordbookmoduleinfo.h" -#include "backend/config/cbtconfig.h" - -//Qt includes -#include <QWidget> +#include <QDebug> #include <QHBoxLayout> #include <QList> -#include <QDebug> +#include <QWidget> +#include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordbookmoduleinfo.h" +#include "backend/keys/cswordtreekey.h" +#include "frontend/keychooser/bthistory.h" + QMap<QObject*, int> boxes; diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h index d32d6e9..f1ac69f 100644 --- a/src/frontend/keychooser/cbookkeychooser.h +++ b/src/frontend/keychooser/cbookkeychooser.h @@ -10,14 +10,14 @@ #ifndef CBOOKKEYCHOOSER_H #define CBOOKKEYCHOOSER_H -//BibleTime includes -#include "ckeychooser.h" -#include "ckeychooserwidget.h" +#include "frontend/keychooser/ckeychooser.h" #include <QList> +#include "frontend/keychooser/ckeychooserwidget.h" + -class CSwordKey; class CSwordBookModuleInfo; +class CSwordKey; class CSwordTreeKey; namespace sword { @@ -27,7 +27,7 @@ class TreeKeyIdx; /** The keychooser implementation for books. * @author The BibleTime team */ -class CBookKeyChooser : public CKeyChooser { +class CBookKeyChooser : public CKeyChooser { Q_OBJECT public: CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0); diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp index e348005..db55dca 100644 --- a/src/frontend/keychooser/cbooktreechooser.cpp +++ b/src/frontend/keychooser/cbooktreechooser.cpp @@ -6,21 +6,20 @@ * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ -#include "cbooktreechooser.h" -#include "bthistory.h" - -#include "backend/keys/cswordtreekey.h" -#include "backend/drivers/cswordbookmoduleinfo.h" -#include "backend/config/cbtconfig.h" +#include "frontend/keychooser/cbooktreechooser.h" +#include <QApplication> +#include <QDebug> #include <QHBoxLayout> +#include <QHeaderView> #include <QTreeWidget> #include <QTreeWidgetItem> -#include <QHeaderView> -#include <QApplication> +#include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordbookmoduleinfo.h" +#include "backend/keys/cswordtreekey.h" +#include "frontend/keychooser/bthistory.h" -#include <QDebug> CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) : CKeyChooser(modules, key, parent), @@ -60,7 +59,7 @@ void CBookTreeChooser::setKey(CSwordKey* key) { /** Sets a new key to this keychooser. Inherited from ckeychooser. */ void CBookTreeChooser::setKey(CSwordKey* newKey, const bool emitSignal) { - qDebug("CBookTreeChooser::setKey"); + qDebug() << "CBookTreeChooser::setKey"; if (m_key != newKey ) { m_key = dynamic_cast<CSwordTreeKey*>(newKey); @@ -131,13 +130,13 @@ void CBookTreeChooser::refreshContent() { } -//TODO: itemActivated is called too many times. As tested in GDB, the function +/// \todo itemActivated is called too many times. As tested in GDB, the function //is called twice with the pointer to the correct book and twice with a null //pointer. /** Slot for signal when item is selected by user. */ void CBookTreeChooser::itemActivated( QTreeWidgetItem* item ) { - qDebug("CBookTreeChooser::itemActivated"); + qDebug() << "CBookTreeChooser::itemActivated"; //Sometimes Qt calls this function with a null pointer. if (item) { m_key->key(item->text(1)); diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h index 943127b..01fd369 100644 --- a/src/frontend/keychooser/cbooktreechooser.h +++ b/src/frontend/keychooser/cbooktreechooser.h @@ -7,35 +7,27 @@ * **********/ - - #ifndef CBOOKTREECHOOSER_H #define CBOOKTREECHOOSER_H +#include "frontend/keychooser/ckeychooser.h" -/** The treechooser implementation for books. - * @author The BibleTime team - */ -//BibleTime includes -#include "ckeychooser.h" -#include "ckeychooserwidget.h" - +#include "frontend/keychooser/ckeychooserwidget.h" -class CSwordKey; -class CSwordBookModuleInfo; -class CSwordTreeKey; namespace sword { class TreeKeyIdx; } - +class CSwordBookModuleInfo; +class CSwordKey; +class CSwordTreeKey; class QTreeWidget; class QTreeWidgetItem; /** The keychooser implementation for books. * @author The BibleTime team */ -class CBookTreeChooser : public CKeyChooser { +class CBookTreeChooser : public CKeyChooser { Q_OBJECT public: CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0); diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp index 11b4db3..905e125 100644 --- a/src/frontend/keychooser/ckeychooser.cpp +++ b/src/frontend/keychooser/ckeychooser.cpp @@ -7,29 +7,25 @@ * **********/ +#include "frontend/keychooser/ckeychooser.h" - -#include "ckeychooser.h" - -#include "backend/drivers/cswordmoduleinfo.h" +#include <QAction> +#include <QDebug> #include "backend/drivers/cswordbiblemoduleinfo.h" #include "backend/drivers/cswordcommentarymoduleinfo.h" #include "backend/drivers/cswordlexiconmoduleinfo.h" - +#include "backend/drivers/cswordmoduleinfo.h" #include "backend/keys/cswordkey.h" +#include "frontend/keychooser/bthistory.h" +#include "frontend/keychooser/cbookkeychooser.h" +#include "frontend/keychooser/clexiconkeychooser.h" +#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h" -#include "bthistory.h" -#include "clexiconkeychooser.h" -#include "versekeychooser/cbiblekeychooser.h" -#include "cbookkeychooser.h" - -#include <QAction> -#include <QDebug> CKeyChooser::CKeyChooser(QList<CSwordModuleInfo*>, CSwordKey *, QWidget *parent) : QWidget(parent), m_history(0) { - //qDebug("CKeyChooser::CKeyChooser"); + //qDebug() << "CKeyChooser::CKeyChooser"; m_history = new BTHistory(this); QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&))); } diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h index 455da20..4441df0 100644 --- a/src/frontend/keychooser/ckeychooser.h +++ b/src/frontend/keychooser/ckeychooser.h @@ -7,23 +7,17 @@ * **********/ - - #ifndef CKEYCHOOSER_H #define CKEYCHOOSER_H - -class CSwordModuleInfo; - #include <QWidget> +class BTHistory; class CSwordKey; +class CSwordModuleInfo; class QAction; -class BTHistory; - - /** * The base class for the KeyChooser. * Do not use directly, create a KeyChooser with @@ -32,10 +26,8 @@ class BTHistory; * * @author The BibleTime team */ - class CKeyChooser : public QWidget { Q_OBJECT - public: /** diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp index 88b7ed7..a11bd6f 100644 --- a/src/frontend/keychooser/ckeychooserwidget.cpp +++ b/src/frontend/keychooser/ckeychooserwidget.cpp @@ -7,20 +7,17 @@ * **********/ +#include "frontend/keychooser/ckeychooserwidget.h" -//BibleTime includes -#include "ckeychooserwidget.h" - -#include "cscrollerwidgetset.h" - -//Qt includes -#include <QString> -#include <QWheelEvent> +#include <QComboBox> +#include <QDebug> #include <QFocusEvent> #include <QHBoxLayout> -#include <QComboBox> #include <QLineEdit> -#include <QDebug> +#include <QString> +#include <QWheelEvent> +#include "frontend/keychooser/cscrollerwidgetset.h" + class BtKeyLineEdit : public QLineEdit { public: @@ -133,7 +130,7 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) { // return; m_list.clear(); - for (int i = 1; i <= count; i++) { //TODO: CHECK + for (int i = 1; i <= count; i++) { /// \todo CHECK m_list.append( QString::number(i) ); } @@ -196,7 +193,7 @@ void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) { /** Initializes this widget. We need this function because we have more than one constructor. */ void CKeyChooserWidget::init() { - qDebug("CKeyChooserWidget::init"); + qDebug() << "CKeyChooserWidget::init"; oldKey = QString::null; setFocusPolicy(Qt::WheelFocus); @@ -237,7 +234,7 @@ void CKeyChooserWidget::init() { /** Is called when the return key was presed in the combobox. */ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) { Q_ASSERT(comboBox()->lineEdit()); - qDebug("return pressed"); + qDebug() << "return pressed"; QString text = comboBox()->lineEdit()->text(); for (int index = 0; index < comboBox()->count(); ++index) { @@ -251,7 +248,7 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) { /** Is called when the current item of the combo box was changed. */ void CKeyChooserWidget::slotComboChanged(int index) { - qDebug("CKeyChooserWidget::slotComboChanged(int index)"); + qDebug() << "CKeyChooserWidget::slotComboChanged(int index)"; if (!updatesEnabled()) { return; } diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h index 4a141c1..1dab8b3 100644 --- a/src/frontend/keychooser/ckeychooserwidget.h +++ b/src/frontend/keychooser/ckeychooserwidget.h @@ -10,26 +10,26 @@ #ifndef CKEYCHOOSERWIDGET_H #define CKEYCHOOSERWIDGET_H +#include <QComboBox> #include <QString> #include <QStringList> -#include <QComboBox> + +class CLexiconKeyChooser; +class CScrollerWidgetSet; class QWheelEvent; class QHBoxLayout; class QWidget; class QObject; class QEvent; -class CLexiconKeyChooser; -class CScrollerWidgetSet; -/* -* We use this class to conrtol the focus move in the combobox +/** +* We use this class to control the focus move in the combobox * This class is used in the key chooser widgets */ class CKCComboBox : public QComboBox { Q_OBJECT - public: CKCComboBox(); /** diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp index c1f3cb1..45fa0e2 100644 --- a/src/frontend/keychooser/clexiconkeychooser.cpp +++ b/src/frontend/keychooser/clexiconkeychooser.cpp @@ -7,25 +7,20 @@ * **********/ +#include "frontend/keychooser/clexiconkeychooser.h" - -#include "clexiconkeychooser.h" - -#include "bthistory.h" -#include "ckeychooserwidget.h" -#include "cscrollbutton.h" - -#include "backend/drivers/cswordlexiconmoduleinfo.h" -#include "backend/keys/cswordldkey.h" -#include "backend/config/cbtconfig.h" -#include "util/cresmgr.h" - -//STL headers #include <algorithm> #include <iterator> #include <map> - #include <QHBoxLayout> +#include <QDebug> +#include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordlexiconmoduleinfo.h" +#include "backend/keys/cswordldkey.h" +#include "frontend/keychooser/bthistory.h" +#include "frontend/keychooser/ckeychooserwidget.h" +#include "frontend/keychooser/cscrollbutton.h" +#include "util/cresmgr.h" CLexiconKeyChooser::CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) @@ -70,7 +65,7 @@ CSwordKey* CLexiconKeyChooser::key() { } void CLexiconKeyChooser::setKey(CSwordKey* key) { - qDebug("CLexiconKeyChooser::setKey"); + qDebug() << "CLexiconKeyChooser::setKey"; if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) { return; diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h index ea1137b..f93a148 100644 --- a/src/frontend/keychooser/clexiconkeychooser.h +++ b/src/frontend/keychooser/clexiconkeychooser.h @@ -7,22 +7,18 @@ * **********/ - - #ifndef CLEXICONKEYCHOOSER_H #define CLEXICONKEYCHOOSER_H - -#include "ckeychooser.h" -class CSwordModuleInfo; +#include "frontend/keychooser/ckeychooser.h" class CKeyChooserWidget; -class CSwordLexiconModuleInfo; class CSwordLDKey; - -class QWidget; +class CSwordLexiconModuleInfo; +class CSwordModuleInfo; class QHBoxLayout; +class QWidget; /** * This class implements the KeyChooser for lexicons @@ -32,7 +28,7 @@ class QHBoxLayout; * * @author The BibleTime team */ -class CLexiconKeyChooser : public CKeyChooser { +class CLexiconKeyChooser : public CKeyChooser { Q_OBJECT public: /** diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp index 4303fb1..5154241 100644 --- a/src/frontend/keychooser/cscrollbutton.cpp +++ b/src/frontend/keychooser/cscrollbutton.cpp @@ -7,16 +7,17 @@ * **********/ -#include "cscrollbutton.h" +#include "frontend/keychooser/cscrollbutton.h" #include <cmath> -#include <QEvent> #include <QApplication> #include <QCursor> -#include <QPoint> +#include <QEvent> #include <QMouseEvent> +#include <QPoint> #include <QWheelEvent> + CScrollButton::CScrollButton(QWidget *parent) : QToolButton(parent), m_isLocked(false) { setFocusPolicy(Qt::WheelFocus); diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h index 54b82e6..f795b24 100644 --- a/src/frontend/keychooser/cscrollbutton.h +++ b/src/frontend/keychooser/cscrollbutton.h @@ -7,15 +7,15 @@ * **********/ -#ifndef CSRCOLLBUTTON_H -#define CSRCOLLBUTTON_H +#ifndef CSCROLLBUTTON_H +#define CSCROLLBUTTON_H #include <QToolButton> -class QMouseEvent; -class QWidget; + class QMouseEvent; class QWheelEvent; +class QWidget; /** * This Class implements the direct chooser button used in the KeyChooser Widget. diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp index 5f417a1..7c987cc 100644 --- a/src/frontend/keychooser/cscrollerwidgetset.cpp +++ b/src/frontend/keychooser/cscrollerwidgetset.cpp @@ -7,16 +7,14 @@ * **********/ +#include "frontend/keychooser/cscrollerwidgetset.h" -//BibleTime includes -#include "cscrollbutton.h" -#include "cscrollerwidgetset.h" - -//Qt includes #include <QString> #include <QToolButton> #include <QVBoxLayout> #include <QWheelEvent> +#include "frontend/keychooser/cscrollbutton.h" + const unsigned int WIDTH = 16; const unsigned int ARROW_HEIGHT = 12; diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h index 90d87b6..ae81636 100644 --- a/src/frontend/keychooser/cscrollerwidgetset.h +++ b/src/frontend/keychooser/cscrollerwidgetset.h @@ -7,20 +7,16 @@ * **********/ - - #ifndef CSCROLLERWIDGETSET_H #define CSCROLLERWIDGETSET_H - #include <QWidget> -class QVBoxLayout; -class QToolButton; -class QString; - class CScrollButton; +class QString; +class QToolButton; +class QVBoxLayout; /** * This class implements the Scroller Widget-set, which diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp index 2d59bed..1e8c292 100644 --- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp +++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp @@ -7,12 +7,13 @@ * **********/ -#include "btdropdownchooserbutton.h" -#include "ckeyreferencewidget.h" -#include "btversekeymenu.h" +#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h" -#include <QWheelEvent> #include <QDebug> +#include <QWheelEvent> +#include "frontend/keychooser/versekeychooser/btversekeymenu.h" +#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h" + const unsigned int ARROW_HEIGHT = 15; @@ -36,7 +37,7 @@ BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref) void BtDropdownChooserButton::mousePressEvent(QMouseEvent* e) { - //qDebug("BtDropdownChooserButton::mousePressEvent"); + //qDebug() << "BtDropdownChooserButton::mousePressEvent"; //recreate the menu menu()->clear(); this->newList(); diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h index 12f2f65..e9dbdc2 100644 --- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h +++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h @@ -10,9 +10,9 @@ #ifndef BTDROPDOWNCHOOSERBUTTON_H #define BTDROPDOWNCHOOSERBUTTON_H - #include <QToolButton> + class CKeyReferenceWidget; /** diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp index 82a07b7..c06a18d 100644 --- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp +++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp @@ -7,19 +7,19 @@ * **********/ -#include "btversekeymenu.h" +#include "frontend/keychooser/versekeychooser/btversekeymenu.h" +#include <QDebug> #include <QMenu> -#include <QTimerEvent> #include <QMouseEvent> +#include <QTimerEvent> -#include <QDebug> BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent) : QMenu(parent), m_timerId(0), m_firstClickLock(true) { - qDebug("BtVerseKeyMenu::BtVerseKeyMenu"); + qDebug() << "BtVerseKeyMenu::BtVerseKeyMenu"; QObject::connect(this, SIGNAL(aboutToShow()), this, SLOT(startFirstClickDelayTimer())); } diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h index 29c0736..f47d0f5 100644 --- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h +++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h @@ -12,6 +12,7 @@ #include <QMenu> + class QMouseEvent; class QTimerEvent; diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp index 493d9c4..7bcfbe1 100644 --- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp +++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp @@ -7,21 +7,18 @@ * **********/ -#include "cbiblekeychooser.h" +#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h" -#include "../bthistory.h" -#include "ckeyreferencewidget.h" -#include "../cscrollbutton.h" - -#include "backend/keys/cswordversekey.h" +#include <QDebug> +#include <QHBoxLayout> #include "backend/drivers/cswordbiblemoduleinfo.h" #include "backend/drivers/cswordmoduleinfo.h" - +#include "backend/keys/cswordversekey.h" +#include "frontend/keychooser/bthistory.h" +#include "frontend/keychooser/cscrollbutton.h" +#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h" #include "util/cresmgr.h" -#include <QHBoxLayout> -#include <QDebug> - CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) : CKeyChooser(modules, key, parent), @@ -42,6 +39,7 @@ CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey * setFocusProxy(w_ref); layout->addWidget(w_ref); + connect(w_ref, SIGNAL(beforeChange(CSwordVerseKey *)), SLOT(beforeRefChange(CSwordVerseKey *))); connect(w_ref, SIGNAL(changed(CSwordVerseKey *)), SLOT(refChanged(CSwordVerseKey *))); setKey(m_key); //set the key without changing it, setKey(key()) would change it @@ -63,14 +61,25 @@ void CBibleKeyChooser::setKey(CSwordKey* key) { emit keyChanged(m_key); } +void CBibleKeyChooser::beforeRefChange(CSwordVerseKey* key) { + Q_ASSERT(m_key); + + if (!updatesEnabled()) + return; + + if (m_key) + emit beforeKeyChange(m_key->key()); + +} + void CBibleKeyChooser::refChanged(CSwordVerseKey* key) { Q_ASSERT(m_key); Q_ASSERT(key); - if (!updatesEnabled()) return; + if (!updatesEnabled()) + return; setUpdatesEnabled(false); - if (m_key) emit beforeKeyChange(m_key->key()); m_key = key; emit keyChanged(m_key); diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h index e412e60..9501099 100644 --- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h +++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h @@ -7,16 +7,14 @@ * **********/ - - #ifndef CBIBLEKEYCHOOSER_H #define CBIBLEKEYCHOOSER_H +#include "frontend/keychooser/ckeychooser.h" -#include "../ckeychooser.h" +#include <QList> #include "backend/drivers/cswordbiblemoduleinfo.h" -#include <QList> class QWidget; @@ -57,8 +55,11 @@ class CBibleKeyChooser : public CKeyChooser { */ virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true); /** - * used to react to changes - * @param index not used + * used to do actions before key changes + */ + void beforeRefChange(CSwordVerseKey *key); + /** + * used to do actions after key changes */ void refChanged(CSwordVerseKey *key); diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp index 7cedfc0..067b4db 100644 --- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp +++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp @@ -7,31 +7,26 @@ * **********/ -//BibleTime includes -#include "ckeyreferencewidget.h" +#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h" -#include "../cscrollerwidgetset.h" -#include "btdropdownchooserbutton.h" - -#include "backend/config/cbtconfig.h" - -#include "backend/keys/cswordversekey.h" - -#include "util/cresmgr.h" -#include "util/directoryutil.h" - -//Qt includes #include <QApplication> #include <QDebug> +#include <QEvent> +#include <QFocusEvent> #include <QHBoxLayout> #include <QLineEdit> -#include <QEvent> #include <QMouseEvent> #include <QPixmap> #include <QString> #include <QStringList> #include <QToolButton> -#include <QFocusEvent> +#include "backend/config/cbtconfig.h" +#include "backend/keys/cswordversekey.h" +#include "frontend/keychooser/cscrollerwidgetset.h" +#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h" +#include "util/cresmgr.h" +#include "util/directory.h" + class BtLineEdit : public QLineEdit { public: @@ -54,6 +49,7 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers QWidget(parent), m_key(key), m_dropDownHoverTimer(this) { + namespace DU = util::directory; updatelock = false; m_module = mod; @@ -61,7 +57,7 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers setFocusPolicy(Qt::WheelFocus); QToolButton* clearRef = new QToolButton(this); - clearRef->setIcon(util::filesystem::DirectoryUtil::getIcon("edit_clear_locationbar")); + clearRef->setIcon(DU::getIcon("edit_clear_locationbar")); clearRef->setAutoRaise(true); clearRef->setStyleSheet("QToolButton{margin:0px;}"); connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) ); @@ -243,32 +239,33 @@ void CKeyReferenceWidget::slotUpdateUnlock() { } void CKeyReferenceWidget::slotStepBook(int n) { - CSwordVerseKey key = *m_key; - n > 0 ? key.next( CSwordVerseKey::UseBook ) : key.previous( CSwordVerseKey::UseBook ); + emit beforeChange(m_key); + n > 0 ? m_key->next( CSwordVerseKey::UseBook ) : m_key->previous( CSwordVerseKey::UseBook ); if (!updatelock) - emit changed(&key); // does *m_key = key + emit changed(m_key); updateText(); } void CKeyReferenceWidget::slotStepChapter(int n) { - CSwordVerseKey key = *m_key; - n > 0 ? key.next( CSwordVerseKey::UseChapter ) : key.previous( CSwordVerseKey::UseChapter ); + emit beforeChange(m_key); + n > 0 ? m_key->next( CSwordVerseKey::UseChapter ) : m_key->previous( CSwordVerseKey::UseChapter ); if (!updatelock) - emit changed(&key); // does *m_key = key + emit changed(m_key); updateText(); } void CKeyReferenceWidget::slotStepVerse(int n) { - CSwordVerseKey key = *m_key; - n > 0 ? key.next( CSwordVerseKey::UseVerse ) : key.previous( CSwordVerseKey::UseVerse ); + emit beforeChange(m_key); + n > 0 ? m_key->next( CSwordVerseKey::UseVerse ) : m_key->previous( CSwordVerseKey::UseVerse ); if (!updatelock) - emit changed(&key); // does *m_key = key + emit changed(m_key); updateText(); } void CKeyReferenceWidget::slotChangeVerse(int n) { if (m_key->Verse() != n) { + emit beforeChange(m_key); m_key->Verse( n ); setKey( m_key ); } @@ -278,6 +275,7 @@ void CKeyReferenceWidget::slotChangeVerse(int n) { void CKeyReferenceWidget::slotChangeChapter(int n) { if (m_key->Chapter() != n) { + emit beforeChange(m_key); m_key->Chapter( n ); setKey( m_key ); } @@ -288,6 +286,7 @@ void CKeyReferenceWidget::slotChangeChapter(int n) { void CKeyReferenceWidget::slotChangeBook(QString bookname) { if (m_key->book() != bookname) { + emit beforeChange(m_key); m_key->book( bookname ); setKey( m_key ); } diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h index 95a188e..637530a 100644 --- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h +++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h @@ -10,20 +10,18 @@ #ifndef CKEYREFERENCEWIDGET_H #define CKEYREFERENCEWIDGET_H -#include "../cscrollerwidgetset.h" -#include "backend/drivers/cswordbiblemoduleinfo.h" - #include <QWidget> + #include <QTimer> +#include "backend/drivers/cswordbiblemoduleinfo.h" +#include "frontend/keychooser/cscrollerwidgetset.h" +class BtDropdownChooserButton; class CLexiconKeyChooser; class CSwordVerseKey; -class BtDropdownChooserButton; - class QLineEdit; - class CKeyReferenceWidget : public QWidget { Q_OBJECT public: @@ -37,7 +35,8 @@ class CKeyReferenceWidget : public QWidget { void setModule(CSwordBibleModuleInfo *m = 0); bool eventFilter(QObject *o, QEvent *e); - signals: +signals: + void beforeChange(CSwordVerseKey* key); void changed(CSwordVerseKey* key); protected: |