}
-bool EmbeddedFiles::enable(bool flag)
+void EmbeddedFiles::enable(bool flag)
{
if (enabled() != flag) {
// if enable, copy all files to temppath()
// if disable, extract all files
if ((flag && !updateFromExternalFile()) || (!flag && !extract()))
- return false;
+ return;
// if operation is successful
buffer_->markDirty();
buffer_->params().embedded = flag;
typedef std::vector<EmbeddedFile> EmbeddedFileList;
public:
///
- EmbeddedFiles(Buffer * buffer = NULL): file_list_(), buffer_(buffer) {}
+ EmbeddedFiles(Buffer * buffer = 0) : file_list_(), buffer_(buffer) {}
///
~EmbeddedFiles() {}
bool enabled() const;
/// set buffer params embedded flag. Files will be updated or extracted
/// if such an operation fails, enable will fail.
- bool enable(bool flag);
+ void enable(bool flag);
/// add a file item.
/* \param filename filename to add
* \param inzipName suggested inzipname
*/
void registerFile(std::string const & filename, bool embed = false,
- Inset const * inset = NULL,
+ Inset const * inset = 0,
std::string const & inzipName = std::string());
/// scan the buffer and get a list of EmbeddedFile
Buffer * buffer_;
};
+} // namespace lyx
-}
#endif
if (wa == 0) {
updateLabels(*newBuffer->getMasterBuffer());
wa = addWorkArea(*newBuffer);
- } else
+ } else {
//Disconnect the old buffer...there's no new one.
disconnectBuffer();
+ }
connectBuffer(*newBuffer);
connectBufferView(wa->bufferView());
setCurrentWorkArea(wa);
void LyXView::updateWindowTitle()
{
- docstring maximize_title = lyx::from_ascii("LyX");
- docstring minimize_title = lyx::from_ascii("LyX");
+ docstring maximize_title = from_ascii("LyX");
+ docstring minimize_title = from_ascii("LyX");
Buffer * buf = buffer();
if (buf) {
minimize_title = lyx::from_utf8(onlyFilename(cur_title));
if (!buf->isClean()) {
maximize_title += _(" (changed)");
- minimize_title += lyx::char_type('*');
+ minimize_title += char_type('*');
}
if (buf->isReadonly())
maximize_title += _(" (read only)");
#ifndef CONTROLCHARACTER_H
#define CONTROLCHARACTER_H
-
#include "Dialog.h"
-#include "frontend_helpers.h"
+#include "Font.h"
#include <boost/scoped_ptr.hpp>
namespace frontend {
+enum FONT_STATE {
+ ///
+ IGNORE,
+ ///
+ EMPH_TOGGLE,
+ ///
+ UNDERBAR_TOGGLE,
+ ///
+ NOUN_TOGGLE,
+ ///
+ INHERIT
+};
+
class ControlCharacter : public Controller {
public:
///
#include "FuncRequest.h"
#include "support/filetools.h"
+#include "support/FileName.h"
+#include "support/lstrings.h"
#include <algorithm>
using std::vector;
namespace lyx {
-
-using support::onlyFilename;
-
namespace frontend {
-void getTexFileList(ControlTexinfo::texFileSuffix type,
- std::vector<string> & list, bool withPath)
-{
- string filename;
- switch (type) {
- case ControlTexinfo::bst:
- filename = "bstFiles.lst";
- break;
- case ControlTexinfo::cls:
- filename = "clsFiles.lst";
- break;
- case ControlTexinfo::sty:
- filename = "styFiles.lst";
- break;
- }
- getTexFileList(filename, list);
- if (list.empty()) {
- // build filelists of all availabe bst/cls/sty-files.
- // Done through kpsewhich and an external script,
- // saved in *Files.lst
- rescanTexStyles();
- getTexFileList(filename, list);
- }
- if (withPath)
- return;
- vector<string>::iterator it = list.begin();
- vector<string>::iterator end = list.end();
- for (; it != end; ++it) {
- *it = onlyFilename(*it);
- }
- // sort on filename only (no path)
- std::sort(list.begin(), list.end());
-}
+using support::FileName;
+using support::contains;
+using support::split;
+using support::token;
ControlTexinfo::ControlTexinfo(Dialog & parent)
}
-string const ControlTexinfo::getClassOptions(string const & filename) const
+string const ControlTexinfo::getClassOptions(string const & classname) const
{
- return getListOfOptions(filename, "cls");
+ FileName const filename(getTexFileFromList(classname, "cls"));
+ if (filename.empty())
+ return string();
+ string optionList = string();
+ std::ifstream is(filename.toFilesystemEncoding().c_str());
+ while (is) {
+ string s;
+ is >> s;
+ if (contains(s, "DeclareOption")) {
+ s = s.substr(s.find("DeclareOption"));
+ s = split(s, '{'); // cut front
+ s = token(s, '}', 0); // cut end
+ optionList += (s + '\n');
+ }
+ }
+ return optionList;
}
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/Package.h"
-#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxalgo.h"
#include "support/os.h"
using std::endl;
namespace lyx {
-
namespace frontend {
-vector<FamilyPair> const getFamilyData()
-{
- vector<FamilyPair> family(5);
-
- FamilyPair pr;
-
- pr.first = _("No change");
- pr.second = Font::IGNORE_FAMILY;
- family[0] = pr;
-
- pr.first = _("Roman");
- pr.second = Font::ROMAN_FAMILY;
- family[1] = pr;
-
- pr.first = _("Sans Serif");
- pr.second = Font::SANS_FAMILY;
- family[2] = pr;
-
- pr.first = _("Typewriter");
- pr.second = Font::TYPEWRITER_FAMILY;
- family[3] = pr;
-
- pr.first = _("Reset");
- pr.second = Font::INHERIT_FAMILY;
- family[4] = pr;
-
- return family;
-}
-
-
-vector<SeriesPair> const getSeriesData()
-{
- vector<SeriesPair> series(4);
-
- SeriesPair pr;
-
- pr.first = _("No change");
- pr.second = Font::IGNORE_SERIES;
- series[0] = pr;
-
- pr.first = _("Medium");
- pr.second = Font::MEDIUM_SERIES;
- series[1] = pr;
-
- pr.first = _("Bold");
- pr.second = Font::BOLD_SERIES;
- series[2] = pr;
-
- pr.first = _("Reset");
- pr.second = Font::INHERIT_SERIES;
- series[3] = pr;
-
- return series;
-}
-
-
-vector<ShapePair> const getShapeData()
-{
- vector<ShapePair> shape(6);
-
- ShapePair pr;
-
- pr.first = _("No change");
- pr.second = Font::IGNORE_SHAPE;
- shape[0] = pr;
-
- pr.first = _("Upright");
- pr.second = Font::UP_SHAPE;
- shape[1] = pr;
-
- pr.first = _("Italic");
- pr.second = Font::ITALIC_SHAPE;
- shape[2] = pr;
-
- pr.first = _("Slanted");
- pr.second = Font::SLANTED_SHAPE;
- shape[3] = pr;
-
- pr.first = _("Small Caps");
- pr.second = Font::SMALLCAPS_SHAPE;
- shape[4] = pr;
-
- pr.first = _("Reset");
- pr.second = Font::INHERIT_SHAPE;
- shape[5] = pr;
-
- return shape;
-}
-
-
-vector<SizePair> const getSizeData()
-{
- vector<SizePair> size(14);
-
- SizePair pr;
-
- pr.first = _("No change");
- pr.second = Font::IGNORE_SIZE;
- size[0] = pr;
-
- pr.first = _("Tiny");
- pr.second = Font::SIZE_TINY;
- size[1] = pr;
-
- pr.first = _("Smallest");
- pr.second = Font::SIZE_SCRIPT;
- size[2] = pr;
-
- pr.first = _("Smaller");
- pr.second = Font::SIZE_FOOTNOTE;
- size[3] = pr;
-
- pr.first = _("Small");
- pr.second = Font::SIZE_SMALL;
- size[4] = pr;
-
- pr.first = _("Normal");
- pr.second = Font::SIZE_NORMAL;
- size[5] = pr;
-
- pr.first = _("Large");
- pr.second = Font::SIZE_LARGE;
- size[6] = pr;
-
- pr.first = _("Larger");
- pr.second = Font::SIZE_LARGER;
- size[7] = pr;
-
- pr.first = _("Largest");
- pr.second = Font::SIZE_LARGEST;
- size[8] = pr;
-
- pr.first = _("Huge");
- pr.second = Font::SIZE_HUGE;
- size[9] = pr;
-
- pr.first = _("Huger");
- pr.second = Font::SIZE_HUGER;
- size[10] = pr;
-
- pr.first = _("Increase");
- pr.second = Font::INCREASE_SIZE;
- size[11] = pr;
-
- pr.first = _("Decrease");
- pr.second = Font::DECREASE_SIZE;
- size[12] = pr;
-
- pr.first = _("Reset");
- pr.second = Font::INHERIT_SIZE;
- size[13] = pr;
-
- return size;
-}
-
-
-vector<BarPair> const getBarData()
-{
- vector<BarPair> bar(5);
-
- BarPair pr;
-
- pr.first = _("No change");
- pr.second = IGNORE;
- bar[0] = pr;
-
- pr.first = _("Emph");
- pr.second = EMPH_TOGGLE;
- bar[1] = pr;
-
- pr.first = _("Underbar");
- pr.second = UNDERBAR_TOGGLE;
- bar[2] = pr;
-
- pr.first = _("Noun");
- pr.second = NOUN_TOGGLE;
- bar[3] = pr;
-
- pr.first = _("Reset");
- pr.second = INHERIT;
- bar[4] = pr;
-
- return bar;
-}
-
-
-vector<ColorPair> const getColorData()
-{
- vector<ColorPair> color(11);
-
- ColorPair pr;
-
- pr.first = _("No change");
- pr.second = Color::ignore;
- color[0] = pr;
-
- pr.first = _("No color");
- pr.second = Color::none;
- color[1] = pr;
-
- pr.first = _("Black");
- pr.second = Color::black;
- color[2] = pr;
-
- pr.first = _("White");
- pr.second = Color::white;
- color[3] = pr;
-
- pr.first = _("Red");
- pr.second = Color::red;
- color[4] = pr;
-
- pr.first = _("Green");
- pr.second = Color::green;
- color[5] = pr;
-
- pr.first = _("Blue");
- pr.second = Color::blue;
- color[6] = pr;
-
- pr.first = _("Cyan");
- pr.second = Color::cyan;
- color[7] = pr;
-
- pr.first = _("Magenta");
- pr.second = Color::magenta;
- color[8] = pr;
-
- pr.first = _("Yellow");
- pr.second = Color::yellow;
- color[9] = pr;
-
- pr.first = _("Reset");
- pr.second = Color::inherit;
- color[10] = pr;
-
- return color;
-}
-
-
namespace {
-class Sorter
- : public std::binary_function<LanguagePair,
- LanguagePair, bool>
+struct Sorter
{
-public:
- bool operator()(LanguagePair const & lhs,
- LanguagePair const & rhs) const {
+ bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const {
return lhs.first < rhs.first;
}
};
-class ColorSorter
-{
-public:
- bool operator()(Color::color const & lhs,
- Color::color const & rhs) const {
- return lcolor.getGUIName(lhs) < lcolor.getGUIName(rhs);
- }
-};
-
} // namespace anon
return langs;
}
-
-vector<Color_color> const getSortedColors(vector<Color_color> colors)
-{
- // sort the colors
- std::sort(colors.begin(), colors.end(), ColorSorter());
- return colors;
-}
-
} // namespace frontend
using support::addName;
using support::onlyFilename;
using support::package;
using support::quoteName;
-using support::split;
using support::Systemcall;
using support::token;
}
-string const getListOfOptions(string const & classname, string const & type)
-{
- FileName const filename(getTexFileFromList(classname, type));
- if (filename.empty())
- return string();
- string optionList = string();
- std::ifstream is(filename.toFilesystemEncoding().c_str());
- while (is) {
- string s;
- is >> s;
- if (contains(s,"DeclareOption")) {
- s = s.substr(s.find("DeclareOption"));
- s = split(s,'{'); // cut front
- s = token(s,'}',0); // cut end
- optionList += (s + '\n');
- }
- }
- return optionList;
-}
-
-
string const getTexFileFromList(string const & file,
string const & type)
{
#ifndef FRONTEND_HELPERS_H
#define FRONTEND_HELPERS_H
-#include "Font.h"
#include "support/docstring.h"
#include <utility>
#include <boost/bind.hpp>
-class Color_color;
-
-/** Functions of use to the character GUI controller and view */
namespace lyx {
namespace support { class FileFilterList; }
namespace frontend {
-///
-enum FONT_STATE {
- ///
- IGNORE,
- ///
- EMPH_TOGGLE,
- ///
- UNDERBAR_TOGGLE,
- ///
- NOUN_TOGGLE,
- ///
- INHERIT
-};
-
-///
-typedef std::pair<docstring, Font::FONT_FAMILY> FamilyPair;
-///
-typedef std::pair<docstring, Font::FONT_SERIES> SeriesPair;
-///
-typedef std::pair<docstring, Font::FONT_SHAPE> ShapePair;
-///
-typedef std::pair<docstring, Font::FONT_SIZE> SizePair;
-///
-typedef std::pair<docstring, FONT_STATE> BarPair;
-///
-typedef std::pair<docstring, Color_color> ColorPair;
-
-///
-std::vector<FamilyPair> const getFamilyData();
-///
-std::vector<SeriesPair> const getSeriesData();
-///
-std::vector<ShapePair> const getShapeData();
-///
-std::vector<SizePair> const getSizeData();
-///
-std::vector<BarPair> const getBarData();
-///
-std::vector<ColorPair> const getColorData();
-
///
template<class Pair>
std::vector<typename Pair::second_type> const
typedef std::pair<docstring, std::string> LanguagePair;
/** If the caller is the character dialog, add "No change" and "Reset"
- * to the vector.
- */
+* to the vector.
+*/
std::vector<LanguagePair> const getLanguageData(bool character_dlg);
-/// sort colors for the gui
-std::vector<Color_color> const getSortedColors(std::vector<Color_color> colors);
/** Launch a file dialog and return the chosen file.
- filename: a suggested filename.
- title: the title of the dialog.
- pattern: *.ps etc.
- dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+ filename: a suggested filename.
+ title: the title of the dialog.
+ pattern: *.ps etc.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
*/
docstring const
browseFile(docstring const & filename,
- docstring const & title,
- support::FileFilterList const & filters,
- bool save = false,
- std::pair<docstring, docstring> const & dir1 =
- std::make_pair(docstring(), docstring()),
- std::pair<docstring, docstring> const & dir2 =
- std::make_pair(docstring(), docstring()));
+ docstring const & title,
+ support::FileFilterList const & filters,
+ bool save = false,
+ std::pair<docstring, docstring> const & dir1 =
+ std::make_pair(docstring(), docstring()),
+ std::pair<docstring, docstring> const & dir2 =
+ std::make_pair(docstring(), docstring()));
/** Wrapper around browseFile which tries to provide a filename
- relative to relpath. If the relative path is of the form "foo.txt"
- or "bar/foo.txt", then it is returned as relative. OTOH, if it is
- of the form "../baz/foo.txt", an absolute path is returned. This is
- intended to be useful for insets which encapsulate files/
+ relative to relpath. If the relative path is of the form "foo.txt"
+ or "bar/foo.txt", then it is returned as relative. OTOH, if it is
+ of the form "../baz/foo.txt", an absolute path is returned. This is
+ intended to be useful for insets which encapsulate files/
*/
docstring const
browseRelFile(docstring const & filename,
- docstring const & refpath,
- docstring const & title,
- support::FileFilterList const & filters,
- bool save = false,
- std::pair<docstring, docstring> const & dir1 =
- std::make_pair(docstring(), docstring()),
- std::pair<docstring, docstring> const & dir2 =
- std::make_pair(docstring(), docstring()));
+ docstring const & refpath,
+ docstring const & title,
+ support::FileFilterList const & filters,
+ bool save = false,
+ std::pair<docstring, docstring> const & dir1 =
+ std::make_pair(docstring(), docstring()),
+ std::pair<docstring, docstring> const & dir2 =
+ std::make_pair(docstring(), docstring()));
/** Wrapper around browseFile which tries to provide a filename
- * relative to the user or system directory. The dir, name and ext
- * parameters have the same meaning as in the
- * support::LibFileSearch function.
- */
+* relative to the user or system directory. The dir, name and ext
+* parameters have the same meaning as in the
+* support::LibFileSearch function.
+*/
docstring const
browseLibFile(docstring const & dir,
- docstring const & name,
- docstring const & ext,
- docstring const & title,
- support::FileFilterList const & filters);
+ docstring const & name,
+ docstring const & ext,
+ docstring const & title,
+ support::FileFilterList const & filters);
/** Launch a file dialog and return the chosen directory.
- pathname: a suggested pathname.
- title: the title of the dialog.
- dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+ pathname: a suggested pathname.
+ title: the title of the dialog.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
*/
docstring const
browseDir(docstring const & pathname,
- docstring const & title,
- std::pair<docstring, docstring> const & dir1 =
- std::make_pair(docstring(), docstring()),
- std::pair<docstring, docstring> const & dir2 =
- std::make_pair(docstring(), docstring()));
+ docstring const & title,
+ std::pair<docstring, docstring> const & dir1 =
+ std::make_pair(docstring(), docstring()),
+ std::pair<docstring, docstring> const & dir2 =
+ std::make_pair(docstring(), docstring()));
/// Returns a vector of units that can be used to create a valid LaTeX length.
/** Build filelists of all availabe bst/cls/sty-files. Done through
- * kpsewhich and an external script, saved in *Files.lst.
- */
+* kpsewhich and an external script, saved in *Files.lst.
+*/
void rescanTexStyles();
/// rebuild the textree
*/
void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
-/// get the options of stylefile
-std::string const getListOfOptions(std::string const & classname, std::string const & type);
-
/// get a class with full path from the list
std::string const getTexFileFromList(std::string const & classname, std::string const & type);
#include "ControlCharacter.h"
#include "qt_helpers.h"
-#include "frontend_helpers.h"
#include "Color.h"
+#include "Font.h"
#include <QCloseEvent>
namespace lyx {
namespace frontend {
+static vector<ShapePair> const getShapeData()
+{
+ vector<ShapePair> shape(6);
+
+ ShapePair pr;
+
+ pr.first = qt_("No change");
+ pr.second = Font::IGNORE_SHAPE;
+ shape[0] = pr;
+
+ pr.first = qt_("Upright");
+ pr.second = Font::UP_SHAPE;
+ shape[1] = pr;
+
+ pr.first = qt_("Italic");
+ pr.second = Font::ITALIC_SHAPE;
+ shape[2] = pr;
+
+ pr.first = qt_("Slanted");
+ pr.second = Font::SLANTED_SHAPE;
+ shape[3] = pr;
+
+ pr.first = qt_("Small Caps");
+ pr.second = Font::SMALLCAPS_SHAPE;
+ shape[4] = pr;
+
+ pr.first = qt_("Reset");
+ pr.second = Font::INHERIT_SHAPE;
+ shape[5] = pr;
+
+ return shape;
+}
+
+
+static vector<SizePair> const getSizeData()
+{
+ vector<SizePair> size(14);
+
+ SizePair pr;
+
+ pr.first = qt_("No change");
+ pr.second = Font::IGNORE_SIZE;
+ 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::INCREASE_SIZE;
+ size[11] = pr;
+
+ pr.first = qt_("Decrease");
+ pr.second = Font::DECREASE_SIZE;
+ size[12] = pr;
+
+ pr.first = qt_("Reset");
+ pr.second = Font::INHERIT_SIZE;
+ size[13] = pr;
+
+ return size;
+}
+
+
+static vector<BarPair> const getBarData()
+{
+ 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;
+}
+
+
+static vector<ColorPair> const getColorData()
+{
+ 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;
+}
+
+
+static vector<SeriesPair> const getSeriesData()
+{
+ vector<SeriesPair> series(4);
+
+ SeriesPair pr;
+
+ pr.first = qt_("No change");
+ pr.second = Font::IGNORE_SERIES;
+ series[0] = pr;
+
+ pr.first = qt_("Medium");
+ pr.second = Font::MEDIUM_SERIES;
+ series[1] = pr;
+
+ pr.first = qt_("Bold");
+ pr.second = Font::BOLD_SERIES;
+ series[2] = pr;
+
+ pr.first = qt_("Reset");
+ pr.second = Font::INHERIT_SERIES;
+ series[3] = pr;
+
+ return series;
+}
+
+
+static vector<FamilyPair> const getFamilyData()
+{
+ vector<FamilyPair> family(5);
+
+ FamilyPair pr;
+
+ pr.first = qt_("No change");
+ pr.second = Font::IGNORE_FAMILY;
+ family[0] = pr;
+
+ pr.first = qt_("Roman");
+ pr.second = Font::ROMAN_FAMILY;
+ family[1] = pr;
+
+ pr.first = qt_("Sans Serif");
+ pr.second = Font::SANS_FAMILY;
+ family[2] = pr;
+
+ pr.first = qt_("Typewriter");
+ pr.second = Font::TYPEWRITER_FAMILY;
+ family[3] = pr;
+
+ pr.first = qt_("Reset");
+ pr.second = Font::INHERIT_FAMILY;
+ family[4] = pr;
+
+ return family;
+}
+
+
GuiCharacterDialog::GuiCharacterDialog(LyXView & lv)
: GuiDialog(lv, "character")
{
for (vector<FamilyPair>::const_iterator cit = family.begin();
cit != family.end(); ++cit) {
- familyCO->addItem(toqstr(cit->first));
+ familyCO->addItem(cit->first);
}
for (vector<SeriesPair>::const_iterator cit = series.begin();
cit != series.end(); ++cit) {
- seriesCO->addItem(toqstr(cit->first));
+ seriesCO->addItem(cit->first);
}
for (vector<ShapePair>::const_iterator cit = shape.begin();
cit != shape.end(); ++cit) {
- shapeCO->addItem(toqstr(cit->first));
+ shapeCO->addItem(cit->first);
}
for (vector<SizePair>::const_iterator cit = size.begin();
cit != size.end(); ++cit) {
- sizeCO->addItem(toqstr(cit->first));
+ sizeCO->addItem(cit->first);
}
for (vector<BarPair>::const_iterator cit = bar.begin();
cit != bar.end(); ++cit) {
- miscCO->addItem(toqstr(cit->first));
+ miscCO->addItem(cit->first);
}
for (vector<ColorPair>::const_iterator cit = color.begin();
cit != color.end(); ++cit) {
- colorCO->addItem(toqstr(cit->first));
+ colorCO->addItem(cit->first);
}
for (vector<LanguagePair>::const_iterator cit = language.begin();
cit != language.end(); ++cit) {
template<class A, class B>
-static int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
+static int findPos2nd(vector<std::pair<A, B> > const & vec, B const & val)
{
typedef typename vector<std::pair<A, B> >::const_iterator
const_iterator;
- const_iterator cit = vec.begin();
- for (; cit != vec.end(); ++cit) {
+ for (const_iterator cit = vec.begin(); cit != vec.end(); ++cit)
if (cit->second == val)
return int(cit - vec.begin());
- }
+
return 0;
}
{
ControlCharacter const & ctrl = controller();
- familyCO->setCurrentIndex(findPos2nd(family,
- ctrl.getFamily()));
- seriesCO->setCurrentIndex(findPos2nd(series,
- ctrl.getSeries()));
+ familyCO->setCurrentIndex(findPos2nd(family, ctrl.getFamily()));
+ seriesCO->setCurrentIndex(findPos2nd(series, ctrl.getSeries()));
shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
- langCO->setCurrentIndex(findPos2nd(language,
- ctrl.getLanguage()));
+ langCO->setCurrentIndex(findPos2nd(language, ctrl.getLanguage()));
toggleallCB->setChecked(ctrl.getToggleAll());
}
#include "GuiDialog.h"
#include "ControlCharacter.h"
#include "ui_CharacterUi.h"
+#include "frontend_helpers.h" // for LanguagePair
#include <vector>
namespace lyx {
namespace frontend {
+typedef std::pair<QString, Font::FONT_FAMILY> FamilyPair;
+typedef std::pair<QString, Font::FONT_SERIES> SeriesPair;
+typedef std::pair<QString, Font::FONT_SHAPE> ShapePair;
+typedef std::pair<QString, Font::FONT_SIZE> SizePair;
+typedef std::pair<QString, FONT_STATE> BarPair;
+typedef std::pair<QString, Color_color> ColorPair;
+
class GuiCharacterDialog : public GuiDialog, public Ui::CharacterUi
{
Q_OBJECT
#include <QString>
#include "support/lstrings.h"
+
using lyx::support::internalLineEnding;
using lyx::support::externalLineEnding;
#include "GuiEmbeddedFiles.h"
#include "debug.h"
-#include "support/convert.h"
-using std::string;
namespace lyx {
-
namespace frontend {
-
GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog
(ControlEmbeddedFiles & controller)
: controller_(controller)
k = (k + 1) % files[idx].refCount();
item->setData(Qt::UserRole, k);
// update label
- string label = files[idx].inzipName() + " ("
- + convert<string>(k + 1) + "/"
- + convert<string>(files[idx].refCount()) + ")";
- item->setText(toqstr(label));
+ QString label = toqstr(files[idx].inzipName())
+ + QString(" (%1/%2)").arg(k + 1).arg(files[idx].refCount());
+ item->setText(label);
} else
controller_.goTo(files[idx], 0);
}
void GuiEmbeddedFilesDialog::updateView()
{
filesLW->clear();
- //
EmbeddedFiles const & files = controller_.embeddedFiles();
EmbeddedFiles::EmbeddedFileList::const_iterator it = files.begin();
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = files.end();
for (; it != it_end; ++it) {
- string label = it->inzipName();
+ QString label = toqstr(it->inzipName());
if (it->refCount() > 1)
- label += " (1/" + convert<string>(it->refCount()) + ")";
- QListWidgetItem * item = new QListWidgetItem(toqstr(label));
+ label += " (1/" + QString::number(it->refCount()) + ")";
+ QListWidgetItem * item = new QListWidgetItem(label);
Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
if (it->valid())
flag |= Qt::ItemIsEnabled;
#include "support/Package.h"
#include "support/os.h"
-#include <qfontinfo.h>
+#include <QFontInfo>
#include <QFontDatabase>
-#include <boost/tuple/tuple.hpp>
-
-#ifdef Q_WS_X11
-#include <qwidget.h>
-//#include <X11/Xlib.h>
-#include <algorithm>
-#endif
-
using lyx::support::contains;
using lyx::support::package;
using lyx::support::addPath;
#include "support/lstrings.h" // ascii_lowercase
#include <QPainter>
-#include <QPictureIO>
-#include <QPicture>
#include <QImage>
#include <QImageReader>
using std::find_if;
using std::string;
-QPictureIO StaticPicture;
-
namespace lyx {
namespace graphics {
}
-namespace {
-
// This code is taken from KImageEffect::toGray
-QImage & toGray(QImage & img)
+static QImage & toGray(QImage & img)
{
if (img.width() == 0 || img.height() == 0)
return img;
return img;
}
-} // namespace anon
-
bool GuiImage::setPixmap_impl(Params const & params)
{
#include "insets/InsetListingsParams.h"
#include "debug.h"
-#include "support/convert.h"
#include "support/lstrings.h"
#include <QLineEdit>
#include <QValidator>
#include <QCloseEvent>
-#include <boost/tuple/tuple.hpp>
-#include <boost/bind.hpp>
-
#include <iomanip>
#include <sstream>
#include <algorithm>
//
/////////////////////////////////////////////////////////////////////
+namespace {
+
+struct ColorSorter
+{
+ bool operator()(Color::color const & lhs, Color::color const & rhs) const {
+ return lcolor.getGUIName(lhs) < lcolor.getGUIName(rhs);
+ }
+};
+
+} // namespace anon
+
PrefColors::PrefColors(GuiPrefsDialog * form, QWidget * parent)
: PrefModule( _("Colors"), form, parent)
{
lcolors_.push_back(lc);
}
- lcolors_ = frontend::getSortedColors(lcolors_);
+ std::sort(lcolors_.begin(), lcolors_.end(), ColorSorter());
vector<Color_color>::const_iterator cit = lcolors_.begin();
vector<Color_color>::const_iterator const end = lcolors_.end();
- for (; cit != end; ++cit)
- {
- // This is not a memory leak:
- /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(icon),
+ for (; cit != end; ++cit) {
+ (void) new QListWidgetItem(QIcon(icon),
toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
}
curcolors_.resize(lcolors_.size());
#include "Validator.h"
#include "qt_helpers.h"
-#include "support/convert.h"
-
#include <QCloseEvent>
#include <QCheckBox>
#include <QPushButton>
Tabular::row_type const row = tabular.cellRow(cell);
Tabular::col_type const col = tabular.cellColumn(cell);
- tabularRowED->setText(toqstr(convert<string>(row + 1)));
- tabularColumnED->setText(toqstr(convert<string>(col + 1)));
+ tabularRowED->setText(QString::number(row + 1));
+ tabularColumnED->setText(QString::number(col + 1));
bool const multicol(tabular.isMultiColumn(cell));
}
-void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
+void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix type)
{
- ContentsType & data = texdata_[whichStyle];
+ ContentsType & data = texdata_[type];
+
+ string filename;
+ switch (type) {
+ case ControlTexinfo::bst:
+ filename = "bstFiles.lst";
+ break;
+ case ControlTexinfo::cls:
+ filename = "clsFiles.lst";
+ break;
+ case ControlTexinfo::sty:
+ filename = "styFiles.lst";
+ break;
+ }
+ getTexFileList(filename, data);
+ 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);
+ }
bool const withFullPath = pathCB->isChecked();
+ if (withFullPath)
+ return;
+ vector<string>::iterator it1 = data.begin();
+ vector<string>::iterator end1 = data.end();
+ for (; it1 != end1; ++it1)
+ *it1 = support::onlyFilename(*it1);
- getTexFileList(whichStyle, data, withFullPath);
+ // sort on filename only (no path)
+ std::sort(data.begin(), data.end());
fileListLW->clear();
ContentsType::const_iterator it = data.begin();
for (; it != end; ++it)
fileListLW->addItem(toqstr(*it));
- activeStyle = whichStyle;
+ activeStyle = type;
}
#include "Spacing.h"
#include "VSpace.h"
-#include "ControlVSpace.h"
-#include "frontend_helpers.h"
-
#include "support/lstrings.h"
#include <QCheckBox>
#include "version.h"
#include "support/filetools.h" // LibFileSearch
-#include "support/convert.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"
#include "insets/InsetWrap.h"
-#include "support/convert.h"
#include "support/lstrings.h"
#include <QLineEdit>
}
-static string const numtostr(double val)
-{
- string a = convert<string>(val);
- return a;
- //0pt is a legal width now, it yields a
- //wrapfloat just wide enough for the contents.
-}
-
-
void GuiWrapDialog::updateContents()
{
InsetWrapParams & params = controller().params();
Length len(params.width);
- widthED->setText(toqstr(numtostr(len.value())));
+ //0pt is a legal width now, it yields a
+ //wrapfloat just wide enough for the contents.
+ widthED->setText(QString::number(len.value()));
unitsLC->setCurrentItem(len.unit());
int item = 0;
#include "support/os.h"
#include "support/lstrings.h"
-#include "support/convert.h"
#include "debug.h"
Length const & len, Length::UNIT /*defaultUnit*/)
{
combo->setCurrentItem(Length(len).unit());
- input->setText(toqstr(convert<string>(Length(len).value())));
+ input->setText(QString::number(Length(len).value()));
}