~ubuntu-branches/ubuntu/trusty/bibletime/trusty

« back to all changes in this revision

Viewing changes to src/frontend/searchdialog/btsearchoptionsarea.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden
  • Date: 2009-11-18 17:30:00 UTC
  • mfrom: (1.3.4 upstream) (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091118173000-endkhjz5qai88tvr
Tags: 2.4-1
* New upstream version 2.4
* debian/control: 
  - Replace incorrect bibletime-data Depends on lib4qt-gui
    with bibletime Depends on libqtgui4 (>= 4.4.0). (Closes: #556209).
  - Add Build-depends: on zlib1g-dev and libcurl4-gnutls-dev 
    (Closes: #556805).

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
*
8
8
**********/
9
9
 
10
 
#include "btsearchoptionsarea.h"
11
 
#include "csearchmodulechooserdialog.h"
12
 
#include "crangechooserdialog.h"
13
 
 
14
 
#include "util/directoryutil.h"
15
 
#include "util/cresmgr.h"
16
 
#include "util/ctoolclass.h"
17
 
#include "util/cpointers.h"
18
 
#include "backend/drivers/cswordmoduleinfo.h"
19
 
#include "backend/config/cbtconfig.h"
20
 
#include "frontend/htmldialogs/bttabhtmldialog.h"
21
 
 
 
10
#include "frontend/searchdialog/btsearchoptionsarea.h"
 
11
 
 
12
#include <QDebug>
 
13
#include <QEvent>
 
14
#include <QGridLayout>
 
15
#include <QGroupBox>
22
16
#include <QHBoxLayout>
23
 
#include <QGroupBox>
24
 
#include <QGridLayout>
25
17
#include <QLabel>
 
18
#include <QLineEdit>
 
19
#include <QMessageBox>
26
20
#include <QPushButton>
27
21
#include <QRadioButton>
28
 
#include <QDebug>
29
 
#include <QLineEdit>
30
 
#include <QMessageBox>
31
 
#include <QEvent>
 
22
#include "backend/config/cbtconfig.h"
 
23
#include "backend/drivers/cswordmoduleinfo.h"
 
24
#include "frontend/htmldialogs/bttabhtmldialog.h"
 
25
#include "frontend/searchdialog/crangechooserdialog.h"
 
26
#include "frontend/searchdialog/csearchmodulechooserdialog.h"
 
27
#include "util/cpointers.h"
 
28
#include "util/cresmgr.h"
 
29
#include "util/tool.h"
 
30
#include "util/directory.h"
32
31
 
33
32
 
34
33
namespace Search {
35
34
 
36
35
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
37
 
        : QWidget(parent)
38
 
{
39
 
        initView();
40
 
        initConnections();
41
 
        readSettings();
 
36
        : QWidget(parent) {
 
37
    initView();
 
38
    initConnections();
 
39
    readSettings();
42
40
}
43
41
 
44
42
BtSearchOptionsArea::~BtSearchOptionsArea() {
45
 
        saveSettings();
 
43
    saveSettings();
46
44
}
47
45
 
48
46
QString BtSearchOptionsArea::searchText() const {
49
 
        return m_searchTextCombo->currentText();
 
47
    return m_searchTextCombo->currentText();
50
48
}
51
49
 
52
 
BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType()
53
 
{
54
 
        if (m_typeAndButton->isChecked()) {
55
 
                return BtSearchOptionsArea::AndType;
56
 
        }
57
 
        if (m_typeOrButton->isChecked()) {
58
 
                return BtSearchOptionsArea::OrType;
59
 
        }
60
 
        return BtSearchOptionsArea::FullType;
 
50
BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType() {
 
51
    if (m_typeAndButton->isChecked()) {
 
52
        return BtSearchOptionsArea::AndType;
 
53
    }
 
54
    if (m_typeOrButton->isChecked()) {
 
55
        return BtSearchOptionsArea::OrType;
 
56
    }
 
57
    return BtSearchOptionsArea::FullType;
61
58
}
62
59
 
63
60
QPushButton* BtSearchOptionsArea::searchButton() const {
64
 
        return m_searchButton;
 
61
    return m_searchButton;
65
62
}
66
63
 
67
64
void BtSearchOptionsArea::setSearchText(const QString& text) {
68
 
        bool found = false;
69
 
        int i = 0;
70
 
        for (i = 0; !found && i < m_searchTextCombo->count(); ++i) {
71
 
                if (m_searchTextCombo->itemText(i) == text) {
72
 
                        found = true;
73
 
                }
74
 
        }
75
 
   // This is needed because in the for loop i is incremented before the comparison (++i)
76
 
   // As a result the index i is actually one greater than expected.
77
 
   i--;
78
 
        if (!found) {
79
 
                i = 0;
80
 
                m_searchTextCombo->insertItem(0, text );
81
 
        }
 
65
    bool found = false;
 
66
    int i = 0;
 
67
    for (i = 0; !found && i < m_searchTextCombo->count(); ++i) {
 
68
        if (m_searchTextCombo->itemText(i) == text) {
 
69
            found = true;
 
70
        }
 
71
    }
 
72
    // This is needed because in the for loop i is incremented before the comparison (++i)
 
73
    // As a result the index i is actually one greater than expected.
 
74
    i--;
 
75
    if (!found) {
 
76
        i = 0;
 
77
        m_searchTextCombo->insertItem(0, text );
 
78
    }
82
79
 
83
 
        m_searchTextCombo->setCurrentIndex(i);
84
 
        m_searchTextCombo->setFocus();
 
80
    m_searchTextCombo->setCurrentIndex(i);
 
81
    m_searchTextCombo->setFocus();
85
82
}
86
83
 
87
 
void BtSearchOptionsArea::initView()
88
 
{
89
 
        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
90
 
        this->setSizePolicy(sizePolicy);
91
 
        hboxLayout = new QHBoxLayout(this);
92
 
 
93
 
        searchGroupBox = new QGroupBox(this);
94
 
 
95
 
        gridLayout = new QGridLayout(searchGroupBox);
96
 
 
97
 
        gridLayout->setHorizontalSpacing(3);
98
 
 
99
 
        // ******** label for search text editor***********
 
84
void BtSearchOptionsArea::initView() {
 
85
    namespace DU = util::directory;
 
86
 
 
87
    QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
 
88
    this->setSizePolicy(sizePolicy);
 
89
    hboxLayout = new QHBoxLayout(this);
 
90
 
 
91
    searchGroupBox = new QGroupBox(this);
 
92
 
 
93
    gridLayout = new QGridLayout(searchGroupBox);
 
94
 
 
95
    gridLayout->setHorizontalSpacing(3);
 
96
 
 
97
    // ******** label for search text editor***********
100
98
    m_searchTextLabel = new QLabel(tr("Search for:"), searchGroupBox);
101
 
        m_searchTextLabel->setWordWrap(false);
102
 
        gridLayout->addWidget(m_searchTextLabel, 0, 0);
103
 
 
104
 
        // **********Buttons******************
105
 
 
106
 
        m_searchButton = new QPushButton(this);
107
 
        m_searchButton->setText(tr("&Search"));
108
 
        m_searchButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::icon));
109
 
        m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
110
 
        gridLayout->addWidget(m_searchButton, 0, 2);
111
 
 
112
 
        m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
113
 
        m_chooseModulesButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::chooseworks_icon));
114
 
        m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
115
 
        gridLayout->addWidget(m_chooseModulesButton, 2, 2);
116
 
 
117
 
        m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
118
 
        m_chooseRangeButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::searchdialog::setupscope_icon));
119
 
        m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
120
 
        gridLayout->addWidget(m_chooseRangeButton, 3, 2);
121
 
 
122
 
        // ************* Search type (AND/OR) selector ***************************************
123
 
        QHBoxLayout* typeSelectorLayout = new QHBoxLayout();
124
 
        int tsLeft, tsTop, tsRight, tsBottom;
125
 
        // Added space looks nicer and enhances readability
126
 
        typeSelectorLayout->getContentsMargins(&tsLeft, &tsTop, &tsRight, &tsBottom);
127
 
        typeSelectorLayout->setContentsMargins(tsLeft, 0, tsRight, tsBottom + CToolClass::mWidth(this,1) );
128
 
        typeSelectorLayout->setSpacing(typeSelectorLayout->spacing()+CToolClass::mWidth(this,1));
129
 
        QHBoxLayout* fullButtonLayout = new QHBoxLayout();
130
 
        fullButtonLayout->setSpacing(CToolClass::mWidth(this,1)/2);
131
 
        m_typeAndButton = new QRadioButton(tr("All words"));
132
 
        m_typeAndButton->setChecked(true);
133
 
        m_typeOrButton = new QRadioButton(tr("Some words"));
134
 
        m_typeFreeButton = new QRadioButton(tr("Free"));
135
 
 
136
 
        m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
137
 
        m_typeOrButton->setToolTip(tr("Some of the words (OR is added between the words)"));
138
 
        m_typeFreeButton->setToolTip(tr("Full lucene syntax"));
139
 
 
140
 
        m_helpLabel = new QLabel(tr(" (<a href='syntax_help'>full syntax</a>)"));
141
 
        m_helpLabel->setToolTip(tr("Click the link to get help for search syntax"));
142
 
 
143
 
        typeSelectorLayout->addWidget(m_typeAndButton);
144
 
        typeSelectorLayout->addWidget(m_typeOrButton);
145
 
        fullButtonLayout->addWidget(m_typeFreeButton);
146
 
        fullButtonLayout->addWidget(m_helpLabel);
147
 
        typeSelectorLayout->addLayout(fullButtonLayout);
148
 
        gridLayout->addLayout(typeSelectorLayout, 1,1, 1,-1, Qt::AlignLeft|Qt::AlignTop);
149
 
 
150
 
        // ************* Label for search range/scope selector *************
151
 
        m_searchScopeLabel = new QLabel(tr("Scope:"), searchGroupBox);
152
 
        m_searchScopeLabel->setWordWrap(false);
153
 
        gridLayout->addWidget(m_searchScopeLabel, 3, 0);
154
 
 
155
 
        // ***********Range/scope selector combo box***********
156
 
        m_rangeChooserCombo = new QComboBox(searchGroupBox);
157
 
        QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed);
158
 
        sizePolicy2.setHorizontalStretch(0);
159
 
        sizePolicy2.setVerticalStretch(0);
160
 
        sizePolicy2.setHeightForWidth(m_rangeChooserCombo->sizePolicy().hasHeightForWidth());
161
 
        m_rangeChooserCombo->setSizePolicy(sizePolicy2);
162
 
        m_rangeChooserCombo->setToolTip(tr("Choose the scope (books/chapters/verses to search in).<br />Applicable for Bibles and commentaries."));
163
 
        gridLayout->addWidget(m_rangeChooserCombo, 3, 1);
164
 
 
165
 
        // ************* Search text combo box *******************
166
 
        m_searchTextCombo = new CHistoryComboBox(searchGroupBox);
167
 
        sizePolicy2.setHeightForWidth(m_searchTextCombo->sizePolicy().hasHeightForWidth());
168
 
        m_searchTextCombo->setSizePolicy(sizePolicy2);
169
 
        m_searchTextCombo->setFocusPolicy(Qt::WheelFocus);
170
 
        m_searchTextCombo->setProperty("sizeLimit", QVariant(25));
171
 
        m_searchTextCombo->setProperty("duplicatesEnabled", QVariant(false));
172
 
        m_searchTextCombo->setToolTip(tr("The text you want to search for"));
173
 
        m_searchTextCombo->setInsertPolicy(QComboBox::NoInsert);
174
 
        gridLayout->addWidget(m_searchTextCombo, 0, 1);
175
 
 
176
 
        m_modulesLabel = new QLabel(tr("Works:"), searchGroupBox);
177
 
        gridLayout->addWidget(m_modulesLabel, 2, 0);
178
 
 
179
 
        m_modulesCombo = new QComboBox(searchGroupBox);
180
 
        m_modulesCombo->setDuplicatesEnabled(false);
181
 
        gridLayout->addWidget(m_modulesCombo, 2, 1);
182
 
 
183
 
        hboxLayout->addWidget(searchGroupBox);
184
 
 
185
 
        // Set the minimum size before the widgets are populated with data.
186
 
        // Otherwise we will get problems with sizing.
187
 
        setMinimumSize(minimumSizeHint());
188
 
 
189
 
        refreshRanges();
190
 
        //set the initial focus
191
 
        m_searchTextCombo->setFocus();
192
 
        // event filter to prevent the Return/Enter presses in the combo box doing something
193
 
        // in the parent widget
194
 
        m_searchTextCombo->installEventFilter(this);
 
99
    m_searchTextLabel->setWordWrap(false);
 
100
    gridLayout->addWidget(m_searchTextLabel, 0, 0);
 
101
 
 
102
    // **********Buttons******************
 
103
 
 
104
    m_searchButton = new QPushButton(this);
 
105
    m_searchButton->setText(tr("&Search"));
 
106
    m_searchButton->setIcon(DU::getIcon(CResMgr::searchdialog::icon));
 
107
    m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
 
108
    gridLayout->addWidget(m_searchButton, 0, 2);
 
109
 
 
110
    m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
 
111
    m_chooseModulesButton->setIcon(DU::getIcon(CResMgr::searchdialog::chooseworks_icon));
 
112
    m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
 
113
    gridLayout->addWidget(m_chooseModulesButton, 2, 2);
 
114
 
 
115
    m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
 
116
    m_chooseRangeButton->setIcon(DU::getIcon(CResMgr::searchdialog::setupscope_icon));
 
117
    m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
 
118
    gridLayout->addWidget(m_chooseRangeButton, 3, 2);
 
119
 
 
120
    // ************* Search type (AND/OR) selector ***************************************
 
121
    QHBoxLayout* typeSelectorLayout = new QHBoxLayout();
 
122
    int tsLeft, tsTop, tsRight, tsBottom;
 
123
    // Added space looks nicer and enhances readability
 
124
    typeSelectorLayout->getContentsMargins(&tsLeft, &tsTop, &tsRight, &tsBottom);
 
125
    typeSelectorLayout->setContentsMargins(tsLeft, 0, tsRight, tsBottom + util::tool::mWidth(this, 1) );
 
126
    typeSelectorLayout->setSpacing(typeSelectorLayout->spacing() + util::tool::mWidth(this, 1));
 
127
    QHBoxLayout* fullButtonLayout = new QHBoxLayout();
 
128
    fullButtonLayout->setSpacing(util::tool::mWidth(this, 1) / 2);
 
129
    m_typeAndButton = new QRadioButton(tr("All words"));
 
130
    m_typeAndButton->setChecked(true);
 
131
    m_typeOrButton = new QRadioButton(tr("Some words"));
 
132
    m_typeFreeButton = new QRadioButton(tr("Free"));
 
133
 
 
134
    m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
 
135
    m_typeOrButton->setToolTip(tr("Some of the words (OR is added between the words)"));
 
136
    m_typeFreeButton->setToolTip(tr("Full lucene syntax"));
 
137
 
 
138
    m_helpLabel = new QLabel(tr(" (<a href='syntax_help'>full syntax</a>)"));
 
139
    m_helpLabel->setToolTip(tr("Click the link to get help for search syntax"));
 
140
 
 
141
    typeSelectorLayout->addWidget(m_typeAndButton);
 
142
    typeSelectorLayout->addWidget(m_typeOrButton);
 
143
    fullButtonLayout->addWidget(m_typeFreeButton);
 
144
    fullButtonLayout->addWidget(m_helpLabel);
 
145
    typeSelectorLayout->addLayout(fullButtonLayout);
 
146
    gridLayout->addLayout(typeSelectorLayout, 1, 1, 1, -1, Qt::AlignLeft | Qt::AlignTop);
 
147
 
 
148
    // ************* Label for search range/scope selector *************
 
149
    m_searchScopeLabel = new QLabel(tr("Scope:"), searchGroupBox);
 
150
    m_searchScopeLabel->setWordWrap(false);
 
151
    gridLayout->addWidget(m_searchScopeLabel, 3, 0);
 
152
 
 
153
    // ***********Range/scope selector combo box***********
 
154
    m_rangeChooserCombo = new QComboBox(searchGroupBox);
 
155
    QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed);
 
