From 152491f9162604dc2060158b497c756b635d4d29 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 18 Oct 2010 14:20:03 +0000 Subject: [PATCH] Some cosmetics (from my local cosmetics branch). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35708 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 6 +++-- src/BufferParams.h | 2 +- src/BufferView.cpp | 2 +- src/Text2.cpp | 5 +++-- src/frontends/qt4/GuiApplication.cpp | 33 ++++++++++++++++------------ src/frontends/qt4/GuiCompare.h | 7 +++--- src/frontends/qt4/GuiView.cpp | 8 +++++-- src/frontends/qt4/GuiWorkArea.cpp | 2 +- src/insets/Inset.h | 6 +++-- src/insets/InsetCommand.cpp | 5 ++--- src/insets/InsetLabel.h | 3 ++- src/mathed/MathParser.cpp | 2 +- 12 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index cbab310859..5455847e96 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1946,12 +1946,14 @@ DocumentClass const & BufferParams::documentClass() const } -DocumentClass const * BufferParams::documentClassPtr() const { +DocumentClass const * BufferParams::documentClassPtr() const +{ return doc_class_; } -void BufferParams::setDocumentClass(DocumentClass const * const tc) { +void BufferParams::setDocumentClass(DocumentClass const * const tc) +{ // evil, but this function is evil doc_class_ = const_cast(tc); } diff --git a/src/BufferParams.h b/src/BufferParams.h index 4aab4c714d..66e09f907e 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -109,7 +109,7 @@ public: InsetQuotes::QuoteTimes quotes_times; /// std::string fontsize; - ///Get the LayoutFile this document is using. + /// Get the LayoutFile this document is using. LayoutFile const * baseClass() const; /// LayoutFileIndex const & baseClassID() const; diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b58a980ecc..b0dc5d47b5 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -58,9 +58,9 @@ #include "insets/InsetCommand.h" // ChangeRefs #include "insets/InsetExternal.h" #include "insets/InsetGraphics.h" +#include "insets/InsetNote.h" #include "insets/InsetRef.h" #include "insets/InsetText.h" -#include "insets/InsetNote.h" #include "frontends/alert.h" #include "frontends/Application.h" diff --git a/src/Text2.cpp b/src/Text2.cpp index 9ce5d98fa9..24a3317cf7 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -919,8 +919,9 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra } } - // don't delete anything if this is the only remaining paragraph within the given range - // note: Text::acceptOrRejectChanges() sets the cursor to 'first' after calling DEPM + // don't delete anything if this is the only remaining paragraph + // within the given range. Note: Text::acceptOrRejectChanges() + // sets the cursor to 'first' after calling DEPM if (first == last) continue; diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index cf6d4d7c82..571e30c9d6 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1124,12 +1124,14 @@ void GuiApplication::dispatch(FuncRequest const & cmd) } -void GuiApplication::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer) +void GuiApplication::gotoBookmark(unsigned int idx, bool openFile, + bool switchToBuffer) { LASSERT(current_view_, /**/); if (!theSession().bookmarks().isValid(idx)) return; - BookmarksSection::Bookmark const & bm = theSession().bookmarks().bookmark(idx); + BookmarksSection::Bookmark const & bm = + theSession().bookmarks().bookmark(idx); LASSERT(!bm.filename.empty(), /**/); string const file = bm.filename.absFileName(); // if the file is not opened, open it. @@ -1151,16 +1153,18 @@ void GuiApplication::gotoBookmark(unsigned int idx, bool openFile, bool switchTo dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0")); // if the current buffer is not that one, switch to it. - if (!current_view_->documentBufferView() - || current_view_->documentBufferView()->buffer().fileName() != tmp.filename) { - if (!switchToBuffer) + BufferView * doc_bv = current_view_->documentBufferView(); + if (!doc_bv || doc_bv->buffer().fileName() != tmp.filename) { + if (switchToBuffer) { + dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file)); + doc_bv = current_view_->documentBufferView(); + } else return; - dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file)); } // moveToPosition try paragraph id first and then paragraph (pit, pos). - if (!current_view_->documentBufferView()->moveToPosition( - tmp.bottom_pit, tmp.bottom_pos, tmp.top_id, tmp.top_pos)) + if (!doc_bv->moveToPosition( + tmp.bottom_pit, tmp.bottom_pos, tmp.top_id, tmp.top_pos)) return; // bm changed @@ -1168,7 +1172,7 @@ void GuiApplication::gotoBookmark(unsigned int idx, bool openFile, bool switchTo return; // Cursor jump succeeded! - Cursor const & cur = current_view_->documentBufferView()->cursor(); + Cursor const & cur = doc_bv->cursor(); pit_type new_pit = cur.pit(); pos_type new_pos = cur.pos(); int new_id = cur.paragraph().id(); @@ -1310,11 +1314,11 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) } break; - case LFUN_FILE_OPEN: + case LFUN_FILE_OPEN: { // FIXME: create a new method shared with LFUN_HELP_OPEN. - if (d->views_.empty() - || (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != 0)) { - string const fname = to_utf8(cmd.argument()); + string const fname = to_utf8(cmd.argument()); + if (d->views_.empty() || (!lyxrc.open_buffers_in_tabs + && current_view_->documentBufferView() != 0)) { // We want the ui session to be saved per document and not per // window number. The filename crc is a good enough identifier. boost::crc_32_type crc; @@ -1324,8 +1328,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) if (current_view_ && !current_view_->documentBufferView()) current_view_->close(); } else - current_view_->openDocument(to_utf8(cmd.argument())); + current_view_->openDocument(fname); break; + } case LFUN_HELP_OPEN: { // FIXME: create a new method shared with LFUN_FILE_OPEN. diff --git a/src/frontends/qt4/GuiCompare.h b/src/frontends/qt4/GuiCompare.h index aa5f701ebb..025d2da989 100644 --- a/src/frontends/qt4/GuiCompare.h +++ b/src/frontends/qt4/GuiCompare.h @@ -13,12 +13,13 @@ #define GUICOMPARE_H #include "GuiDialog.h" -#include "ui_CompareUi.h" -#include "qt_helpers.h" -#include "Compare.h" +#include "ui_CompareUi.h" namespace lyx { + +class Compare; + namespace frontend { diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index eb2dfc3080..0d878badfe 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2533,8 +2533,11 @@ static bool ensureBufferClean(Buffer * buffer) bool GuiView::reloadBuffer() { - Buffer * buf = &documentBufferView()->buffer(); - return buf->reload(); + Buffer * buffer = documentBufferView() + ? &(documentBufferView()->buffer()) : 0; + if (buffer) + return buffer->reload(); + return false; } @@ -3046,6 +3049,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) case LFUN_FILE_INSERT: insertLyXFile(cmd.argument()); break; + case LFUN_FILE_INSERT_PLAINTEXT_PARA: insertPlaintextFile(cmd.argument(), true); break; diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 718872b6f8..cc1c8091dc 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1319,7 +1319,7 @@ EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w) EmbeddedWorkArea::~EmbeddedWorkArea() { // No need to destroy buffer and bufferview here, because it is done - // in theBuffeerList() destruction loop at application exit + // in theBufferList() destruction loop at application exit } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index fca566f29d..5ff1d53275 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -280,7 +280,8 @@ public: /// Returns true if cursor is now invalid, e.g. if former /// insets in higher cursor slices of \c old do not exist /// anymore. - /// \c cur is the new cursor, some slice points to this. Use the update flags to cause a redraw. + /// \c cur is the new cursor, some slice points to this. Use the update + /// flags to cause a redraw. virtual bool notifyCursorEnters(Cursor & /*cur*/) { return false; } /// is called when the mouse enters or leaves this inset @@ -381,7 +382,8 @@ public: virtual bool forcePlainLayout(idx_type = 0) const { return false; } /// if this inset has paragraphs should the user be allowed to /// customize alignment, etc? - virtual bool allowParagraphCustomization(idx_type = 0) const { return true; } + virtual bool allowParagraphCustomization(idx_type = 0) const + { return true; } /// Is the width forced to some value? virtual bool hasFixedWidth() const { return false; } diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index 065bd383e5..f02477afab 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -54,9 +54,7 @@ namespace lyx { // place of the mailer name and recover that information? InsetCommand::InsetCommand(Buffer * buf, InsetCommandParams const & p, string const & mailer_name) - : Inset(buf), p_(p), - mailer_name_(mailer_name), - mouse_hover_() + : Inset(buf), p_(p), mailer_name_(mailer_name) {} @@ -71,6 +69,7 @@ InsetCommand::~InsetCommand() { if (!mailer_name_.empty()) hideDialogs(mailer_name_, this); + map::iterator it = mouse_hover_.begin(); map::iterator end = mouse_hover_.end(); for (; it != end; ++it) diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 37b9cdb27c..375430b7bf 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -19,7 +19,8 @@ namespace lyx { class Counter; -class InsetLabel : public InsetCommand { +class InsetLabel : public InsetCommand +{ public: /// InsetLabel(Buffer * buf, InsetCommandParams const &); diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index c4fad04b46..4767dc1536 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -1348,7 +1348,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, #endif else if (t.cs() == "limits" || t.cs() == "nolimits") { - CatCode cat = nextToken().cat(); + CatCode const cat = nextToken().cat(); if (cat == catSuper || cat == catSub) limits = t.cs() == "limits" ? 1 : -1; else { -- 2.39.2