Parent: [15855b] (diff)

Child: [82334f] (diff)

Download this file

recollmain.ui.h    158 lines (129 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
void RecollMain::fileExit()
{
exit(0);
}
void RecollMain::helpIndex()
{
}
void RecollMain::helpContents()
{
}
void RecollMain::helpAbout()
{
}
#include <qmessagebox.h>
#include "rcldb.h"
#include "rclconfig.h"
#include "debuglog.h"
#include "mimehandler.h"
extern RclConfig *rclconfig;
extern Rcl::Db *rcldb;
static string plaintorich(const string &in)
{
string out = "<qt><head><title></title></head><body><p>";
for (unsigned int i = 0; i < in.length() ; i++) {
if (in[i] == '\n') {
out += "<br>";
} else {
out += in[i];
}
if (i == 10) {
out += "<mytag>";
}
if (i == 20) {
out += "</mytag>";
}
}
return out;
}
void RecollMain::resTextEdit_clicked( int par, int car )
{
fprintf(stderr, "Clicked at paragraph %d, char %d\n", par, car);
Rcl::Doc doc;
doc.erase();
if (rcldb->getDoc(par, doc)) {
// Go to the file system to retrieve / convert the document text
// for preview:
// Look for appropriate handler
MimeHandlerFunc fun =
getMimeHandler(doc.mimetype, rclconfig->getMimeConf());
if (!fun) {
QMessageBox::warning(0, "Recoll",
QString("No mime handler for mime type ") +
doc.mimetype.c_str());
return;
}
string fn = doc.url.substr(6, string::npos);
Rcl::Doc fdoc;
if (!fun(rclconfig, fn, doc.mimetype, fdoc)) {
QMessageBox::warning(0, "Recoll",
QString("Failed to convert document for preview!\n") +
fn.c_str() + " mimetype " +
doc.mimetype.c_str());
return;
}
string rich = plaintorich(fdoc.text);
#if 0
//Highlighting; pass a list of (search term, style name) to plaintorich
// and create the corresponding styles with different colors here
// We need to :
// - Break the query into terms : wait for the query analyzer
// - Break the text into words. This should use a version of
// textsplit with an option to keep the punctuation (see how to do
// this). We do want the same splitter code to be used here and
// when indexing.
QStyleSheetItem *item =
new QStyleSheetItem( previewTextEdit->styleSheet(), "mytag" );
item->setColor("red");
item->setFontWeight(QFont::Bold);
#endif
QString str = QString::fromUtf8(rich.c_str(), rich.length());
previewTextEdit->setTextFormat(RichText);
previewTextEdit->setText(str);
}
}
void RecollMain::queryText_returnPressed()
{
LOGDEB(("RecollMain::queryText_returnPressed()\n"));
resTextEdit->clear();
previewTextEdit->clear();
string rawq = queryText->text();
rcldb->setQuery(rawq);
Rcl::Doc doc;
// Insert results if any in result list window
QString result;
resTextEdit->append("<qt><head></head><body>");
for (int i = 0;; i++) {
doc.erase();
if (!rcldb->getDoc(i, doc))
break;
LOGDEB(("Url: %s\n", doc.url.c_str()));
LOGDEB(("Mimetype: \n", doc.mimetype.c_str()));
LOGDEB(("Mtime: \n", doc.mtime.c_str()));
LOGDEB(("Origcharset: \n", doc.origcharset.c_str()));
LOGDEB(("Title: \n", doc.title.c_str()));
LOGDEB(("Text: \n", doc.text.c_str()));
LOGDEB(("Keywords: \n", doc.keywords.c_str()));
LOGDEB(("Abstract: \n", doc.abstract.c_str()));
result = "<p>" + doc.url + "</p>";
resTextEdit->append(result);
}
resTextEdit->append("</body></qt>");
// Display preview for 1st doc in list
resTextEdit_clicked(0, 0);
}
void RecollMain::Search_clicked()
{
queryText_returnPressed();
}