mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
less string conversions as long as we stay in the frontend
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23552 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9337d73f1f
commit
be624b3de0
@ -133,8 +133,7 @@ void GuiBibtex::browsePressed()
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
// FIXME UNICODE
|
||||
QString const filen = toqstr(changeExtension(fromqstr(file), ""));
|
||||
QString const filen = changeExtension(file, "");
|
||||
bool present = false;
|
||||
unsigned int pres = 0;
|
||||
|
||||
@ -160,7 +159,7 @@ void GuiBibtex::browseBibPressed()
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
QString const f = toqstr(changeExtension(fromqstr(file), ""));
|
||||
QString const f = changeExtension(file, "");
|
||||
bool present = false;
|
||||
|
||||
for (int i = 0; i < add_->bibLW->count(); ++i) {
|
||||
@ -213,7 +212,7 @@ void GuiBibtex::addDatabase()
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
add_->bibED->clear();
|
||||
QString const f = toqstr(changeExtension(fromqstr(file), ""));
|
||||
QString const f = changeExtension(file, "");
|
||||
QList<QListWidgetItem *> matches =
|
||||
databaseLW->findItems(f, Qt::MatchExactly);
|
||||
if (matches.empty()) {
|
||||
@ -304,15 +303,11 @@ void GuiBibtex::updateContents()
|
||||
|
||||
add_->bibLW->clear();
|
||||
|
||||
vector<string> bib_str;
|
||||
getBibFiles(bib_str);
|
||||
for (vector<string>::const_iterator it = bib_str.begin();
|
||||
it != bib_str.end(); ++it) {
|
||||
string bibItem(changeExtension(*it, ""));
|
||||
add_->bibLW->addItem(toqstr(bibItem));
|
||||
}
|
||||
QStringList bibfiles = bibFiles();
|
||||
for (int i = 0; i != bibfiles.count(); ++i)
|
||||
add_->bibLW->addItem(changeExtension(bibfiles[i], ""));
|
||||
|
||||
string bibstyle = getStylefile();
|
||||
QString bibstyle = styleFile();
|
||||
|
||||
bibtocCB->setChecked(bibtotoc() && !bibtopic);
|
||||
bibtocCB->setEnabled(!bibtopic);
|
||||
@ -334,20 +329,18 @@ void GuiBibtex::updateContents()
|
||||
|
||||
styleCB->clear();
|
||||
|
||||
int item_nr(-1);
|
||||
int item_nr = -1;
|
||||
|
||||
vector<string> str;
|
||||
getBibStyles(str);
|
||||
for (vector<string>::const_iterator it = str.begin();
|
||||
it != str.end(); ++it) {
|
||||
string item(changeExtension(*it, ""));
|
||||
QStringList str = bibStyles();
|
||||
for (int i = 0; i != str.count(); ++i) {
|
||||
QString item = changeExtension(str[i], "");
|
||||
if (item == bibstyle)
|
||||
item_nr = int(it - str.begin());
|
||||
styleCB->addItem(toqstr(item));
|
||||
item_nr = i;
|
||||
styleCB->addItem(item);
|
||||
}
|
||||
|
||||
if (item_nr == -1 && !bibstyle.empty()) {
|
||||
styleCB->addItem(toqstr(bibstyle));
|
||||
if (item_nr == -1 && !bibstyle.isEmpty()) {
|
||||
styleCB->addItem(bibstyle);
|
||||
item_nr = styleCB->count() - 1;
|
||||
}
|
||||
|
||||
@ -448,41 +441,35 @@ QString GuiBibtex::browseBst(QString const & in_name) const
|
||||
}
|
||||
|
||||
|
||||
void GuiBibtex::getBibStyles(vector<string> & data) const
|
||||
QStringList GuiBibtex::bibStyles() const
|
||||
{
|
||||
data.clear();
|
||||
|
||||
getTexFileList("bstFiles.lst", data);
|
||||
// test, if we have a valid list, otherwise run rescan
|
||||
if (data.empty()) {
|
||||
QStringList data = texFileList("bstFiles.lst");
|
||||
// test whether we have a valid list, otherwise run rescan
|
||||
if (data.isEmpty()) {
|
||||
rescanBibStyles();
|
||||
getTexFileList("bstFiles.lst", data);
|
||||
data = texFileList("bstFiles.lst");
|
||||
}
|
||||
vector<string>::iterator it = data.begin();
|
||||
vector<string>::iterator end = data.end();
|
||||
for (; it != end; ++it)
|
||||
*it = support::onlyFilename(*it);
|
||||
for (int i = 0; i != data.size(); ++i)
|
||||
data[i] = onlyFilename(data[i]);
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
data.sort();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void GuiBibtex::getBibFiles(vector<string> & data) const
|
||||
QStringList GuiBibtex::bibFiles() const
|
||||
{
|
||||
data.clear();
|
||||
|
||||
getTexFileList("bibFiles.lst", data);
|
||||
// test, if we have a valid list, otherwise run rescan
|
||||
if (data.empty()) {
|
||||
QStringList data = texFileList("bibFiles.lst");
|
||||
// test whether we have a valid list, otherwise run rescan
|
||||
if (data.isEmpty()) {
|
||||
rescanBibStyles();
|
||||
getTexFileList("bibFiles.lst", data);
|
||||
data = texFileList("bibFiles.lst");
|
||||
}
|
||||
vector<string>::iterator it = data.begin();
|
||||
vector<string>::iterator end = data.end();
|
||||
for (; it != end; ++it)
|
||||
*it = support::onlyFilename(*it);
|
||||
for (int i = 0; i != data.size(); ++i)
|
||||
data[i] = onlyFilename(data[i]);
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
data.sort();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@ -504,45 +491,48 @@ bool GuiBibtex::bibtotoc() const
|
||||
}
|
||||
|
||||
|
||||
string const GuiBibtex::getStylefile() const
|
||||
QString GuiBibtex::styleFile() const
|
||||
{
|
||||
// the different bibtex packages have (and need) their
|
||||
// own "plain" stylefiles
|
||||
biblio::CiteEngine const engine = buffer().params().getEngine();
|
||||
docstring defaultstyle;
|
||||
QString defaultstyle;
|
||||
switch (engine) {
|
||||
case biblio::ENGINE_BASIC:
|
||||
defaultstyle = from_ascii("plain");
|
||||
defaultstyle = "plain";
|
||||
break;
|
||||
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
||||
defaultstyle = from_ascii("plainnat");
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case biblio::ENGINE_NATBIB_NUMERICAL:
|
||||
defaultstyle = from_ascii("plainnat");
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case biblio::ENGINE_JURABIB:
|
||||
defaultstyle = from_ascii("jurabib");
|
||||
defaultstyle = "jurabib";
|
||||
break;
|
||||
}
|
||||
|
||||
docstring bst = params_["options"];
|
||||
QString bst = toqstr(params_["options"]);
|
||||
if (bibtotoc()){
|
||||
// bibstyle exists?
|
||||
if (contains(bst, ',')) {
|
||||
docstring bibtotoc = from_ascii("bibtotoc");
|
||||
bst = split(bst, bibtotoc, ',');
|
||||
} else
|
||||
bst.erase();
|
||||
int pos = bst.indexOf(',');
|
||||
if (pos != -1) {
|
||||
// FIXME: check
|
||||
// docstring bibtotoc = from_ascii("bibtotoc");
|
||||
// bst = split(bst, bibtotoc, ',');
|
||||
bst = bst.mid(pos);
|
||||
} else {
|
||||
bst.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// propose default style file for new insets
|
||||
// existing insets might have (legally) no bst files
|
||||
// (if the class already provides a style)
|
||||
if (bst.empty() && params_["bibfiles"].empty())
|
||||
if (bst.isEmpty() && params_["bibfiles"].empty())
|
||||
bst = defaultstyle;
|
||||
|
||||
// FIXME UNICODE
|
||||
return to_utf8(bst);
|
||||
return bst;
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,13 +18,8 @@
|
||||
#include "ui_BibtexUi.h"
|
||||
#include "ui_BibtexAddUi.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace support { class FileFilterList; }
|
||||
|
||||
namespace frontend {
|
||||
|
||||
class GuiBibtexAddDialog : public QDialog, public Ui::BibtexAddUi
|
||||
@ -43,7 +38,7 @@ class GuiBibtex : public GuiCommand, public Ui::BibtexUi
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiBibtex(GuiView & lv);
|
||||
explicit GuiBibtex(GuiView & lv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void change_adaptor();
|
||||
@ -68,14 +63,12 @@ private:
|
||||
|
||||
/// Browse for a .bib file
|
||||
QString browseBib(QString const & in_name) const;
|
||||
|
||||
/// Browse for a .bst file
|
||||
QString browseBst(QString const & in_name) const;
|
||||
|
||||
/// get the list of bst files
|
||||
void getBibStyles(std::vector<std::string> & data) const;
|
||||
QStringList bibStyles() const;
|
||||
/// get the list of bib files
|
||||
void getBibFiles(std::vector<std::string> & data) const;
|
||||
QStringList bibFiles() const;
|
||||
/// build filelists of all availabe bib/bst/cls/sty-files. done through
|
||||
/// kpsewhich and an external script, saved in *Files.lst
|
||||
void rescanBibStyles() const;
|
||||
@ -84,7 +77,7 @@ private:
|
||||
/// should we put the bibliography to the TOC?
|
||||
bool bibtotoc() const;
|
||||
/// which stylefile do we use?
|
||||
std::string const getStylefile() const;
|
||||
QString styleFile() const;
|
||||
|
||||
///
|
||||
GuiBibtexAddDialog * add_;
|
||||
|
@ -27,243 +27,90 @@ using namespace std;
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
static vector<ShapePair> const getShapeData()
|
||||
static QList<ShapePair> shapeData()
|
||||
{
|
||||
vector<ShapePair> shape(6);
|
||||
|
||||
ShapePair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = IGNORE_SHAPE;
|
||||
shape[0] = pr;
|
||||
|
||||
pr.first = qt_("Upright");
|
||||
pr.second = UP_SHAPE;
|
||||
shape[1] = pr;
|
||||
|
||||
pr.first = qt_("Italic");
|
||||
pr.second = ITALIC_SHAPE;
|
||||
shape[2] = pr;
|
||||
|
||||
pr.first = qt_("Slanted");
|
||||
pr.second = SLANTED_SHAPE;
|
||||
shape[3] = pr;
|
||||
|
||||
pr.first = qt_("Small Caps");
|
||||
pr.second = SMALLCAPS_SHAPE;
|
||||
shape[4] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = INHERIT_SHAPE;
|
||||
shape[5] = pr;
|
||||
|
||||
return shape;
|
||||
QList<ShapePair> shapes;
|
||||
shapes << ShapePair(qt_("No change"), IGNORE_SHAPE);
|
||||
shapes << ShapePair(qt_("Upright"), UP_SHAPE);
|
||||
shapes << ShapePair(qt_("Italic"), ITALIC_SHAPE);
|
||||
shapes << ShapePair(qt_("Slanted"), SLANTED_SHAPE);
|
||||
shapes << ShapePair(qt_("Small Caps"), SMALLCAPS_SHAPE);
|
||||
shapes << ShapePair(qt_("Reset"), INHERIT_SHAPE);
|
||||
return shapes;
|
||||
}
|
||||
|
||||
|
||||
static vector<SizePair> const getSizeData()
|
||||
static QList<SizePair> sizeData()
|
||||
{
|
||||
vector<SizePair> size(14);
|
||||
|
||||
SizePair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = FONT_SIZE_IGNORE;
|
||||
size[0] = pr;
|
||||
|
||||
pr.first = qt_("Tiny");
|
||||
pr.second = FONT_SIZE_TINY;
|
||||
size[1] = pr;
|
||||
|
||||
pr.first = qt_("Smallest");
|
||||
pr.second = FONT_SIZE_SCRIPT;
|
||||
size[2] = pr;
|
||||
|
||||
pr.first = qt_("Smaller");
|
||||
pr.second = FONT_SIZE_FOOTNOTE;
|
||||
size[3] = pr;
|
||||
|
||||
pr.first = qt_("Small");
|
||||
pr.second = FONT_SIZE_SMALL;
|
||||
size[4] = pr;
|
||||
|
||||
pr.first = qt_("Normal");
|
||||
pr.second = FONT_SIZE_NORMAL;
|
||||
size[5] = pr;
|
||||
|
||||
pr.first = qt_("Large");
|
||||
pr.second = FONT_SIZE_LARGE;
|
||||
size[6] = pr;
|
||||
|
||||
pr.first = qt_("Larger");
|
||||
pr.second = FONT_SIZE_LARGER;
|
||||
size[7] = pr;
|
||||
|
||||
pr.first = qt_("Largest");
|
||||
pr.second = FONT_SIZE_LARGEST;
|
||||
size[8] = pr;
|
||||
|
||||
pr.first = qt_("Huge");
|
||||
pr.second = FONT_SIZE_HUGE;
|
||||
size[9] = pr;
|
||||
|
||||
pr.first = qt_("Huger");
|
||||
pr.second = FONT_SIZE_HUGER;
|
||||
size[10] = pr;
|
||||
|
||||
pr.first = qt_("Increase");
|
||||
pr.second = FONT_SIZE_INCREASE;
|
||||
size[11] = pr;
|
||||
|
||||
pr.first = qt_("Decrease");
|
||||
pr.second = FONT_SIZE_DECREASE;
|
||||
size[12] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = FONT_SIZE_INHERIT;
|
||||
size[13] = pr;
|
||||
|
||||
return size;
|
||||
QList<SizePair> sizes;
|
||||
sizes << SizePair(qt_("No change"), FONT_SIZE_IGNORE);
|
||||
sizes << SizePair(qt_("Tiny"), FONT_SIZE_TINY);
|
||||
sizes << SizePair(qt_("Smallest"), FONT_SIZE_SCRIPT);
|
||||
sizes << SizePair(qt_("Smaller"), FONT_SIZE_FOOTNOTE);
|
||||
sizes << SizePair(qt_("Small"), FONT_SIZE_SMALL);
|
||||
sizes << SizePair(qt_("Normal"), FONT_SIZE_NORMAL);
|
||||
sizes << SizePair(qt_("Large"), FONT_SIZE_LARGE);
|
||||
sizes << SizePair(qt_("Larger"), FONT_SIZE_LARGER);
|
||||
sizes << SizePair(qt_("Largest"), FONT_SIZE_LARGEST);
|
||||
sizes << SizePair(qt_("Huge"), FONT_SIZE_HUGE);
|
||||
sizes << SizePair(qt_("Huger"), FONT_SIZE_HUGER);
|
||||
sizes << SizePair(qt_("Increase"), FONT_SIZE_INCREASE);
|
||||
sizes << SizePair(qt_("Decrease"), FONT_SIZE_DECREASE);
|
||||
sizes << SizePair(qt_("Reset"), FONT_SIZE_INHERIT);
|
||||
return sizes;
|
||||
}
|
||||
|
||||
|
||||
static vector<BarPair> const getBarData()
|
||||
static QList<BarPair> barData()
|
||||
{
|
||||
vector<BarPair> bar(5);
|
||||
|
||||
BarPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = IGNORE;
|
||||
bar[0] = pr;
|
||||
|
||||
pr.first = qt_("Emph");
|
||||
pr.second = EMPH_TOGGLE;
|
||||
bar[1] = pr;
|
||||
|
||||
pr.first = qt_("Underbar");
|
||||
pr.second = UNDERBAR_TOGGLE;
|
||||
bar[2] = pr;
|
||||
|
||||
pr.first = qt_("Noun");
|
||||
pr.second = NOUN_TOGGLE;
|
||||
bar[3] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = INHERIT;
|
||||
bar[4] = pr;
|
||||
|
||||
return bar;
|
||||
QList<BarPair> bars;
|
||||
bars << BarPair(qt_("No change"), IGNORE);
|
||||
bars << BarPair(qt_("Emph"), EMPH_TOGGLE);
|
||||
bars << BarPair(qt_("Underbar"), UNDERBAR_TOGGLE);
|
||||
bars << BarPair(qt_("Noun"), NOUN_TOGGLE);
|
||||
bars << BarPair(qt_("Reset"), INHERIT);
|
||||
return bars;
|
||||
}
|
||||
|
||||
|
||||
static vector<ColorPair> const getColorData()
|
||||
static QList<ColorPair> colorData()
|
||||
{
|
||||
vector<ColorPair> color(11);
|
||||
|
||||
ColorPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = Color_ignore;
|
||||
color[0] = pr;
|
||||
|
||||
pr.first = qt_("No color");
|
||||
pr.second = Color_none;
|
||||
color[1] = pr;
|
||||
|
||||
pr.first = qt_("Black");
|
||||
pr.second = Color_black;
|
||||
color[2] = pr;
|
||||
|
||||
pr.first = qt_("White");
|
||||
pr.second = Color_white;
|
||||
color[3] = pr;
|
||||
|
||||
pr.first = qt_("Red");
|
||||
pr.second = Color_red;
|
||||
color[4] = pr;
|
||||
|
||||
pr.first = qt_("Green");
|
||||
pr.second = Color_green;
|
||||
color[5] = pr;
|
||||
|
||||
pr.first = qt_("Blue");
|
||||
pr.second = Color_blue;
|
||||
color[6] = pr;
|
||||
|
||||
pr.first = qt_("Cyan");
|
||||
pr.second = Color_cyan;
|
||||
color[7] = pr;
|
||||
|
||||
pr.first = qt_("Magenta");
|
||||
pr.second = Color_magenta;
|
||||
color[8] = pr;
|
||||
|
||||
pr.first = qt_("Yellow");
|
||||
pr.second = Color_yellow;
|
||||
color[9] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = Color_inherit;
|
||||
color[10] = pr;
|
||||
|
||||
return color;
|
||||
QList<ColorPair> colors;
|
||||
colors << ColorPair(qt_("No change"), Color_ignore);
|
||||
colors << ColorPair(qt_("No color"), Color_none);
|
||||
colors << ColorPair(qt_("Black"), Color_black);
|
||||
colors << ColorPair(qt_("White"), Color_white);
|
||||
colors << ColorPair(qt_("Red"), Color_red);
|
||||
colors << ColorPair(qt_("Green"), Color_green);
|
||||
colors << ColorPair(qt_("Blue"), Color_blue);
|
||||
colors << ColorPair(qt_("Cyan"), Color_cyan);
|
||||
colors << ColorPair(qt_("Magenta"), Color_magenta);
|
||||
colors << ColorPair(qt_("Yellow"), Color_yellow);
|
||||
colors << ColorPair(qt_("Reset"), Color_inherit);
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
||||
static vector<SeriesPair> const getSeriesData()
|
||||
static QList<SeriesPair> seriesData()
|
||||
{
|
||||
vector<SeriesPair> series(4);
|
||||
|
||||
SeriesPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = IGNORE_SERIES;
|
||||
series[0] = pr;
|
||||
|
||||
pr.first = qt_("Medium");
|
||||
pr.second = MEDIUM_SERIES;
|
||||
series[1] = pr;
|
||||
|
||||
pr.first = qt_("Bold");
|
||||
pr.second = BOLD_SERIES;
|
||||
series[2] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = INHERIT_SERIES;
|
||||
series[3] = pr;
|
||||
|
||||
QList<SeriesPair> series;
|
||||
series << SeriesPair(qt_("No change"), IGNORE_SERIES);
|
||||
series << SeriesPair(qt_("Medium"), MEDIUM_SERIES);
|
||||
series << SeriesPair(qt_("Bold"), BOLD_SERIES);
|
||||
series << SeriesPair(qt_("Reset"), INHERIT_SERIES);
|
||||
return series;
|
||||
}
|
||||
|
||||
|
||||
static vector<FamilyPair> const getFamilyData()
|
||||
static QList<FamilyPair> familyData()
|
||||
{
|
||||
vector<FamilyPair> family(5);
|
||||
|
||||
FamilyPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = IGNORE_FAMILY;
|
||||
family[0] = pr;
|
||||
|
||||
pr.first = qt_("Roman");
|
||||
pr.second = ROMAN_FAMILY;
|
||||
family[1] = pr;
|
||||
|
||||
pr.first = qt_("Sans Serif");
|
||||
pr.second = SANS_FAMILY;
|
||||
family[2] = pr;
|
||||
|
||||
pr.first = qt_("Typewriter");
|
||||
pr.second = TYPEWRITER_FAMILY;
|
||||
family[3] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = INHERIT_FAMILY;
|
||||
family[4] = pr;
|
||||
|
||||
return family;
|
||||
QList<FamilyPair> families;
|
||||
families << FamilyPair(qt_("No change"), IGNORE_FAMILY);
|
||||
families << FamilyPair(qt_("Roman"), ROMAN_FAMILY);
|
||||
families << FamilyPair(qt_("Sans Serif"), SANS_FAMILY);
|
||||
families << FamilyPair(qt_("Typewriter"), TYPEWRITER_FAMILY);
|
||||
families << FamilyPair(qt_("Reset"), INHERIT_FAMILY);
|
||||
return families;
|
||||
}
|
||||
|
||||
|
||||
@ -293,42 +140,42 @@ GuiCharacter::GuiCharacter(GuiView & lv)
|
||||
autoapplyCB->setChecked(true);
|
||||
#endif
|
||||
|
||||
family = getFamilyData();
|
||||
series = getSeriesData();
|
||||
shape = getShapeData();
|
||||
size = getSizeData();
|
||||
bar = getBarData();
|
||||
color = getColorData();
|
||||
language = getLanguageData(true);
|
||||
family = familyData();
|
||||
series = seriesData();
|
||||
shape = shapeData();
|
||||
size = sizeData();
|
||||
bar = barData();
|
||||
color = colorData();
|
||||
language = languageData(true);
|
||||
|
||||
for (vector<FamilyPair>::const_iterator cit = family.begin();
|
||||
for (QList<FamilyPair>::const_iterator cit = family.begin();
|
||||
cit != family.end(); ++cit) {
|
||||
familyCO->addItem(cit->first);
|
||||
}
|
||||
|
||||
for (vector<SeriesPair>::const_iterator cit = series.begin();
|
||||
for (QList<SeriesPair>::const_iterator cit = series.begin();
|
||||
cit != series.end(); ++cit) {
|
||||
seriesCO->addItem(cit->first);
|
||||
}
|
||||
for (vector<ShapePair>::const_iterator cit = shape.begin();
|
||||
for (QList<ShapePair>::const_iterator cit = shape.begin();
|
||||
cit != shape.end(); ++cit) {
|
||||
shapeCO->addItem(cit->first);
|
||||
}
|
||||
for (vector<SizePair>::const_iterator cit = size.begin();
|
||||
for (QList<SizePair>::const_iterator cit = size.begin();
|
||||
cit != size.end(); ++cit) {
|
||||
sizeCO->addItem(cit->first);
|
||||
}
|
||||
for (vector<BarPair>::const_iterator cit = bar.begin();
|
||||
for (QList<BarPair>::const_iterator cit = bar.begin();
|
||||
cit != bar.end(); ++cit) {
|
||||
miscCO->addItem(cit->first);
|
||||
}
|
||||
for (vector<ColorPair>::const_iterator cit = color.begin();
|
||||
for (QList<ColorPair>::const_iterator cit = color.begin();
|
||||
cit != color.end(); ++cit) {
|
||||
colorCO->addItem(cit->first);
|
||||
}
|
||||
for (vector<LanguagePair>::const_iterator cit = language.begin();
|
||||
for (QList<LanguagePair>::const_iterator cit = language.begin();
|
||||
cit != language.end(); ++cit) {
|
||||
langCO->addItem(toqstr(cit->first));
|
||||
langCO->addItem(cit->first);
|
||||
}
|
||||
|
||||
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
|
||||
@ -376,16 +223,12 @@ void GuiCharacter::change_adaptor()
|
||||
}
|
||||
|
||||
|
||||
template<class A, class B>
|
||||
static int findPos2nd(vector<pair<A, B> > const & vec, B const & val)
|
||||
template<class B>
|
||||
static int findPos2nd(QList<pair<QString, B> > const & vec, B const & val)
|
||||
{
|
||||
typedef typename vector<pair<A, B> >::const_iterator
|
||||
const_iterator;
|
||||
|
||||
for (const_iterator cit = vec.begin(); cit != vec.end(); ++cit)
|
||||
if (cit->second == val)
|
||||
return int(cit - vec.begin());
|
||||
|
||||
for (int i = 0; i != vec.size(); ++i)
|
||||
if (vec[i].second == val)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -566,17 +409,17 @@ void GuiCharacter::setColor(ColorCode val)
|
||||
}
|
||||
|
||||
|
||||
string GuiCharacter::getLanguage() const
|
||||
QString GuiCharacter::getLanguage() const
|
||||
{
|
||||
if (reset_lang_)
|
||||
return "reset";
|
||||
if (font_.language())
|
||||
return font_.language()->lang();
|
||||
return toqstr(font_.language()->lang());
|
||||
return "ignore";
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::setLanguage(string const & val)
|
||||
void GuiCharacter::setLanguage(QString const & val)
|
||||
{
|
||||
if (val == "ignore")
|
||||
font_.setLanguage(ignore_language);
|
||||
@ -585,7 +428,7 @@ void GuiCharacter::setLanguage(string const & val)
|
||||
// Ignored in getLanguage, but needed for dispatchParams
|
||||
font_.setLanguage(buffer().params().language);
|
||||
} else {
|
||||
font_.setLanguage(languages.getLanguage(val));
|
||||
font_.setLanguage(languages.getLanguage(fromqstr(val)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,8 @@
|
||||
#include "qt_helpers.h" // for LanguagePair
|
||||
#include "Font.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace frontend {
|
||||
|
||||
enum FontState {
|
||||
@ -39,6 +36,7 @@ enum FontState {
|
||||
INHERIT
|
||||
};
|
||||
|
||||
typedef std::pair<QString, FontFamily> FamilyPair;
|
||||
typedef std::pair<QString, FontFamily> FamilyPair;
|
||||
typedef std::pair<QString, FontSeries> SeriesPair;
|
||||
typedef std::pair<QString, FontShape> ShapePair;
|
||||
@ -62,13 +60,13 @@ private:
|
||||
/// update
|
||||
void updateContents();
|
||||
|
||||
std::vector<FamilyPair> family;
|
||||
std::vector<SeriesPair> series;
|
||||
std::vector<ShapePair> shape;
|
||||
std::vector<SizePair> size;
|
||||
std::vector<BarPair> bar;
|
||||
std::vector<ColorPair> color;
|
||||
std::vector<LanguagePair> language;
|
||||
QList<FamilyPair> family;
|
||||
QList<SeriesPair> series;
|
||||
QList<ShapePair> shape;
|
||||
QList<SizePair> size;
|
||||
QList<BarPair> bar;
|
||||
QList<ColorPair> color;
|
||||
QList<LanguagePair> language;
|
||||
|
||||
///
|
||||
bool initialiseParams(std::string const & data);
|
||||
@ -94,7 +92,7 @@ private:
|
||||
///
|
||||
void setColor(ColorCode);
|
||||
///
|
||||
void setLanguage(std::string const &);
|
||||
void setLanguage(QString const &);
|
||||
|
||||
///
|
||||
FontFamily getFamily() const;
|
||||
@ -109,7 +107,7 @@ private:
|
||||
///
|
||||
ColorCode getColor() const;
|
||||
///
|
||||
std::string getLanguage() const;
|
||||
QString getLanguage() const;
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -49,13 +49,10 @@
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QTextCursor>
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
@ -63,17 +60,6 @@ using namespace lyx::support;
|
||||
|
||||
|
||||
namespace {
|
||||
///
|
||||
template<class Pair>
|
||||
vector<typename Pair::second_type> const
|
||||
getSecond(vector<Pair> const & pr)
|
||||
{
|
||||
vector<typename Pair::second_type> tmp(pr.size());
|
||||
transform(pr.begin(), pr.end(), tmp.begin(),
|
||||
boost::bind(&Pair::second, _1));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
char const * const tex_graphics[] =
|
||||
{
|
||||
@ -520,7 +506,9 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
lang_ = getSecond(getLanguageData(false));
|
||||
QList<LanguagePair> langs = languageData(false);
|
||||
for (int i = 0; i != langs.size(); ++i)
|
||||
lang_.append(langs[i].second);
|
||||
|
||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
||||
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
||||
@ -797,12 +785,11 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
// language & quotes
|
||||
vector<LanguagePair> const langs = getLanguageData(false);
|
||||
vector<LanguagePair>::const_iterator lit = langs.begin();
|
||||
vector<LanguagePair>::const_iterator lend = langs.end();
|
||||
for (; lit != lend; ++lit) {
|
||||
langModule->languageCO->addItem(toqstr(lit->first));
|
||||
}
|
||||
|
||||
QList<LanguagePair>::const_iterator lit = langs.begin();
|
||||
QList<LanguagePair>::const_iterator lend = langs.end();
|
||||
for (; lit != lend; ++lit)
|
||||
langModule->languageCO->addItem(lit->first);
|
||||
|
||||
// Always put the default encoding in the first position.
|
||||
// It is special because the displayed text is translated.
|
||||
@ -820,7 +807,6 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
langModule->quoteStyleCO->addItem(qt_(">>text<<"));
|
||||
|
||||
|
||||
|
||||
numberingModule = new UiWidget<Ui::NumberingUi>;
|
||||
// numbering
|
||||
connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
|
||||
@ -1486,7 +1472,7 @@ void GuiDocument::apply(BufferParams & params)
|
||||
params.quotes_language = lga;
|
||||
|
||||
int const pos = langModule->languageCO->currentIndex();
|
||||
params.language = lyx::languages.getLanguage(lang_[pos]);
|
||||
params.language = lyx::languages.getLanguage(fromqstr(lang_[pos]));
|
||||
|
||||
// numbering
|
||||
if (params.documentClass().hasTocLevels()) {
|
||||
@ -1659,11 +1645,10 @@ void GuiDocument::apply(BufferParams & params)
|
||||
params.orientation = ORIENTATION_PORTRAIT;
|
||||
|
||||
// margins
|
||||
params.use_geometry =
|
||||
(!marginsModule->marginCB->isChecked()
|
||||
|| geom_papersize);
|
||||
params.use_geometry = !marginsModule->marginCB->isChecked()
|
||||
|| geom_papersize;
|
||||
|
||||
Ui::MarginsUi const * m(marginsModule);
|
||||
Ui::MarginsUi const * m = marginsModule;
|
||||
|
||||
params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
|
||||
params.topmargin = widgetsToLength(m->topLE, m->topUnit);
|
||||
@ -1707,17 +1692,12 @@ void GuiDocument::apply(BufferParams & params)
|
||||
}
|
||||
|
||||
|
||||
/** Return the position of val in the vector if found.
|
||||
If not found, return 0.
|
||||
*/
|
||||
template<class A>
|
||||
static size_t findPos(vector<A> const & vec, A const & val)
|
||||
static int findPos(QStringList const & vec, QString const & val)
|
||||
{
|
||||
typename vector<A>::const_iterator it =
|
||||
find(vec.begin(), vec.end(), val);
|
||||
if (it == vec.end())
|
||||
for (int i = 0; i != vec.size(); ++i)
|
||||
if (vec[i] == val)
|
||||
return i;
|
||||
return 0;
|
||||
return distance(vec.begin(), it);
|
||||
}
|
||||
|
||||
|
||||
@ -1773,8 +1753,7 @@ void GuiDocument::updateParams(BufferParams const & params)
|
||||
params.use_bibtopic);
|
||||
|
||||
// language & quotes
|
||||
int const pos = int(findPos(lang_,
|
||||
params.language->lang()));
|
||||
int const pos = findPos(lang_, toqstr(params.language->lang()));
|
||||
langModule->languageCO->setCurrentIndex(pos);
|
||||
|
||||
langModule->quoteStyleCO->setCurrentIndex(
|
||||
@ -2039,7 +2018,7 @@ void GuiDocument::updateAvailableModules()
|
||||
modules_av_model_.clear();
|
||||
vector<modInfoStruct> const modInfoList = getModuleInfo();
|
||||
int const mSize = modInfoList.size();
|
||||
for (int i = 0; i < mSize; ++i) {
|
||||
for (int i = 0; i != mSize; ++i) {
|
||||
modInfoStruct const & modInfo = modInfoList[i];
|
||||
modules_av_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
|
||||
}
|
||||
@ -2052,7 +2031,7 @@ void GuiDocument::updateSelectedModules()
|
||||
modules_sel_model_.clear();
|
||||
vector<modInfoStruct> const selModList = getSelectedModules();
|
||||
int const sSize = selModList.size();
|
||||
for (int i = 0; i < sSize; ++i) {
|
||||
for (int i = 0; i != sSize; ++i) {
|
||||
modInfoStruct const & modInfo = selModList[i];
|
||||
modules_sel_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
|
||||
}
|
||||
@ -2119,9 +2098,9 @@ void GuiDocument::setLayoutComboByIDString(std::string const & idString)
|
||||
|
||||
bool GuiDocument::isValid()
|
||||
{
|
||||
return (validate_listings_params().empty() &&
|
||||
(textLayoutModule->skipCO->currentIndex() != 3 ||
|
||||
!textLayoutModule->skipLE->text().isEmpty()));
|
||||
return validate_listings_params().empty()
|
||||
&& (textLayoutModule->skipCO->currentIndex() != 3
|
||||
|| !textLayoutModule->skipLE->text().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,8 +160,8 @@ private:
|
||||
|
||||
GuiSelectionManager * selectionManager;
|
||||
|
||||
// FIXME
|
||||
std::vector<std::string> lang_;
|
||||
///
|
||||
QStringList lang_;
|
||||
|
||||
/// Available modules
|
||||
GuiIdListModel * availableModel() { return &modules_av_model_; }
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "support/FileFilterList.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/foreach.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/os.h"
|
||||
@ -77,13 +78,6 @@ namespace frontend {
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext = QString())
|
||||
{
|
||||
return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext));
|
||||
}
|
||||
|
||||
|
||||
/** Launch a file dialog and return the chosen file.
|
||||
filename: a suggested filename.
|
||||
title: the title of the dialog.
|
||||
@ -144,8 +138,8 @@ QString browseLibFile(QString const & dir,
|
||||
|
||||
// remove the extension if it is the default one
|
||||
QString noextresult;
|
||||
if (toqstr(getExtension(fromqstr(result))) == ext)
|
||||
noextresult = toqstr(removeExtension(fromqstr(result)));
|
||||
if (getExtension(result) == ext)
|
||||
noextresult = removeExtension(result);
|
||||
else
|
||||
noextresult = result;
|
||||
|
||||
@ -216,15 +210,12 @@ QString browseRelFile(QString const & filename, QString const & refpath,
|
||||
|
||||
namespace frontend {
|
||||
|
||||
template<class A>
|
||||
static size_t findPos_helper(vector<A> const & vec, A const & val)
|
||||
static int findPos_helper(QStringList const & vec, QString const & val)
|
||||
{
|
||||
typedef typename vector<A>::const_iterator Cit;
|
||||
|
||||
Cit it = find(vec.begin(), vec.end(), val);
|
||||
if (it == vec.end())
|
||||
for (int i = 0; i != vec.size(); ++i)
|
||||
if (vec[i] == val)
|
||||
return i;
|
||||
return 0;
|
||||
return distance(vec.begin(), it);
|
||||
}
|
||||
|
||||
|
||||
@ -1630,13 +1621,9 @@ PrefLanguage::PrefLanguage(QWidget * parent)
|
||||
defaultLanguageCO->clear();
|
||||
|
||||
// store the lang identifiers for later
|
||||
vector<LanguagePair> const langs = getLanguageData(false);
|
||||
vector<LanguagePair>::const_iterator lit = langs.begin();
|
||||
vector<LanguagePair>::const_iterator lend = langs.end();
|
||||
lang_.clear();
|
||||
for (; lit != lend; ++lit) {
|
||||
defaultLanguageCO->addItem(toqstr(lit->first));
|
||||
lang_.push_back(lit->second);
|
||||
foreach (LanguagePair const & lpair, languageData(false)) {
|
||||
defaultLanguageCO->addItem(lpair.first);
|
||||
lang_.append(lpair.second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1654,7 +1641,7 @@ void PrefLanguage::apply(LyXRC & rc) const
|
||||
rc.language_package = fromqstr(languagePackageED->text());
|
||||
rc.language_command_begin = fromqstr(startCommandED->text());
|
||||
rc.language_command_end = fromqstr(endCommandED->text());
|
||||
rc.default_language = lang_[defaultLanguageCO->currentIndex()];
|
||||
rc.default_language = fromqstr(lang_[defaultLanguageCO->currentIndex()]);
|
||||
}
|
||||
|
||||
|
||||
@ -1675,7 +1662,7 @@ void PrefLanguage::update(LyXRC const & rc)
|
||||
startCommandED->setText(toqstr(rc.language_command_begin));
|
||||
endCommandED->setText(toqstr(rc.language_command_end));
|
||||
|
||||
int const pos = int(findPos_helper(lang_, rc.default_language));
|
||||
int const pos = findPos_helper(lang_, toqstr(rc.default_language));
|
||||
defaultLanguageCO->setCurrentIndex(pos);
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ public:
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
std::vector<std::string> lang_;
|
||||
QStringList lang_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -179,7 +179,7 @@ void GuiPrint::applyView()
|
||||
bool GuiPrint::initialiseParams(string const &)
|
||||
{
|
||||
/// get global printer parameters
|
||||
string const name = changeExtension(buffer().absFileName(),
|
||||
string const name = support::changeExtension(buffer().absFileName(),
|
||||
lyxrc.print_file_extension);
|
||||
params_ = PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name);
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/foreach.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -35,17 +36,16 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
static string texFileFromList(string const & file, string const & type)
|
||||
static QString texFileFromList(QString const & file, QString const & type)
|
||||
{
|
||||
string file_ = file;
|
||||
QString file_ = file;
|
||||
// do we need to add the suffix?
|
||||
if (!(getExtension(file) == type))
|
||||
if (getExtension(file) != type)
|
||||
file_ += '.' + type;
|
||||
|
||||
lyxerr << "Searching for file " << file_ << endl;
|
||||
lyxerr << "Searching for file " << fromqstr(file_) << endl;
|
||||
|
||||
string lstfile = type + "Files.lst";
|
||||
QString lstfile = type + "Files.lst";
|
||||
if (type == "cls")
|
||||
lstfile = "clsFiles.lst";
|
||||
else if (type == "sty")
|
||||
@ -54,26 +54,26 @@ static string texFileFromList(string const & file, string const & type)
|
||||
lstfile = "bstFiles.lst";
|
||||
else if (type == "bib")
|
||||
lstfile = "bibFiles.lst";
|
||||
FileName const abslstfile = libFileSearch(string(), lstfile);
|
||||
FileName const abslstfile = libFileSearch(QString(), lstfile);
|
||||
if (abslstfile.empty()) {
|
||||
lyxerr << "File `'" << lstfile << "' not found." << endl;
|
||||
return string();
|
||||
lyxerr << "File `'" << fromqstr(lstfile) << "' not found." << endl;
|
||||
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, file) ||
|
||||
(support::onlyFilename(classfile) != file)) &&
|
||||
(++count < 1000)) {
|
||||
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 classfile;
|
||||
return toqstr(classfile);
|
||||
}
|
||||
|
||||
|
||||
@ -82,8 +82,8 @@ GuiTexInfo::GuiTexInfo(GuiView & lv)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
warningPosted = false;
|
||||
activeStyle = ClsType;
|
||||
warningPosted_ = false;
|
||||
activeStyle_ = ClsType;
|
||||
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
|
||||
@ -121,11 +121,13 @@ void GuiTexInfo::rescanClicked()
|
||||
|
||||
void GuiTexInfo::viewClicked()
|
||||
{
|
||||
size_t const fitem = fileListLW->currentRow();
|
||||
vector<string> const & data = texdata_[activeStyle];
|
||||
string file = data[fitem];
|
||||
// takes advantage of enum order
|
||||
static QString const ext[] = { "cls", "sty", "bst" };
|
||||
int const fitem = fileListLW->currentRow();
|
||||
QStringList const & data = texdata_[activeStyle_];
|
||||
QString file = data[fitem];
|
||||
if (!pathCB->isChecked())
|
||||
file = texFileFromList(data[fitem], fileType(activeStyle));
|
||||
file = texFileFromList(data[fitem], ext[activeStyle_]);
|
||||
viewFile(file);
|
||||
}
|
||||
|
||||
@ -146,51 +148,51 @@ void GuiTexInfo::enableViewPB()
|
||||
|
||||
void GuiTexInfo::updateStyles(TexFileType type)
|
||||
{
|
||||
ContentsType & data = texdata_[type];
|
||||
static QString const filenames[] = {
|
||||
"clsFile.lst", "styFiles.lst", "bstFiles.lst"
|
||||
};
|
||||
|
||||
static string filenames[] = { "clsFiles.lst", "styFiles.lst", "bstFiles.lst" };
|
||||
string filename = filenames[type];
|
||||
QString const filename = filenames[type];
|
||||
|
||||
getTexFileList(filename, data);
|
||||
QStringList data = texFileList(filename);
|
||||
if (data.empty()) {
|
||||
// build filelists of all availabe bst/cls/sty-files.
|
||||
// Done through kpsewhich and an external script,
|
||||
// saved in *Files.lst
|
||||
rescanTexStyles();
|
||||
getTexFileList(filename, data);
|
||||
data = texFileList(filename);
|
||||
}
|
||||
|
||||
if (!pathCB->isChecked()) {
|
||||
vector<string>::iterator it1 = data.begin();
|
||||
vector<string>::iterator end1 = data.end();
|
||||
for (; it1 != end1; ++it1)
|
||||
*it1 = support::onlyFilename(*it1);
|
||||
for (int i = 0; i != data.size(); ++i)
|
||||
data[i] = onlyFilename(data[i]);
|
||||
}
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
data.sort();
|
||||
|
||||
fileListLW->clear();
|
||||
ContentsType::const_iterator it = data.begin();
|
||||
ContentsType::const_iterator end = data.end();
|
||||
for (; it != end; ++it)
|
||||
fileListLW->addItem(toqstr(*it));
|
||||
foreach (QString const & item, data)
|
||||
fileListLW->addItem(item);
|
||||
|
||||
activeStyle = type;
|
||||
activeStyle_ = type;
|
||||
texdata_[type] = data;
|
||||
}
|
||||
|
||||
|
||||
void GuiTexInfo::updateStyles()
|
||||
{
|
||||
updateStyles(activeStyle);
|
||||
updateStyles(activeStyle_);
|
||||
}
|
||||
|
||||
|
||||
void GuiTexInfo::viewFile(string const & filename) const
|
||||
void GuiTexInfo::viewFile(QString const & filename) const
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "file " + filename));
|
||||
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "file " + fromqstr(filename)));
|
||||
}
|
||||
|
||||
|
||||
/// get a class with full path from the list
|
||||
/*
|
||||
string GuiTexInfo::classOptions(string const & classname) const
|
||||
{
|
||||
FileName const filename(texFileFromList(classname, "cls"));
|
||||
@ -210,14 +212,7 @@ string GuiTexInfo::classOptions(string const & classname) const
|
||||
}
|
||||
return optionList;
|
||||
}
|
||||
|
||||
|
||||
string GuiTexInfo::fileType(TexFileType type) const
|
||||
{
|
||||
// takes advantage of enum order
|
||||
static string const ext[] = { "cls", "sty", "bst" };
|
||||
return ext[type];
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Dialog * createGuiTexInfo(GuiView & lv) { return new GuiTexInfo(lv); }
|
||||
|
@ -17,9 +17,6 @@
|
||||
#include "ui_TexinfoUi.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -32,7 +29,7 @@ public:
|
||||
///
|
||||
GuiTexInfo(GuiView & lv);
|
||||
/// the file extensions. order matters in GuiTexInfo::fileType()
|
||||
enum TexFileType { ClsType, StyType, BstType };
|
||||
enum TexFileType { ClsType = 0, StyType, BstType, DummyLastType };
|
||||
|
||||
public Q_SLOTS:
|
||||
///
|
||||
@ -49,14 +46,6 @@ private Q_SLOTS:
|
||||
void enableViewPB();
|
||||
|
||||
private:
|
||||
///
|
||||
void updateStyles(TexFileType);
|
||||
///
|
||||
void updateStyles();
|
||||
///
|
||||
bool warningPosted;
|
||||
///
|
||||
TexFileType activeStyle;
|
||||
/// Nothing to initialise in this case.
|
||||
bool initialiseParams(std::string const &) { return true; }
|
||||
///
|
||||
@ -68,15 +57,21 @@ private:
|
||||
///
|
||||
void apply() {}
|
||||
|
||||
/// show contents af a file
|
||||
void viewFile(std::string const & filename) const;
|
||||
/// show all classoptions
|
||||
std::string classOptions(std::string const & filename) const;
|
||||
/// return file type as string
|
||||
std::string fileType(TexFileType type) const;
|
||||
///
|
||||
void updateStyles(TexFileType);
|
||||
///
|
||||
void updateStyles();
|
||||
///
|
||||
bool warningPosted_;
|
||||
///
|
||||
TexFileType activeStyle_;
|
||||
|
||||
typedef std::vector<std::string> ContentsType;
|
||||
std::map<TexFileType, ContentsType> texdata_;
|
||||
/// show contents af a file
|
||||
void viewFile(QString const & filename) const;
|
||||
/// show all classoptions
|
||||
//std::string classOptions(std::string const & filename) const;
|
||||
|
||||
QStringList texdata_[DummyLastType];
|
||||
};
|
||||
|
||||
|
||||
|
@ -80,23 +80,23 @@ namespace frontend {
|
||||
namespace {
|
||||
|
||||
struct PngMap {
|
||||
char const * key;
|
||||
char const * value;
|
||||
QString key;
|
||||
QString value;
|
||||
};
|
||||
|
||||
|
||||
bool operator<(PngMap const & lhs, PngMap const & rhs)
|
||||
{
|
||||
return strcmp(lhs.key, rhs.key) < 0;
|
||||
return lhs.key < rhs.key;
|
||||
}
|
||||
|
||||
|
||||
class CompareKey {
|
||||
public:
|
||||
CompareKey(string const & name) : name_(name) {}
|
||||
CompareKey(QString const & name) : name_(name) {}
|
||||
bool operator()(PngMap const & other) const { return other.key == name_; }
|
||||
private:
|
||||
string const name_;
|
||||
QString const name_;
|
||||
};
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ PngMap sorted_png_map[] = {
|
||||
size_t const nr_sorted_png_map = sizeof(sorted_png_map) / sizeof(PngMap);
|
||||
|
||||
|
||||
string const find_png(string const & name)
|
||||
QString findPng(QString const & name)
|
||||
{
|
||||
PngMap const * const begin = sorted_png_map;
|
||||
PngMap const * const end = begin + nr_sorted_png_map;
|
||||
@ -148,29 +148,30 @@ string const find_png(string const & name)
|
||||
|
||||
PngMap const * const it = find_if(begin, end, CompareKey(name));
|
||||
|
||||
string png_name;
|
||||
if (it != end)
|
||||
QString png_name;
|
||||
if (it != end) {
|
||||
png_name = it->value;
|
||||
else {
|
||||
png_name = subst(name, "_", "underscore");
|
||||
png_name = subst(png_name, ' ', '_');
|
||||
} else {
|
||||
png_name = name;
|
||||
png_name.replace('_', "underscore");
|
||||
png_name.replace(' ', '_');
|
||||
|
||||
// This way we can have "math-delim { }" on the toolbar.
|
||||
png_name = subst(png_name, "(", "lparen");
|
||||
png_name = subst(png_name, ")", "rparen");
|
||||
png_name = subst(png_name, "[", "lbracket");
|
||||
png_name = subst(png_name, "]", "rbracket");
|
||||
png_name = subst(png_name, "{", "lbrace");
|
||||
png_name = subst(png_name, "}", "rbrace");
|
||||
png_name = subst(png_name, "|", "bars");
|
||||
png_name = subst(png_name, ",", "thinspace");
|
||||
png_name = subst(png_name, ":", "mediumspace");
|
||||
png_name = subst(png_name, ";", "thickspace");
|
||||
png_name = subst(png_name, "!", "negthinspace");
|
||||
png_name.replace('(', "lparen");
|
||||
png_name.replace(')', "rparen");
|
||||
png_name.replace('[', "lbracket");
|
||||
png_name.replace(']', "rbracket");
|
||||
png_name.replace('{', "lbrace");
|
||||
png_name.replace('}', "rbrace");
|
||||
png_name.replace('|', "bars");
|
||||
png_name.replace(',', "thinspace");
|
||||
png_name.replace(':', "mediumspace");
|
||||
png_name.replace(';', "thickspace");
|
||||
png_name.replace('!', "negthinspace");
|
||||
}
|
||||
|
||||
LYXERR(Debug::GUI, "find_png(" << name << ")\n"
|
||||
<< "Looking for math PNG called \"" << png_name << '"');
|
||||
LYXERR(Debug::GUI, "findPng(" << fromqstr(name) << ")\n"
|
||||
<< "Looking for math PNG called \"" << fromqstr(png_name) << '"');
|
||||
return png_name;
|
||||
}
|
||||
|
||||
@ -182,36 +183,36 @@ static QIcon getIcon(FuncRequest const & f, bool unknown)
|
||||
{
|
||||
initializeResources();
|
||||
QPixmap pm;
|
||||
string name1;
|
||||
string name2;
|
||||
string path;
|
||||
string fullname;
|
||||
|
||||
QString name1;
|
||||
QString name2;
|
||||
QString path;
|
||||
switch (f.action) {
|
||||
case LFUN_MATH_INSERT:
|
||||
if (!f.argument().empty()) {
|
||||
path = "math/";
|
||||
name1 = find_png(to_utf8(f.argument()).substr(1));
|
||||
name1 = findPng(toqstr(f.argument()).mid(1));
|
||||
}
|
||||
break;
|
||||
case LFUN_MATH_DELIM:
|
||||
case LFUN_MATH_BIGDELIM:
|
||||
path = "math/";
|
||||
name1 = find_png(to_utf8(f.argument()));
|
||||
name1 = findPng(toqstr(f.argument()));
|
||||
break;
|
||||
case LFUN_CALL:
|
||||
path = "commands/";
|
||||
name1 = to_utf8(f.argument());
|
||||
name1 = toqstr(f.argument());
|
||||
break;
|
||||
default:
|
||||
name2 = lyxaction.getActionName(f.action);
|
||||
name2 = toqstr(lyxaction.getActionName(f.action));
|
||||
name1 = name2;
|
||||
|
||||
if (!f.argument().empty())
|
||||
name1 = subst(name2 + ' ' + to_utf8(f.argument()), ' ', '_');
|
||||
if (!f.argument().empty()) {
|
||||
name1 = name2 + ' ' + toqstr(f.argument());
|
||||
name1.replace(' ', '_');
|
||||
}
|
||||
}
|
||||
|
||||
fullname = libFileSearch("images/" + path, name1, "png").absFilename();
|
||||
string fullname = libFileSearch("images/" + path, name1, "png").absFilename();
|
||||
if (pm.load(toqstr(fullname)))
|
||||
return pm;
|
||||
|
||||
@ -219,10 +220,10 @@ static QIcon getIcon(FuncRequest const & f, bool unknown)
|
||||
if (pm.load(toqstr(fullname)))
|
||||
return pm;
|
||||
|
||||
if (pm.load(":/images/" + toqstr(path + name1) + ".png"))
|
||||
if (pm.load(":/images/" + path + name1 + ".png"))
|
||||
return pm;
|
||||
|
||||
if (pm.load(":/images/" + toqstr(path + name2) + ".png"))
|
||||
if (pm.load(":/images/" + path + name2 + ".png"))
|
||||
return pm;
|
||||
|
||||
LYXERR(Debug::GUI, "Cannot find icon for command \""
|
||||
@ -245,11 +246,13 @@ class FilterItemDelegate : public QAbstractItemDelegate {
|
||||
public:
|
||||
///
|
||||
explicit FilterItemDelegate(QObject * parent = 0)
|
||||
: QAbstractItemDelegate(parent) {}
|
||||
: QAbstractItemDelegate(parent)
|
||||
{}
|
||||
|
||||
///
|
||||
void paint(QPainter * painter, QStyleOptionViewItem const & option,
|
||||
QModelIndex const & index) const {
|
||||
QModelIndex const & index) const
|
||||
{
|
||||
QComboBox * combo = static_cast<QComboBox *>(parent());
|
||||
QStyleOptionMenuItem opt = getStyleOption(option, index);
|
||||
|
||||
@ -326,7 +329,8 @@ public:
|
||||
|
||||
///
|
||||
QSize sizeHint(QStyleOptionViewItem const & option,
|
||||
QModelIndex const & index) const {
|
||||
QModelIndex const & index) const
|
||||
{
|
||||
QComboBox * combo = static_cast<QComboBox *>(parent());
|
||||
|
||||
QStyleOptionMenuItem opt = getStyleOption(option, index);
|
||||
|
@ -1196,7 +1196,7 @@ void GuiView::openDocument(string const & fname)
|
||||
static bool import(GuiView * lv, FileName const & filename,
|
||||
string const & format, ErrorList & errorList)
|
||||
{
|
||||
FileName const lyxfile(changeExtension(filename.absFilename(), ".lyx"));
|
||||
FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
|
||||
|
||||
string loader_format;
|
||||
vector<string> loaders = theConverters().loaders();
|
||||
@ -1207,7 +1207,7 @@ static bool import(GuiView * lv, FileName const & filename,
|
||||
continue;
|
||||
|
||||
string const tofile =
|
||||
changeExtension(filename.absFilename(),
|
||||
support::changeExtension(filename.absFilename(),
|
||||
formats.extension(*it));
|
||||
if (!theConverters().convert(0, filename, FileName(tofile),
|
||||
filename, format, *it, errorList))
|
||||
@ -1238,7 +1238,7 @@ static bool import(GuiView * lv, FileName const & filename,
|
||||
lv->setBuffer(b);
|
||||
bool as_paragraphs = loader_format == "textparagraph";
|
||||
string filename2 = (loader_format == format) ? filename.absFilename()
|
||||
: changeExtension(filename.absFilename(),
|
||||
: support::changeExtension(filename.absFilename(),
|
||||
formats.extension(loader_format));
|
||||
lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
|
||||
theLyXFunc().setLyXView(lv);
|
||||
@ -1301,7 +1301,7 @@ void GuiView::importDocument(string const & argument)
|
||||
// get absolute path of file
|
||||
FileName const fullname(makeAbsPath(filename));
|
||||
|
||||
FileName const lyxfile(changeExtension(fullname.absFilename(), ".lyx"));
|
||||
FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
|
||||
|
||||
// Check if the document already is open
|
||||
Buffer * buf = theBufferList().getBuffer(lyxfile.absFilename());
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/foreach.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
@ -32,12 +33,11 @@
|
||||
#include "support/Path.h"
|
||||
#include "support/Systemcall.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPalette>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <QPalette>
|
||||
#include <QSet>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@ -47,6 +47,13 @@ using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext)
|
||||
{
|
||||
return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext));
|
||||
}
|
||||
|
||||
namespace frontend {
|
||||
|
||||
string widgetsToLength(QLineEdit const * input, LengthCombo const * combo)
|
||||
@ -146,7 +153,8 @@ class Sorter
|
||||
{
|
||||
public:
|
||||
#if !defined(USE_WCHAR_T) && defined(__GNUC__)
|
||||
bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const {
|
||||
bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const
|
||||
{
|
||||
return lhs.first < rhs.first;
|
||||
}
|
||||
#else
|
||||
@ -157,12 +165,13 @@ public:
|
||||
} catch (...) {
|
||||
loc_ok = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool operator()(LanguagePair const & lhs,
|
||||
LanguagePair const & rhs) const {
|
||||
bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const
|
||||
{
|
||||
// FIXME: would that be "QString::localeAwareCompare()"?
|
||||
if (loc_ok)
|
||||
return loc_(lhs.first, rhs.first);
|
||||
return loc_(fromqstr(lhs.first), fromqstr(rhs.first));
|
||||
else
|
||||
return lhs.first < rhs.first;
|
||||
}
|
||||
@ -176,36 +185,35 @@ private:
|
||||
} // namespace anon
|
||||
|
||||
|
||||
vector<LanguagePair> const getLanguageData(bool character_dlg)
|
||||
QList<LanguagePair> languageData(bool character_dlg)
|
||||
{
|
||||
size_t const size = languages.size() + (character_dlg ? 2 : 0);
|
||||
|
||||
vector<LanguagePair> langs(size);
|
||||
size_t const offset = character_dlg ? 2 : 0;
|
||||
vector<LanguagePair> langs(languages.size() + offset);
|
||||
|
||||
if (character_dlg) {
|
||||
langs[0].first = _("No change");
|
||||
langs[0].first = qt_("No change");
|
||||
langs[0].second = "ignore";
|
||||
langs[1].first = _("Reset");
|
||||
langs[1].first = qt_("Reset");
|
||||
langs[1].second = "reset";
|
||||
}
|
||||
|
||||
size_t i = character_dlg ? 2 : 0;
|
||||
for (Languages::const_iterator cit = languages.begin();
|
||||
cit != languages.end(); ++cit) {
|
||||
langs[i].first = _(cit->second.display());
|
||||
langs[i].second = cit->second.lang();
|
||||
++i;
|
||||
Languages::const_iterator it = languages.begin();
|
||||
for (size_t i = 0; i != languages.size(); ++i, ++it) {
|
||||
langs[i + offset].first = qt_(it->second.display());
|
||||
langs[i + offset].second = toqstr(it->second.lang());
|
||||
}
|
||||
|
||||
// Don't sort "ignore" and "reset"
|
||||
vector<LanguagePair>::iterator begin = character_dlg ?
|
||||
langs.begin() + 2 : langs.begin();
|
||||
|
||||
vector<LanguagePair>::iterator begin = langs.begin() + offset;
|
||||
sort(begin, langs.end(), Sorter());
|
||||
|
||||
return langs;
|
||||
QList<LanguagePair> list;
|
||||
foreach (LanguagePair const & l, langs)
|
||||
list.append(l);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
void rescanTexStyles()
|
||||
{
|
||||
// Run rescan in user lyx directory
|
||||
@ -223,27 +231,29 @@ void rescanTexStyles()
|
||||
}
|
||||
|
||||
|
||||
void getTexFileList(string const & filename, vector<string> & list)
|
||||
QStringList texFileList(QString const & filename)
|
||||
{
|
||||
list.clear();
|
||||
FileName const file = libFileSearch("", filename);
|
||||
QStringList list;
|
||||
FileName const file = libFileSearch(QString(), filename);
|
||||
if (file.empty())
|
||||
return;
|
||||
return list;
|
||||
|
||||
// FIXME Unicode.
|
||||
vector<docstring> doclist =
|
||||
getVectorFromString(file.fileContents("UTF-8"), from_ascii("\n"));
|
||||
|
||||
// Normalise paths like /foo//bar ==> /foo/bar
|
||||
boost::RegEx regex("/{2,}");
|
||||
vector<docstring>::iterator it = doclist.begin();
|
||||
vector<docstring>::iterator end = doclist.end();
|
||||
for (; it != end; ++it)
|
||||
list.push_back(regex.Merge(to_utf8(*it), "/"));
|
||||
QSet<QString> set;
|
||||
for (size_t i = 0; i != doclist.size(); ++i) {
|
||||
QString file = toqstr(doclist[i]);
|
||||
while (file.contains("//"))
|
||||
file.replace("//", "/");
|
||||
if (!file.isEmpty())
|
||||
set.insert(file);
|
||||
}
|
||||
|
||||
// remove empty items and duplicates
|
||||
list.erase(remove(list.begin(), list.end(), ""), list.end());
|
||||
eliminate_duplicates(list);
|
||||
// remove duplicates
|
||||
return QList<QString>::fromSet(set);
|
||||
}
|
||||
|
||||
|
||||
@ -264,4 +274,32 @@ QString onlyPath(const QString & str)
|
||||
return toqstr(support::onlyPath(fromqstr(str)));
|
||||
}
|
||||
|
||||
|
||||
QString changeExtension(QString const & oldname, QString const & ext)
|
||||
{
|
||||
return toqstr(support::changeExtension(fromqstr(oldname), fromqstr(ext)));
|
||||
}
|
||||
|
||||
/// Remove the extension from \p name
|
||||
QString removeExtension(QString const & name)
|
||||
{
|
||||
return toqstr(support::removeExtension(fromqstr(name)));
|
||||
}
|
||||
|
||||
/** Add the extension \p ext to \p name.
|
||||
Use this instead of changeExtension if you know that \p name is without
|
||||
extension, because changeExtension would wrongly interpret \p name if it
|
||||
contains a dot.
|
||||
*/
|
||||
QString addExtension(QString const & name, QString const & ext)
|
||||
{
|
||||
return toqstr(support::addExtension(fromqstr(name), fromqstr(ext)));
|
||||
}
|
||||
|
||||
/// Return the extension of the file (not including the .)
|
||||
QString getExtension(QString const & name)
|
||||
{
|
||||
return toqstr(support::getExtension(fromqstr(name)));
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -17,19 +17,19 @@
|
||||
#include "support/qstring_helpers.h"
|
||||
#include "support/strfwd.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QString;
|
||||
class QWidget;
|
||||
template <class T> class QList;
|
||||
|
||||
class LengthCombo;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace support { class FileFilterList; }
|
||||
namespace support { class FileName; }
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -71,12 +71,15 @@ QString const qt_(char const * str, const char * comment = 0);
|
||||
QString const qt_(std::string const & str);
|
||||
|
||||
///
|
||||
typedef std::pair<docstring, std::string> LanguagePair;
|
||||
typedef std::pair<QString, QString> LanguagePair;
|
||||
|
||||
/** If the caller is the character dialog, add "No change" and "Reset"
|
||||
* to the vector.
|
||||
*/
|
||||
std::vector<LanguagePair> const getLanguageData(bool character_dlg);
|
||||
QList<LanguagePair> languageData(bool character_dlg);
|
||||
|
||||
support::FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext = QString());
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
relative to relpath. If the relative path is of the form "foo.txt"
|
||||
@ -103,12 +106,27 @@ void rescanTexStyles();
|
||||
/** Fill \c contents from one of the three texfiles.
|
||||
* Each entry in the file list is returned as a name_with_path
|
||||
*/
|
||||
void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
|
||||
QStringList texFileList(QString const & filename);
|
||||
|
||||
// wrapper around the docstring versions
|
||||
QString internalPath(const QString &);
|
||||
QString onlyFilename(const QString & str);
|
||||
QString onlyPath(const QString & str);
|
||||
QString internalPath(QString const &);
|
||||
QString onlyFilename(QString const & str);
|
||||
QString onlyPath(QString const & str);
|
||||
|
||||
QString changeExtension(QString const & oldname, QString const & extension);
|
||||
|
||||
/// Remove the extension from \p name
|
||||
QString removeExtension(QString const & name);
|
||||
|
||||
/** Add the extension \p ext to \p name.
|
||||
Use this instead of changeExtension if you know that \p name is without
|
||||
extension, because changeExtension would wrongly interpret \p name if it
|
||||
contains a dot.
|
||||
*/
|
||||
QString addExtension(QString const & name, QString const & extension);
|
||||
|
||||
/// Return the extension of the file (not including the .)
|
||||
QString getExtension(QString const & name);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user