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>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
using namespace std;
|
2007-12-12 19:57:42 +00:00
|
|
|
using namespace lyx::support;
|
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
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiShowFile::GuiShowFile(GuiView & lv)
|
2008-02-05 12:43:19 +00:00
|
|
|
: GuiDialog(lv, "file", qt_("Show File"))
|
2007-04-24 19:37:34 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
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::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-02-05 12:43:19 +00:00
|
|
|
QString contents = toqstr(filename_.fileContents("UTF-8"));
|
|
|
|
if (contents.isEmpty())
|
|
|
|
contents = qt_("Error -> Cannot load file!");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-02-05 12:43:19 +00:00
|
|
|
textTB->setPlainText(contents);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-05 22:53:01 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
bool GuiShowFile::initialiseParams(string const & data)
|
2007-10-05 22:53:01 +00:00
|
|
|
{
|
|
|
|
filename_ = FileName(data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiShowFile::clearParams()
|
|
|
|
{
|
|
|
|
filename_.erase();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
|
2007-10-05 22:53:01 +00:00
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 19:37:34 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiShowFile.cpp"
|