]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/FormTabularCreate.C
Fix for qt2 citation dialog crash when selecting first key
[lyx.git] / src / frontends / qt2 / FormTabularCreate.C
1 /**
2  * \file FormTabularCreate.C
3  * Copyright 2001 LyX Team
4  * see the file COPYING
5  *
6  * \author John Levon, moz@compsoc.man.ac.uk
7  */
8
9 #include <config.h>
10
11 #include "tabularcreatedlgimpl.h"
12 #include "Dialogs.h"
13 #include "FormTabularCreate.h"
14 #include "gettext.h"
15 #include "QtLyXView.h"
16 #include "BufferView.h"
17 #include "insets/insettabular.h"
18 #include "support/lstrings.h"
19
20 using SigC::slot;
21
22 FormTabularCreate::FormTabularCreate(LyXView *v, Dialogs *d)
23         : dialog_(0), lv_(v), d_(d), h_(0)
24 {
25         // let the dialog be shown
26         // This is a permanent connection so we won't bother
27         // storing a copy because we won't be disconnecting.
28         d->showTabularCreate.connect(slot(this, &FormTabularCreate::show));
29 }
30
31 FormTabularCreate::~FormTabularCreate()
32 {
33         delete dialog_;
34 }
35
36 void FormTabularCreate::apply(int rows, int cols)
37 {
38         if (!lv_->view()->available())
39                 return;
40
41         string tmp = tostr(rows) + " " + tostr(cols);
42         lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
43 }
44
45 void FormTabularCreate::show()
46 {
47         if (!dialog_)
48           dialog_ = new TabularCreateDlgImpl(this, 0, _("LyX: Insert Table"));
49
50         if (!dialog_->isVisible()) {
51                 h_ = d_->hideBufferDependent.connect(slot(this, &FormTabularCreate::hide));
52         }
53
54         dialog_->raise();
55         dialog_->setActiveWindow();
56
57         update();
58         dialog_->show();
59 }
60
61 void FormTabularCreate::close()
62 {
63         h_.disconnect();
64 }
65
66 void FormTabularCreate::hide()
67 {
68         dialog_->hide();
69         close();
70 }