Switch to unified view

a/src/qtgui/ssearch_w.h b/src/qtgui/ssearch_w.h
...
...
20
20
21
#include <string>
21
#include <string>
22
22
23
#include <QVariant>
23
#include <QVariant>
24
#include <QWidget>
24
#include <QWidget>
25
#include <QAbstractListModel>
26
#include <QVariant>
27
#include <QPixmap>
25
28
26
class QTimer;
29
class QTimer;
27
30
28
#include "recoll.h"
31
#include "recoll.h"
29
#include "searchdata.h"
32
#include "searchdata.h"
...
...
31
34
32
#include "ui_ssearchb.h"
35
#include "ui_ssearchb.h"
33
36
34
struct SSearchDef;
37
struct SSearchDef;
35
38
39
class RclCompleterModel : public QAbstractListModel {
40
    Q_OBJECT
41
42
public:
43
    RclCompleterModel(QWidget *parent = 0)
44
        : QAbstractListModel(parent) {
45
        init();
46
    }
47
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48
    QVariant data(const QModelIndex &index,
49
                  int role = Qt::DisplayRole) const override;
50
public slots:
51
    virtual void onPartialWord(int, const QString&, const QString&);
52
private:
53
    void init();
54
    vector<QString> currentlist;
55
    int firstfromindex;
56
    QPixmap clockPixmap;
57
    QPixmap interroPixmap;
58
};
59
36
class SSearch : public QWidget, public Ui::SSearchBase
60
class SSearch : public QWidget, public Ui::SSearchBase {
37
{
38
    Q_OBJECT
61
    Q_OBJECT
39
62
40
public:
63
public:
41
    // The values MUST NOT change, there are assumptions about them in
64
    // The values MUST NOT change, there are assumptions about them in
42
    // different parts of the code
65
    // different parts of the code
43
    enum SSearchType {SST_ANY = 0, SST_ALL = 1, SST_FNM = 2, SST_LANG = 3};
66
    enum SSearchType {SST_ANY = 0, SST_ALL = 1, SST_FNM = 2, SST_LANG = 3};
44
67
45
    SSearch(QWidget* parent = 0, const char * = 0)
68
    SSearch(QWidget* parent = 0, const char * = 0)
46
  : QWidget(parent) 
69
        : QWidget(parent) {
47
    {
48
  setupUi(this);
70
        setupUi(this);
49
  init();
71
        init();
50
    }
72
    }
51
73
52
    virtual void init();
74
    virtual void init();
53
    virtual void setAnyTermMode();
75
    virtual void setAnyTermMode();
54
    virtual void completion();
55
    virtual bool eventFilter(QObject *target, QEvent *event);
56
    virtual bool hasSearchString();
76
    virtual bool hasSearchString();
57
    virtual void setPrefs();
77
    virtual void setPrefs();
58
    // Return last performed search as XML text.
78
    // Return last performed search as XML text.
59
    virtual std::string asXML();
79
    virtual std::string asXML();
60
    // Restore ssearch UI from saved search
80
    // Restore ssearch UI from saved search
61
    virtual bool fromXML(const SSearchDef& fxml);
81
    virtual bool fromXML(const SSearchDef& fxml);
62
82
    virtual QString currentText();
83
                                  
63
public slots:
84
public slots:
64
    virtual void searchTextChanged(const QString & text);
65
    virtual void searchTypeChanged(int);
85
    virtual void searchTypeChanged(int);
66
    virtual void setSearchString(const QString& text);
86
    virtual void setSearchString(const QString& text);
67
    virtual void startSimpleSearch();
87
    virtual void startSimpleSearch();
68
    virtual void addTerm(QString);
88
    virtual void addTerm(QString);
69
    virtual void onWordReplace(const QString&, const QString&);
89
    virtual void onWordReplace(const QString&, const QString&);
70
    virtual void completionTermChosen(const QString& text);
71
    virtual void wrapupCompletion();
72
    virtual void timerDone();
73
    virtual void takeFocus();
90
    virtual void takeFocus();
91
    // Forget current entry and any state (history)
92
    virtual void clearAll();
74
93
94
private slots:
95
    virtual void searchTextChanged(const QString&);
96
    virtual void searchTextEdited(const QString&);
97
    virtual void onCompletionActivated(const QString&);
98
    virtual void restoreText();
99
    
75
signals:
100
signals:
76
    void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
101
    void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
77
    void clearSearch();
102
    void clearSearch();
78
 private:
103
    void partialWord(int, const QString& text, const QString &partial);
79
    bool m_escape;
80
104
81
    bool m_displayingCompletions;
105
private:
82
    QString m_chosenCompletion;
106
    int getPartialWord(QString& word);
107
    bool startSimpleSearch(const string& q, int maxexp = -1);
108
109
    /* We save multiword entries because the completer replaces them with
110
       the completion */
83
    QString m_savedEditText;
111
    QString m_savedEditText;
84
    unsigned int m_completedWordStart;
85
86
    bool m_disableAutosearch;
87
    QTimer *m_stroketimeout;
88
    bool m_keystroke;
89
    QString m_tstartqs;
90
    QAbstractItemModel *m_savedModel;
91
    std::string m_xml; /* Saved xml version of the search, as we start it */
112
     /* Saved xml version of the search, as we start it */
92
113
    std::string m_xml;
93
    int partialWord(string& s);
94
    int completionList(string s, QStringList& lst, int max = 100);
95
    bool startSimpleSearch(const string& q, int maxexp = -1);
96
};
114
};
97
115
98
116
99
#endif /* _SSEARCH_W_H_INCLUDED_ */
117
#endif /* _SSEARCH_W_H_INCLUDED_ */