57 QFileInfo info (infoPath);
59 QString path = info.absolutePath ();
60 QString fileName = info.fileName ();
64 filter.append (fileName +
"*");
66 _info_files = infoDir.entryInfoList (filter, QDir::Files);
79 QIODevice *iodevice = 0;
83 gzip.start (
_compressors_map.value (file_info.suffix ()).
arg (file_info.absoluteFilePath ()));
85 if (!gzip.waitForFinished ())
88 QByteArray result = gzip.readAll ();
90 QBuffer *io =
new QBuffer (
this);
93 if (!io->open (QIODevice::ReadOnly | QIODevice::Text))
100 QFile *io =
new QFile (file_info.absoluteFilePath ());
101 if (!io->open (QIODevice::ReadOnly | QIODevice::Text))
124 QString node = node_arg;
166 while (!io->atEnd ())
182 QByteArray
line, line_buffer;
186 while (!io->atEnd ())
193 line = io->readLine ();
198 line_buffer = io->readLine ();
199 line = io->readLine ();
200 for (i=1; i<line_buffer.size ()+6; i++)
201 line.insert (line.size ()-1,QByteArray(
" "));
204 if (line.at (0) ==
'"' && line.size () == 5)
207 if (line.at(0) == 31)
222 int n = text.indexOf (
"\n");
229 QString first_line = text.left (n);
237 QStringList nodes = firstLine.split (
",");
238 for (
int i = 0; i < nodes.size (); i++)
240 QString node = nodes.at (i).trimmed ();
242 if (node.startsWith (node_name))
244 return node.remove (0, node_name.size ()).trimmed ();
277 QRegExp re (
"(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.]+)");
280 while ( (i = re.indexIn (text,i)) != -1)
282 QString
type = re.cap (1);
283 QString note = re.cap (3);
284 QString url_link = re.cap (4);
285 QString term = re.cap (5);
287 if (url_link.isEmpty ())
292 term.replace(
":",
"");
293 note.replace(
":",
"");
294 note.replace (QRegExp (
"`([^']+)'"),
"\\1");
296 QRegExp re_break (
"(\n[ ]*)");
298 if (note ==
"fig" || note ==
"tab")
299 url_link.prepend(
"#");
305 if (re_break.indexIn (url_link) != -1)
306 term += re_break.cap (1);
307 else if (re_break.indexIn (re.cap (2)) != -1)
308 href = re_break.cap (1) +
" ";
309 else if (re_break.indexIn (note) != -1)
310 term += re_break.cap (1);
311 note.replace(re_break,
" ");
313 url_link = url_link.trimmed ();
314 url_link.replace (
"\n",
" ");
315 url_link.replace (QRegExp (
" +"),
" ");
316 url_link.replace (
"<b>",
"");
317 url_link.replace (
"</b>",
"");
318 url_link = QUrl::toPercentEncoding (url_link,
"",
"'");
320 href +=
"<img src=':/actions/icons/bookmark.png' width=10/>";
321 href +=
" <a href='" + url_link +
"'>" + note +
"</a>" + term;
322 f = re.matchedLength ();
323 text.replace (i,
f,href);
331 QRegExp re (
"`([^']+)'");
333 while ( (i = re.indexIn (text, i)) != -1)
335 QString t = re.cap (1);
336 QString bold =
"<font style=\"color:SteelBlue;font-weight:bold\">" + t +
339 f = re.matchedLength ();
340 text.replace (i,
f,bold);
348 text.replace (
"&",
"&");
349 text.replace (
"<",
"<");
350 text.replace (
">",
">");
352 text.replace (
"\n* Menu:",
353 "\n<font style=\"color:DarkRed;font-weight:bold\">Menu:</font>");
354 text.replace (
"See also:",
355 "<font style=\"color:DarkRed;font-style:italic;font-weight:bold\">See also:</font>");
362 const QString& anchor)
364 QString
text = text_arg;
373 QString text1 = text.left (anchorPos);
374 QString text2 = text.mid (anchorPos);
376 int n = text1.indexOf (
"\n");
382 text = text1 +
"<a name='" + anchor
383 +
"'/><img src=':/actions/icons/arrow_down.png'><br> "
388 int n = text.indexOf (
"\n");
393 QString navigationLinks = QString (
394 "<b>Section:</b> <font style=\"color:DarkRed\">%1</font><br>"
395 "<img src=':/actions/icons/arrow_left.png'/> <b>Previous Section:</b> <a href='%2'>%3</a><br>"
396 "<img src=':/actions/icons/arrow_right.png'/> <b>Next Section:</b> <a href='%4'>%5</a><br>"
397 "<img src=':/actions/icons/arrow_up.png'/> <b>Up:</b> <a href='%6'>%7</a><br>\n"
400 .arg (QString (QUrl::toPercentEncoding (nodePrev,
"",
"'")))
402 .arg (QString (QUrl::toPercentEncoding (nodeNext,
"",
"'")))
404 .arg (QString (QUrl::toPercentEncoding (nodeUp,
"",
"'")))
407 text.prepend (
"<hr>\n<pre style=\"font-family:monospace\">");
408 text.append (
"</pre>\n<hr><hr>\n");
409 text.prepend (navigationLinks);
410 text.append (navigationLinks);
411 text.prepend (
"<html><body>\n");
412 text.append (
"</body></html>\n");
421 QRegExp re (
"(Node|Ref): ([^\\0177]+)\\0177(\\d+)\n");
422 QRegExp re_files (
"([^:]+): (\\d+)\n");
436 while (! (nodeText=
get_next_node (io)).isEmpty () && foundCount < 2)
439 if (first_line.startsWith (
"Tag") )
445 while ((pos = re.indexIn (nodeText, pos)) != -1)
447 QString
type = re.cap (1);
448 QString node = re.cap (2);
449 int index = re.cap (3).toInt ();
458 else if (type ==
"Ref")
465 pos += re.matchedLength ();
469 else if (first_line.startsWith (
"Indirect:"))
474 while ( (pos = re_files.indexIn (nodeText, pos)) != -1)
476 QString fileCap = re_files.cap (1).trimmed ();
477 int index = re_files.cap (2).toInt ();
483 if (info.fileName ().startsWith (fileCap))
491 pos += re_files.matchedLength ();
504 int header = -1, sum = 0;
522 real_pos = pos - sum + header + 2;
529 while (!io->atEnd () && pos > 0)
541 while ( (pos = re.indexIn (text, pos)) != -1)
543 QString cap = text.mid (pos,re.matchedLength ());
546 text.remove (pos, re.matchedLength ());
547 text.insert (pos, a);
556 QStringList words = text.split (
" ",QString::SkipEmptyParts);
558 QString re_program (
"(" + words.at (0));
559 for (
int i = 1; i < words.size (); i++)
561 re_program +=
"|" + words.at (i);
565 QRegExp re (re_program, Qt::CaseInsensitive);
567 results.append (
"<html><body>\n<h1>Search results</h1>\n<b>Results for:</b> ");
568 results.append (text);
569 results.append (
"<br>\n");
590 int n = node_text.indexOf (
"\n");
591 node_text.remove (0, n);
596 for (; founds < words.size ()
597 && node_text.indexOf (words.at (founds)) >= 0; founds++)
600 if (founds<words.size ())
606 while ((pos = re.indexIn (node_text, pos)) != -1
607 && founds < max_founds)
609 int line_start, line_end;
610 line_start = node_text.lastIndexOf (
"\n", pos);
611 line_end = node_text.indexOf (
"\n", pos);
612 QString
line = node_text.mid (line_start,
613 line_end - line_start).trimmed ();
614 pos += re.matchedLength ();
619 "<br>\n<img src=':/actions/icons/bookmark.png' width=10> <a href='"
620 + QString(QUrl::toPercentEncoding(node,
"",
"'")) +
622 results.append (node);
623 results.append (
"</a><br>\n");
626 replace (line, re,
"<i>%1</i>");
627 results.append (line);
628 results.append (
"<br>\n");
637 results.append (
"</body></html>");
646 QHash<QString,node_position>::iterator it;
649 QString k = it.key ();
652 if (k ==
"XREF" + ref_name)
655 text =
"XREF" + ref_name;