]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QTabularCreate.C
some more random changes, added Timeout (make clean if LyX crashes !!)
[lyx.git] / src / frontends / qt2 / QTabularCreate.C
1 /**
2  * \file QTabularCreate.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10
11 #include "QTabularCreateDialog.h"
12 #include "Dialogs.h"
13 #include "QTabularCreate.h"
14 #include "gettext.h"
15 #include "QtLyXView.h"
16 #include "lyxfunc.h"
17 #include "BufferView.h"
18 #include "insets/insettabular.h"
19 #include "support/lstrings.h"
20
21 using SigC::slot;
22
23 QTabularCreate::QTabularCreate(LyXView *v, Dialogs *d)
24         : dialog_(0), lv_(v), d_(d), h_(0)
25 {
26         d->showTabularCreate.connect(slot(this, &QTabularCreate::show));
27 }
28
29
30 QTabularCreate::~QTabularCreate()
31 {
32         delete dialog_;
33 }
34
35  
36 void QTabularCreate::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  
46 void QTabularCreate::show()
47 {
48         if (!dialog_)
49                 dialog_ = new QTabularCreateDialog(this, 0, _("LyX: Insert Table"));
50
51         if (!dialog_->isVisible()) {
52                 h_ = d_->hideBufferDependent.connect(slot(this, &QTabularCreate::hide));
53         }
54
55         dialog_->raise();
56         dialog_->setActiveWindow();
57
58         update();
59         dialog_->show();
60 }
61
62  
63 void QTabularCreate::close()
64 {
65         h_.disconnect();
66 }
67
68  
69 void QTabularCreate::hide()
70 {
71         dialog_->hide();
72         close();
73 }