156
    sizePolicy2.setHorizontalStretch(0);
 
157
    sizePolicy2.setVerticalStretch(0);
 
158
    sizePolicy2.setHeightForWidth(m_rangeChooserCombo->sizePolicy().hasHeightForWidth());
 
159
    m_rangeChooserCombo->setSizePolicy(sizePolicy2);
 
160
    m_rangeChooserCombo->setToolTip(tr("Choose the scope (books/chapters/verses to search in).<br />Applicable for Bibles and commentaries."));
 
161
    gridLayout->addWidget(m_rangeChooserCombo, 3, 1);
 
162
 
 
163
    // ************* Search text combo box *******************
 
164
    m_searchTextCombo = new CHistoryComboBox(searchGroupBox);
 
165
    sizePolicy2.setHeightForWidth(m_searchTextCombo->sizePolicy().hasHeightForWidth());
 
166
    m_searchTextCombo->setSizePolicy(sizePolicy2);
 
167
    m_searchTextCombo->setFocusPolicy(Qt::WheelFocus);
 
168
    m_searchTextCombo->setProperty("sizeLimit", QVariant(25));
 
169
    m_searchTextCombo->setProperty("duplicatesEnabled", QVariant(false));
 
170
    m_searchTextCombo->setToolTip(tr("The text you want to search for"));
 
