comparison 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
comparison
equal deleted inserted replaced
19489:17f5db3a9149 19495:17e6c770e6ac
45 _compressors_map.insert ("lzma", "lzma -dc \"%1\""); 45 _compressors_map.insert ("lzma", "lzma -dc \"%1\"");
46 _compressors_map.insert ("xz", "xz -dc \"%1\""); 46 _compressors_map.insert ("xz", "xz -dc \"%1\"");
47 _compressors_map.insert ("Z", "gunzip -c \"%1\""); 47 _compressors_map.insert ("Z", "gunzip -c \"%1\"");
48 } 48 }
49 49
50 void 50 bool
51 parser::set_info_path (const QString& infoPath) 51 parser::set_info_path (const QString& infoPath)
52 { 52 {
53 this->_info_path = infoPath; 53 this->_info_path = infoPath;
54 54
55 _info_files.clear (); 55 _info_files.clear ();
56 56
57 QFileInfo info (infoPath); 57 QFileInfo info (infoPath);
58 58
59 QString path = info.absolutePath (); 59 bool info_file_exists = info.exists ();
60 QString fileName = info.fileName (); 60 QHash<QString, QString>::iterator it;
61 61 for (it = _compressors_map.begin (); it != _compressors_map.end (); it++)
62 QDir infoDir (path); 62 {
63 QStringList filter; 63 if (info_file_exists)
64 filter.append (fileName + "*"); 64 break;
65 65 info_file_exists = QFileInfo (info.absoluteFilePath () + "." + it.key ()).exists ();
66 _info_files = infoDir.entryInfoList (filter, QDir::Files); 66 }
67 parse_info_map (); 67
68 if (info_file_exists)
69 {
70 QString path = info.absolutePath ();
71 QString fileName = info.fileName ();
72
73 QDir infoDir (path);
74 QStringList filter;
75 filter.append (fileName + "*");
76
77 _info_files = infoDir.entryInfoList (filter, QDir::Files);
78
79 parse_info_map ();
80
81 return true;
82 }
83 else
84 return false;
68 } 85 }
69 86
70 QString 87 QString
71 parser::get_info_path () 88 parser::get_info_path ()
72 { 89 {