# HG changeset patch # User Torsten # Date 1420220849 -3600 # Node ID 17e6c770e6acac16b931e98809e6e8222f842f74 # Parent 17f5db3a91490d4ac25c1f904bf1e5bc5ba59256 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 diff -r 17f5db3a9149 -r 17e6c770e6ac libgui/src/qtinfo/parser.cc --- 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::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 diff -r 17f5db3a9149 -r 17e6c770e6ac libgui/src/qtinfo/parser.h --- 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); diff -r 17f5db3a9149 -r 17e6c770e6ac libgui/src/qtinfo/webinfo.cc --- 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 ("

%1" - "
"). - arg (tr ("The info file %1 does not exist"). - arg(info_file.absoluteFilePath ())); + QString msg_text = QString ( + "

%1
"). + arg (tr ("The info file

%1

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 diff -r 17f5db3a9149 -r 17e6c770e6ac libgui/src/qtinfo/webinfo.h --- 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);