4 * John Levon, moz@compsoc.man.ac.uk
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
21 #include "FormDocument.h"
23 #include "CutAndPaste.h"
27 #include "QtLyXView.h"
30 #ifdef CXX_WORKING_NAMESPACES
31 using Liason::setMinibuffer;
34 FormDocument::FormDocument(LyXView *v, Dialogs *d)
35 : dialog_(0), lv_(v), d_(d), h_(0)
37 // let the dialog be shown
38 // This is a permanent connection so we won't bother
39 // storing a copy because we won't be disconnecting.
40 d->showLayoutDocument.connect(slot(this, &FormDocument::show));
43 FormDocument::~FormDocument()
48 void FormDocument::update(bool switched)
55 if (!lv_->view()->available())
58 Buffer *buf = lv_->buffer();
60 if (readonly!=buf->isReadonly()) {
61 readonly = buf->isReadonly();
62 dialog_->setReadOnly(readonly);
65 dialog_->setFromParams(buf->params);
68 void FormDocument::apply()
73 if (!lv_->view()->available())
76 BufferParams & params = lv_->buffer()->params;
78 if (dialog_->updateParams(params))
79 lv_->view()->redoCurrentBuffer();
81 lv_->buffer()->markDirty();
82 setMinibuffer(lv_, _("Document layout set"));
85 void FormDocument::show()
88 dialog_ = new DocDialog(this, 0, _("LyX: Document Options"), false);
90 if (!dialog_->isVisible())
91 h_ = d_->hideBufferDependent.connect(slot(this, &FormDocument::hide));
95 dialog_->setActiveWindow();
101 bool FormDocument::changeClass(BufferParams & params, int new_class)
103 if (textclasslist.Load(new_class)) {
104 // successfully loaded
105 setMinibuffer(lv_, _("Converting document to new document class..."));
108 int ret = cap.SwitchLayoutsBetweenClasses(
109 params.textclass, new_class,
110 lv_->buffer()->paragraph);
112 /* FIXME: error message */
115 params.textclass = new_class;
122 void FormDocument::close()
127 void FormDocument::hide()