2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file QShowFile.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 John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QShowFile.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "controllers/ControlShowFile.h"
|
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QShowFileDialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
QShowFileDialog::QShowFileDialog(QShowFile * form)
|
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QShowFileDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QShowFile
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
typedef QController<ControlShowFile, QView<QShowFileDialog> >
|
|
|
|
ShowFileBase;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
QShowFile::QShowFile(Dialog & parent)
|
2007-04-24 19:37:34 +00:00
|
|
|
: ShowFileBase(parent, _("Show File"))
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QShowFile::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QShowFileDialog(this));
|
|
|
|
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QShowFile::update_contents()
|
|
|
|
{
|
2006-08-17 08:59:28 +00:00
|
|
|
dialog_->setWindowTitle(toqstr(controller().getFileName()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
std::string contents = controller().getFileContents();
|
2006-03-05 17:24:44 +00:00
|
|
|
if (contents.empty()) {
|
|
|
|
contents = "Error -> Cannot load file!";
|
|
|
|
}
|
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
dialog_->textTB->setPlainText(toqstr(contents));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 19:37:34 +00:00
|
|
|
|
|
|
|
#include "QShowFile_moc.cpp"
|