]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Dialog.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / Dialog.cpp
index 801abd2ef8c684c00f9e826da3c53ed1f4463300..65d4a5598141dbb3471e02af0c1471a2e638051c 100644 (file)
@@ -58,7 +58,6 @@ bool Dialog::canApply() const
 
 void Dialog::dispatch(FuncRequest const & fr) const
 {
-       theLyXFunc().setLyXView(lyxview_);
        lyx::dispatch(fr);
 }
 
@@ -77,15 +76,15 @@ 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();
 }
 
 
@@ -106,29 +105,16 @@ KernelDocType Dialog::docType() const
 }
 
 
-BufferView * Dialog::bufferview()
-{
-       return lyxview_->view();
-}
-
-
 BufferView const * Dialog::bufferview() const
 {
-       return lyxview_->view();
-}
-
-
-Buffer & Dialog::buffer()
-{
-       LASSERT(lyxview_->buffer(), /**/);
-       return *lyxview_->buffer();
+       return lyxview_->currentBufferView();
 }
 
 
 Buffer const & Dialog::buffer() const
 {
-       LASSERT(lyxview_->buffer(), /**/);
-       return *lyxview_->buffer();
+       LASSERT(lyxview_->currentBufferView(), /**/);
+       return lyxview_->currentBufferView()->buffer();
 }
 
 
@@ -166,13 +152,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 +164,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();
@@ -189,8 +180,11 @@ void Dialog::showView()
 
        if (wantInitialFocus())
                w->setFocus();
-       else
+       else {
+               lyxview_->raise();
+               lyxview_->activateWindow();
                lyxview_->setFocus();
+       }
 }
 
 
@@ -224,7 +218,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();
@@ -240,13 +234,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);
 }
@@ -254,7 +246,7 @@ void Dialog::checkStatus()
 
 QString Dialog::sessionKey() const
 {
-       return "view-" + QString::number(lyxview_->id())
+       return "views/" + QString::number(lyxview_->id())
                + "/" + name();
 }