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"
|
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
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-04-24 15:10:14 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiTexinfoDialog
|
2007-04-24 15:10:14 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
|
2007-04-24 15:10:14 +00:00
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
|
|
|
|
|
|
|
|
connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
|
|
|
|
connect(whatStyleCO, SIGNAL(activated(const QString &)),
|
|
|
|
this, SLOT(enableViewPB()));
|
|
|
|
connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(update()));
|
|
|
|
connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(update()));
|
|
|
|
connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
|
|
|
|
connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
|
|
|
|
connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
|
|
|
|
this, SLOT( enableViewPB() ) );
|
|
|
|
connect(fileListLW, SIGNAL(itemSelectionChanged()),
|
|
|
|
this, SLOT(enableViewPB()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::change_adaptor()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
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();
|
|
|
|
form_->updateStyles();
|
|
|
|
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-04-24 15:10:14 +00:00
|
|
|
vector<string> const & data = form_->texdata_[form_->activeStyle];
|
|
|
|
string file = data[fitem];
|
|
|
|
if (!pathCB->isChecked())
|
|
|
|
file = getTexFileFromList(data[fitem],
|
|
|
|
form_->controller().getFileType(form_->activeStyle));
|
|
|
|
form_->controller().viewFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfoDialog::update()
|
2007-04-24 15:10:14 +00:00
|
|
|
{
|
|
|
|
switch (whatStyleCO->currentIndex()) {
|
|
|
|
case 0:
|
|
|
|
form_->updateStyles(ControlTexinfo::cls);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
form_->updateStyles(ControlTexinfo::sty);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
form_->updateStyles(ControlTexinfo::bst);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-08-31 05:53:55 +00:00
|
|
|
// GuiTexinfo
|
2007-04-24 15:10:14 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
GuiTexinfo::GuiTexinfo(GuiDialog & parent)
|
2007-08-31 22:16:11 +00:00
|
|
|
: GuiView<GuiTexinfoDialog>(parent, _("TeX Information")),
|
2006-03-05 17:24:44 +00:00
|
|
|
warningPosted(false), activeStyle(ControlTexinfo::cls)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfo::build_dialog()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-08-31 05:53:55 +00:00
|
|
|
dialog_.reset(new GuiTexinfoDialog(this));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
updateStyles(ControlTexinfo::cls);
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setCancel(dialog_->closePB);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
ContentsType & data = texdata_[whichStyle];
|
2007-03-28 16:58:08 +00:00
|
|
|
bool const withFullPath = dialog_->pathCB->isChecked();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
getTexFileList(whichStyle, data, withFullPath);
|
|
|
|
|
2007-03-28 16:58:08 +00:00
|
|
|
dialog_->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-03-28 16:58:08 +00:00
|
|
|
dialog_->fileListLW->addItem(toqstr(*it));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
activeStyle = whichStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiTexinfo::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"
|