From: Edwin Leuven Date: Sat, 8 Mar 2008 20:18:22 +0000 (+0000) Subject: fix view file when path is not shown X-Git-Tag: 1.6.10~5777 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ad19114709c6fef98fabd9fb6ec54f6e506b55dc;p=features.git fix view file when path is not shown git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23572 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiTexinfo.cpp b/src/frontends/qt4/GuiTexinfo.cpp index de2c7e118a..6a1e64aa9b 100644 --- a/src/frontends/qt4/GuiTexinfo.cpp +++ b/src/frontends/qt4/GuiTexinfo.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -38,42 +39,16 @@ namespace frontend { static QString texFileFromList(QString const & file, QString const & type) { - QString file_ = file; - // do we need to add the suffix? - if (getExtension(file) != type) - file_ += '.' + type; - - lyxerr << "Searching for file " << fromqstr(file_) << endl; - QString lstfile = type + "Files.lst"; - if (type == "cls") - lstfile = "clsFiles.lst"; - else if (type == "sty") - lstfile = "styFiles.lst"; - else if (type == "bst") - lstfile = "bstFiles.lst"; - else if (type == "bib") - lstfile = "bibFiles.lst"; FileName const abslstfile = libFileSearch(QString(), lstfile); - if (abslstfile.empty()) { - lyxerr << "File `'" << fromqstr(lstfile) << "' not found." << endl; + if (abslstfile.empty()) return QString(); - } - // FIXME UNICODE - string const allClasses = to_utf8(abslstfile.fileContents("UTF-8")); - int entries = 0; - string classfile = token(allClasses, '\n', entries); - int count = 0; - while ((!contains(classfile, fromqstr(file)) - || support::onlyFilename(classfile) != fromqstr(file)) - && ++count < 1000) { - classfile = token(allClasses, '\n', ++entries); - } - - // now we have filename with full path - lyxerr << "with full path: " << classfile << endl; - - return toqstr(classfile); + QString cs = toqstr(abslstfile.fileContents("UTF-8")); + cs.replace("\r", ""); + QStringList const result = cs.split("\n").filter(file); + if (result.empty()) + return QString(); + return result.at(0); }