Switch to unified view

a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h
...
...
14
{
14
{
15
    exit(0);
15
    exit(0);
16
}
16
}
17
17
18
18
19
void RecollMain::helpIndex()
20
{
21
22
}
23
24
25
void RecollMain::helpContents()
26
{
27
28
}
29
30
31
void RecollMain::helpAbout()
32
{
33
34
}
35
#include <qmessagebox.h>
19
#include <qmessagebox.h>
36
20
37
#include "rcldb.h"
21
#include "rcldb.h"
38
#include "rclconfig.h"
22
#include "rclconfig.h"
39
#include "debuglog.h"
23
#include "debuglog.h"
...
...
60
44
61
    }
45
    }
62
    return out;
46
    return out;
63
}
47
}
64
48
49
// Click in the result list window: display preview for selected document, 
50
// and highlight entry. The paragraph number is doc number in window + 1
65
void RecollMain::resTextEdit_clicked( int par, int car )
51
void RecollMain::resTextEdit_clicked(int par, int car)
66
{
52
{
67
    fprintf(stderr, "Clicked at paragraph %d, char %d\n", par, car);
53
    LOGDEB(("RecollMain::resTextEdi_clicked: par %d, char %d\n", par, car));
54
    if (reslist_winfirst == -1)
55
  return;
68
    Rcl::Doc doc;
56
    Rcl::Doc doc;
69
    doc.erase();
57
    doc.erase();
70
    if (rcldb->getDoc(par, doc)) {
58
    if (reslist_current != -1) {
59
  QColor color("white");
60
  resTextEdit->setParagraphBackgroundColor(reslist_current+1, color);
61
    }
62
    QColor color("lightblue");
63
    resTextEdit->setParagraphBackgroundColor(par, color);
64
65
    int reldocnum = par-1;
66
    reslist_current = reldocnum;
67
    previewTextEdit->clear();
68
69
    if (rcldb->getDoc(reslist_winfirst + reldocnum, doc, 0)) {
71
    
70
    
72
    // Go to the file system to retrieve / convert the document text
71
    // Go to the file system to retrieve / convert the document text
73
    // for preview:
72
    // for preview:
74
73
75
    // Look for appropriate handler
74
    // Look for appropriate handler
...
...
84
83
85
    string fn = doc.url.substr(6, string::npos);
84
    string fn = doc.url.substr(6, string::npos);
86
    Rcl::Doc fdoc;
85
    Rcl::Doc fdoc;
87
    if (!fun(rclconfig, fn,  doc.mimetype, fdoc)) {
86
    if (!fun(rclconfig, fn,  doc.mimetype, fdoc)) {
88
        QMessageBox::warning(0, "Recoll",
87
        QMessageBox::warning(0, "Recoll",
89
              QString("Failed to convert document for preview!\n") +
88
             QString("Failed to convert document for preview!\n") +
90
                 fn.c_str() + " mimetype " + 
89
                 fn.c_str() + " mimetype " + 
91
                 doc.mimetype.c_str());
90
                 doc.mimetype.c_str());
92
        return;
91
        return;
93
    }
92
    }
94
93
...
...
106
    QStyleSheetItem *item = 
105
    QStyleSheetItem *item = 
107
        new QStyleSheetItem( previewTextEdit->styleSheet(), "mytag" );
106
        new QStyleSheetItem( previewTextEdit->styleSheet(), "mytag" );
108
    item->setColor("red");
107
    item->setColor("red");
109
    item->setFontWeight(QFont::Bold);
108
    item->setFontWeight(QFont::Bold);
110
#endif
109
#endif
110
111
    QString str = QString::fromUtf8(rich.c_str(), rich.length());
111
    QString str = QString::fromUtf8(rich.c_str(), rich.length());
112
113
    previewTextEdit->setTextFormat(RichText);
112
    previewTextEdit->setTextFormat(RichText);
114
    previewTextEdit->setText(str);
113
    previewTextEdit->setText(str);
115
    }
114
    }
116
}
115
}
117
116
117
#include "pathut.h"
118
118
void RecollMain::queryText_returnPressed()
119
void RecollMain::queryText_returnPressed()
119
{
120
{
120
    LOGDEB(("RecollMain::queryText_returnPressed()\n"));
121
    LOGDEB(("RecollMain::queryText_returnPressed()\n"));
121
    resTextEdit->clear();
122
    reslist_current = -1;
122
    previewTextEdit->clear();
123
    reslist_winfirst = -1;
123
124
124
    string rawq =  queryText->text();
125
    string rawq =  queryText->text();
125
    rcldb->setQuery(rawq);
126
    rcldb->setQuery(rawq);
126
    Rcl::Doc doc;
127
    listNextPB_clicked();
128
}
129
130
131
void RecollMain::Search_clicked()
132
{
133
    queryText_returnPressed();
134
}
135
136
137
static const int respagesize = 10;
138
void RecollMain::listPrevPB_clicked()
139
{
140
    reslist_winfirst -= 2*respagesize;
141
    listNextPB_clicked();
142
}
143
144
#ifndef MIN
145
#define MIN(A,B) ((A) < (B) ? (A) : (B))
146
#endif
147
148
void RecollMain::listNextPB_clicked()
149
{
150
    LOGDEB(("listNextPB_clicked: winfirst %d\n", reslist_winfirst));
151
152
    if (reslist_winfirst < 0)
153
  reslist_winfirst = 0;
154
    else
155
  reslist_winfirst += respagesize;
127
156
128
    // Insert results if any in result list window 
157
    // Insert results if any in result list window 
129
    QString result;
158
    bool gotone = false;
130
    resTextEdit->append("<qt><head></head><body>");
131
    for (int i = 0;; i++) {
159
    for (int i = 0; i < respagesize; i++) {
160
  Rcl::Doc doc;
132
    doc.erase();
161
    doc.erase();
133
 if (!rcldb->getDoc(i, doc))
162
  int percent;
163
  if (!rcldb->getDoc(reslist_winfirst + i, doc, &percent))
134
     break;
164
      break;
165
  int resCnt = rcldb->getResCnt();
166
  int last = MIN(resCnt, reslist_winfirst+respagesize);
167
  if (i == 0) {
168
      resTextEdit->clear();
169
      previewTextEdit->clear();
170
      resTextEdit->append("<qt><head></head><body><p>");
171
      char line[80];
172
      sprintf(line, "<p><b>Displaying results %d-%d out of %d</b><br>",
173
          reslist_winfirst+1, last, resCnt);
174
      resTextEdit->append(line);
175
  }
176
      
177
  gotone = true;
178
135
 LOGDEB(("Url: %s\n", doc.url.c_str()));
179
  LOGDEB1(("Url: %s\n", doc.url.c_str()));
136
 LOGDEB(("Mimetype: \n", doc.mimetype.c_str()));
180
  LOGDEB1(("Mimetype: %s\n", doc.mimetype.c_str()));
137
 LOGDEB(("Mtime: \n", doc.mtime.c_str()));
181
  LOGDEB1(("Mtime: %s\n", doc.mtime.c_str()));
138
 LOGDEB(("Origcharset: \n", doc.origcharset.c_str()));
182
  LOGDEB1(("Origcharset: %s\n", doc.origcharset.c_str()));
139
 LOGDEB(("Title: \n", doc.title.c_str()));
183
  LOGDEB1(("Title: %s\n", doc.title.c_str()));
140
 LOGDEB(("Text: \n", doc.text.c_str()));
184
  LOGDEB1(("Text: %s\n", doc.text.c_str()));
141
 LOGDEB(("Keywords: \n", doc.keywords.c_str()));
185
  LOGDEB1(("Keywords: %s\n", doc.keywords.c_str()));
142
 LOGDEB(("Abstract: \n", doc.abstract.c_str()));
186
  LOGDEB1(("Abstract: %s\n", doc.abstract.c_str()));
187
  
188
  // Result list display. Standard Omega includes:
189
  //  - title or simple file name or url
190
  //  - abstract and keywords
191
  //  - url 
192
  //  - relevancy percentage + keywords matched
193
  //  - date de modification
194
  //  - langue
195
        //  - taille 
196
  char perbuf[10];
197
  sprintf(perbuf, "%3d%%", percent);
198
  if (doc.title.empty()) 
199
      doc.title = path_getsimple(doc.url);
200
  char datebuf[100];
201
  datebuf[0] = 0;
202
  if (!doc.mtime.empty()) {
203
      time_t mtime = atol(doc.mtime.c_str());
204
      struct tm *tm = localtime(&mtime);
205
      strftime(datebuf, 99, "<i>Modified:</i> %F %T", tm);
206
  }
207
      
208
  string result = "<p>" + 
209
      string(perbuf) + " <b>" + doc.title + "</b><br>" +
210
      (!doc.mtime.empty() ? string(datebuf) + "<br>" : string("")) +
211
      (!doc.abstract.empty() ? doc.abstract + "<br>" : string("")) +
212
      (!doc.keywords.empty() ? doc.keywords + "<br>" : string("")) +
213
      "<i>" + doc.url + +"</i><br>" +
214
      "</p>";
215
  QString str = QString::fromUtf8(result.c_str(), result.length());
143
216
144
 result = "<p>" + doc.url + "</p>";
145
 resTextEdit->append(result);
217
  resTextEdit->append(str);
146
    }
218
    }
219
220
    if (gotone) {
147
    resTextEdit->append("</body></qt>");
221
  resTextEdit->append("</body></qt>");
148
222
  resTextEdit->setCursorPosition(0,0);
223
  resTextEdit->ensureCursorVisible();
149
    // Display preview for 1st doc in list
224
  // Display preview for 1st doc in list
150
    resTextEdit_clicked(0, 0);
225
  resTextEdit_clicked(1, 0);
226
    } else {
227
  // Restore first in win parameter that we shouln't have incremented
228
  reslist_winfirst -= respagesize;
229
  if (reslist_winfirst < 0)
230
      reslist_winfirst = 0;
231
    }
151
}
232
}
152
153
154
void RecollMain::Search_clicked()
155
{
156
    queryText_returnPressed();
157
}