]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Dialog.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / Dialog.cpp
index ee2557abb3f71da3cf176f01f000e6b93bba3c2f..65c9a881bbb7e0e1dd61d9142e3cf17c7f878c30 100644 (file)
 #include "qt_helpers.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferView.h"
 #include "Cursor.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "LyXFunc.h"
+#include "LyX.h"
 
 #include "insets/Inset.h"
 
 #include "support/debug.h"
 #include "support/lassert.h"
 
+#include <QLabel>
+#include <QLineEdit>
+#include <QList>
 #include <QSettings>
 #include <QString>
+#include <QValidator>
 
 #include <string>
 
@@ -38,7 +43,6 @@ using namespace lyx::support;
 namespace lyx {
 namespace frontend {
 
-
 Dialog::Dialog(GuiView & lv, QString const & name, QString const & title)
        : name_(name), title_(title), lyxview_(&lv)
 {}
@@ -58,7 +62,6 @@ bool Dialog::canApply() const
 
 void Dialog::dispatch(FuncRequest const & fr) const
 {
-       theLyXFunc().setLyXView(lyxview_);
        lyx::dispatch(fr);
 }
 
@@ -77,19 +80,19 @@ void Dialog::disconnect() const
 
 bool Dialog::isBufferAvailable() const
 {
-       return lyxview_->buffer() != 0;
+       return lyxview_->currentBufferView() != 0;
 }
 
 
 bool Dialog::isBufferReadonly() const
 {
-       if (!lyxview_->buffer())
+       if (!lyxview_->documentBufferView())
                return true;
-       return lyxview_->buffer()->isReadonly();
+       return lyxview_->documentBufferView()->buffer().isReadonly();
 }
 
 
-QString Dialog::bufferFilepath() const
+QString Dialog::bufferFilePath() const
 {
        return toqstr(buffer().filePath());
 }
@@ -97,38 +100,32 @@ QString Dialog::bufferFilepath() const
 
 KernelDocType Dialog::docType() const
 {
-       if (buffer().isLatex())
+       if (buffer().params().isLatex())
                return LATEX;
-       if (buffer().isLiterate())
+       if (buffer().params().isLiterate())
                return LITERATE;
 
        return DOCBOOK;
 }
 
 
-BufferView * Dialog::bufferview()
-{
-       return lyxview_->view();
-}
-
-
 BufferView const * Dialog::bufferview() const
 {
-       return lyxview_->view();
+       return lyxview_->currentBufferView();
 }
 
 
-Buffer & Dialog::buffer()
+Buffer const & Dialog::buffer() const
 {
-       LASSERT(lyxview_->buffer(), /**/);
-       return *lyxview_->buffer();
+       LASSERT(lyxview_->currentBufferView(), /**/);
+       return lyxview_->currentBufferView()->buffer();
 }
 
 
-Buffer const & Dialog::buffer() const
+Buffer const & Dialog::documentBuffer() const
 {
-       LASSERT(lyxview_->buffer(), /**/);
-       return *lyxview_->buffer();
+       LASSERT(lyxview_->documentBufferView(), /**/);
+       return lyxview_->documentBufferView()->buffer();
 }
 
 
@@ -166,13 +163,11 @@ void Dialog::apply()
 }
 
 
-void Dialog::showView()
+void Dialog::prepareView()
 {
        // Make sure the dialog controls are correctly enabled/disabled with
        // readonly status.
        checkStatus();
-       if (exitEarly())
-               return;
 
        QWidget * w = asQWidget();
        w->setWindowTitle(title_);
@@ -180,7 +175,14 @@ void Dialog::showView()
        QSize const hint = w->sizeHint();
        if (hint.height() >= 0 && hint.width() >= 0)
                w->setMinimumSize(hint);
+}
+
+
+void Dialog::showView()
+{
+       prepareView();
 
+       QWidget * w = asQWidget();
        if (w->isVisible()) {
                w->raise();
                w->activateWindow();
@@ -227,7 +229,7 @@ Inset const * Dialog::inset(InsetCode code) const
 
 void Dialog::checkStatus()
 {
-       // buffer independant dialogs are always active.
+       // buffer independent dialogs are always active.
        // This check allows us leave canApply unimplemented for some dialogs.
        if (!isBufferDependent()) {
                updateView();
@@ -243,13 +245,11 @@ void Dialog::checkStatus()
        // check whether this dialog may be active
        if (canApply()) {
                bool const readonly = isBufferReadonly();
-               enableView(!readonly);
+               enableView(!readonly || canApplyToReadOnly());
                // refreshReadOnly() is too generous in _enabling_ widgets
                // update dialog to disable disabled widgets again
 
-               if (!readonly || canApplyToReadOnly())
-                       updateView();
-
+               updateView();
        } else
                enableView(false);
 }