X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiTexinfo.cpp;h=cc901c9c2866876f33dbf1fd8a48a4f8bb083652;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=de2c7e118a078ef31d3ec0be205a48d3c17ecb9c;hpb=d1aff33dd59115e8c2bf17cd7fe63709db8de35b;p=lyx.git diff --git a/src/frontends/qt4/GuiTexinfo.cpp b/src/frontends/qt4/GuiTexinfo.cpp index de2c7e118a..cc901c9c28 100644 --- a/src/frontends/qt4/GuiTexinfo.cpp +++ b/src/frontends/qt4/GuiTexinfo.cpp @@ -15,20 +15,16 @@ #include "FuncRequest.h" -#include "support/debug.h" #include "support/filetools.h" #include "support/foreach.h" #include "support/FileName.h" -#include "support/lstrings.h" #include "qt_helpers.h" #include #include #include - -#include -#include +#include using namespace std; using namespace lyx::support; @@ -38,42 +34,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); } @@ -222,4 +192,4 @@ Dialog * createGuiTexInfo(GuiView & lv) { return new GuiTexInfo(lv); } } // namespace lyx -#include "GuiTexinfo_moc.cpp" +#include "moc_GuiTexinfo.cpp"