]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiViewSource.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiViewSource.cpp
index d6b141b969b6bced755bba23b96cda1ae095ff5a..3f6a8158eae68b4ba69ad454f8d98147ccdc6ba7 100644 (file)
 
 #include <config.h>
 
+#include "GuiApplication.h"
 #include "GuiViewSource.h"
 #include "LaTeXHighlighter.h"
 #include "qt_helpers.h"
 
-#include "Application.h"
 #include "BufferView.h"
 #include "Buffer.h"
 #include "Cursor.h"
-#include "gettext.h"
 #include "Paragraph.h"
 #include "TexRow.h"
 
+#include "support/assert.h"
+#include "support/docstream.h"
+#include "support/gettext.h"
+
 #include <QTextCursor>
 #include <QTextDocument>
-#include <boost/tuple/tuple.hpp>
 
-using std::string;
+using namespace std;
 
 namespace lyx {
 namespace frontend {
@@ -38,7 +40,6 @@ ViewSourceWidget::ViewSourceWidget(GuiViewSource & controller)
                highlighter_(new LaTeXHighlighter(document_))
 {
        setupUi(this);
-       setWindowTitle(qt_("LaTeX Source"));
 
        connect(viewFullSourceCB, SIGNAL(clicked()),
                this, SLOT(updateView()));
@@ -55,7 +56,7 @@ ViewSourceWidget::ViewSourceWidget(GuiViewSource & controller)
        viewSourceTV->setReadOnly(true);
        ///dialog_->viewSourceTV->setAcceptRichText(false);
        // this is personal. I think source code should be in fixed-size font
-       QFont font(toqstr(theApp()->typewriterFontName()));
+       QFont font(guiApp->typewriterFontName());
        font.setKerning(false);
        font.setFixedPitch(true);
        font.setStyleHint(QFont::TypeWriter);
@@ -70,12 +71,12 @@ void ViewSourceWidget::updateView()
        if (autoUpdateCB->isChecked())
                update(viewFullSourceCB->isChecked());
 
-       int beg, end;
-       boost::tie(beg, end) = controller_.getRows();
+       GuiViewSource::Row row = controller_.getRows();
        QTextCursor c = QTextCursor(viewSourceTV->document());
-       c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
+       c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, row.begin);
        c.select(QTextCursor::BlockUnderCursor);
-       c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, end - beg + 1);
+       c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor,
+               row.end - row.begin + 1);
        viewSourceTV->setTextCursor(c);
 }
 
@@ -86,12 +87,12 @@ void ViewSourceWidget::update(bool full_source)
 }
 
 
-GuiViewSource::GuiViewSource(GuiViewBase & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
-       : DockView(parent, "view-source", area, flags)
+GuiViewSource::GuiViewSource(GuiView & parent,
+               Qt::DockWidgetArea area, Qt::WindowFlags flags)
+       : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)
 {
        widget_ = new ViewSourceWidget(*this);
        setWidget(widget_);
-       setWindowTitle(widget_->windowTitle());
 }
 
 
@@ -130,14 +131,14 @@ QString GuiViewSource::getContent(bool fullSource)
                par_end = view->cursor().selectionEnd().bottom().pit();
        }
        if (par_begin > par_end)
-               std::swap(par_begin, par_end);
+               swap(par_begin, par_end);
        odocstringstream ostr;
        view->buffer().getSourceCode(ostr, par_begin, par_end + 1, fullSource);
        return toqstr(ostr.str());
 }
 
 
-std::pair<int, int> GuiViewSource::getRows() const
+GuiViewSource::Row GuiViewSource::getRows() const
 {
        BufferView const * view = bufferview();
        CursorSlice beg = view->cursor().selectionBegin().bottom();
@@ -149,7 +150,10 @@ std::pair<int, int> GuiViewSource::getRows() const
                getRowFromIdPos(end.paragraph().id(), end.pos());
        int nextendrow = view->buffer().texrow().
                getRowFromIdPos(end.paragraph().id(), end.pos() + 1);
-       return std::make_pair(begrow, endrow == nextendrow ? endrow : (nextendrow - 1));
+       Row row;
+       row.begin = begrow;
+       row.end = endrow == nextendrow ? endrow : (nextendrow - 1);
+       return row;
 }
 
 
@@ -163,14 +167,14 @@ QString GuiViewSource::title() const
                case LITERATE:
                        return qt_("Literate Source");
        }
-       BOOST_ASSERT(false);
+       LASSERT(false, /**/);
        return QString();
 }
 
 
-Dialog * createGuiViewSource(LyXView & lv)
+Dialog * createGuiViewSource(GuiView & lv)
 {
-       return new GuiViewSource(static_cast<GuiViewBase &>(lv));
+       return new GuiViewSource(lv);
 }