summaryrefslogtreecommitdiff
path: root/src/main-view/FindPanel.h
blob: 553522e8e6c859c412d2e4b234dda66456804a53 (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
#ifndef FINDPANEL_H
#define FINDPANEL_H

#include <QWidget>
#include <QString>
#include <QModelIndex>
#include <QComboBox>
#include <QPushButton>
#include <QToolButton>
#include <QCheckBox>
#include <QMenu>
#include <QLabel>

class DictTableView;
class MainWindow;

/**
 * Modern find panel for dictionary records.
 */

class FindPanel: public QWidget
{
    Q_OBJECT
public:
    FindPanel( MainWindow* aMainWindow );

    void setTableView( DictTableView* aTableView );
    bool canFindAgain();

protected:
    void keyPressEvent( QKeyEvent* event );
    
private:
    bool findRegExp( const QRegExp& aSearchRegExp, QListIterator<QModelIndex> aStartingPoint );

public slots:
    void show();
    void find();

private slots:
    void updateFindButtons();

private:
    static const int ComboBoxMaxItems = 10;
    static const int TextEditMinWidth = 300;
    
private:
    // Data
    MainWindow* m_mainWindow;
    int m_direction;    // Search direction: 1 or -1
    bool m_foundOnce;   // The search text was already found once. For "Find again".

    // GUI
    QToolButton* m_closeButton;
    QComboBox* m_textEdit;
    QToolButton* m_findForwardBtn;
    QToolButton* m_findBackwardBtn;
    QToolButton* m_caseSensitiveBtn;
    QToolButton* m_wholeWordsBtn;
    QToolButton* m_regExpBtn;
    QToolButton* m_inSelectionBtn;
    QWidget* m_infoPane;
    QLabel* m_infoLbl;
};

#endif