From cc4b9be8930debb4ba91d2b859539197c5306551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 11 Sep 2007 21:27:57 +0000 Subject: [PATCH] shuffle stuff around git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20225 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/EmbeddedFiles.cpp | 4 +- src/EmbeddedFiles.h | 8 +- src/frontends/LyXView.cpp | 9 +- src/frontends/controllers/ControlCharacter.h | 16 +- src/frontends/controllers/ControlTexinfo.cpp | 61 ++-- .../controllers/frontend_helpers.cpp | 289 +----------------- src/frontends/controllers/frontend_helpers.h | 135 +++----- src/frontends/qt4/GuiCharacter.cpp | 270 ++++++++++++++-- src/frontends/qt4/GuiCharacter.h | 8 + src/frontends/qt4/GuiClipboard.cpp | 1 + src/frontends/qt4/GuiEmbeddedFiles.cpp | 18 +- src/frontends/qt4/GuiFontLoader.cpp | 10 +- src/frontends/qt4/GuiImage.cpp | 10 +- src/frontends/qt4/GuiListings.cpp | 1 - src/frontends/qt4/GuiPrefs.cpp | 22 +- src/frontends/qt4/GuiTabular.cpp | 6 +- src/frontends/qt4/GuiTexinfo.cpp | 38 ++- src/frontends/qt4/GuiVSpace.cpp | 3 - src/frontends/qt4/GuiWorkArea.cpp | 1 - src/frontends/qt4/GuiWrap.cpp | 14 +- src/frontends/qt4/qt_helpers.cpp | 3 +- 21 files changed, 416 insertions(+), 511 deletions(-) diff --git a/src/EmbeddedFiles.cpp b/src/EmbeddedFiles.cpp index 28add45c67..e6a02c4aac 100644 --- a/src/EmbeddedFiles.cpp +++ b/src/EmbeddedFiles.cpp @@ -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; diff --git a/src/EmbeddedFiles.h b/src/EmbeddedFiles.h index a8f570b730..115a8e5b6c 100644 --- a/src/EmbeddedFiles.h +++ b/src/EmbeddedFiles.h @@ -174,7 +174,7 @@ public: typedef std::vector 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 diff --git a/src/frontends/LyXView.cpp b/src/frontends/LyXView.cpp index 926ceaa59c..0ebbe0b676 100644 --- a/src/frontends/LyXView.cpp +++ b/src/frontends/LyXView.cpp @@ -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)"); diff --git a/src/frontends/controllers/ControlCharacter.h b/src/frontends/controllers/ControlCharacter.h index d568f4a86c..b36888d46b 100644 --- a/src/frontends/controllers/ControlCharacter.h +++ b/src/frontends/controllers/ControlCharacter.h @@ -12,9 +12,8 @@ #ifndef CONTROLCHARACTER_H #define CONTROLCHARACTER_H - #include "Dialog.h" -#include "frontend_helpers.h" +#include "Font.h" #include @@ -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: /// diff --git a/src/frontends/controllers/ControlTexinfo.cpp b/src/frontends/controllers/ControlTexinfo.cpp index 96106b3b8b..1d2e7af7a0 100644 --- a/src/frontends/controllers/ControlTexinfo.cpp +++ b/src/frontends/controllers/ControlTexinfo.cpp @@ -14,6 +14,8 @@ #include "FuncRequest.h" #include "support/filetools.h" +#include "support/FileName.h" +#include "support/lstrings.h" #include @@ -21,44 +23,12 @@ using std::string; using std::vector; namespace lyx { - -using support::onlyFilename; - namespace frontend { -void getTexFileList(ControlTexinfo::texFileSuffix type, - std::vector & 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::iterator it = list.begin(); - vector::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; } diff --git a/src/frontends/controllers/frontend_helpers.cpp b/src/frontends/controllers/frontend_helpers.cpp index 1d383c5b41..4311a762fd 100644 --- a/src/frontends/controllers/frontend_helpers.cpp +++ b/src/frontends/controllers/frontend_helpers.cpp @@ -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 const getFamilyData() -{ - vector 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 const getSeriesData() -{ - vector 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 const getShapeData() -{ - vector 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 const getSizeData() -{ - vector 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 const getBarData() -{ - vector 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 const getColorData() -{ - vector 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 +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 const getLanguageData(bool character_dlg) return langs; } - -vector const getSortedColors(vector 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 & 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) { diff --git a/src/frontends/controllers/frontend_helpers.h b/src/frontends/controllers/frontend_helpers.h index f0db68b326..911eeb9490 100644 --- a/src/frontends/controllers/frontend_helpers.h +++ b/src/frontends/controllers/frontend_helpers.h @@ -13,7 +13,6 @@ #ifndef FRONTEND_HELPERS_H #define FRONTEND_HELPERS_H -#include "Font.h" #include "support/docstring.h" #include @@ -22,55 +21,12 @@ #include -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 FamilyPair; -/// -typedef std::pair SeriesPair; -/// -typedef std::pair ShapePair; -/// -typedef std::pair SizePair; -/// -typedef std::pair BarPair; -/// -typedef std::pair ColorPair; - -/// -std::vector const getFamilyData(); -/// -std::vector const getSeriesData(); -/// -std::vector const getShapeData(); -/// -std::vector const getSizeData(); -/// -std::vector const getBarData(); -/// -std::vector const getColorData(); - /// template std::vector const @@ -86,72 +42,70 @@ getSecond(std::vector const & pr) typedef std::pair LanguagePair; /** If the caller is the character dialog, add "No change" and "Reset" - * to the vector. - */ +* to the vector. +*/ std::vector const getLanguageData(bool character_dlg); -/// sort colors for the gui -std::vector const getSortedColors(std::vector 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 const & dir1 = - std::make_pair(docstring(), docstring()), - std::pair const & dir2 = - std::make_pair(docstring(), docstring())); + docstring const & title, + support::FileFilterList const & filters, + bool save = false, + std::pair const & dir1 = + std::make_pair(docstring(), docstring()), + std::pair 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 const & dir1 = - std::make_pair(docstring(), docstring()), - std::pair const & dir2 = - std::make_pair(docstring(), docstring())); + docstring const & refpath, + docstring const & title, + support::FileFilterList const & filters, + bool save = false, + std::pair const & dir1 = + std::make_pair(docstring(), docstring()), + std::pair 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 const & dir1 = - std::make_pair(docstring(), docstring()), - std::pair const & dir2 = - std::make_pair(docstring(), docstring())); + docstring const & title, + std::pair const & dir1 = + std::make_pair(docstring(), docstring()), + std::pair 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 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 & 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); diff --git a/src/frontends/qt4/GuiCharacter.cpp b/src/frontends/qt4/GuiCharacter.cpp index 14c2b17f4b..8957ab3a90 100644 --- a/src/frontends/qt4/GuiCharacter.cpp +++ b/src/frontends/qt4/GuiCharacter.cpp @@ -15,8 +15,8 @@ #include "ControlCharacter.h" #include "qt_helpers.h" -#include "frontend_helpers.h" #include "Color.h" +#include "Font.h" #include @@ -25,6 +25,246 @@ using std::vector; namespace lyx { namespace frontend { +static vector const getShapeData() +{ + vector 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 const getSizeData() +{ + vector 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 const getBarData() +{ + vector 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 const getColorData() +{ + vector 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 const getSeriesData() +{ + vector 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 const getFamilyData() +{ + vector 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::const_iterator cit = family.begin(); cit != family.end(); ++cit) { - familyCO->addItem(toqstr(cit->first)); + familyCO->addItem(cit->first); } for (vector::const_iterator cit = series.begin(); cit != series.end(); ++cit) { - seriesCO->addItem(toqstr(cit->first)); + seriesCO->addItem(cit->first); } for (vector::const_iterator cit = shape.begin(); cit != shape.end(); ++cit) { - shapeCO->addItem(toqstr(cit->first)); + shapeCO->addItem(cit->first); } for (vector::const_iterator cit = size.begin(); cit != size.end(); ++cit) { - sizeCO->addItem(toqstr(cit->first)); + sizeCO->addItem(cit->first); } for (vector::const_iterator cit = bar.begin(); cit != bar.end(); ++cit) { - miscCO->addItem(toqstr(cit->first)); + miscCO->addItem(cit->first); } for (vector::const_iterator cit = color.begin(); cit != color.end(); ++cit) { - colorCO->addItem(toqstr(cit->first)); + colorCO->addItem(cit->first); } for (vector::const_iterator cit = language.begin(); cit != language.end(); ++cit) { @@ -142,16 +382,15 @@ void GuiCharacterDialog::closeEvent(QCloseEvent * e) template -static int findPos2nd(vector > const & vec, B const & val) +static int findPos2nd(vector > const & vec, B const & val) { typedef typename vector >::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()); } diff --git a/src/frontends/qt4/GuiCharacter.h b/src/frontends/qt4/GuiCharacter.h index b9e7eedc02..6283b6fc2c 100644 --- a/src/frontends/qt4/GuiCharacter.h +++ b/src/frontends/qt4/GuiCharacter.h @@ -16,12 +16,20 @@ #include "GuiDialog.h" #include "ControlCharacter.h" #include "ui_CharacterUi.h" +#include "frontend_helpers.h" // for LanguagePair #include namespace lyx { namespace frontend { +typedef std::pair FamilyPair; +typedef std::pair SeriesPair; +typedef std::pair ShapePair; +typedef std::pair SizePair; +typedef std::pair BarPair; +typedef std::pair ColorPair; + class GuiCharacterDialog : public GuiDialog, public Ui::CharacterUi { Q_OBJECT diff --git a/src/frontends/qt4/GuiClipboard.cpp b/src/frontends/qt4/GuiClipboard.cpp index 13139ec08e..cd9914cde6 100644 --- a/src/frontends/qt4/GuiClipboard.cpp +++ b/src/frontends/qt4/GuiClipboard.cpp @@ -23,6 +23,7 @@ #include #include "support/lstrings.h" + using lyx::support::internalLineEnding; using lyx::support::externalLineEnding; diff --git a/src/frontends/qt4/GuiEmbeddedFiles.cpp b/src/frontends/qt4/GuiEmbeddedFiles.cpp index be720a7023..71858db6c8 100644 --- a/src/frontends/qt4/GuiEmbeddedFiles.cpp +++ b/src/frontends/qt4/GuiEmbeddedFiles.cpp @@ -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(k + 1) + "/" - + convert(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(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; diff --git a/src/frontends/qt4/GuiFontLoader.cpp b/src/frontends/qt4/GuiFontLoader.cpp index 41913a673b..08da0a032f 100644 --- a/src/frontends/qt4/GuiFontLoader.cpp +++ b/src/frontends/qt4/GuiFontLoader.cpp @@ -24,17 +24,9 @@ #include "support/Package.h" #include "support/os.h" -#include +#include #include -#include - -#ifdef Q_WS_X11 -#include -//#include -#include -#endif - using lyx::support::contains; using lyx::support::package; using lyx::support::addPath; diff --git a/src/frontends/qt4/GuiImage.cpp b/src/frontends/qt4/GuiImage.cpp index a65a09deaa..d0d0e8d071 100644 --- a/src/frontends/qt4/GuiImage.cpp +++ b/src/frontends/qt4/GuiImage.cpp @@ -23,8 +23,6 @@ #include "support/lstrings.h" // ascii_lowercase #include -#include -#include #include #include @@ -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) { diff --git a/src/frontends/qt4/GuiListings.cpp b/src/frontends/qt4/GuiListings.cpp index 3fd4318392..01f671812e 100644 --- a/src/frontends/qt4/GuiListings.cpp +++ b/src/frontends/qt4/GuiListings.cpp @@ -18,7 +18,6 @@ #include "insets/InsetListingsParams.h" #include "debug.h" -#include "support/convert.h" #include "support/lstrings.h" #include diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index b30389ac1a..26e23ac4a9 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -43,9 +43,6 @@ #include #include -#include -#include - #include #include #include @@ -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::const_iterator cit = lcolors_.begin(); vector::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()); diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 0d60664068..cca86d5a59 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -20,8 +20,6 @@ #include "Validator.h" #include "qt_helpers.h" -#include "support/convert.h" - #include #include #include @@ -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(row + 1))); - tabularColumnED->setText(toqstr(convert(col + 1))); + tabularRowED->setText(QString::number(row + 1)); + tabularColumnED->setText(QString::number(col + 1)); bool const multicol(tabular.isMultiColumn(cell)); diff --git a/src/frontends/qt4/GuiTexinfo.cpp b/src/frontends/qt4/GuiTexinfo.cpp index 26a0d85d06..db0c470fc4 100644 --- a/src/frontends/qt4/GuiTexinfo.cpp +++ b/src/frontends/qt4/GuiTexinfo.cpp @@ -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::iterator it1 = data.begin(); + vector::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; } diff --git a/src/frontends/qt4/GuiVSpace.cpp b/src/frontends/qt4/GuiVSpace.cpp index e3332c95a8..c1a5dd113c 100644 --- a/src/frontends/qt4/GuiVSpace.cpp +++ b/src/frontends/qt4/GuiVSpace.cpp @@ -26,9 +26,6 @@ #include "Spacing.h" #include "VSpace.h" -#include "ControlVSpace.h" -#include "frontend_helpers.h" - #include "support/lstrings.h" #include diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 99f0b4b712..ec30f9b2d7 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -28,7 +28,6 @@ #include "version.h" #include "support/filetools.h" // LibFileSearch -#include "support/convert.h" #include "graphics/GraphicsImage.h" #include "graphics/GraphicsLoader.h" diff --git a/src/frontends/qt4/GuiWrap.cpp b/src/frontends/qt4/GuiWrap.cpp index 21122c3b34..727cb58978 100644 --- a/src/frontends/qt4/GuiWrap.cpp +++ b/src/frontends/qt4/GuiWrap.cpp @@ -18,7 +18,6 @@ #include "insets/InsetWrap.h" -#include "support/convert.h" #include "support/lstrings.h" #include @@ -109,21 +108,14 @@ void GuiWrapDialog::applyView() } -static string const numtostr(double val) -{ - string a = convert(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; diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp index d89f1b2bf7..2c14d42149 100644 --- a/src/frontends/qt4/qt_helpers.cpp +++ b/src/frontends/qt4/qt_helpers.cpp @@ -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(Length(len).value()))); + input->setText(QString::number(Length(len).value())); }