]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QTexinfoDialog.C
Added initial qt4 work by Abdelrazak Younes
[lyx.git] / src / frontends / qt4 / QTexinfoDialog.C
1 /**
2  * \file QTexinfoDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QTexinfoDialog.h"
14 #include "QTexinfo.h"
15
16 #include <qcheckbox.h>
17 #include <q3listbox.h>
18 #include <qpushbutton.h>
19 //Added by qt3to4:
20 #include <QCloseEvent>
21
22 using std::vector;
23 using std::string;
24
25 namespace lyx {
26 namespace frontend {
27
28
29 QTexinfoDialog::QTexinfoDialog(QTexinfo * form)
30         :form_(form)
31 {
32         setupUi(this);
33
34         connect(closePB, SIGNAL(clicked()),
35                 form, SLOT(slotClose()));
36
37     connect( viewPB, SIGNAL( clicked() ), this, SLOT( viewClicked() ) );
38     connect( whatStyle, SIGNAL( activated(const QString&) ), this, SLOT( enableViewPB() ) );
39     connect( whatStyle, SIGNAL( activated(int) ), this, SLOT( update() ) );
40     connect( path, SIGNAL( stateChanged(int) ), this, SLOT( update() ) );
41     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( enableViewPB() ) );
42     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( rescanClicked() ) );
43     connect( fileList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( enableViewPB() ) );
44 }
45
46
47 void QTexinfoDialog::change_adaptor()
48 {
49         form_->changed();
50 }
51
52
53 void QTexinfoDialog::closeEvent(QCloseEvent * e)
54 {
55         form_->slotWMHide();
56         e->accept();
57 }
58
59
60 void QTexinfoDialog::rescanClicked()
61 {
62         // build new *Files.lst
63         rescanTexStyles();
64         form_->updateStyles();
65         enableViewPB();
66 }
67
68
69 void QTexinfoDialog::viewClicked()
70 {
71         vector<string>::size_type const fitem = fileList->currentItem();
72         vector<string> const & data = form_->texdata_[form_->activeStyle];
73         string file = data[fitem];
74         if (!path->isChecked())
75                 file = getTexFileFromList(data[fitem],
76                         form_->controller().getFileType(form_->activeStyle));
77         form_->controller().viewFile(file);
78 }
79
80
81 void QTexinfoDialog::update()
82 {
83         switch (whatStyle->currentItem()) {
84         case 0:
85                 form_->updateStyles(ControlTexinfo::cls);
86                 break;
87         case 1:
88                 form_->updateStyles(ControlTexinfo::sty);
89                 break;
90         case 2:
91                 form_->updateStyles(ControlTexinfo::bst);
92                 break;
93         default:
94                 break;
95         }
96
97         enableViewPB();
98 }
99
100
101 void QTexinfoDialog::enableViewPB()
102 {
103         viewPB->setEnabled(fileList->currentItem() > -1);
104 }
105
106 } // namespace frontend
107 } // namespace lyx