171
    m_searchTextCombo->setInsertPolicy(QComboBox::NoInsert);
 
172
    gridLayout->addWidget(m_searchTextCombo, 0, 1);
 
173
 
 
174
    m_modulesLabel = new QLabel(tr("Works:"), searchGroupBox);
 
175
    gridLayout->addWidget(m_modulesLabel, 2, 0);
 
176
 
 
177
    m_modulesCombo = new QComboBox(searchGroupBox);
 
178
    m_modulesCombo->setDuplicatesEnabled(false);
 
179
    gridLayout->addWidget(m_modulesCombo, 2, 1);
 
180
 
 
181
    hboxLayout->addWidget(searchGroupBox);
 
182
 
 
183
    // Set the minimum size before the widgets are populated with data.
 
184
    // Otherwise we will get problems with sizing.
 
185
    setMinimumSize(minimumSizeHint());
 
186
 
 
187
    refreshRanges();
 
188
    //set the initial focus
 
189
    m_searchTextCombo->setFocus();
 
190
    // event filter to prevent the Return/Enter presses in the combo box doing something
 
191
    // in the parent widget
 
192
    m_searchTextCombo->installEventFilter(this);
195
193
}
196
194
 
197
 
void BtSearchOptionsArea::initConnections()
198
 
{
199
 
        QObject::connect( m_searchTextCombo->lineEdit(), SIGNAL(returnPressed ()),
200
 
                                this, SLOT( slotSearchTextEditReturnPressed() )
201
 
                        );
202
 
        connect(m_chooseModulesButton, SIGNAL(clicked()), this, SLOT(chooseModules()));
203
 
        connect(m_chooseRangeButton, SIGNAL(clicked()), this, SLOT(setupRanges()));
204
 
        connect(m_modulesCombo, SIGNAL(activated(int)), this, SLOT(moduleListTextSelected(int) ) );
205
 
        connect(m_helpLabel, SIGNAL(linkActivated(QString)), this, SLOT(syntaxHelp()));
206
 
        connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
 
195
void BtSearchOptionsArea::initConnections() {
 
196
    QObject::connect( m_searchTextCombo->lineEdit(), SIGNAL(returnPressed ()),
 
197
                      this, SLOT( slotSearchTextEditReturnPressed() )
 
198
                    );
 
199
    connect(m_chooseModulesButton, SIGNAL(clicked()), this, SLOT(chooseModules()));
 
200
    connect(m_chooseRangeButton, SIGNAL(clicked()), this, SLOT(setupRanges()));
 
201
    connect(m_modulesCombo, SIGNAL(activated(int)), this, SLOT(moduleListTextSelected(int) ) );
 
202
    connect(m_helpLabel, SIGNAL(linkActivated(QString)), this, SLOT(syntaxHelp()));
 
203
    connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
207
204
}
208
205
 
209
206
/** Sets the modules used by the search. */
210
 
void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules )
211
 
