57 QFileInfo info (infoPath);
59 bool info_file_exists = info.exists ();
60 QHash<QString, QString>::iterator it;
65 info_file_exists = QFileInfo (info.absoluteFilePath () +
"." + it.key ()).exists ();
70 QString path = info.absolutePath ();
71 QString fileName = info.fileName ();
75 filter.append (fileName +
"*");
77 _info_files = infoDir.entryInfoList (filter, QDir::Files);
96 QIODevice *iodevice = 0;
99 QString command =
_compressors_map.value (file_info.suffix ()).
arg (file_info.absoluteFilePath ());
110 ips.read (buffer,
sizeof (buffer));
111 result.append (buffer, ips.gcount ());
114 QBuffer *io =
new QBuffer (
this);
115 io->setData (result);
117 if (!io->open (QIODevice::ReadOnly | QIODevice::Text))
124 QFile *io =
new QFile (file_info.absoluteFilePath ());
125 if (!io->open (QIODevice::ReadOnly | QIODevice::Text))
152 QString node = node_arg;
194 while (!io->atEnd ())
210 QByteArray
line, line_buffer;
214 while (!io->atEnd ())
221 line = io->readLine ();
226 line_buffer = io->readLine ();
227 line = io->readLine ();
228 for (i=1; i<line_buffer.size ()+6; i++)
229 line.insert (line.size ()-1,QByteArray(
" "));
232 if (line.at (0) ==
'"' && line.size () == 5)
235 if (line.at(0) == 31)
250 int n = text.indexOf (
"\n");
257 QString first_line = text.left (n);
265 QStringList nodes = firstLine.split (
",");
266 for (
int i = 0; i < nodes.size (); i++)
268 QString node = nodes.at (i).trimmed ();
270 if (node.startsWith (node_name))
272 return node.remove (0, node_name.size ()).trimmed ();
305 QRegExp re (
"(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.]+)");
308 while ((i = re.indexIn (text,i)) != -1)
310 QString
type = re.cap (1);
311 QString note = re.cap (3);
312 QString url_link = re.cap (4);
313 QString term = re.cap (5);
315 if (url_link.isEmpty ())
320 term.replace(
":",
"");
321 note.replace(
":",
"");
322 note.replace (QRegExp (
"`([^']+)'"),
"\\1");
324 QRegExp re_break (
"(\n[ ]*)");
326 if (note ==
"fig" || note ==
"tab")
327 url_link.prepend(
"#");
333 if (re_break.indexIn (url_link) != -1)
334 term += re_break.cap (1);
335 else if (re_break.indexIn (re.cap (2)) != -1)
336 href = re_break.cap (1) +
" ";
337 else if (re_break.indexIn (note) != -1)
338 term += re_break.cap (1);
339 note.replace(re_break,
" ");
341 url_link = url_link.trimmed ();
342 url_link.replace (
"\n",
" ");
343 url_link.replace (QRegExp (
" +"),
" ");
344 url_link.replace (
"<b>",
"");
345 url_link.replace (
"</b>",
"");
346 url_link = QUrl::toPercentEncoding (url_link,
"",
"'");
348 href +=
"<font style=\"color:DarkGray; font-weight:bold;\">»</font>";
349 href +=
" <a href='" + url_link +
"'>" + note +
"</a>" + term;
350 f = re.matchedLength ();
351 text.replace (i,
f,href);
359 QRegExp re (
"`([^']+)'");
361 while ((i = re.indexIn (text, i)) != -1)
363 QString t = re.cap (1);
364 QString bold =
"<font style=\"color:SteelBlue;font-weight:bold\">" + t +
367 f = re.matchedLength ();
368 text.replace (i,
f,bold);
376 text.replace (
"&",
"&");
377 text.replace (
"<",
"<");
378 text.replace (
">",
">");
380 text.replace (
"\n* Menu:",
381 "\n<font style=\"color:DarkRed;font-weight:bold\">Menu:</font>");
382 text.replace (
"See also:",
383 "<font style=\"color:DarkRed;font-style:italic;font-weight:bold\">See also:</font>");
390 const QString& anchor)
392 QString
text = text_arg;
401 QString text1 = text.left (anchorPos);
402 QString text2 = text.mid (anchorPos);
404 int n = text1.indexOf (
"\n");
410 text = text1 +
"<a name='" + anchor
411 +
"'/><font style=\"color:DarkBlue; font: bold monospace large;\">♦</font><br> "
416 int n = text.indexOf (
"\n");
421 QString navigationLinks = QString (
422 "<b>Section:</b> <font style=\"color:DarkRed\">%1</font><br>"
423 "<b>Previous Section:</b> <a href='%2'>%3</a><br>"
424 "<b>Next Section:</b> <a href='%4'>%5</a><br>"
425 "<b>Up:</b> <a href='%6'>%7</a><br>\n"
428 .arg (QString (QUrl::toPercentEncoding (nodePrev,
"",
"'")))
430 .arg (QString (QUrl::toPercentEncoding (nodeNext,
"",
"'")))
432 .arg (QString (QUrl::toPercentEncoding (nodeUp,
"",
"'")))
435 text.prepend (
"<hr>\n<pre style=\"font-family:monospace\">");
436 text.append (
"</pre>\n<hr><hr>\n");
437 text.prepend (navigationLinks);
438 text.append (navigationLinks);
439 text.prepend (
"<html><body>\n");
440 text.append (
"</body></html>\n");
449 QRegExp re (
"(Node|Ref): ([^\\0177]+)\\0177(\\d+)\n");
450 QRegExp re_files (
"([^:]+): (\\d+)\n");
464 while (! (nodeText=
get_next_node (io)).isEmpty () && foundCount < 2)
467 if (first_line.startsWith (
"Tag"))
473 while ((pos = re.indexIn (nodeText, pos)) != -1)
475 QString
type = re.cap (1);
476 QString node = re.cap (2);
477 int index = re.cap (3).toInt ();
486 else if (type ==
"Ref")
493 pos += re.matchedLength ();
497 else if (first_line.startsWith (
"Indirect:"))
502 while ((pos = re_files.indexIn (nodeText, pos)) != -1)
504 QString fileCap = re_files.cap (1).trimmed ();
505 int index = re_files.cap (2).toInt ();
511 if (info.fileName ().startsWith (fileCap))
519 pos += re_files.matchedLength ();
551 real_pos = pos - sum + header + 2;
558 while (!io->atEnd () && pos > 0)
570 while ((pos = re.indexIn (text, pos)) != -1)
572 QString cap = text.mid (pos,re.matchedLength ());
575 text.remove (pos, re.matchedLength ());
576 text.insert (pos, a);
585 QStringList words = text.split (
" ",QString::SkipEmptyParts);
587 QString re_program (
"(" + words.at (0));
588 for (
int i = 1; i < words.size (); i++)
590 re_program +=
"|" + words.at (i);
594 QRegExp re (re_program, Qt::CaseInsensitive);
596 results.append (
"<html><body>\n<h1>Search results</h1>\n<b>Results for:</b> ");
597 results.append (text);
598 results.append (
"<br>\n");
619 int n = node_text.indexOf (
"\n");
620 node_text.remove (0, n);
625 for (; founds < words.size ()
626 && node_text.indexOf (words.at (founds)) >= 0; founds++)
629 if (founds<words.size ())
635 while ((pos = re.indexIn (node_text, pos)) != -1
636 && founds < max_founds)
638 int line_start, line_end;
639 line_start = node_text.lastIndexOf (
"\n", pos);
640 line_end = node_text.indexOf (
"\n", pos);
641 QString
line = node_text.mid (line_start,
642 line_end - line_start).trimmed ();
643 pos += re.matchedLength ();
648 "<br>\n<font style=\"color:DarkGray; font-weight:bold;\">»</font> <a href='"
649 + QString(QUrl::toPercentEncoding(node,
"",
"'")) +
651 results.append (node);
652 results.append (
"</a><br>\n");
655 replace (line, re,
"<i>%1</i>");
656 results.append (line);
657 results.append (
"<br>\n");
666 results.append (
"</body></html>");
675 QHash<QString,node_position>::iterator it;
678 QString k = it.key ();
681 if (k ==
"XREF" + ref_name)
684 text =
"XREF" + ref_name;
691 QHash<QString, node_map_item>::iterator itn;
694 QString k = itn.key ();
695 if (k ==
"The " + ref_name +
" Statement")
QList< info_file_item > _info_file_real_size_list
QString get_node_name(const QString &text)
void seek(QIODevice *io, int pos)
Seeks to position pos.
QString global_search(const QString &text, int maxFounds)
QString get_next_node(QIODevice *io)
QIODevice * open_file(QFileInfo &fileInfo)
Open info files and uncompress them.
QString get_node_next(const QString &text)
QHash< QString, node_position > _ref_map
QHash< QString, QString > _compressors_map
static QString get_first_line(const QString &text)
static void replace_links(QString &text)
F77_RET_T const double const double * f
QFileInfoList _info_files
static void replace(QString &text, const QRegExp &re, const QString &after)
void parse_info_map()
Parses info files and gets map of node positions.
MArray< double > filter(MArray< double > &, MArray< double > &, MArray< double > &, int dim)
void real_position(int pos, QFileInfo &file_info, int &real_pos)
Calculates real position of nodes.
static QString parser_node(const QString &text, const QString &node_name)
parser(QObject *parent=0)
QHash< QString, node_map_item > _node_map
QString node_text_to_html(const QString &text, int anchorPos=-1, const QString &anchor=QString())
Translates text of node to Html.
int is_ref(const QString &node)
Checks if this node is reference.
bool set_info_path(const QString &_info_path)
QString find_ref(const QString &name)
QString get_node_prev(const QString &text)
static void info_to_html(QString &text)
QString search_node(const QString &node)
QString get_node_up(const QString &text)
static void replace_colons(QString &text)