changeset 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 17f5db3a9149
children ffc339cea115 c2d01ed114ba
files libgui/src/qtinfo/parser.cc libgui/src/qtinfo/parser.h libgui/src/qtinfo/webinfo.cc libgui/src/qtinfo/webinfo.h
diffstat 4 files changed, 40 insertions(+), 22 deletions(-) [+]
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
--- a/libgui/src/qtinfo/parser.h	Thu Jan 01 18:51:50 2015 -0800
+++ b/libgui/src/qtinfo/parser.h	Fri Jan 02 18:47:29 2015 +0100
@@ -53,7 +53,7 @@
 
 public:
   parser (QObject *parent = 0);
-  void set_info_path (const QString& _info_path);
+  bool set_info_path (const QString& _info_path);
   QString get_info_path ();
   QString search_node (const QString& node);
   QString global_search (const QString& text, int maxFounds);
--- a/libgui/src/qtinfo/webinfo.cc	Thu Jan 01 18:51:50 2015 -0800
+++ b/libgui/src/qtinfo/webinfo.cc	Fri Jan 02 18:47:29 2015 +0100
@@ -96,29 +96,30 @@
 
   resize (500, 300);
 
-  QFileInfo info_file = QFileInfo (QString::fromStdString (Vinfo_file));
-
-  if (info_file.exists ())
-    set_info_path (QString::fromStdString (Vinfo_file));
-  else
+  if (! set_info_path (QString::fromStdString (Vinfo_file)))
     { // Info file does not exist
       _search_check_box->setEnabled (false);
       _search_line_edit->setEnabled (false);
 
       QTextBrowser *msg = addNewTab (tr ("Error"));
-      QString msg_text = QString ("<html><body><br><br><center><b>%1"
-                                      "</b></center></body></html>").
-                         arg (tr ("The info file %1 does not exist").
-                              arg(info_file.absoluteFilePath ()));
+      QString msg_text = QString (
+          "<html><body><br><br><center><b>%1</b></center></body></html>").
+          arg (tr ("The info file<p>%1<p>or compressed versions do not exist").
+          arg(QString::fromStdString (Vinfo_file)));
       msg->setHtml (msg_text);
     }
 }
 
-void
+bool
 webinfo::set_info_path (const QString& info_path)
 {
-  _parser.set_info_path (info_path);
-  load_node ("Top");
+  if (_parser.set_info_path (info_path))
+    {
+      load_node ("Top");
+      return true;
+    }
+  else
+    return false;
 }
 
 void
--- a/libgui/src/qtinfo/webinfo.h	Thu Jan 01 18:51:50 2015 -0800
+++ b/libgui/src/qtinfo/webinfo.h	Fri Jan 02 18:47:29 2015 +0100
@@ -38,7 +38,7 @@
   Q_OBJECT
 public:
   webinfo (QWidget *parent = 0);
-  void set_info_path (const QString& info_path);
+  bool set_info_path (const QString& info_path);
   void load_node (const QString& node_name);
 
   void load_ref (const QString &ref_name);