#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);
}
warningPosted_ = false;
activeStyle_ = ClsType;
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+ connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(slotButtonBox(QAbstractButton *)));
connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
connect(whatStyleCO, SIGNAL(activated(QString)),
this, SLOT(enableViewPB()));
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
- bc().setCancel(closePB);
+ bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
}
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];
+ QStringList const & sdata = texdata_[activeStyle_];
+ QString file = sdata[fitem];
if (!pathCB->isChecked())
- file = texFileFromList(data[fitem], ext[activeStyle_]);
+ file = texFileFromList(sdata[fitem], ext[activeStyle_]);
viewFile(file);
}
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];
- QStringList data = texFileList(filename);
- if (data.empty()) {
+ QStringList flist = texFileList(filename);
+ if (flist.empty()) {
// build filelists of all availabe bst/cls/sty-files.
// Done through kpsewhich and an external script,
// saved in *Files.lst
rescanTexStyles();
- data = texFileList(filename);
+ flist = texFileList(filename);
}
if (!pathCB->isChecked()) {
- for (int i = 0; i != data.size(); ++i)
- data[i] = onlyFilename(data[i]);
+ for (int i = 0; i != flist.size(); ++i)
+ flist[i] = onlyFileName(flist[i]);
}
// sort on filename only (no path)
- data.sort();
+ flist.sort();
fileListLW->clear();
- foreach (QString const & item, data)
+ for(QString const & item : flist)
fileListLW->addItem(item);
activeStyle_ = type;
- texdata_[type] = data;
+ texdata_[type] = flist;
}
} // namespace lyx
-#include "GuiTexinfo_moc.cpp"
+#include "moc_GuiTexinfo.cpp"