Switch to unified view

a/src/qtgui/preview_w.h b/src/qtgui/preview_w.h
...
...
16
 *   along with this program; if not, write to the
16
 *   along with this program; if not, write to the
17
 *   Free Software Foundation, Inc.,
17
 *   Free Software Foundation, Inc.,
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 */
19
 */
20
20
21
#include <stdio.h>
22
21
#include <qvariant.h>
23
#include <qvariant.h>
22
#include <qwidget.h>
24
#include <qwidget.h>
23
#include <stdio.h>
25
#include <qtextedit.h>
24
26
25
#include "rcldb.h"
27
#include "rcldb.h"
26
#include "refcntr.h"
28
#include "refcntr.h"
27
#include "plaintorich.h"
29
#include "plaintorich.h"
28
30
...
...
31
class QLineEdit;
33
class QLineEdit;
32
class QPushButton;
34
class QPushButton;
33
class QCheckBox;
35
class QCheckBox;
34
class PreviewTextEdit;
36
class PreviewTextEdit;
35
class Preview;
37
class Preview;
36
37
#if (QT_VERSION < 0x040000)
38
#include <qtextedit.h>
39
#include <private/qrichtext_p.h>
40
#define QTEXTEDIT QTextEdit
41
class QPopupMenu;
42
#define RCLPOPUP QPopupMenu
43
#else
44
#include <q3textedit.h>
45
#include <q3richtext_p.h>
46
class Q3PopupMenu;
47
#define RCLPOPUP Q3PopupMenu
48
#define QTEXTEDIT Q3TextEdit
49
#endif
50
38
51
// We keep a list of data associated to each tab
39
// We keep a list of data associated to each tab
52
class TabData {
40
class TabData {
53
public:
41
public:
54
    string url; // filename for this tab
42
    string url; // filename for this tab
...
...
65
    TabData() 
53
    TabData() 
66
    : docnum(-1) 
54
    : docnum(-1) 
67
    {}
55
    {}
68
};
56
};
69
57
58
class Preview;
59
class PlainToRichQtPreview;
60
70
class PreviewTextEdit : public QTEXTEDIT {
61
class PreviewTextEdit : public QTextEdit {
71
    Q_OBJECT
62
    Q_OBJECT
72
public:
63
public:
73
    PreviewTextEdit(QWidget* parent, const char* name, Preview *pv) 
64
    PreviewTextEdit(QWidget* parent, const char* name, Preview *pv);
74
  : QTEXTEDIT(parent, name), m_preview(pv), m_dspflds(false)
65
    virtual ~PreviewTextEdit();
75
    {}
76
    void moveToAnchor(const QString& name);
66
    void moveToAnchor(const QString& name);
77
#if (QT_VERSION >= 0x040000)
78
    virtual bool find(const QString &expr, bool cs, bool wo,bool forward = true,
79
                      int *para = 0, int *index = 0);
80
#endif
81
public slots:
67
public slots:
82
    virtual void toggleFields();
68
    virtual void toggleFields();
83
    virtual void print();
69
    virtual void print();
70
    virtual void createPopupMenu(const QPoint& pos);
84
    friend class Preview;
71
    friend class Preview;
72
protected:
73
    void mouseDoubleClickEvent(QMouseEvent *);
74
85
private:
75
private:
86
    virtual RCLPOPUP *createPopupMenu(const QPoint& pos);
76
    PlainToRichQtPreview *m_plaintorich;
87
    Preview *m_preview;
77
    Preview *m_preview;
88
    TabData  m_data;
78
    TabData  m_data;
89
    bool     m_dspflds;
79
    bool     m_dspflds;
90
};
80
};
91
81
92
82
93
// Subclass plainToRich to add <termtag>s and anchors to the preview text
94
class PlainToRichQtPreview : public PlainToRich {
95
public:
96
    int lastanchor;
97
    PlainToRichQtPreview() 
98
    {
99
  lastanchor = 0;
100
    }    
101
    virtual ~PlainToRichQtPreview() {}
102
    virtual string header() {
103
  if (m_inputhtml) {
104
      return snull;
105
  } else {
106
      return string("<qt><head><title></title></head><body><pre>");
107
  }
108
    }
109
    virtual string startMatch() {return string("<termtag>");}
110
    virtual string endMatch() {return string("</termtag>");}
111
    virtual string termAnchorName(int i) {
112
  static const char *termAnchorNameBase = "TRM";
113
  char acname[sizeof(termAnchorNameBase) + 20];
114
  sprintf(acname, "%s%d", termAnchorNameBase, i);
115
  if (i > lastanchor)
116
      lastanchor = i;
117
  return string(acname);
118
    }
119
120
    virtual string startAnchor(int i) {
121
  return string("<a name=\"") + termAnchorName(i) + "\">";
122
    }
123
    virtual string endAnchor() {
124
  return string("</a>");
125
    }
126
    virtual string startChunk() { return "<pre>";}
127
};
128
129
class Preview : public QWidget {
83
class Preview : public QWidget {
130
84
131
    Q_OBJECT
85
    Q_OBJECT
132
86
133
public:
87
    public:
134
88
135
    Preview(int sid, // Search Id
89
    Preview(int sid, // Search Id
136
        const HiliteData& hdata) // Search terms etc. for highlighting
90
        const HiliteData& hdata) // Search terms etc. for highlighting
137
    : QWidget(0), m_searchId(sid), m_hData(hdata)
91
    : QWidget(0), m_searchId(sid), m_hData(hdata)
138
    {
92
    {
...
...
148
     * @para docnum is used to link back to the result list (to highlight 
102
     * @para docnum is used to link back to the result list (to highlight 
149
     *   paragraph when tab exposed etc.
103
     *   paragraph when tab exposed etc.
150
     */
104
     */
151
    virtual bool makeDocCurrent(const Rcl::Doc& idoc, int docnum, 
105
    virtual bool makeDocCurrent(const Rcl::Doc& idoc, int docnum, 
152
                bool sametab = false);
106
                bool sametab = false);
107
    void emitWordSelect(QString);
153
    friend class PreviewTextEdit;
108
    friend class PreviewTextEdit;
109
154
public slots:
110
public slots:
155
    virtual void searchTextLine_textChanged(const QString& text);
111
    virtual void searchTextLine_textChanged(const QString& text);
156
    virtual void doSearch(const QString& str, bool next, bool reverse,
112
    virtual void doSearch(const QString& str, bool next, bool reverse,
157
              bool wo = false);
113
              bool wo = false);
158
    virtual void nextPressed();
114
    virtual void nextPressed();
159
    virtual void prevPressed();
115
    virtual void prevPressed();
160
    virtual void currentChanged(QWidget *tw);
116
    virtual void currentChanged(QWidget *tw);
161
    virtual void closeCurrentTab();
117
    virtual void closeCurrentTab();
162
    virtual void textDoubleClicked(int, int);
163
    virtual void selecChanged();
164
118
165
signals:
119
signals:
166
    void previewClosed(Preview *);
120
    void previewClosed(Preview *);
167
    void wordSelect(QString);
121
    void wordSelect(QString);
168
    void showNext(Preview *w, int sid, int docnum);
122
    void showNext(Preview *w, int sid, int docnum);
...
...
180
    bool          m_canBeep;
134
    bool          m_canBeep;
181
    bool          m_loading;
135
    bool          m_loading;
182
    QWidget      *m_currentW;
136
    QWidget      *m_currentW;
183
    HiliteData    m_hData;
137
    HiliteData    m_hData;
184
    bool          m_justCreated; // First tab create is different
138
    bool          m_justCreated; // First tab create is different
185
    PlainToRichQtPreview m_plaintorich;
186
    bool          m_haveAnchors; // Search terms are marked in text
139
    bool          m_haveAnchors; // Search terms are marked in text
187
    int           m_lastAnchor; // Number of last anchor. Then rewind to 1
140
    int           m_lastAnchor; // Number of last anchor. Then rewind to 1
188
    int           m_curAnchor;
141
    int           m_curAnchor;
189
142
190
    QTabWidget* pvTab;
143
    QTabWidget* pvTab;