3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "GuiTexinfo.h"
15 #include "ControlTexinfo.h"
16 #include "qt_helpers.h"
18 #include "support/filetools.h"
20 #include <QCloseEvent>
22 #include <QListWidget>
23 #include <QPushButton>
34 GuiTexinfoDialog::GuiTexinfoDialog(LyXView & lv)
35 : GuiDialog(lv, "texinfo")
38 setViewTitle(_("TeX Information"));
39 setController(new ControlTexinfo(*this));
41 warningPosted = false;
42 activeStyle = ControlTexinfo::cls;
44 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
46 connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
47 connect(whatStyleCO, SIGNAL(activated(const QString &)),
48 this, SLOT(enableViewPB()));
49 connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(updateView()));
50 connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(updateView()));
51 connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
52 connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
53 connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
54 this, SLOT(enableViewPB()));
55 connect(fileListLW, SIGNAL(itemSelectionChanged()),
56 this, SLOT(enableViewPB()));
58 updateStyles(ControlTexinfo::cls);
60 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
61 bc().setCancel(closePB);
65 ControlTexinfo & GuiTexinfoDialog::controller()
67 return static_cast<ControlTexinfo &>(GuiDialog::controller());
71 void GuiTexinfoDialog::change_adaptor()
77 void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
84 void GuiTexinfoDialog::rescanClicked()
86 // build new *Files.lst
93 void GuiTexinfoDialog::viewClicked()
95 size_t const fitem = fileListLW->currentRow();
96 vector<string> const & data = texdata_[activeStyle];
97 string file = data[fitem];
98 if (!pathCB->isChecked())
99 file = getTexFileFromList(data[fitem],
100 controller().getFileType(activeStyle));
101 controller().viewFile(file);
105 void GuiTexinfoDialog::updateView()
107 switch (whatStyleCO->currentIndex()) {
109 updateStyles(ControlTexinfo::cls);
112 updateStyles(ControlTexinfo::sty);
115 updateStyles(ControlTexinfo::bst);
125 void GuiTexinfoDialog::enableViewPB()
127 viewPB->setEnabled(fileListLW->currentRow() > -1);
131 void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix type)
133 ContentsType & data = texdata_[type];
137 case ControlTexinfo::bst:
138 filename = "bstFiles.lst";
140 case ControlTexinfo::cls:
141 filename = "clsFiles.lst";
143 case ControlTexinfo::sty:
144 filename = "styFiles.lst";
147 getTexFileList(filename, data);
149 // build filelists of all availabe bst/cls/sty-files.
150 // Done through kpsewhich and an external script,
151 // saved in *Files.lst
153 getTexFileList(filename, data);
155 bool const withFullPath = pathCB->isChecked();
158 vector<string>::iterator it1 = data.begin();
159 vector<string>::iterator end1 = data.end();
160 for (; it1 != end1; ++it1)
161 *it1 = support::onlyFilename(*it1);
163 // sort on filename only (no path)
164 std::sort(data.begin(), data.end());
167 ContentsType::const_iterator it = data.begin();
168 ContentsType::const_iterator end = data.end();
169 for (; it != end; ++it)
170 fileListLW->addItem(toqstr(*it));
176 void GuiTexinfoDialog::updateStyles()
178 updateStyles(activeStyle);
181 } // namespace frontend
185 #include "GuiTexinfo_moc.cpp"