2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file QTexinfo.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>
|
|
|
|
|
|
|
|
#include "QTexinfo.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
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
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QTexinfoDialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
QTexinfoDialog::QTexinfoDialog(QTexinfo * form)
|
|
|
|
: 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()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::change_adaptor()
|
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::rescanClicked()
|
|
|
|
{
|
|
|
|
// build new *Files.lst
|
|
|
|
rescanTexStyles();
|
|
|
|
form_->updateStyles();
|
|
|
|
enableViewPB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::viewClicked()
|
|
|
|
{
|
|
|
|
vector<string>::size_type const fitem = fileListLW->currentRow();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::update()
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfoDialog::enableViewPB()
|
|
|
|
{
|
|
|
|
viewPB->setEnabled(fileListLW->currentRow() > -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QTexinfo
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-03-22 23:07:24 +00:00
|
|
|
typedef QController<ControlTexinfo, QView<QTexinfoDialog> > texinfo_base_class;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
QTexinfo::QTexinfo(Dialog & parent)
|
2007-03-22 23:07:24 +00:00
|
|
|
: texinfo_base_class(parent, _("TeX Information")),
|
2006-03-05 17:24:44 +00:00
|
|
|
warningPosted(false), activeStyle(ControlTexinfo::cls)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfo::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QTexinfoDialog(this));
|
|
|
|
|
|
|
|
updateStyles(ControlTexinfo::cls);
|
|
|
|
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTexinfo::updateStyles()
|
|
|
|
{
|
|
|
|
updateStyles(activeStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 15:10:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "QTexinfo_moc.cpp"
|