{
212
 
        qDebug("BtSearchOptionsArea::setModules");
213
 
        qDebug() << modules;
214
 
        QString t;
215
 
 
216
 
        m_modules.clear(); //remove old modules
217
 
        QList<CSwordModuleInfo*>::iterator end_it = modules.end();
218
 
 
219
 
        for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
220
 
                //ToDo:  Check for containsRef compat
221
 
                if (*it == 0) { //don't operate on null modules.
222
 
                        continue;
223
 
                }
224
 
                qDebug() << "new module:" << (*it)->name();
225
 
                if ( !m_modules.contains(*it) ) {
226
 
                        m_modules.append( *it );
227
 
                        t.append( (*it)->name() );
228
 
                        if (*it != modules.last()) {
229
 
                                t += QString::fromLatin1(", "); // so that it will become a readable list (WLC, LXX, GerLut...)
230
 
                        }
231
 
                }
232
 
        };
233
 
        //m_modulesLabel->setText(t);
234
 
        int existingIndex = m_modulesCombo->findText(t);
235
 
        qDebug() << "index of the module list string which already exists in combobox:" << existingIndex;
236
 
        if (existingIndex >= 0) {
237
 
                m_modulesCombo->removeItem(existingIndex);
238
 
        }
239
 
        if (m_modulesCombo->count() > 10) {
240
 
                m_modulesCombo->removeItem(m_modulesCombo->count()-1);
241
 
        }
