]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiViewSource.cpp
fix completion painting for RTL (inline completion and completion list)
[lyx.git] / src / frontends / qt4 / GuiViewSource.cpp
index 3f6a8158eae68b4ba69ad454f8d98147ccdc6ba7..2d9ec85655efd60093913a431712bba26ee87954 100644 (file)
 #include "Paragraph.h"
 #include "TexRow.h"
 
-#include "support/assert.h"
+#include "support/lassert.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
 
+#include <QSettings>
 #include <QTextCursor>
 #include <QTextDocument>
+#include <QVariant>
 
 using namespace std;
 
@@ -68,8 +70,14 @@ ViewSourceWidget::ViewSourceWidget(GuiViewSource & controller)
 
 void ViewSourceWidget::updateView()
 {
-       if (autoUpdateCB->isChecked())
-               update(viewFullSourceCB->isChecked());
+       BufferView * view = controller_.bufferview();
+       if (!view) {
+               document_->setPlainText(QString());
+               setEnabled(false);
+               return;
+       }
+       document_->setPlainText(controller_.getContent(
+               viewFullSourceCB->isChecked()));
 
        GuiViewSource::Row row = controller_.getRows();
        QTextCursor c = QTextCursor(viewSourceTV->document());
@@ -81,12 +89,6 @@ void ViewSourceWidget::updateView()
 }
 
 
-void ViewSourceWidget::update(bool full_source)
-{
-       document_->setPlainText(controller_.getContent(full_source));
-}
-
-
 GuiViewSource::GuiViewSource(GuiView & parent,
                Qt::DockWidgetArea area, Qt::WindowFlags flags)
        : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)
@@ -104,7 +106,17 @@ GuiViewSource::~GuiViewSource()
 
 void GuiViewSource::updateView()
 {
-       widget_->updateView();
+       if (widget_->autoUpdateCB->isChecked())
+               widget_->updateView();
+}
+
+
+void GuiViewSource::enableView(bool enable)
+{
+       if (!enable)
+               // In the opposite case, updateView() will be called anyway.
+               widget_->updateView();
+       widget_->setEnabled(enable);
 }
 
 
@@ -172,6 +184,28 @@ QString GuiViewSource::title() const
 }
 
 
+void GuiViewSource::saveSession() const
+{
+       Dialog::saveSession();
+       QSettings settings;
+       settings.setValue(
+               sessionKey() + "/fullsource", widget_->viewFullSourceCB->isChecked());
+       settings.setValue(
+               sessionKey() + "/autoupdate", widget_->autoUpdateCB->isChecked());
+}
+
+
+void GuiViewSource::restoreSession()
+{
+       Dialog::restoreSession();
+       QSettings settings;
+       widget_->viewFullSourceCB->setChecked(
+               settings.value(sessionKey() + "/fullsource", false).toBool());
+       widget_->autoUpdateCB->setChecked(
+               settings.value(sessionKey() + "/autoupdate", true).toBool());
+}
+
+
 Dialog * createGuiViewSource(GuiView & lv)
 {
        return new GuiViewSource(lv);