2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiTexinfo.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiTexinfo.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
#include "ControlTexinfo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QCloseEvent>
|
2006-05-03 19:51:15 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
using std::string;
|
2007-04-24 15:10:14 +00:00
|
|
|
using std::vector;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
GuiTexinfoDialog::GuiTexinfoDialog(LyXView & lv)
|
|
|
|
: GuiDialog(lv, "texinfo")
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle(_("TeX Information"));
|
|
|
|
setController(new ControlTexinfo(*this));
|
2007-04-24 15:10:14 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
warningPosted = false;
|
|
|
|
activeStyle = ControlTexinfo::cls;
|
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-24 15:10:14 +00:00
|
|
|
|
|
|
|
connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
|
|
|
|
connect(whatStyleCO, SIGNAL(activated(const QString &)),
|
|
|
|
this, SLOT(enableViewPB()));
|
2007-09-09 12:06:37 +00:00
|
|
|
connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(updateView()));
|
|
|
|
connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(updateView()));
|
2007-04-24 15:10:14 +00:00
|
|
|
connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
|
|
|
|
connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
|
|
|
|
connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
|
2007-09-05 20:33:29 +00:00
|
|
|
this, SLOT(enableViewPB()));
|
2007-04-24 15:10:14 +00:00
|
|
|
connect(fileListLW, SIGNAL(itemSelectionChanged()),
|
|
|
|
this, SLOT(enableViewPB()));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
updateStyles(ControlTexinfo::cls);
|
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ControlTexinfo & GuiTexinfoDialog::controller() const
|
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return static_cast<ControlTexinfo &>(GuiDialog::controller());
|
2007-04-24 15:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::change_adaptor()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-24 15:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-04-24 15:10:14 +00:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::rescanClicked()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
// build new *Files.lst
|
|
|
|
rescanTexStyles();
|
2007-09-05 20:33:29 +00:00
|
|
|
updateStyles();
|
2007-04-24 15:10:14 +00:00
|
|
|
enableViewPB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::viewClicked()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
2007-08-31 05:53:55 +00:00
|
|
|
size_t const fitem = fileListLW->currentRow();
|
2007-09-05 20:33:29 +00:00
|
|
|
vector<string> const & data = texdata_[activeStyle];
|
2007-04-24 15:10:14 +00:00
|
|
|
string file = data[fitem];
|
|
|
|
if (!pathCB->isChecked())
|
|
|
|
file = getTexFileFromList(data[fitem],
|
2007-09-05 20:33:29 +00:00
|
|
|
controller().getFileType(activeStyle));
|
|
|
|
controller().viewFile(file);
|
2007-04-24 15:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-03 20:28:26 +00:00
|
|
|
void GuiTexinfoDialog::updateView()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
switch (whatStyleCO->currentIndex()) {
|
2007-09-05 20:33:29 +00:00
|
|
|
case 0:
|
|
|
|
updateStyles(ControlTexinfo::cls);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
updateStyles(ControlTexinfo::sty);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
updateStyles(ControlTexinfo::bst);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-04-24 15:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enableViewPB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::enableViewPB()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
viewPB->setEnabled(fileListLW->currentRow() > -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
ContentsType & data = texdata_[whichStyle];
|
2007-09-05 20:33:29 +00:00
|
|
|
bool const withFullPath = pathCB->isChecked();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
getTexFileList(whichStyle, data, withFullPath);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
fileListLW->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
ContentsType::const_iterator it = data.begin();
|
|
|
|
ContentsType::const_iterator end = data.end();
|
|
|
|
for (; it != end; ++it)
|
2007-09-05 20:33:29 +00:00
|
|
|
fileListLW->addItem(toqstr(*it));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
activeStyle = whichStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiTexinfoDialog::updateStyles()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 15:10:14 +00:00
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiTexinfo_moc.cpp"
|