242
 
        m_modulesCombo->insertItem(0, t);
243
 
        m_modulesCombo->setItemData(0, t, Qt::ToolTipRole);
244
 
        m_modulesCombo->setCurrentIndex(0);
245
 
        m_modulesCombo->setToolTip(t);
246
 
        //Save the list in config here, not when deleting, because the history may be used
247
 
        // elsewhere while the dialog is still open
248
 
        QStringList historyList;
249
 
        for (int i = 0; i < m_modulesCombo->count(); ++i) {
250
 
                historyList.append(m_modulesCombo->itemText(i));
251
 
        }
252
 
        CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
253
 
        emit( sigSetSearchButtonStatus( (modules.count() != 0) ) );
 
207
void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules ) {
 
208
    qDebug() << "BtSearchOptionsArea::setModules";
 
209
    qDebug() << modules;
 
210
    QString t;
 
211
 
 
212
    m_modules.clear(); //remove old modules
 
213
    QList<CSwordModuleInfo*>::iterator end_it = modules.end();
 
214
 
 
215
    for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
 
216
        /// \todo Check for containsRef compat
 
217
        if (*it == 0) { //don't operate on null modules.
 
218
            continue;
 
219
        }
 
220
        qDebug() << "new module:" << (*it)->name();
 
221
        if ( !m_modules.contains(*it) ) {
 
222
            m_modules.append( *it );
 
223
            t.append( (*it)->name() );
 
224
            if (*it != modules.last()) {
 
225
                t += QString::fromLatin1(", "); // so that it will become a readable list (WLC, LXX, GerLut...)
 
226
            }
 
227
        }
 
228
    };
 
229
    //m_modulesLabel->setText(t);
 
230
    int existingIndex = m_modulesCombo->findText(t);
 
231
    qDebug() << "index of the module list string which already exists in combobox:" << existingIndex;
 
232
    if (existingIndex >= 0) {
 
233
        m_modulesCombo->removeItem(existingIndex);
 
234
    }
 
235
    if (m_modulesCombo->count() > 10) {
 
236
        m_modulesCombo->removeItem(m_modulesCombo->count() - 1);
 
237
    }
 
238
    m_modulesCombo->insertItem(0, t);
 
239
    m_modulesCombo->setItemData(0, t, Qt::ToolTipRole);
 
240
    m_modulesCombo->setCurrentIndex(0);
 
241
    m_modulesCombo->setToolTip(t);
 
242
    //Save the list in config here, not when deleting, because the history may be used
 
243
    // elsewhere while the dialog is still open
 
244
    QStringList historyList;
 
245
    for (int i = 0; i < m_modulesCombo->count(); ++i) {
 
246
        historyList.append(m_modulesCombo->itemText(i));
 
247
    }
 
248
    CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
 
249
    emit sigSetSearchButtonStatus(modules.count() != 0);
254
250
}
255
251
 
256
252
// Catch activated signal of module selector combobox
257
 
void BtSearchOptionsArea::moduleListTextSelected(int index)
258
 
