]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QTexinfoDialog.C
enable Font cache only for MacOSX and inline width() for other platform.
[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( whatStyle, SIGNAL( activated(const QString&) ), this, SLOT( enableViewPB() ) );
38     connect( whatStyle, SIGNAL( activated(int) ), this, SLOT( update() ) );
39     connect( path, SIGNAL( stateChanged(int) ), this, SLOT( update() ) );
40     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( enableViewPB() ) );
41     connect( rescanPB, SIGNAL( clicked() ), this, SLOT( rescanClicked() ) );
42     connect( fileList, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( enableViewPB() ) );
43 }
44
45
46 void QTexinfoDialog::change_adaptor()
47 {
48         form_->changed();
49 }
50
51
52 void QTexinfoDialog::closeEvent(QCloseEvent * e)
53 {
54         form_->slotWMHide();
55         e->accept();
56 }
57
58
59 void QTexinfoDialog::rescanClicked()
60 {
61         // build new *Files.lst
62         rescanTexStyles();
63         form_->updateStyles();
64         enableViewPB();
65 }
66
67
68 void QTexinfoDialog::viewClicked()
69 {
70         vector<string>::size_type const fitem = fileList->currentRow();
71         vector<string> const & data = form_->texdata_[form_->activeStyle];
72         string file = data[fitem];
73         if (!path->isChecked())
74                 file = getTexFileFromList(data[fitem],
75                         form_->controller().getFileType(form_->activeStyle));
76         form_->controller().viewFile(file);
77 }
78
79
80 void QTexinfoDialog::update()
81 {
82         switch (whatStyle->currentIndex()) {
83         case 0:
84                 form_->updateStyles(ControlTexinfo::cls);
85                 break;
86         case 1:
87                 form_->updateStyles(ControlTexinfo::sty);
88                 break;
89         case 2:
90                 form_->updateStyles(ControlTexinfo::bst);
91                 break;
92         default:
93                 break;
94         }
95
96         enableViewPB();
97 }
98
99
100 void QTexinfoDialog::enableViewPB()
101 {
102         viewPB->setEnabled(fileList->currentRow() > -1);
103 }
104
105 } // namespace frontend
106 } // namespace lyx
107
108 #include "QTexinfoDialog_moc.cpp"