]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QTexinfoDialog.C
Fix unreported bug related to 3246 by Richard Heck:
[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>
17 #include <QListWidget>
18 #include <QPushButton>
19 #include <QCloseEvent>
20
21 using std::vector;
22 using std::string;
23
24 namespace lyx {
25 namespace frontend {
26
27
28 QTexinfoDialog::QTexinfoDialog(QTexinfo * form)
29         :form_(form)
30 {
31         setupUi(this);
32
33         connect(closePB, SIGNAL(clicked()),
34                 form, SLOT(slotClose()));
35
36     connect( viewPB, SIGNAL( clicked() ), this, SLOT( viewClicked() ) );
37     connect( whatStyleCO, SIGNAL( activated(const QString&) ), this, SLOT( enableViewPB() ) );
38     connect( whatStyleCO, SIGNAL( activated(int) ), this, SLOT( update() ) );
39     connect( pathCB, SIGNAL( stateChanged(int) ), this, SLOT( update() ) );
40     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( enableViewPB() ) );
41     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( rescanClicked() ) );
42     connect( fileListLW, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( enableViewPB() ) );
43     connect( fileListLW, SIGNAL( itemSelectionChanged() ), 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 = fileListLW->currentRow();
72         vector<string> const & data = form_->texdata_[form_->activeStyle];
73         string file = data[fitem];
74         if (!pathCB->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 (whatStyleCO->currentIndex()) {
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(fileListLW->currentRow() > -1);
104 }
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #include "QTexinfoDialog_moc.cpp"