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 "qt_helpers.h"
17 #include "support/filetools.h"
20 #include <QListWidget>
21 #include <QPushButton>
29 /////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////
36 GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
41 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
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()));
57 void GuiTexinfoDialog::change_adaptor()
63 void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
70 void GuiTexinfoDialog::rescanClicked()
72 // build new *Files.lst
74 form_->updateStyles();
79 void GuiTexinfoDialog::viewClicked()
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);
91 void GuiTexinfoDialog::update()
93 switch (whatStyleCO->currentIndex()) {
95 form_->updateStyles(ControlTexinfo::cls);
98 form_->updateStyles(ControlTexinfo::sty);
101 form_->updateStyles(ControlTexinfo::bst);
111 void GuiTexinfoDialog::enableViewPB()
113 viewPB->setEnabled(fileListLW->currentRow() > -1);
118 /////////////////////////////////////////////////////////////////////
122 /////////////////////////////////////////////////////////////////////
124 typedef QController<ControlTexinfo, GuiView<GuiTexinfoDialog> >
127 GuiTexinfo::GuiTexinfo(Dialog & parent)
128 : texinfo_base_class(parent, _("TeX Information")),
129 warningPosted(false), activeStyle(ControlTexinfo::cls)
134 void GuiTexinfo::build_dialog()
136 dialog_.reset(new GuiTexinfoDialog(this));
138 updateStyles(ControlTexinfo::cls);
140 bcview().setCancel(dialog_->closePB);
144 void GuiTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
146 ContentsType & data = texdata_[whichStyle];
147 bool const withFullPath = dialog_->pathCB->isChecked();
149 getTexFileList(whichStyle, data, withFullPath);
151 dialog_->fileListLW->clear();
152 ContentsType::const_iterator it = data.begin();
153 ContentsType::const_iterator end = data.end();
154 for (; it != end; ++it)
155 dialog_->fileListLW->addItem(toqstr(*it));
157 activeStyle = whichStyle;
161 void GuiTexinfo::updateStyles()
163 updateStyles(activeStyle);
166 } // namespace frontend
170 #include "GuiTexinfo_moc.cpp"