summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog/btsearchoptionsarea.h
blob: c7c1b1ca57d3bbf005524af9acf30361db68455b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*********
*
* 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 BTSEARCHOPTIONSAREA_H
#define BTSEARCHOPTIONSAREA_H

#include <QWidget>

#include "backend/keys/cswordversekey.h"
#include "frontend/searchdialog/chistorycombobox.h"


class CSwordModuleInfo;
class QComboBox;
class QEvent;
class QGridLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QObject;
class QPushButton;
class QRadioButton;

namespace Search {

class BtSearchOptionsArea : public QWidget {
        Q_OBJECT
    public:

        enum SearchType {AndType, OrType, FullType};

        friend class CSearchDialog;

        BtSearchOptionsArea(QWidget *parent = 0);
        ~BtSearchOptionsArea();
        /*
        * Add text to search combox box history
        */
        void addToHistory(const QString& text);
        /**
        * Sets the search text used in the page.
        */
        void setSearchText(const QString& text);
        /**
        * Returns the search text set in this page.
        */
        QString searchText() const;

        SearchType searchType();

        QPushButton* searchButton() const;

        /**
        * Returns the list of used modules.
        */
        QList<CSwordModuleInfo*> modules() const;

        /**
        * Sets all options back to the default.
        */
        void reset();
        /**
        * Returns the selected search scope if a search scope was selected.
        */
        sword::ListKey searchScope();

        bool hasSearchScope();


    protected:
        /**
        * Initializes this page.
        */
        void initView();
        void initConnections();
        /**
        * Reads the settings of the last searchdialog session.
        */
        void readSettings();
        /**
        * Reads the settings for the searchdialog from disk.
        */
        void saveSettings();
        bool eventFilter(QObject* obj, QEvent* event);
    public slots:
        /**
        * Sets the modules used by the search.
        */
        void setModules( QList<CSwordModuleInfo*> modules );

        /** Sets the modules when user selects them from the combobox.*/
        void moduleListTextSelected(int index);

        /**
        * Reimplementation.
        */
        void aboutToShow();
        /**
        * Refreshes the list of ranges and the range combobox.
        */
        void refreshRanges();
        /**
         * Opens the modules chooser dialog.
         */
        void chooseModules();

    protected slots:
        void setupRanges();
        void syntaxHelp();
        void slotSearchTextEditReturnPressed();
        void slotValidateText(const QString& newText);

    signals:
        void sigSetSearchButtonStatus(bool);
        void sigStartSearch();

    private:
        QList<CSwordModuleInfo*> m_modules;

        QHBoxLayout *hboxLayout;
        QGroupBox *searchGroupBox;
        QGridLayout *gridLayout;
        QLabel *m_searchTextLabel;
        QPushButton* m_searchButton;
        QLabel* m_helpLabel;
        QRadioButton* m_typeAndButton;
        QRadioButton* m_typeOrButton;
        QRadioButton* m_typeFreeButton;
        QPushButton *m_chooseModulesButton;
        QPushButton *m_chooseRangeButton;
        QLabel *m_searchScopeLabel;
        QComboBox *m_rangeChooserCombo;
        CHistoryComboBox *m_searchTextCombo;
        QLabel *m_modulesLabel;
        QComboBox* m_modulesCombo;

};

}

#endif