ckpt
This commit is contained in:
parent
39338b4b4b
commit
75628a18bc
@ -13,8 +13,65 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Form1</string>
|
||||
<string>Advanced search</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_3</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>110</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Complex search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>searchPB</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>20</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line">
|
||||
<property name="name">
|
||||
<cstring>line1</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>22</x>
|
||||
<y>58</y>
|
||||
<width>550</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout6</cstring>
|
||||
@ -147,28 +204,6 @@
|
||||
<string>Search For</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line">
|
||||
<property name="name">
|
||||
<cstring>line1</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>22</x>
|
||||
<y>58</y>
|
||||
<width>550</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line">
|
||||
<property name="name">
|
||||
<cstring>line2</cstring>
|
||||
@ -224,6 +259,9 @@
|
||||
<property name="name">
|
||||
<cstring>noFiltypsLB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
@ -260,72 +298,51 @@
|
||||
<property name="name">
|
||||
<cstring>yesFiltypsLB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_3</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>110</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Complex search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>delFiltypPB</cstring>
|
||||
<cstring>layout11</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>300</y>
|
||||
<width>86</width>
|
||||
<height>30</height>
|
||||
<width>82</width>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>--------></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addFiltypPB</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>360</y>
|
||||
<width>86</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><---------</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>searchPB</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>20</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>delFiltypPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>--------></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addFiltypPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><---------</string>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</widget>
|
||||
<connections>
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.9 2005-10-10 12:29:42 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>Preview</class>
|
||||
<widget class="QDialog">
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>Preview</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>159</x>
|
||||
<y>362</y>
|
||||
<width>469</width>
|
||||
<height>174</height>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>751</width>
|
||||
<height>727</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -35,26 +35,44 @@
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout5</cstring>
|
||||
<cstring>layout9</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QTextEdit">
|
||||
<widget class="QTabWidget">
|
||||
<property name="name">
|
||||
<cstring>pvEdit</cstring>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
<cstring>pvTab</cstring>
|
||||
</property>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Preview 1</string>
|
||||
</attribute>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QTextEdit">
|
||||
<property name="name">
|
||||
<cstring>pvEdit</cstring>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout4</cstring>
|
||||
<cstring>layout7</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
@ -156,6 +174,7 @@
|
||||
<slot>doSearch( bool next, bool reverse )</slot>
|
||||
<slot>nextPressed()</slot>
|
||||
<slot>prevPressed()</slot>
|
||||
<slot>currentChanged( QWidget * tw )</slot>
|
||||
</slots>
|
||||
<functions>
|
||||
<function access="private" specifier="non virtual">init()</function>
|
||||
|
||||
@ -12,20 +12,19 @@
|
||||
|
||||
void Preview::init()
|
||||
{
|
||||
pvEdit->installEventFilter(this);
|
||||
connect(pvTab, SIGNAL(currentChanged(QWidget *)),
|
||||
this, SLOT(currentChanged(QWidget *)));
|
||||
searchTextLine->installEventFilter(this);
|
||||
dynSearchActive = false;
|
||||
canBeep = true;
|
||||
matchPara = 0;
|
||||
matchIndex = 0;
|
||||
}
|
||||
|
||||
bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
|
||||
if (event->type() != QEvent::KeyPress)
|
||||
return QWidget::eventFilter(target, event);
|
||||
|
||||
fprintf(stderr, "Preview::eventFilter: keyEvent\n");
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (dynSearchActive) {
|
||||
if (keyEvent->key() == Key_F3) {
|
||||
@ -35,7 +34,12 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
if (target != searchTextLine)
|
||||
return QApplication::sendEvent(searchTextLine, event);
|
||||
} else {
|
||||
if (keyEvent->key() == Key_Slash && target == pvEdit) {
|
||||
QWidget *tw = pvTab->currentPage();
|
||||
QWidget *e = 0;
|
||||
if (tw)
|
||||
e = (QTextEdit *)tw->child("pvEdit");
|
||||
fprintf(stderr, "Widget: %p, edit %p, target %p\n", tw, e, target);
|
||||
if (e && target == tw && keyEvent->key() == Key_Slash) {
|
||||
dynSearchActive = true;
|
||||
return true;
|
||||
}
|
||||
@ -46,7 +50,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
||||
|
||||
void Preview::searchTextLine_textChanged(const QString & text)
|
||||
{
|
||||
//fprintf(stderr, "search line text changed. text: '%s'\n", text.ascii());
|
||||
fprintf(stderr, "search line text changed. text: '%s'\n", text.ascii());
|
||||
if (text.isEmpty()) {
|
||||
dynSearchActive = false;
|
||||
} else {
|
||||
@ -62,41 +66,53 @@ void Preview::searchTextLine_textChanged(const QString & text)
|
||||
// starting from the current position
|
||||
void Preview::doSearch(bool next, bool reverse)
|
||||
{
|
||||
//fprintf(stderr, "Preview::doSearch: next %d rev %d para %d index %d\n",
|
||||
// int(next), int(reverse), matchPara, matchIndex);
|
||||
|
||||
//fprintf(stderr, "Preview::doSearch: next %d rev %d\n",
|
||||
// int(next), int(reverse));
|
||||
QWidget *tw = pvTab->currentPage();
|
||||
QTextEdit *edit = 0;
|
||||
if (tw) {
|
||||
if ((edit = (QTextEdit*)tw->child("pvEdit")) == 0) {
|
||||
// ??
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool matchCase = matchCheck->isChecked();
|
||||
int mspara, msindex, mepara, meindex;
|
||||
edit->getSelection(&mspara, &msindex, &mepara, &meindex);
|
||||
if (mspara == -1)
|
||||
mspara = msindex = mepara = meindex = 0;
|
||||
|
||||
if (next) {
|
||||
// We search again, starting from the current match
|
||||
if (reverse) {
|
||||
// when searching backwards, have to move back one char
|
||||
if (matchIndex > 0)
|
||||
matchIndex --;
|
||||
else if (matchPara > 0) {
|
||||
matchPara --;
|
||||
matchIndex = pvEdit->paragraphLength(matchPara);
|
||||
if (msindex > 0)
|
||||
msindex --;
|
||||
else if (mspara > 0) {
|
||||
mspara --;
|
||||
msindex = edit->paragraphLength(mspara);
|
||||
}
|
||||
} else {
|
||||
// Forward search: start from end of selection
|
||||
int bogus;
|
||||
pvEdit->getSelection(&bogus, &bogus, &matchPara, &matchIndex);
|
||||
//fprintf(stderr, "New para: %d index %d\n",matchPara, matchIndex);
|
||||
mspara = mepara;
|
||||
msindex = meindex;
|
||||
//fprintf(stderr, "New para: %d index %d\n", mspara, msindex);
|
||||
}
|
||||
}
|
||||
|
||||
bool found = pvEdit->find(searchTextLine->text(), matchCase, false,
|
||||
!reverse, &matchPara, &matchIndex);
|
||||
bool found = edit->find(searchTextLine->text(), matchCase, false,
|
||||
!reverse, &mspara, &msindex);
|
||||
|
||||
if (!found && next && true) { // need a 'canwrap' test here
|
||||
if (reverse) {
|
||||
matchPara = pvEdit->paragraphs();
|
||||
matchIndex = pvEdit->paragraphLength(matchPara);
|
||||
mspara = edit->paragraphs();
|
||||
msindex = edit->paragraphLength(mspara);
|
||||
} else {
|
||||
matchPara = matchIndex = 0;
|
||||
mspara = msindex = 0;
|
||||
}
|
||||
found = pvEdit->find(searchTextLine->text(), matchCase, false,
|
||||
!reverse, &matchPara, &matchIndex);
|
||||
found = edit->find(searchTextLine->text(), matchCase, false,
|
||||
!reverse, &mspara, &msindex);
|
||||
}
|
||||
|
||||
if (found) {
|
||||
@ -119,3 +135,18 @@ void Preview::prevPressed()
|
||||
{
|
||||
doSearch(true, true);
|
||||
}
|
||||
|
||||
|
||||
void Preview::currentChanged(QWidget * tw)
|
||||
{
|
||||
QObject *o;
|
||||
o = tw->child("pvEdit");
|
||||
fprintf(stderr, "Preview::currentChanged(). Edit %p\n", o);
|
||||
|
||||
if (o == 0) {
|
||||
fprintf(stderr, "Editor child not found\n");
|
||||
} else {
|
||||
tw->installEventFilter(this);
|
||||
o->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.1 2005-09-27 06:20:16 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.2 2005-10-10 12:29:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -14,6 +14,8 @@ using std::pair;
|
||||
#include <qapplication.h>
|
||||
#include <qobject.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qtabwidget.h>
|
||||
#include <qlayout.h>
|
||||
|
||||
#include "preview.h"
|
||||
#include "../plaintorich.h"
|
||||
@ -25,7 +27,6 @@ int main( int argc, char ** argv )
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
Preview w;
|
||||
w.show();
|
||||
|
||||
string text;
|
||||
if (!file_to_string(filename, text)) {
|
||||
@ -38,5 +39,18 @@ int main( int argc, char ** argv )
|
||||
QString str = QString::fromUtf8(rich.c_str(), rich.length());
|
||||
w.pvEdit->setText(str);
|
||||
|
||||
// QVBoxLayout *unnamedLayout =
|
||||
// new QVBoxLayout(0, 11, 6, "unnamedLayout");
|
||||
QWidget *anon = new QWidget(w.pvTab);
|
||||
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 11, 6, "unnamedLayout");
|
||||
QTextEdit *newEd = new QTextEdit(anon, "pvEdit");
|
||||
anonLayout->addWidget(newEd);
|
||||
fprintf(stderr, "pvEdit %p newEd: %p\n", w.pvEdit, newEd);
|
||||
newEd->setReadOnly( TRUE );
|
||||
newEd->setUndoRedoEnabled( FALSE );
|
||||
newEd->setText(str);
|
||||
|
||||
w.pvTab->addTab(anon, "Tab 2");
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@ -8,18 +8,24 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>782</width>
|
||||
<height>622</height>
|
||||
<width>160</width>
|
||||
<height>750</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>recoll</string>
|
||||
</property>
|
||||
@ -29,131 +35,117 @@
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout3</cstring>
|
||||
<cstring>layout8</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLineEdit">
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>queryText</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>LineEditPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
<cstring>layout9</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>queryText</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>8</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>155</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>LineEditPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>Search</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>clearqPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listPrevPb</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Previous page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listNextPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>advSearchPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Adv. search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>346</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>Search</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>clearqPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listPrevPb</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Previous page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>listNextPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next page</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>346</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QSplitter">
|
||||
<property name="name">
|
||||
<cstring>splitter6</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTextEdit">
|
||||
<property name="name">
|
||||
<cstring>reslistTE</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>RichText</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSplitter">
|
||||
<property name="name">
|
||||
<cstring>splitter5</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>5</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTextEdit">
|
||||
<property name="name">
|
||||
<cstring>previewTextEdit</cstring>
|
||||
<cstring>reslistTE</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>4</verstretch>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
@ -166,26 +158,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit">
|
||||
<property name="name">
|
||||
<cstring>metaTextEdit</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>RichText</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
@ -253,10 +226,16 @@
|
||||
<slot>fileExit()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>queryText</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<sender>fileStart_IndexingAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>queryText_returnPressed()</slot>
|
||||
<slot>fileStart_IndexingAction_activated()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>helpQuick_startAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>helpQuick_startAction_activated()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>Search</sender>
|
||||
@ -264,6 +243,12 @@
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>Search_clicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>queryText</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>queryText_returnPressed()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>listPrevPb</sender>
|
||||
<signal>clicked()</signal>
|
||||
@ -288,33 +273,23 @@
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>reslistTE_clicked(int,int)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>fileStart_IndexingAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>fileStart_IndexingAction_activated()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>clearqPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>clearqPB_clicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>helpQuick_startAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>helpQuick_startAction_activated()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in declaration">preview/.ui/preview.h</include>
|
||||
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
|
||||
</includes>
|
||||
<variables>
|
||||
<variable>std::string stemlang;</variable>
|
||||
<variable>bool dostem;</variable>
|
||||
<variable>int reslist_current;</variable>
|
||||
<variable>int reslist_winfirst;</variable>
|
||||
<variable>int reslist_current;</variable>
|
||||
<variable>bool dostem;</variable>
|
||||
<variable>std::string stemlang;</variable>
|
||||
<variable>Preview *curPreview;</variable>
|
||||
</variables>
|
||||
<slots>
|
||||
<slot>fileExit()</slot>
|
||||
@ -328,7 +303,11 @@
|
||||
<slot>listPrevPB_clicked()</slot>
|
||||
<slot>listNextPB_clicked()</slot>
|
||||
<slot>helpQuick_startAction_activated()</slot>
|
||||
<slot>advSearchPB_clicked()</slot>
|
||||
</slots>
|
||||
<functions>
|
||||
<function access="private">init()</function>
|
||||
</functions>
|
||||
<pixmapinproject/>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
|
||||
@ -20,7 +20,7 @@ using std::pair;
|
||||
|
||||
#include <qmessagebox.h>
|
||||
#include <qcstring.h>
|
||||
|
||||
#include <qtabwidget.h>
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "rclconfig.h"
|
||||
@ -29,16 +29,24 @@ using std::pair;
|
||||
#include "pathut.h"
|
||||
#include "recoll.h"
|
||||
#include "internfile.h"
|
||||
#include "textsplit.h"
|
||||
#include "smallut.h"
|
||||
#include "utf8iter.h"
|
||||
#include "transcode.h"
|
||||
#include "plaintorich.h"
|
||||
|
||||
|
||||
#include "unacpp.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
static const int respagesize = 8;
|
||||
|
||||
|
||||
void RecollMain::init()
|
||||
{
|
||||
curPreview = 0;
|
||||
}
|
||||
|
||||
void RecollMain::fileExit()
|
||||
{
|
||||
LOGDEB1(("RecollMain: fileExit\n"));
|
||||
@ -65,112 +73,6 @@ void RecollMain::fileStart_IndexingAction_activated()
|
||||
startindexing = 1;
|
||||
}
|
||||
|
||||
// Text splitter callback used to take note of the position of query terms
|
||||
// inside the result text. This is then used to post highlight tags.
|
||||
class myTextSplitCB : public TextSplitCB {
|
||||
public:
|
||||
const list<string> *terms; // in: query terms
|
||||
list<pair<int, int> > tboffs; // out: begin and end positions of
|
||||
// query terms in text
|
||||
|
||||
myTextSplitCB(const list<string>& terms)
|
||||
: terms(&terms) {
|
||||
}
|
||||
|
||||
// Callback called by the text-to-words breaker for each word
|
||||
virtual bool takeword(const std::string& term, int pos, int bts, int bte) {
|
||||
string dumb;
|
||||
Rcl::dumb_string(term, dumb);
|
||||
//LOGDEB(("Input dumbbed term: '%s' %d %d %d\n", dumb.c_str(),
|
||||
// pos, bts, bte));
|
||||
for (list<string>::const_iterator it = terms->begin();
|
||||
it != terms->end(); it++) {
|
||||
if (!stringlowercmp(*it, dumb)) {
|
||||
tboffs.push_back(pair<int, int>(bts, bte));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Fix result text for display inside the gui text window
|
||||
static string plaintorich(const string &in, const list<string>& terms,
|
||||
list<pair<int, int> >&termoffsets)
|
||||
{
|
||||
LOGDEB(("plaintorich: terms: %s\n",
|
||||
stringlistdisp(terms).c_str()));
|
||||
|
||||
termoffsets.erase(termoffsets.begin(), termoffsets.end());
|
||||
|
||||
myTextSplitCB cb(terms);
|
||||
TextSplit splitter(&cb, true);
|
||||
splitter.text_to_words(in);
|
||||
|
||||
for (list<pair<int, int> >::iterator li = cb.tboffs.begin();
|
||||
li != cb.tboffs.end(); li++) {
|
||||
}
|
||||
|
||||
// State variable used to limitate the number of consecutive empty lines
|
||||
int ateol = 0;
|
||||
|
||||
// Rich text output
|
||||
string out = "<qt><head><title></title></head><body><p>";
|
||||
|
||||
// Iterator for the list of input term positions. We use it to
|
||||
// output highlight tags and to compute term positions in the
|
||||
// output text
|
||||
list<pair<int, int> >::iterator it = cb.tboffs.begin();
|
||||
|
||||
// Storage for the current term position in output.
|
||||
pair<int, int> opos;
|
||||
int outbytepos; // This is the current position in output, excluding tags
|
||||
for (unsigned int ibyteidx = 0; ibyteidx < in.length(); ibyteidx++) {
|
||||
if (it != cb.tboffs.end()) {
|
||||
if (ibyteidx == (unsigned int)it->first) {
|
||||
out += "<termtag>";
|
||||
opos.first = outbytepos;
|
||||
} else if (ibyteidx == (unsigned int)it->second) {
|
||||
if (it != cb.tboffs.end())
|
||||
it++;
|
||||
opos.second = outbytepos;
|
||||
termoffsets.push_back(opos);
|
||||
out += "</termtag>";
|
||||
}
|
||||
}
|
||||
switch(in[ibyteidx]) {
|
||||
case '\n':
|
||||
if (ateol < 2)
|
||||
out += "<br>\n";
|
||||
ateol++;
|
||||
outbytepos++;
|
||||
break;
|
||||
case '\r': break;
|
||||
case '<':
|
||||
ateol = 0;
|
||||
out += "<";
|
||||
outbytepos++;
|
||||
break;
|
||||
default:
|
||||
ateol = 0;
|
||||
out += in[ibyteidx];
|
||||
outbytepos++;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
FILE *fp = fopen("/tmp/termsdeb", "w");
|
||||
string unaced, ascii;
|
||||
fprintf(fp, "plaintorich: text:\n%s\n", out.c_str());
|
||||
unac_cpp(out, unaced);
|
||||
fprintf(fp, "plaintorich: text:\n%s\n", unaced.c_str());
|
||||
transcode(unaced, ascii, "UTF-8", "ASCII");
|
||||
fprintf(fp, "plaintorich: text:\n%s\n", ascii.c_str());
|
||||
fclose(fp);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static string urltolocalpath(string url)
|
||||
{
|
||||
@ -180,7 +82,8 @@ static string urltolocalpath(string url)
|
||||
// Use external viewer to display file
|
||||
void RecollMain::reslistTE_doubleClicked(int par, int)
|
||||
{
|
||||
// restlistTE_clicked(par, car);
|
||||
LOGDEB(("RecollMain::reslistTE_doubleClicked: par %d\n", par));
|
||||
|
||||
Rcl::Doc doc;
|
||||
int reldocnum = par - 1;
|
||||
if (!rcldb->getDoc(reslist_winfirst + reldocnum, doc, 0))
|
||||
@ -239,8 +142,10 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
reslistTE->setParagraphBackgroundColor(par, color);
|
||||
|
||||
int reldocnum = par - 1;
|
||||
if (reslist_current == reldocnum)
|
||||
return;
|
||||
|
||||
reslist_current = reldocnum;
|
||||
previewTextEdit->clear();
|
||||
|
||||
if (!rcldb->getDoc(reslist_winfirst + reldocnum, doc, 0)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
@ -264,33 +169,52 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
list<pair<int, int> > termoffsets;
|
||||
string rich = plaintorich(fdoc.text, terms, termoffsets);
|
||||
|
||||
QTextEdit *editor;
|
||||
if (curPreview == 0) {
|
||||
curPreview = new Preview(0, "Preview");
|
||||
curPreview->setCaption(queryText->text());
|
||||
if (curPreview == 0) {
|
||||
QMessageBox::warning(0, "Warning",
|
||||
"Can't create preview window",
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::NoButton);
|
||||
return;
|
||||
}
|
||||
curPreview->show();
|
||||
editor = curPreview->pvEdit;
|
||||
} else {
|
||||
QWidget *anon = new QWidget((QWidget *)curPreview->pvTab);
|
||||
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 1, 1, "anonLayout");
|
||||
editor = new QTextEdit(anon, "pvEdit");
|
||||
editor->setReadOnly( TRUE );
|
||||
editor->setUndoRedoEnabled( FALSE );
|
||||
anonLayout->addWidget(editor);
|
||||
curPreview->pvTab->addTab(anon, "Tab");
|
||||
curPreview->pvTab->showPage(anon);
|
||||
}
|
||||
curPreview->pvTab->changeTab(curPreview->pvTab->currentPage(),
|
||||
QString::fromUtf8(doc.title.c_str(),
|
||||
doc.title.length()));
|
||||
|
||||
QStyleSheetItem *item =
|
||||
new QStyleSheetItem( previewTextEdit->styleSheet(), "termtag" );
|
||||
new QStyleSheetItem(editor->styleSheet(),
|
||||
"termtag" );
|
||||
item->setColor("blue");
|
||||
item->setFontWeight(QFont::Bold);
|
||||
|
||||
QString str = QString::fromUtf8(rich.c_str(), rich.length());
|
||||
previewTextEdit->setText(str);
|
||||
editor->setText(str);
|
||||
int para = 0, index = 1;
|
||||
if (!termoffsets.empty()) {
|
||||
index = (termoffsets.begin())->first;
|
||||
LOGDEB(("Preview: Byte index for first term: %d\n", index));
|
||||
// Translate byte to character offset
|
||||
string::size_type pos = 0;
|
||||
Utf8Iter it(rich);
|
||||
for (; pos != string::npos && (int)pos < index; it++) {
|
||||
pos = it.getBpos();
|
||||
}
|
||||
index = pos == string::npos ? 0 : it.getCpos();
|
||||
LOGDEB(("Set cursor position: para %d, character index %d\n",
|
||||
para,index));
|
||||
previewTextEdit->setCursorPosition(0, index);
|
||||
editor->setCursorPosition(0, index);
|
||||
}
|
||||
previewTextEdit->ensureCursorVisible();
|
||||
previewTextEdit->getCursorPosition(¶, &index);
|
||||
editor->ensureCursorVisible();
|
||||
editor->getCursorPosition(¶, &index);
|
||||
LOGDEB(("PREVIEW len %d paragraphs: %d. Cpos: %d %d\n",
|
||||
previewTextEdit->length(), previewTextEdit->paragraphs(),
|
||||
para, index));
|
||||
editor->length(), editor->paragraphs(), para, index));
|
||||
}
|
||||
|
||||
|
||||
@ -333,7 +257,7 @@ void RecollMain::queryText_returnPressed()
|
||||
if (!rcldb->setQuery(string((const char *)u8), dostem ?
|
||||
Rcl::Db::QO_STEM : Rcl::Db::QO_NONE, stemlang))
|
||||
return;
|
||||
list<string> terms;
|
||||
curPreview = 0;
|
||||
listNextPB_clicked();
|
||||
}
|
||||
|
||||
@ -348,7 +272,6 @@ void RecollMain::clearqPB_clicked()
|
||||
queryText->clear();
|
||||
}
|
||||
|
||||
static const int respagesize = 10;
|
||||
void RecollMain::listPrevPB_clicked()
|
||||
{
|
||||
if (reslist_winfirst <= 0)
|
||||
@ -361,12 +284,14 @@ void RecollMain::listPrevPB_clicked()
|
||||
// Fill up result list window with next screen of hits
|
||||
void RecollMain::listNextPB_clicked()
|
||||
{
|
||||
fprintf(stderr, "listNextPB_clicked\n");
|
||||
if (!rcldb)
|
||||
return;
|
||||
int percent;
|
||||
Rcl::Doc doc;
|
||||
rcldb->getDoc(0, doc, &percent);
|
||||
int resCnt = rcldb->getResCnt();
|
||||
fprintf(stderr, "listNextPB_clicked rescnt\n");
|
||||
LOGDEB(("listNextPB_clicked: rescnt %d, winfirst %d\n", resCnt,
|
||||
reslist_winfirst));
|
||||
|
||||
@ -381,7 +306,7 @@ void RecollMain::listNextPB_clicked()
|
||||
|
||||
bool gotone = false;
|
||||
reslistTE->clear();
|
||||
previewTextEdit->clear();
|
||||
|
||||
int last = MIN(resCnt-reslist_winfirst, respagesize);
|
||||
|
||||
// Insert results if any in result list window
|
||||
@ -438,7 +363,7 @@ void RecollMain::listNextPB_clicked()
|
||||
reslistTE->setCursorPosition(0,0);
|
||||
reslistTE->ensureCursorVisible();
|
||||
// Display preview for 1st doc in list
|
||||
reslistTE_clicked(1, 0);
|
||||
// reslistTE_clicked(1, 0);
|
||||
} else {
|
||||
// Restore first in win parameter that we shouln't have incremented
|
||||
reslist_winfirst -= respagesize;
|
||||
@ -473,3 +398,5 @@ void RecollMain::advSearchPB_clicked()
|
||||
asearchform->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user