|
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.15 2007-07-20 14:43:21 dockes Exp $ (C) 2006 J.F.Dockes */
|
3 |
/* @(#$Id: preview_w.h,v 1.16 2007-11-15 18:05:32 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.
|
|
... |
|
... |
20 |
|
20 |
|
21 |
#include <qvariant.h>
|
21 |
#include <qvariant.h>
|
22 |
#include <qwidget.h>
|
22 |
#include <qwidget.h>
|
23 |
|
23 |
|
24 |
#include "rcldb.h"
|
24 |
#include "rcldb.h"
|
25 |
#if (QT_VERSION < 0x040000)
|
|
|
26 |
#include "preview.h"
|
|
|
27 |
#else
|
|
|
28 |
#include "ui_preview.h"
|
|
|
29 |
#define QTextEdit Q3TextEdit
|
|
|
30 |
#endif
|
|
|
31 |
#include "refcntr.h"
|
25 |
#include "refcntr.h"
|
32 |
#include "plaintorich.h"
|
26 |
#include "plaintorich.h"
|
|
|
27 |
|
|
|
28 |
class QTabWidget;
|
|
|
29 |
class QLabel;
|
|
|
30 |
class QLineEdit;
|
|
|
31 |
class QPushButton;
|
|
|
32 |
class QCheckBox;
|
|
|
33 |
class QTextEditFixed;
|
|
|
34 |
|
|
|
35 |
#include <qtextedit.h>
|
|
|
36 |
#include <private/qrichtext_p.h>
|
|
|
37 |
class QTextEditFixed : public QTextEdit {
|
|
|
38 |
Q_OBJECT
|
|
|
39 |
public:
|
|
|
40 |
QTextEditFixed( QWidget* parent=0, const char* name=0 )
|
|
|
41 |
: QTextEdit(parent, name)
|
|
|
42 |
{}
|
|
|
43 |
void moveToAnchor(const QString& name)
|
|
|
44 |
{
|
|
|
45 |
if (name.isEmpty())
|
|
|
46 |
return;
|
|
|
47 |
sync();
|
|
|
48 |
QTextCursor l_cursor(document());
|
|
|
49 |
QTextParagraph* last = document()->lastParagraph();
|
|
|
50 |
for (;;) {
|
|
|
51 |
QTextStringChar* c = l_cursor.paragraph()->at(l_cursor.index());
|
|
|
52 |
if(c->isAnchor()) {
|
|
|
53 |
QString a = c->anchorName();
|
|
|
54 |
fprintf(stderr, "QTextEdit::scrollToAnchor: anchor nm [%s]\n",
|
|
|
55 |
(const char *)a.ascii());
|
|
|
56 |
if ( a == name ||
|
|
|
57 |
(a.contains( '#' ) &&
|
|
|
58 |
QStringList::split('#', a).contains(name))) {
|
|
|
59 |
|
|
|
60 |
*(textCursor()) = l_cursor;
|
|
|
61 |
ensureCursorVisible();
|
|
|
62 |
break;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
if (l_cursor.paragraph() == last && l_cursor.atParagEnd())
|
|
|
66 |
break;
|
|
|
67 |
l_cursor.gotoNextLetter();
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
};
|
|
|
71 |
|
33 |
|
72 |
|
34 |
// We keep a list of data associated to each tab
|
73 |
// We keep a list of data associated to each tab
|
35 |
class TabData {
|
74 |
class TabData {
|
36 |
public:
|
75 |
public:
|
37 |
string fn; // filename for this tab
|
76 |
string fn; // filename for this tab
|
|
... |
|
... |
42 |
TabData(QWidget *wi)
|
81 |
TabData(QWidget *wi)
|
43 |
: w(wi), docnum(-1)
|
82 |
: w(wi), docnum(-1)
|
44 |
{}
|
83 |
{}
|
45 |
};
|
84 |
};
|
46 |
|
85 |
|
47 |
class QTextEdit;
|
86 |
class Preview : public QWidget {
|
48 |
|
87 |
|
49 |
//MOC_SKIP_BEGIN
|
|
|
50 |
#if QT_VERSION < 0x040000
|
|
|
51 |
class DummyPreviewBase : public PreviewBase
|
|
|
52 |
{
|
|
|
53 |
public: DummyPreviewBase(QWidget* parent = 0) : PreviewBase(parent) {}
|
|
|
54 |
};
|
|
|
55 |
#else
|
|
|
56 |
class DummyPreviewBase : public QWidget, public Ui::PreviewBase
|
|
|
57 |
{
|
|
|
58 |
public: DummyPreviewBase(QWidget* parent):QWidget(parent){setupUi(this);}
|
|
|
59 |
};
|
|
|
60 |
#endif
|
|
|
61 |
//MOC_SKIP_END
|
|
|
62 |
|
|
|
63 |
class Preview : public DummyPreviewBase
|
|
|
64 |
{
|
|
|
65 |
Q_OBJECT
|
88 |
Q_OBJECT
|
66 |
|
89 |
|
67 |
public:
|
90 |
public:
|
|
|
91 |
|
68 |
Preview(int sid, // Search Id
|
92 |
Preview(int sid, // Search Id
|
69 |
const HiliteData& hdata) // Search terms etc. for highlighting
|
93 |
const HiliteData& hdata) // Search terms etc. for highlighting
|
70 |
: DummyPreviewBase(0)
|
94 |
: QWidget(0), m_searchId(sid), m_hData(hdata)
|
71 |
{
|
95 |
{
|
72 |
init();
|
96 |
init();
|
73 |
m_searchId = sid;
|
|
|
74 |
m_hData = hdata;
|
|
|
75 |
}
|
97 |
}
|
76 |
|
|
|
77 |
~Preview(){}
|
98 |
~Preview(){}
|
78 |
|
99 |
|
79 |
virtual void closeEvent(QCloseEvent *e );
|
100 |
virtual void closeEvent(QCloseEvent *e );
|
80 |
virtual bool eventFilter(QObject *target, QEvent *event );
|
101 |
virtual bool eventFilter(QObject *target, QEvent *event );
|
81 |
virtual bool makeDocCurrent(const string &fn, size_t sz,
|
102 |
virtual bool makeDocCurrent(const string &fn, size_t sz,
|
|
... |
|
... |
112 |
list<TabData> m_tabData;
|
133 |
list<TabData> m_tabData;
|
113 |
QWidget *m_currentW;
|
134 |
QWidget *m_currentW;
|
114 |
HiliteData m_hData;
|
135 |
HiliteData m_hData;
|
115 |
bool m_justCreated; // First tab create is different
|
136 |
bool m_justCreated; // First tab create is different
|
116 |
bool m_haveAnchors; // Search terms are marked in text
|
137 |
bool m_haveAnchors; // Search terms are marked in text
|
|
|
138 |
int m_lastAnchor; // Number of last anchor. Then rewind to 1
|
|
|
139 |
int m_curAnchor;
|
|
|
140 |
|
|
|
141 |
QTabWidget* pvTab;
|
|
|
142 |
QLabel* searchLabel;
|
|
|
143 |
QLineEdit* searchTextLine;
|
|
|
144 |
QPushButton* nextButton;
|
|
|
145 |
QPushButton* prevButton;
|
|
|
146 |
QPushButton* clearPB;
|
|
|
147 |
QCheckBox* matchCheck;
|
117 |
|
148 |
|
118 |
void init();
|
149 |
void init();
|
119 |
virtual void setCurTabProps(const string& fn, const Rcl::Doc& doc,
|
150 |
virtual void setCurTabProps(const string& fn, const Rcl::Doc& doc,
|
120 |
int docnum);
|
151 |
int docnum);
|
121 |
virtual QTextEdit *getCurrentEditor();
|
152 |
virtual QTextEditFixed *getCurrentEditor();
|
122 |
virtual QTextEdit *addEditorTab();
|
153 |
virtual QTextEditFixed *addEditorTab();
|
123 |
virtual bool loadFileInCurrentTab(string fn, size_t sz,
|
154 |
virtual bool loadFileInCurrentTab(string fn, size_t sz,
|
124 |
const Rcl::Doc& idoc, int dnm);
|
155 |
const Rcl::Doc& idoc, int dnm);
|
125 |
TabData *tabDataForCurrent(); // Return auxiliary data pointer for cur tab
|
156 |
TabData *tabDataForCurrent(); // Return auxiliary data pointer for cur tab
|
126 |
};
|
157 |
};
|
127 |
|
158 |
|