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.
15 #include "qt_helpers.h"
17 #include "support/filetools.h"
20 #include <QListWidget>
21 #include <QPushButton>
29 /////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////
36 QTexinfoDialog::QTexinfoDialog(QTexinfo * 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 QTexinfoDialog::change_adaptor()
63 void QTexinfoDialog::closeEvent(QCloseEvent * e)
70 void QTexinfoDialog::rescanClicked()
72 // build new *Files.lst
74 form_->updateStyles();
79 void QTexinfoDialog::viewClicked()
81 vector<string>::size_type 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 QTexinfoDialog::update()
93 switch (whatStyleCO->currentIndex()) {
95 form_->updateStyles(ControlTexinfo::cls);
98 form_->updateStyles(ControlTexinfo::sty);
101 form_->updateStyles(ControlTexinfo::bst);
111 void QTexinfoDialog::enableViewPB()
113 viewPB->setEnabled(fileListLW->currentRow() > -1);
118 /////////////////////////////////////////////////////////////////////
122 /////////////////////////////////////////////////////////////////////
124 typedef QController<ControlTexinfo, QView<QTexinfoDialog> > texinfo_base_class;
126 QTexinfo::QTexinfo(Dialog & parent)
127 : texinfo_base_class(parent, _("TeX Information")),
128 warningPosted(false), activeStyle(ControlTexinfo::cls)
133 void QTexinfo::build_dialog()
135 dialog_.reset(new QTexinfoDialog(this));
137 updateStyles(ControlTexinfo::cls);
139 bcview().setCancel(dialog_->closePB);
143 void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
145 ContentsType & data = texdata_[whichStyle];
146 bool const withFullPath = dialog_->pathCB->isChecked();
148 getTexFileList(whichStyle, data, withFullPath);
150 dialog_->fileListLW->clear();
151 ContentsType::const_iterator it = data.begin();
152 ContentsType::const_iterator end = data.end();
153 for (; it != end; ++it)
154 dialog_->fileListLW->addItem(toqstr(*it));
156 activeStyle = whichStyle;
160 void QTexinfo::updateStyles()
162 updateStyles(activeStyle);
165 } // namespace frontend
169 #include "QTexinfo_moc.cpp"