#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;
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);
}
void GuiTexInfo::viewClicked()
{
// takes advantage of enum order
- static QString const ext[] = { "cls", "sty", "bst" };
+ static QString const ext[] = { "cls", "sty", "bst", "bib", "bbx", "cbx" };
int const fitem = fileListLW->currentRow();
QStringList const & data = texdata_[activeStyle_];
QString file = data[fitem];
void GuiTexInfo::updateStyles(TexFileType type)
{
static QString const filenames[] = {
- "clsFiles.lst", "styFiles.lst", "bstFiles.lst"
+ "clsFiles.lst", "styFiles.lst", "bstFiles.lst", "bibFiles.lst",
+ "bbxFiles.lst", "cbxFiles.lst"
};
QString const filename = filenames[type];
if (!pathCB->isChecked()) {
for (int i = 0; i != data.size(); ++i)
- data[i] = onlyFilename(data[i]);
+ data[i] = onlyFileName(data[i]);
}
// sort on filename only (no path)
data.sort();
fileListLW->clear();
- foreach (QString const & item, data)
+ for(QString const & item : data)
fileListLW->addItem(item);
activeStyle_ = type;
} // namespace lyx
-#include "GuiTexinfo_moc.cpp"
+#include "moc_GuiTexinfo.cpp"