diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index af4505a14e..ee4541ce4b 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -124,16 +124,16 @@ void LyXVC::registrer() } LYXERR(Debug::LYXVC) << "LyXVC: registrer" << endl; - pair tmp = - Alert::askForText(_("LyX VC: Initial description"), - _("(no initial description)")); - if (!tmp.first || tmp.second.empty()) { - // should we insist on checking tmp.second.empty()? + docstring response; + bool ok = Alert::askForText(response, _("LyX VC: Initial description"), + _("(no initial description)")); + if (!ok || response.empty()) { + // should we insist on checking response.empty()? LYXERR(Debug::LYXVC) << "LyXVC: user cancelled" << endl; return; } - vcs->registrer(to_utf8(tmp.second)); + vcs->registrer(to_utf8(response)); } @@ -141,12 +141,12 @@ void LyXVC::checkIn() { LYXERR(Debug::LYXVC) << "LyXVC: checkIn" << endl; - pair tmp = Alert::askForText(_("LyX VC: Log Message")); - if (tmp.first) { - if (tmp.second.empty()) { - tmp.second = _("(no log message)"); - } - vcs->checkIn(to_utf8(tmp.second)); + docstring response; + bool ok = Alert::askForText(response, _("LyX VC: Log Message")); + if (ok) { + if (response.empty()) + response = _("(no log message)"); + vcs->checkIn(to_utf8(response)); } else { LYXERR(Debug::LYXVC) << "LyXVC: user cancelled" << endl; } diff --git a/src/frontends/Alert_pimpl.h b/src/frontends/Alert_pimpl.h index c95892e3bf..4fc4d08dc9 100644 --- a/src/frontends/Alert_pimpl.h +++ b/src/frontends/Alert_pimpl.h @@ -9,12 +9,8 @@ * Full author contact details are available in file CREDITS. */ -// GUI-specific implementations - -#include "support/docstring.h" - -#include +#include "support/strfwd.h" namespace lyx { @@ -28,6 +24,7 @@ void warning_pimpl(docstring const & title, docstring const & warning); void error_pimpl(docstring const & title, docstring const & warning); void information_pimpl(docstring const & title, docstring const & warning); -std::pair const askForText_pimpl(docstring const & msg, docstring const & dflt); +bool askForText_pimpl(docstring & response, + docstring const & msg, docstring const & dflt); } // namespace lyx diff --git a/src/frontends/Application.cpp b/src/frontends/Application.cpp index f942aed085..890aa257ac 100644 --- a/src/frontends/Application.cpp +++ b/src/frontends/Application.cpp @@ -31,34 +31,6 @@ namespace lyx { -namespace frontend { - - -Application::Application(int &, char **) - : current_view_(0) -{ -} - - -LyXView const * Application::currentView() const -{ - return current_view_; -} - - -LyXView * Application::currentView() -{ - return current_view_; -} - - -void Application::setCurrentView(LyXView & current_view) -{ - current_view_ = ¤t_view; -} - -} // namespace frontend - frontend::FontLoader & theFontLoader() diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 63e593d918..f341358ddb 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -144,7 +144,7 @@ class Application { public: /// - Application(int & argc, char ** argv); + Application() : current_view_(0) {} /// virtual ~Application() {} @@ -219,20 +219,17 @@ public: unsigned int iconSizeXY, const std::string & geometryArg) = 0; /// - LyXView const * currentView() const; - + LyXView const * currentView() const { return current_view_; } /// - LyXView * currentView(); - + LyXView * currentView() { return current_view_; } /// - void setCurrentView(LyXView & current_view); + void setCurrentView(LyXView & view) { current_view_ = &view; } private: /// This LyXView is the one receiving Clipboard and Selection - /// Events + /// events LyXView * current_view_; - -}; // Application +}; } // namespace frontend diff --git a/src/frontends/ButtonPolicy.cpp b/src/frontends/ButtonPolicy.cpp index 69c15f9772..e4b91ff467 100644 --- a/src/frontends/ButtonPolicy.cpp +++ b/src/frontends/ButtonPolicy.cpp @@ -13,6 +13,7 @@ #include "ButtonPolicy.h" #include "debug.h" +#include namespace lyx { namespace frontend { @@ -565,5 +566,17 @@ void ButtonPolicy::initNoRepeatedApply() } +std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st) +{ + return os << int(st); +} + + +std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi) +{ + return os << int(smi); +} + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/ButtonPolicy.h b/src/frontends/ButtonPolicy.h index beebc62c79..1f39f1b833 100644 --- a/src/frontends/ButtonPolicy.h +++ b/src/frontends/ButtonPolicy.h @@ -16,7 +16,7 @@ #define BUTTONPOLICY_H #include -#include +#include namespace lyx { namespace frontend { @@ -280,19 +280,8 @@ private: }; -inline -std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st) -{ - return os << int(st); -} - - -inline -std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi) -{ - return os << int(smi); -} - +std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st); +std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi); } // namespace frontend } // namespace lyx diff --git a/src/frontends/Clipboard.h b/src/frontends/Clipboard.h index 3381475cbc..0db784c926 100644 --- a/src/frontends/Clipboard.h +++ b/src/frontends/Clipboard.h @@ -14,7 +14,7 @@ #ifndef BASE_CLIPBOARD_H #define BASE_CLIPBOARD_H -#include "support/docstring.h" +#include "support/strfwd.h" namespace lyx { namespace frontend { diff --git a/src/frontends/Delegates.h b/src/frontends/Delegates.h index 270e4fabf1..330b9aa4ff 100644 --- a/src/frontends/Delegates.h +++ b/src/frontends/Delegates.h @@ -12,7 +12,7 @@ #ifndef DELEGATES_H #define DELEGATES_H -#include "support/docstring.h" +#include "support/strfwd.h" namespace lyx { diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 9a57462982..f74bcc9960 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -14,7 +14,6 @@ #define DIALOGS_H #include -#include #include @@ -29,7 +28,7 @@ class LyXView; /** Container of all dialogs. */ -class Dialogs : boost::noncopyable { +class Dialogs { public: /// Dialogs(LyXView &); @@ -89,7 +88,12 @@ public: void disconnect(std::string const & name); /// Inset * getOpenInset(std::string const & name) const; + private: + /// noncopyable + Dialogs(Dialogs const &); + void operator=(Dialogs const &); + /// void redraw() const; /// diff --git a/src/frontends/FontMetrics.h b/src/frontends/FontMetrics.h index 808658de03..59de63088c 100644 --- a/src/frontends/FontMetrics.h +++ b/src/frontends/FontMetrics.h @@ -14,7 +14,7 @@ #ifndef FONT_METRICS_H #define FONT_METRICS_H -#include "support/docstring.h" +#include "support/strfwd.h" /** * A class holding helper functions for determining @@ -97,15 +97,10 @@ public: int & descent) const = 0; /// return the maximum descent of the font - inline int maxHeight() const { - return maxAscent() + maxDescent(); - } + inline int maxHeight() const { return maxAscent() + maxDescent(); } /// return the descent of the char in the font - inline int height(char_type c) const - { - return ascent(c) + descent(c); - } + inline int height(char_type c) const { return ascent(c) + descent(c); } /// return the inner width of the char in the font inline int center(char_type c) const { diff --git a/src/frontends/Gui.h b/src/frontends/Gui.h index 06ac5c4343..6dd9c8316a 100644 --- a/src/frontends/Gui.h +++ b/src/frontends/Gui.h @@ -14,19 +14,12 @@ #ifndef BASE_GUI_H #define BASE_GUI_H -#include - -#include #include namespace lyx { - -class BufferView; - namespace frontend { class LyXView; -class WorkArea; /** @@ -42,18 +35,15 @@ public: /// virtual bool unregisterView(int id) = 0; /// - virtual bool closeAllViews()= 0; + virtual bool closeAllViews() = 0; /// - virtual LyXView& view(int id) const = 0; + virtual LyXView & view(int id) const = 0; /// - std::vector const & viewIds() - { - return view_ids_; - } + std::vector const & viewIds() { return view_ids_; } protected: - + /// std::vector view_ids_; }; diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index c67e83a72b..f4d54265c3 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -4,13 +4,9 @@ SUBDIRS = $(FRONTENDS_SUBDIRS) . DIST_SUBDIRS = qt4 . -EXTRA_DIST = pch.h - -BUILT_SOURCES = $(PCH_FILE) - noinst_LTLIBRARIES = liblyxfrontends.la -AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES) +AM_CPPFLAGS += -I$(srcdir)/.. $(BOOST_INCLUDES) liblyxfrontends_la_SOURCES = \ alert.cpp \ @@ -40,7 +36,7 @@ liblyxfrontends_la_SOURCES = \ ################################# Tests ################################ -EXTRA_DIST += tests/test_biblio +EXTRA_DIST = tests/test_biblio TESTS = \ test_biblio diff --git a/src/frontends/NoGuiFontMetrics.h b/src/frontends/NoGuiFontMetrics.h index c1680960aa..e6d92cd932 100644 --- a/src/frontends/NoGuiFontMetrics.h +++ b/src/frontends/NoGuiFontMetrics.h @@ -16,7 +16,7 @@ #include "Dimension.h" -#include "support/docstring.h" +#include "support/strfwd.h" namespace lyx { namespace frontend { diff --git a/src/frontends/Painter.cpp b/src/frontends/Painter.cpp index 1e7b4fa7b8..1181ddf7ed 100644 --- a/src/frontends/Painter.cpp +++ b/src/frontends/Painter.cpp @@ -12,19 +12,17 @@ #include #include "frontends/Painter.h" - #include "frontends/FontMetrics.h" #include "FontInfo.h" -using lyx::docstring; - -using std::max; -using std::string; - namespace lyx { namespace frontend { + +static int max(int a, int b) { return a > b ? a : b; } + + void Painter::button(int x, int y, int w, int h, bool mouseHover) { if (mouseHover) diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h index 6eca5a9f5f..c405b3028a 100644 --- a/src/frontends/Painter.h +++ b/src/frontends/Painter.h @@ -15,7 +15,7 @@ #include "ColorCode.h" -#include "support/docstring.h" +#include "support/strfwd.h" namespace lyx { diff --git a/src/frontends/Selection.h b/src/frontends/Selection.h index 9f8af37f2d..ac902ffc1e 100644 --- a/src/frontends/Selection.h +++ b/src/frontends/Selection.h @@ -11,10 +11,10 @@ * Full author contact details are available in file CREDITS. */ -#ifndef BASE_SELECTION_H -#define BASE_SELECTION_H +#ifndef SELECTION_H +#define SELECTION_H -#include "support/docstring.h" +#include "support/strfwd.h" namespace lyx { namespace frontend { @@ -73,4 +73,4 @@ extern frontend::Selection & theSelection(); } // namespace lyx -#endif // BASE_SELECTION_H +#endif // SELECTION_H diff --git a/src/frontends/alert.cpp b/src/frontends/alert.cpp index 69ac6c849c..6f7febad9c 100644 --- a/src/frontends/alert.cpp +++ b/src/frontends/alert.cpp @@ -17,13 +17,10 @@ #include "LyX.h" // for lyx::use_gui using std::endl; -using std::make_pair; -using std::pair; using std::string; namespace lyx { - namespace frontend { int Alert::prompt(docstring const & title, docstring const & question, @@ -85,19 +82,21 @@ void Alert::information(docstring const & title, docstring const & message) } -pair const Alert::askForText(docstring const & msg, - docstring const & dflt) +bool Alert::askForText(docstring & response, docstring const & msg, + docstring const & dflt) { if (!use_gui || lyxerr.debugging()) { lyxerr << "----------------------------------------\n" << to_utf8(msg) << '\n' << "Assuming answer is " << to_utf8(dflt) << '\n' << "----------------------------------------" << endl; - if (!use_gui) - return make_pair(true, dflt); + if (!use_gui) { + response = dflt; + return true; + } } - return askForText_pimpl(msg, dflt); + return askForText_pimpl(response, msg, dflt); } } // namespace frontend diff --git a/src/frontends/alert.h b/src/frontends/alert.h index a163caf69a..e10a73a5f8 100644 --- a/src/frontends/alert.h +++ b/src/frontends/alert.h @@ -55,8 +55,8 @@ void error(docstring const & title, docstring const & message); void information(docstring const & title, docstring const & message); /// Asks for a text. DO NOT USE !! -std::pair const -askForText(docstring const & msg, docstring const & dflt = docstring()); +bool askForText(docstring & response, docstring const & msg, + docstring const & dflt = docstring()); } // namespace Alert } // namespace frontend diff --git a/src/frontends/pch.h b/src/frontends/pch.h deleted file mode 100644 index 65ab4bc659..0000000000 --- a/src/frontends/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -#include - -#include -#include -#include -#include diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 2203252d63..a61b2a8080 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -126,7 +126,7 @@ GuiApplication * guiApp; GuiApplication::GuiApplication(int & argc, char ** argv) - : QApplication(argc, argv), Application(argc, argv) + : QApplication(argc, argv), Application() { QCoreApplication::setOrganizationName("The LyX Community"); QCoreApplication::setOrganizationDomain("lyx.org"); @@ -311,21 +311,20 @@ bool GuiApplication::event(QEvent * e) bool GuiApplication::notify(QObject * receiver, QEvent * event) { - bool return_value = false; try { - return_value = QApplication::notify(receiver, event); + return QApplication::notify(receiver, event); } - catch (support::ExceptionMessage const & e) { + catch (support::ExceptionMessage const & e) { if (e.type_ == support::ErrorException) { Alert::error(e.title_, e.details_); LyX::cref().emergencyCleanup(); QApplication::exit(1); } else if (e.type_ == support::WarningException) { Alert::warning(e.title_, e.details_); - return return_value; + return false; } } - catch (std::exception const & e) { + catch (std::exception const & e) { docstring s = _("LyX has caught an exception, it will now " "attemp to save all unsaved documents and exit." "\n\nException: "); @@ -342,7 +341,7 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event) QApplication::exit(1); } - return return_value; + return false; } @@ -356,8 +355,7 @@ void GuiApplication::syncEvents() } -bool GuiApplication::getRgbColor(ColorCode col, - RGBColor & rgbcol) +bool GuiApplication::getRgbColor(ColorCode col, RGBColor & rgbcol) { QColor const & qcol = color_cache_.get(col); if (!qcol.isValid()) { diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index 67d0a16a90..b6eb969278 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -101,11 +101,12 @@ int GuiFontMetrics::rbearing(char_type c) const if (is_utf16(c)) { QChar sc = ucs4_to_qchar(c); value = width(c) - metrics_.rightBearing(sc); - } else - // FIXME: QFontMetrics::leftBearingdoes not support the + } else { + // FIXME: QFontMetrics::leftBearing does not support the // full unicode range. Once it does, we could use: // metrics_.rightBearing(toqstr(docstring(1,c))); value = width(c); + } rbearing_cache_.insert(c, value); @@ -272,5 +273,5 @@ int GuiFontMetrics::descent(char_type c) const return value.descent; } -} // frontend -} // lyx +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/qt4/GuiImplementation.cpp b/src/frontends/qt4/GuiImplementation.cpp index d234d6446b..52f4da4fe6 100644 --- a/src/frontends/qt4/GuiImplementation.cpp +++ b/src/frontends/qt4/GuiImplementation.cpp @@ -13,29 +13,29 @@ #include #include "GuiImplementation.h" - #include "GuiView.h" +#include + #include - -namespace -{ - template - void updateIds(std::map const & stdmap, std::vector & ids) - { - ids.clear(); - typename std::map::const_iterator it; - for (it = stdmap.begin(); it != stdmap.end(); ++it) - ids.push_back(it->first); - } -} +using std::map; +using std::vector; namespace lyx { namespace frontend { +static void updateIds(map const & stdmap, vector & ids) +{ + ids.clear(); + map::const_iterator it; + for (it = stdmap.begin(); it != stdmap.end(); ++it) + ids.push_back(it->first); +} + + GuiImplementation::GuiImplementation() { view_ids_.clear(); @@ -48,7 +48,7 @@ int GuiImplementation::createRegisteredView() int id = 0; while (views_.find(id) != views_.end()) id++; - views_.insert(std::pair(id, new GuiView(id))); + views_[id] = new GuiView(id); updateIds(views_, view_ids_); return id; } @@ -60,7 +60,7 @@ bool GuiImplementation::unregisterView(int id) BOOST_ASSERT(views_.find(id) != views_.end()); BOOST_ASSERT(views_[id]); - std::map::iterator it; + map::iterator it; for (it = views_.begin(); it != views_.end(); ++it) { if (it->first == id) { views_.erase(id); @@ -75,17 +75,15 @@ bool GuiImplementation::unregisterView(int id) bool GuiImplementation::closeAllViews() { updateIds(views_, view_ids_); - if (views_.empty()) - { + if (views_.empty()) { // quit in CloseEvent will not be triggert qApp->quit(); return true; } - std::map const cmap = views_; - std::map::const_iterator it; - for (it = cmap.begin(); it != cmap.end(); ++it) - { + map const cmap = views_; + map::const_iterator it; + for (it = cmap.begin(); it != cmap.end(); ++it) { // TODO: return false when close event was ignored // e.g. quitWriteAll()->'Cancel' // maybe we need something like 'bool closeView()' @@ -99,7 +97,7 @@ bool GuiImplementation::closeAllViews() } -LyXView& GuiImplementation::view(int id) const +LyXView & GuiImplementation::view(int id) const { BOOST_ASSERT(views_.find(id) != views_.end()); return *views_.find(id)->second; diff --git a/src/frontends/qt4/GuiSelection.cpp b/src/frontends/qt4/GuiSelection.cpp index 29cb8951e7..1e11f93f8c 100644 --- a/src/frontends/qt4/GuiSelection.cpp +++ b/src/frontends/qt4/GuiSelection.cpp @@ -13,23 +13,26 @@ #include #include "GuiSelection.h" -#include "qt_helpers.h" +#include "qt_helpers.h" #include "debug.h" +#include "support/lstrings.h" + #include #include #include -#include "support/lstrings.h" -using lyx::support::internalLineEnding; -using lyx::support::externalLineEnding; using std::endl; namespace lyx { namespace frontend { +using support::internalLineEnding; +using support::externalLineEnding; + + GuiSelection::GuiSelection() : selection_supported_(qApp->clipboard()->supportsSelection()) { diff --git a/src/frontends/qt4/GuiSelection.h b/src/frontends/qt4/GuiSelection.h index 7e77da715a..c7f2096aa8 100644 --- a/src/frontends/qt4/GuiSelection.h +++ b/src/frontends/qt4/GuiSelection.h @@ -11,8 +11,8 @@ * Full author contact details are available in file CREDITS. */ -#ifndef SELECTION_H -#define SELECTION_H +#ifndef GUISELECTION_H +#define GUISELECTION_H #include "frontends/Selection.h" @@ -51,4 +51,4 @@ private: } // namespace frontend } // namespace lyx -#endif // SELECTION_H +#endif // GUISELECTION_H diff --git a/src/frontends/qt4/alert_pimpl.cpp b/src/frontends/qt4/alert_pimpl.cpp index 00bc6003aa..01885409de 100644 --- a/src/frontends/qt4/alert_pimpl.cpp +++ b/src/frontends/qt4/alert_pimpl.cpp @@ -29,14 +29,11 @@ #include #include -#include - -using std::pair; -using std::make_pair; -using lyx::support::bformat; namespace lyx { +using support::bformat; + static docstring const formatted(docstring const & text) { const int w = 80; @@ -45,13 +42,13 @@ static docstring const formatted(docstring const & text) if (text.empty()) return sout; - docstring::size_type curpos = 0; + size_t curpos = 0; docstring line; - for (;;) { - docstring::size_type const nxtpos1 = text.find(' ', curpos); - docstring::size_type const nxtpos2 = text.find('\n', curpos); - docstring::size_type const nxtpos = std::min(nxtpos1, nxtpos2); + while (true) { + size_t const nxtpos1 = text.find(' ', curpos); + size_t const nxtpos2 = text.find('\n', curpos); + size_t const nxtpos = std::min(nxtpos1, nxtpos2); docstring const word = nxtpos == docstring::npos ? @@ -172,8 +169,8 @@ void information_pimpl(docstring const & tit, docstring const & message) } -pair const -askForText_pimpl(docstring const & msg, docstring const & dflt) +bool askForText_pimpl(docstring & response, docstring const & msg, + docstring const & dflt) { docstring const title = bformat(_("LyX: %1$s"), msg); @@ -184,10 +181,12 @@ askForText_pimpl(docstring const & msg, docstring const & dflt) QLineEdit::Normal, toqstr(dflt), &ok); - if (ok && !text.isEmpty()) - return make_pair(true, qstring_to_ucs4(text)); - else - return make_pair(false, docstring()); + if (ok && !text.isEmpty()) { + response = qstring_to_ucs4(text); + return true; + } + response.clear(); + return false; }