shuffle stuff around

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20225 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-11 21:27:57 +00:00
parent 470aba2a0e
commit cc4b9be893
21 changed files with 416 additions and 511 deletions

View File

@ -231,13 +231,13 @@ bool EmbeddedFiles::enabled() const
}
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;

View File

@ -174,7 +174,7 @@ public:
typedef std::vector<EmbeddedFile> EmbeddedFileList;
public:
///
EmbeddedFiles(Buffer * buffer = NULL): file_list_(), buffer_(buffer) {}
EmbeddedFiles(Buffer * buffer = 0) : file_list_(), buffer_(buffer) {}
///
~EmbeddedFiles() {}
@ -182,7 +182,7 @@ public:
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
@ -192,7 +192,7 @@ public:
* \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
@ -229,6 +229,6 @@ private:
Buffer * buffer_;
};
} // namespace lyx
}
#endif

View File

@ -115,9 +115,10 @@ void LyXView::setBuffer(Buffer * newBuffer)
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);
@ -384,8 +385,8 @@ void LyXView::updateLayoutChoice()
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) {
@ -395,7 +396,7 @@ void LyXView::updateWindowTitle()
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)");

View File

@ -12,9 +12,8 @@
#ifndef CONTROLCHARACTER_H
#define CONTROLCHARACTER_H
#include "Dialog.h"
#include "frontend_helpers.h"
#include "Font.h"
#include <boost/scoped_ptr.hpp>
@ -24,6 +23,19 @@ class Color_color;
namespace frontend {
enum FONT_STATE {
///
IGNORE,
///
EMPH_TOGGLE,
///
UNDERBAR_TOGGLE,
///
NOUN_TOGGLE,
///
INHERIT
};
class ControlCharacter : public Controller {
public:
///

View File

@ -14,6 +14,8 @@
#include "FuncRequest.h"
#include "support/filetools.h"
#include "support/FileName.h"
#include "support/lstrings.h"
#include <algorithm>
@ -21,44 +23,12 @@ using std::string;
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)
@ -73,9 +43,24 @@ void ControlTexinfo::viewFile(string const & filename) const
}
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;
}

View File

@ -27,7 +27,6 @@
#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"
@ -47,273 +46,19 @@ using std::pair;
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
@ -348,14 +93,6 @@ vector<LanguagePair> const getLanguageData(bool character_dlg)
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;
@ -496,7 +233,6 @@ using support::libFileSearch;
using support::onlyFilename;
using support::package;
using support::quoteName;
using support::split;
using support::Systemcall;
using support::token;
@ -553,27 +289,6 @@ void getTexFileList(string const & filename, std::vector<string> & list)
}
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)
{

View File

@ -13,7 +13,6 @@
#ifndef FRONTEND_HELPERS_H
#define FRONTEND_HELPERS_H
#include "Font.h"
#include "support/docstring.h"
#include <utility>
@ -22,55 +21,12 @@
#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
@ -86,72 +42,70 @@ getSecond(std::vector<Pair> const & pr)
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.
@ -159,8 +113,8 @@ std::vector<docstring> const getLatexUnits();
/** 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
@ -171,9 +125,6 @@ void texhash();
*/
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);

View File

@ -15,8 +15,8 @@
#include "ControlCharacter.h"
#include "qt_helpers.h"
#include "frontend_helpers.h"
#include "Color.h"
#include "Font.h"
#include <QCloseEvent>
@ -25,6 +25,246 @@ using std::vector;
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")
{
@ -55,28 +295,28 @@ GuiCharacterDialog::GuiCharacterDialog(LyXView & lv)
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) {
@ -142,16 +382,15 @@ void GuiCharacterDialog::closeEvent(QCloseEvent * e)
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;
}
@ -160,16 +399,13 @@ void GuiCharacterDialog::updateContents()
{
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());
}

View File

@ -16,12 +16,20 @@
#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

View File

@ -23,6 +23,7 @@
#include <QString>
#include "support/lstrings.h"
using lyx::support::internalLineEnding;
using lyx::support::externalLineEnding;

View File

@ -12,15 +12,11 @@
#include "GuiEmbeddedFiles.h"
#include "debug.h"
#include "support/convert.h"
using std::string;
namespace lyx {
namespace frontend {
GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog
(ControlEmbeddedFiles & controller)
: controller_(controller)
@ -96,10 +92,9 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemClicked(QListWidgetItem* item)
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);
}
@ -115,15 +110,14 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked(QListWidgetItem* item)
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;

View File

@ -24,17 +24,9 @@
#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;

View File

@ -23,8 +23,6 @@
#include "support/lstrings.h" // ascii_lowercase
#include <QPainter>
#include <QPictureIO>
#include <QPicture>
#include <QImage>
#include <QImageReader>
@ -40,8 +38,6 @@ using std::equal_to;
using std::find_if;
using std::string;
QPictureIO StaticPicture;
namespace lyx {
namespace graphics {
@ -167,10 +163,8 @@ void GuiImage::load_impl(support::FileName const & filename)
}
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;
@ -189,8 +183,6 @@ QImage & toGray(QImage & img)
return img;
}
} // namespace anon
bool GuiImage::setPixmap_impl(Params const & params)
{

View File

@ -18,7 +18,6 @@
#include "insets/InsetListingsParams.h"
#include "debug.h"
#include "support/convert.h"
#include "support/lstrings.h"
#include <QLineEdit>

View File

@ -43,9 +43,6 @@
#include <QValidator>
#include <QCloseEvent>
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>
#include <iomanip>
#include <sstream>
#include <algorithm>
@ -522,6 +519,17 @@ void PrefScreenFonts::select_typewriter(const QString& name)
//
/////////////////////////////////////////////////////////////////////
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)
{
@ -547,13 +555,11 @@ PrefColors::PrefColors(GuiPrefsDialog * form, QWidget * 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());

View File

@ -20,8 +20,6 @@
#include "Validator.h"
#include "qt_helpers.h"
#include "support/convert.h"
#include <QCloseEvent>
#include <QCheckBox>
#include <QPushButton>
@ -610,8 +608,8 @@ void GuiTabularDialog::updateContents()
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));

View File

@ -126,12 +126,40 @@ void GuiTexinfoDialog::enableViewPB()
}
void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix type)
{
ContentsType & data = texdata_[whichStyle];
bool const withFullPath = pathCB->isChecked();
ContentsType & data = texdata_[type];
getTexFileList(whichStyle, data, withFullPath);
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);
// sort on filename only (no path)
std::sort(data.begin(), data.end());
fileListLW->clear();
ContentsType::const_iterator it = data.begin();
@ -139,7 +167,7 @@ void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
for (; it != end; ++it)
fileListLW->addItem(toqstr(*it));
activeStyle = whichStyle;
activeStyle = type;
}

View File

@ -26,9 +26,6 @@
#include "Spacing.h"
#include "VSpace.h"
#include "ControlVSpace.h"
#include "frontend_helpers.h"
#include "support/lstrings.h"
#include <QCheckBox>

View File

@ -28,7 +28,6 @@
#include "version.h"
#include "support/filetools.h" // LibFileSearch
#include "support/convert.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"

View File

@ -18,7 +18,6 @@
#include "insets/InsetWrap.h"
#include "support/convert.h"
#include "support/lstrings.h"
#include <QLineEdit>
@ -109,21 +108,14 @@ void GuiWrapDialog::applyView()
}
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;

View File

@ -20,7 +20,6 @@
#include "support/os.h"
#include "support/lstrings.h"
#include "support/convert.h"
#include "debug.h"
@ -97,7 +96,7 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
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()));
}