]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiTexinfo.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiTexinfo.cpp
index 2b13cba7941419bfc333e38eccf93ca6fed34ec3..cc901c9c2866876f33dbf1fd8a48a4f8bb083652 100644 (file)
 
 #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 <QCheckBox>
 #include <QListWidget>
 #include <QPushButton>
-
-#include <fstream>
-#include <algorithm>
+#include <QStringList>
 
 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);
 }
 
 
@@ -149,7 +119,7 @@ void GuiTexInfo::enableViewPB()
 void GuiTexInfo::updateStyles(TexFileType type)
 {
        static QString const filenames[] = {
-               "clsFile.lst", "styFiles.lst", "bstFiles.lst"
+               "clsFiles.lst", "styFiles.lst", "bstFiles.lst"
        };
 
        QString const filename = filenames[type];
@@ -222,4 +192,4 @@ Dialog * createGuiTexInfo(GuiView & lv) { return new GuiTexInfo(lv); }
 } // namespace lyx
 
 
-#include "GuiTexinfo_moc.cpp"
+#include "moc_GuiTexinfo.cpp"