* Licence details can be found in the file COPYING.
*
* \author John Levon
+ * \author Herbert Voß
*
* Full author contact details are available in file CREDITS.
*/
#include "GuiShowFile.h"
-#include "ControlShowFile.h"
#include "qt_helpers.h"
+#include "support/filetools.h"
#include <QTextBrowser>
#include <QPushButton>
-#include <QCloseEvent>
+using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace frontend {
-GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
- : GuiDialog(lv, "file")
+
+GuiShowFile::GuiShowFile(GuiView & lv)
+ : GuiDialog(lv, "file", qt_("Show File"))
{
setupUi(this);
- setViewTitle(_("Show File"));
- setController(new ControlShowFile(*this));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
}
-ControlShowFile & GuiShowFileDialog::controller() const
+void GuiShowFile::updateContents()
{
- return static_cast<ControlShowFile &>(Dialog::controller());
+ setWindowTitle(onlyFileName(toqstr(filename_.absFileName())));
+
+ QString contents = toqstr(filename_.fileContents("UTF-8"));
+ if (contents.isEmpty())
+ contents = qt_("Error -> Cannot load file!");
+
+ textTB->setPlainText(contents);
}
-void GuiShowFileDialog::closeEvent(QCloseEvent * e)
+bool GuiShowFile::initialiseParams(string const & data)
{
- slotWMHide();
- e->accept();
+ filename_ = FileName(data);
+ return true;
}
-void GuiShowFileDialog::update_contents()
+void GuiShowFile::clearParams()
{
- setWindowTitle(toqstr(controller().getFileName()));
+ filename_.erase();
+}
- std::string contents = controller().getFileContents();
- if (contents.empty()) {
- contents = "Error -> Cannot load file!";
- }
- textTB->setPlainText(toqstr(contents));
-}
+Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
+
} // namespace frontend
} // namespace lyx
-#include "GuiShowFile_moc.cpp"
+#include "moc_GuiShowFile.cpp"