2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiShowFile.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
|
2007-10-05 22:53:01 +00:00
|
|
|
* \author Herbert Voß
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiShowFile.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-05 22:53:01 +00:00
|
|
|
#include "support/filetools.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QPushButton>
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QCloseEvent>
|
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-10-05 22:53:01 +00:00
|
|
|
using support::FileName;
|
|
|
|
using support::onlyFilename;
|
|
|
|
|
|
|
|
GuiShowFile::GuiShowFile(LyXView & lv)
|
2007-10-09 19:34:27 +00:00
|
|
|
: GuiDialog(lv, "file")
|
2007-04-24 19:37:34 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle(_("Show File"));
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
|
|
|
bc().setCancel(closePB);
|
2007-04-24 19:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-05 22:53:01 +00:00
|
|
|
void GuiShowFile::closeEvent(QCloseEvent * e)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
e->accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-05 22:53:01 +00:00
|
|
|
void GuiShowFile::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-05 22:53:01 +00:00
|
|
|
setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-05 22:53:01 +00:00
|
|
|
std::string contents = support::getFileContents(filename_);
|
|
|
|
if (contents.empty())
|
2006-03-05 17:24:44 +00:00
|
|
|
contents = "Error -> Cannot load file!";
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
textTB->setPlainText(toqstr(contents));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-05 22:53:01 +00:00
|
|
|
|
|
|
|
bool GuiShowFile::initialiseParams(std::string const & data)
|
|
|
|
{
|
|
|
|
filename_ = FileName(data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiShowFile::clearParams()
|
|
|
|
{
|
|
|
|
filename_.erase();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dialog * createGuiShowFile(LyXView & lv) { return new GuiShowFile(lv); }
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiShowFile_moc.cpp"
|