|
a/src/qtgui/preview_w.h |
|
b/src/qtgui/preview_w.h |
1 |
#ifndef _PREVIEW_W_H_INCLUDED_
|
1 |
#ifndef _PREVIEW_W_H_INCLUDED_
|
2 |
#define _PREVIEW_W_H_INCLUDED_
|
2 |
#define _PREVIEW_W_H_INCLUDED_
|
3 |
/* @(#$Id: preview_w.h,v 1.17 2007-11-15 18:34:49 dockes Exp $ (C) 2006 J.F.Dockes */
|
3 |
/* @(#$Id: preview_w.h,v 1.18 2008-07-01 08:27:58 dockes Exp $ (C) 2006 J.F.Dockes */
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
8 |
* (at your option) any later version.
|
8 |
* (at your option) any later version.
|
|
... |
|
... |
63 |
TabData(QWidget *wi)
|
63 |
TabData(QWidget *wi)
|
64 |
: w(wi), docnum(-1)
|
64 |
: w(wi), docnum(-1)
|
65 |
{}
|
65 |
{}
|
66 |
};
|
66 |
};
|
67 |
|
67 |
|
|
|
68 |
// Subclass plainToRich to add <termtag>s and anchors to the preview text
|
|
|
69 |
class PlainToRichQtPreview : public PlainToRich {
|
|
|
70 |
public:
|
|
|
71 |
int lastanchor;
|
|
|
72 |
PlainToRichQtPreview() {
|
|
|
73 |
lastanchor = 0;
|
|
|
74 |
}
|
|
|
75 |
virtual ~PlainToRichQtPreview() {}
|
|
|
76 |
virtual string header() {
|
|
|
77 |
return string("<qt><head><title></title></head><body><p>");
|
|
|
78 |
}
|
|
|
79 |
virtual string startMatch() {return string("<termtag>");}
|
|
|
80 |
virtual string endMatch() {return string("</termtag>");}
|
|
|
81 |
virtual string termAnchorName(int i) {
|
|
|
82 |
static const char *termAnchorNameBase = "TRM";
|
|
|
83 |
char acname[sizeof(termAnchorNameBase) + 20];
|
|
|
84 |
sprintf(acname, "%s%d", termAnchorNameBase, i);
|
|
|
85 |
if (i > lastanchor)
|
|
|
86 |
lastanchor = i;
|
|
|
87 |
return string(acname);
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
virtual string startAnchor(int i) {
|
|
|
91 |
return string("<a name=\"") + termAnchorName(i) + "\">";
|
|
|
92 |
}
|
|
|
93 |
};
|
|
|
94 |
|
68 |
class Preview : public QWidget {
|
95 |
class Preview : public QWidget {
|
69 |
|
96 |
|
70 |
Q_OBJECT
|
97 |
Q_OBJECT
|
71 |
|
98 |
|
72 |
public:
|
99 |
public:
|
|
... |
|
... |
114 |
bool m_loading;
|
141 |
bool m_loading;
|
115 |
list<TabData> m_tabData;
|
142 |
list<TabData> m_tabData;
|
116 |
QWidget *m_currentW;
|
143 |
QWidget *m_currentW;
|
117 |
HiliteData m_hData;
|
144 |
HiliteData m_hData;
|
118 |
bool m_justCreated; // First tab create is different
|
145 |
bool m_justCreated; // First tab create is different
|
|
|
146 |
PlainToRichQtPreview m_plaintorich;
|
119 |
bool m_haveAnchors; // Search terms are marked in text
|
147 |
bool m_haveAnchors; // Search terms are marked in text
|
120 |
int m_lastAnchor; // Number of last anchor. Then rewind to 1
|
148 |
int m_lastAnchor; // Number of last anchor. Then rewind to 1
|
121 |
int m_curAnchor;
|
149 |
int m_curAnchor;
|
122 |
|
150 |
|
123 |
QTabWidget* pvTab;
|
151 |
QTabWidget* pvTab;
|