]> git.lyx.org Git - features.git/blobdiff - src/frontends/kde/FormIndex.C
Update to MVC. Ref,Toc and citation don't work at all currently.
[features.git] / src / frontends / kde / FormIndex.C
index c8ee2573dc97c0d362744c27701ecfa983eb7afd..cd3ddb6d9ee8d27029df76090fa492dd6f0d1e01 100644 (file)
 
 #include <config.h>
 
-#include "Dialogs.h"
+#include "QtLyXView.h"
 #include "FormIndex.h"
+#include "indexdlg.h" 
+#include "ControlIndex.h" 
 #include "gettext.h"
-#include "buffer.h"
-#include "LyXView.h"
-#include "lyxfunc.h" 
-#include "indexdlg.h"
 
-FormIndex::FormIndex(LyXView *v, Dialogs *d)
-       : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
+FormIndex::FormIndex(ControlIndex & c)
+       : KFormBase<ControlIndex, IndexDialog>(c) 
 {
-       d->showIndex.connect(slot(this, &FormIndex::showIndex));
-       d->createIndex.connect(slot(this, &FormIndex::createIndex));
 }
 
 
-FormIndex::~FormIndex()
+void FormIndex::build()
 {
-       delete dialog_;
-}
-
-
-void FormIndex::showIndex(InsetCommand * const inset)
-{
-       // FIXME: when could inset be 0 here ?
-       if (inset==0)
-               return;
-
-       inset_ = inset;
-       readonly = lv_->buffer()->isReadonly();
-       ih_ = inset_->hideDialog.connect(slot(this,&FormIndex::hide));
-       params = inset->params();
-       
-       show();
-}
-
-void FormIndex::createIndex(string const & arg)
-{
-       // we could already be showing an index entry, clear it out
-       if (inset_)
-               close();
-       readonly = lv_->buffer()->isReadonly();
-       params.setFromString(arg);
-       show();
-}
-
-void FormIndex::update(bool switched)
-{
-       if (switched) {
-               hide();
-               return;
-       }
-
-       dialog_->setIndexText(params.getContents().c_str());
-       dialog_->setReadOnly(readonly);
-}
+       dialog_.reset(new IndexDialog(this, 0, _("LyX: Index")));
 
+       // FIXME
  
-void FormIndex::apply()
-{
-       if (readonly)
-               return;
-
-       params.setContents(dialog_->getIndexText());
-
-       if (inset_ != 0) {
-               if (params != inset_->params()) {
-                       inset_->setParams(params);
-                       lv_->view()->updateInset(inset_, true);
-               }
-       } else
-               lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str());
+       //bc().setUndoAll(dialog_->buttonRestore);
+       bc().setOK(dialog_->button_ok);
+       //bc().setApply(dialog_->buttonApply); 
+       bc().setCancel(dialog_->button_cancel);
+       bc().addReadOnly(dialog_->line_index);
 }
-
  
-void FormIndex::show()
-{
-       if (!dialog_)
-               dialog_ = new IndexDialog(this, 0, _("LyX: Index"));
-       if (!dialog_->isVisible()) {
-               h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide));
-               u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update));
-       }
 
-       dialog_->raise();
-       dialog_->setActiveWindow();
-       update();
-       dialog_->show();
-}
-
-
-void FormIndex::close()
+void FormIndex::update()
 {
-       h_.disconnect();
-       u_.disconnect();
-       ih_.disconnect();
-       inset_ = 0;
+       dialog_->setIndexText(controller().params().getContents().c_str());
 }
 
  
-void FormIndex::hide()
+void FormIndex::apply()
 {
-       dialog_->hide();
-       close();
+       controller().params().setContents(dialog_->getIndexText());
 }