diff libgui/src/qtinfo/parser.cc @ 19495:17e6c770e6ac gui-release

check existence of uncompressed or compressed info files for doc viewer * parser.cc (set_info_path): return type changed to bool, checking existence of info file uncompressed and with all known compressed file extensions, returns false if no file was found and true after parsing the found file; * parser.h: return type of set_info_path changed to bool * webinfo.cc (ctor): do not check existence of info file since this is done via set_info_path; (set_info_path): return type changed to bool, load Top-node if parser::set_info_path returns true and return the related return value * webinfo.h: return type of set_info_path changed to bool
author Torsten <ttl@justmail.de>
date Fri, 02 Jan 2015 18:47:29 +0100
parents 8c47eb286151
children ffc339cea115
line wrap: on
line diff
--- a/libgui/src/qtinfo/parser.cc	Thu Jan 01 18:51:50 2015 -0800
+++ b/libgui/src/qtinfo/parser.cc	Fri Jan 02 18:47:29 2015 +0100
@@ -47,7 +47,7 @@
   _compressors_map.insert ("Z",    "gunzip -c \"%1\"");
 }
 
-void
+bool
 parser::set_info_path (const QString& infoPath)
 {
   this->_info_path = infoPath;
@@ -56,15 +56,32 @@
 
   QFileInfo info (infoPath);
 
-  QString path = info.absolutePath ();
-  QString fileName = info.fileName ();
+  bool info_file_exists = info.exists ();
+  QHash<QString, QString>::iterator it;
+  for (it = _compressors_map.begin (); it != _compressors_map.end (); it++)
+    {
+      if (info_file_exists)
+        break;
+      info_file_exists = QFileInfo (info.absoluteFilePath () + "." + it.key ()).exists ();
+    }
 
-  QDir infoDir (path);
-  QStringList filter;
-  filter.append (fileName + "*");
+  if (info_file_exists)
+    {
+      QString path = info.absolutePath ();
+      QString fileName = info.fileName ();
+
+      QDir infoDir (path);
+      QStringList filter;
+      filter.append (fileName + "*");
 
-  _info_files = infoDir.entryInfoList (filter, QDir::Files);
-  parse_info_map ();
+      _info_files = infoDir.entryInfoList (filter, QDir::Files);
+
+      parse_info_map ();
+
+      return true;
+    }
+  else
+    return false;
 }
 
 QString