]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiTexinfo.cpp
renaming of some methods that hurt the eyes + removal of:
[lyx.git] / src / frontends / qt4 / GuiTexinfo.cpp
1 /**
2  * \file GuiTexinfo.cpp
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 "GuiTexinfo.h"
14 #include "qt_helpers.h"
15
16 #include "support/filetools.h"
17
18 #include <QCloseEvent>
19 #include <QCheckBox>
20 #include <QListWidget>
21 #include <QPushButton>
22
23 using std::string;
24 using std::vector;
25
26 namespace lyx {
27 namespace frontend {
28
29 /////////////////////////////////////////////////////////////////////
30 //
31 // GuiTexinfoDialog
32 //
33 /////////////////////////////////////////////////////////////////////
34
35
36 GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
37         : form_(form)
38 {
39         setupUi(this);
40
41         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
42
43         connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
44         connect(whatStyleCO, SIGNAL(activated(const QString &)),
45                 this, SLOT(enableViewPB()));
46         connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(update()));
47         connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(update()));
48         connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
49         connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
50         connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
51                 this, SLOT( enableViewPB() ) );
52         connect(fileListLW, SIGNAL(itemSelectionChanged()),
53                 this, SLOT(enableViewPB()));
54 }
55
56
57 void GuiTexinfoDialog::change_adaptor()
58 {
59         form_->changed();
60 }
61
62
63 void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
64 {
65         form_->slotWMHide();
66         e->accept();
67 }
68
69
70 void GuiTexinfoDialog::rescanClicked()
71 {
72         // build new *Files.lst
73         rescanTexStyles();
74         form_->updateStyles();
75         enableViewPB();
76 }
77
78
79 void GuiTexinfoDialog::viewClicked()
80 {
81         size_t const fitem = fileListLW->currentRow();
82         vector<string> const & data = form_->texdata_[form_->activeStyle];
83         string file = data[fitem];
84         if (!pathCB->isChecked())
85                 file = getTexFileFromList(data[fitem],
86                         form_->controller().getFileType(form_->activeStyle));
87         form_->controller().viewFile(file);
88 }
89
90
91 void GuiTexinfoDialog::updateView()
92 {
93         switch (whatStyleCO->currentIndex()) {
94         case 0:
95                 form_->updateStyles(ControlTexinfo::cls);
96                 break;
97         case 1:
98                 form_->updateStyles(ControlTexinfo::sty);
99                 break;
100         case 2:
101                 form_->updateStyles(ControlTexinfo::bst);
102                 break;
103         default:
104                 break;
105         }
106
107         enableViewPB();
108 }
109
110
111 void GuiTexinfoDialog::enableViewPB()
112 {
113         viewPB->setEnabled(fileListLW->currentRow() > -1);
114 }
115
116
117 /////////////////////////////////////////////////////////////////////
118 //
119 // GuiTexinfo
120 //
121 /////////////////////////////////////////////////////////////////////
122
123
124 GuiTexinfo::GuiTexinfo(GuiDialog & parent)
125         : GuiView<GuiTexinfoDialog>(parent, _("TeX Information")),
126           warningPosted(false), activeStyle(ControlTexinfo::cls)
127 {
128 }
129
130
131 void GuiTexinfo::build_dialog()
132 {
133         dialog_.reset(new GuiTexinfoDialog(this));
134
135         updateStyles(ControlTexinfo::cls);
136
137         bc().setCancel(dialog_->closePB);
138 }
139
140
141 void GuiTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
142 {
143         ContentsType & data = texdata_[whichStyle];
144         bool const withFullPath = dialog_->pathCB->isChecked();
145
146         getTexFileList(whichStyle, data, withFullPath);
147
148         dialog_->fileListLW->clear();
149         ContentsType::const_iterator it  = data.begin();
150         ContentsType::const_iterator end = data.end();
151         for (; it != end; ++it)
152                 dialog_->fileListLW->addItem(toqstr(*it));
153
154         activeStyle = whichStyle;
155 }
156
157
158 void GuiTexinfo::updateStyles()
159 {
160         updateStyles(activeStyle);
161 }
162
163 } // namespace frontend
164 } // namespace lyx
165
166
167 #include "GuiTexinfo_moc.cpp"