{
259
 
        qDebug("BtSearchOptionsArea::moduleListTextSelected");
260
 
        //create the module list
261
 
        QString text = m_modulesCombo->itemText(index);
262
 
        qDebug() << text;
263
 
        QStringList moduleNamesList = text.split(", ");
264
 
        QList<CSwordModuleInfo*> moduleList;
265
 
        foreach(QString name, moduleNamesList) {
266
 
                moduleList.append(CPointers::backend()->findModuleByName(name));
267
 
        }
268
 
        //set the list and the combobox list and text
269
 
        setModules(moduleList);
 
253
void BtSearchOptionsArea::moduleListTextSelected(int index) {
 
254
    qDebug() << "BtSearchOptionsArea::moduleListTextSelected";
 
255
    //create the module list
 
256
    QString text = m_modulesCombo->itemText(index);
 
257
    qDebug() << text;
 
258
    QStringList moduleNamesList = text.split(", ");
 
259
    QList<CSwordModuleInfo*> moduleList;
 
260
    foreach(QString name, moduleNamesList) {
 
261
        moduleList.append(CPointers::backend()->findModuleByName(name));
 
262
    }
 
263
    //set the list and the combobox list and text
 
264
    setModules(moduleList);
270
265
}
271
266
 
272
267
void BtSearchOptionsArea::chooseModules() {
273
 
        QString title(tr("Works to Search in"));
274
 
        QString label(tr("Select the works which should be searched."));
275
 
        CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
276
 
        connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
277
 
        dlg->exec();
 
268
    QString title(tr("Works to Search in"));
 
269
    QString label(tr("Select the works which should be searched."));
 
270
    CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
 
271
    connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
 
272
    dlg->exec();
278
273
}
279
274
 
280
275
QList<CSwordModuleInfo*> BtSearchOptionsArea::modules() const {
281
 
        return m_modules;
 
276
    return m_modules;
282
277
}
283
278
 
284
279
void BtSearchOptionsArea::reset() {
285
 
        m_rangeChooserCombo->setCurrentIndex(0);
286
 
        m_searchTextCombo->clearEditText();
 
280
    m_rangeChooserCombo->setCurrentIndex(0);
 
281
    m_searchTextCombo->clearEditText();
287
282
}
288
283
 
289
284
void BtSearchOptionsArea::saveSettings() {
290
 
        CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
291
 
        SearchType t = FullType;
292
 
        if (m_typeAndButton->isChecked()) {
293
 
                t = AndType;
294
 
        }
295
 
        if (m_typeOrButton->isChecked()) {
296
 
                t = OrType;
297
 
        }
298
 
        CBTConfig::set(CBTConfig::searchType, t);
 
285
    CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
 
286
    SearchType t = FullType;
 
287
    if (m_typeAndButton->isChecked()) {
 
288
        t = AndType;
 
289
    }
 
290
    if (m_typeOrButton->isChecked()) {
 
291
        t = OrType;
 
292
    }
 
293
    CBTConfig::set(CBTConfig::searchType, t);
299
294
}
300
295
 
301
296
void BtSearchOptionsArea::readSettings() {
302
 
        QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
303
 
        //for some reason the slot was called when setting the upmost item
304
 
        disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
305
 
        for (int i=0; i<texts.size(); i++)
306
 
        {
307
 
                if (texts.at(i).size() > 0)
308
 
                        m_searchTextCombo->addItem(texts.at(i));
309
 
        }
310
 
        connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
311
 
 
312
 
        m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
313
 
        for (int i = 0; i < m_modulesCombo->count(); ++i) {
314
 
                m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
315
 
        }
316
 
 
317
 
        int stype = CBTConfig::get(CBTConfig::searchType);
318
 
        switch (stype) {
319
 
                case AndType: m_typeAndButton->setChecked(true);
320
 
                break;
321
 
                case OrType: m_typeOrButton->setChecked(true);
322
 
                break;
323
 
                default: m_typeFreeButton->setChecked(true);
324
 
        }
 
297
    QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
 
298
    //for some reason the slot was called when setting the upmost item
 
299
    disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
 
300
    for (int i = 0; i < texts.size(); i++) {
 
301
        if (texts.at(i).size() > 0)
 
302
            m_searchTextCombo->addItem(texts.at(i));
 
303
    }
 
304
    connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
 
305
 
 
306
    m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
 
307
    for (int i = 0; i < m_modulesCombo->count(); ++i) {
 
308
        m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
 
309
    }
 
310
 
 
311
    int stype = CBTConfig::get(CBTConfig::searchType);
 
312
    switch (stype) {
 
313
        case AndType:
 
314
            m_typeAndButton->setChecked(true);
 
315
            break;
 
316
        case OrType:
 
317
            m_typeOrButton->setChecked(true);
 
318
            break;
 
319
        default:
 
320
            m_typeFreeButton->setChecked(true);
 
321
    }
325
322
}
326
323
 
327
324
void BtSearchOptionsArea::aboutToShow() {
328
 
        m_searchTextCombo->setFocus();
 
325
    m_searchTextCombo->setFocus();
329
326
}
330
327
 
331
328
void BtSearchOptionsArea::setupRanges() {
332
 
        CRangeChooserDialog* chooser = new CRangeChooserDialog(this);
333
 
        chooser->exec();
 
329
    CRangeChooserDialog* chooser = new CRangeChooserDialog(this);
 
330
    chooser->exec();
334
331
 
335
 
        refreshRanges();
 
332
    refreshRanges();
336
333
}
337
334
 
338
335
void BtSearchOptionsArea::syntaxHelp() {
339
336
 
340
 
        QString style = QString(
341
 
        "<style type='text/css'>"
342
 
        "h1 a {font-size: medium}"
343
 
        "table {margin-left: 20px}"
344
 
        "td {"
345
 
        "       border-width: 3px 3px 3px 3px;"
346
 
        "       border-style: solid solid solid solid;"
347
 
        "       border-color: white white white white;"
348
 
        "       background-color: #faf0e6;"
349
 
        "}"
350
 
        "p#links {margin-left: 20px}"
351
 
        "</style>");
352
 
        
353
 
        //: Don't translate words inside <> tags!
354
 
        //: Translate 'All words' etc. indentically to the Search dialog options.
355
 
        QString intro = tr(
356
 
        "<p>"
357
 
        "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
358
 
        "</p>");
359
 
        
360
 
        QString links = tr(
361
 
        "<p id='links'>"
362
 
        "<A href='#allsome'>Which words to find</A><br />"
363
 
        "<A href='#grouping'>Grouping and order</A><br />"
364
 
        "<A href='#wildcards'>Wildcards (partial words)</A><br />"
365
 
        "<A href='#fields'>Text fields (different parts of text)</A><br/>"
366
 
        "<A href='#lucene'>Other syntax features</A><br/>"
367
 
        "</p>");
368
 
        
369
 
        //: Syntax words (AND, OR...) must not be translated.
370
 
        QString whichwords = tr(
371
 
        "<h1><A name='allsome'>Which words to find</A></h1>"
372
 
        "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
373
 
        
374
 
        //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
375
 
        QString whichwordstable = tr(
376
 
        "<p><table><tr>"
377
 
        "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
378
 
        "</tr><tr>"
379
 
        "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
380
 
        "</tr><tr>"
381
 
        "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
382
 
        "</tr><tr>"
383
 
        "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
384
 
        "</tr></table></p>");
385
 
        
386
 
        QString grouping = tr(
387
 
        "<h1><A name='grouping'>Grouping and order</A></h1>"
388
 
        "<p>Words can be grouped with <strong>parenthesis</strong>. "
389
 
        "Strict word order can be defined with <strong>quotes</strong>.</p>");
390
 
        
391
 
        QString groupingtable = tr(
392
 
        "<p><table><tr>"
393
 
        "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
394
 
        "</tr><tr>"
395
 
        "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
396
 
        "</tr><tr>"
397
 
        "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
398
 
        "</tr></table></p>");
399
 
        
400
 
        QString wildcards = tr(
401
 
        "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
402
 
        "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
403
 
        
404
 
        QString wildcardstable = tr(
405
 
        "<p><table><tr>"
406
 
        "<td>a*</td><td>All words beginning with 'a'</td>"
407
 
        "</tr><tr>"
408
 
        "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
409
 
        "</tr><tr>"
410
 
        "<td>a?</td><td>'at' and 'an'</td>"
411
 
        "</tr><tr>"
412
 
        "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
413
 
        "</tr></table></p>");
414
 
        
415
 
        QString fields = tr(
416
 
        "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
417
 
        "<p>Available text fields:<br /><table>"
418
 
        "<tr><td>heading:</td><td>Searches headings</td></tr>"
419
 
        "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
420
 
        "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
421
 
        "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
422
 
        
423
 
        QString fieldstable = tr(
424
 
        "<p>Examples:<br /><table>"
425
 
        "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
426
 
        "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
427
 
        "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
428
 
        "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
429
 
        "</tr></table></p>");
430
 
        
431
 
        QString lucene = tr(
432
 
        "<h1><A name='lucene'>Other syntax features</A></h1>"
433
 
        "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
434
 
 
435
 
        QString syntax = style + intro + links + whichwords + whichwordstable +
436
 
                grouping + groupingtable + wildcards + wildcardstable +
437
 
                fields + fieldstable + lucene;
438
 
 
439
 
        BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
440
 
        dlg->setHtml(syntax);
441
 
        dlg->show();
 
337
    QString style = QString(
 
338
                        "<style type='text/css'>"
 
339
                        "h1 a {font-size: medium}"
 
340
                        "table {margin-left: 20px}"
 
341
                        "td {"
 
342
                        "       border-width: 3px 3px 3px 3px;"
 
343
                        "       border-style: solid solid solid solid;"
 
344
                        "       border-color: white white white white;"
 
345
                        "       background-color: #faf0e6;"
 
346
                        "}"
 
347
                        "p#links {margin-left: 20px}"
 
348
                        "</style>");
 
349
 
 
350
    //: Don't translate words inside <> tags!
 
351
    //: Translate 'All words' etc. indentically to the Search dialog options.
 
352
    QString intro = tr(
 
353
                        "<p>"
 
354
                        "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
 
355
                        "</p>");
 
356
 
 
357
    QString links = tr(
 
358
                        "<p id='links'>"
 
359
                        "<A href='#allsome'>Which words to find</A><br />"
 
360
                        "<A href='#grouping'>Grouping and order</A><br />"
 
361
                        "<A href='#wildcards'>Wildcards (partial words)</A><br />"
 
362
                        "<A href='#fields'>Text fields (different parts of text)</A><br/>"
 
363
                        "<A href='#lucene'>Other syntax features</A><br/>"
 
364
                        "</p>");
 
365
 
 
366
    //: Syntax words (AND, OR...) must not be translated.
 
367
    QString whichwords = tr(
 
368
                             "<h1><A name='allsome'>Which words to find</A></h1>"
 
369
                             "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
 
370
 
 
371
    //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
 
372
    QString whichwordstable = tr(
 
373
                                  "<p><table><tr>"
 
374
                                  "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
 
375
                                  "</tr><tr>"
 
376
                                  "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
 
377
                                  "</tr><tr>"
 
378
                                  "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
 
379
                                  "</tr><tr>"
 
380
                                  "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
 
381
                                  "</tr></table></p>");
 
382
 
 
383
    QString grouping = tr(
 
384
                           "<h1><A name='grouping'>Grouping and order</A></h1>"
 
385
                           "<p>Words can be grouped with <strong>parenthesis</strong>. "
 
386
                           "Strict word order can be defined with <strong>quotes</strong>.</p>");
 
387
 
 
388
    QString groupingtable = tr(
 
389
                                "<p><table><tr>"
 
390
                                "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
 
391
                                "</tr><tr>"
 
392
                                "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
 
393
                                "</tr><tr>"
 
394
                                "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
 
395
                                "</tr></table></p>");
 
396
 
 
397
    QString wildcards = tr(
 
398
                            "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
 
399
                            "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
 
400
 
 
401
    QString wildcardstable = tr(
 
402
                                 "<p><table><tr>"
 
403
                                 "<td>a*</td><td>All words beginning with 'a'</td>"
 
404
                                 "</tr><tr>"
 
405
                                 "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
 
406
                                 "</tr><tr>"
 
407
                                 "<td>a?</td><td>'at' and 'an'</td>"
 
408
                                 "</tr><tr>"
 
409
                                 "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
 
410
                                 "</tr></table></p>");
 
411
 
 
412
    QString fields = tr(
 
413
                         "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
 
414
                         "<p>Available text fields:<br /><table>"
 
415
                         "<tr><td>heading:</td><td>Searches headings</td></tr>"
 
416
                         "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
 
417
                         "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
 
418
                         "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
 
419
 
 
420
    QString fieldstable = tr(
 
421
                              "<p>Examples:<br /><table>"
 
422
                              "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
 
423
                              "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
 
424
                              "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
 
425
                              "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
 
426
                              "</tr></table></p>");
 
427
 
 
428
    QString lucene = tr(
 
429
                         "<h1><A name='lucene'>Other syntax features</A></h1>"
 
430
                         "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
 
431
 
 
432
    QString syntax = style + intro + links + whichwords + whichwordstable +
 
433
                     grouping + groupingtable + wildcards + wildcardstable +
 
434
                     fields + fieldstable + lucene;
 
435
 
 
436
    BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
 
437
    dlg->setHtml(syntax);
 
438
    dlg->show();
442
439
}
443
440
 
444
441
void BtSearchOptionsArea::refreshRanges() {
445
 
        //the first option is fixed, the others can be edited using the "Setup ranges" button.
446
 
        m_rangeChooserCombo->clear();
447
 
        m_rangeChooserCombo->insertItem(0, QString("[") + tr("No search scope") + QString("]"));
448
 
        //TODO: what about this?
449
 
        //m_rangeChooserCombo->insertItem(tr("Last search result"));
 
442
    //the first option is fixed, the others can be edited using the "Setup ranges" button.
 
443
    m_rangeChooserCombo->clear();
 
444
    m_rangeChooserCombo->insertItem(0, QString("[") + tr("No search scope") + QString("]"));
 
445
    /// \todo what about this?
 
446
    //m_rangeChooserCombo->insertItem(tr("Last search result"));
450
447
 
451
 
        //insert the user-defined ranges
452
 
        m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
 
448
    //insert the user-defined ranges
 
449
    m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
453
450
 
454
451
}
455
452
 
456
453
sword::ListKey BtSearchOptionsArea::searchScope() {
457
 
        if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
458
 
                CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
459
 
                QString scope = map[ m_rangeChooserCombo->currentText() ];
460
 
                if (!scope.isEmpty()) {
461
 
                        return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
462
 
                }
463
 
        }
464
 
        return sword::ListKey();
 
454
    if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
 
455
        CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
 
456
        QString scope = map[ m_rangeChooserCombo->currentText() ];
 
457
        if (!scope.isEmpty()) {
 
458
            return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
 
459
        }
 
460
    }
 
461
    return sword::ListKey();
465
462
}
466
463
 
467
464
bool BtSearchOptionsArea::hasSearchScope() {
468
 
        return (searchScope().Count() > 0);
469
 
}
470
 
 
471
 
void BtSearchOptionsArea::addToHistory(const QString& text)
472
 
{
473
 
        m_searchTextCombo->addToHistory(text);
474
 
}
475
 
 
476
 
void BtSearchOptionsArea::slotSearchTextEditReturnPressed()
477
 
{
478
 
        qDebug("BtSearchOptionsArea::slotSearchTextEditReturnPressed");
479
 
        m_searchTextCombo->addToHistory( m_searchTextCombo->currentText() );
480
 
        emit sigStartSearch();
481
 
}
482
 
 
483
 
bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event)
484
 
{
485
 
        if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
486
 
                //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
487
 
                if (obj == m_searchTextCombo->view() || obj == m_searchTextCombo || obj == m_searchTextCombo->lineEdit()) {
488
 
                        //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
489
 
                        obj->event(event);
490
 
                        // don't handle this event in parent
491
 
                        event->accept();
492
 
                        return true;
493
 
                }
494
 
        }
495
 
        return QWidget::eventFilter(obj, event);
496
 
}
497
 
 
498
 
void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/)
499
 
{
 
465
    return (searchScope().Count() > 0);
 
466
}
 
467
 
 
468
void BtSearchOptionsArea::addToHistory(const QString& text) {
 
469
    m_searchTextCombo->addToHistory(text);
 
470
}
 
471
 
 
472
void BtSearchOptionsArea::slotSearchTextEditReturnPressed() {
 
473
    qDebug() << "BtSearchOptionsArea::slotSearchTextEditReturnPressed";
 
474
    m_searchTextCombo->addToHistory( m_searchTextCombo->currentText() );
 
475
    emit sigStartSearch();
 
476
}
 
477
 
 
478
bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event) {
 
479
    if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
 
480
        //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
 
481
        if (obj == m_searchTextCombo->view() || obj == m_searchTextCombo || obj == m_searchTextCombo->lineEdit()) {
 
482
            //qDebug() << "BtSearchOptionsArea::eventFilter" << obj << event;
 
483
            obj->event(event);
 
484
            // don't handle this event in parent
 
485
            event->accept();
 
486
            return true;
 
487
        }
 
488
    }
 
489
    return QWidget::eventFilter(obj, event);
 
490
}
 
491
 
 
492
void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
500
493
//      static const QRegExp re("\\b(AND|OR)\\b");
501
494
//      qDebug() << "new text:" << newText;
502
495
//      qDebug() << "contains:" << (newText.contains(re));
510
503
//              }
511
504
//      }
512
505
//      else {
513
 
//              qDebug("AND/OR!");
 
506
//              qDebug() << "AND/OR!";
514
507
//              if (m_typeAndButton->isEnabled()) {
515
508
//                      m_typeOrButton->setChecked(true);
516
509
//                      m_typeOrButton->setEnabled(false);