+++ /dev/null
-/**
- * \file ControlShowFile.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlShowFile.h"
-
-#include "support/filetools.h"
-
-using std::string;
-
-namespace lyx {
-
-using support::FileName;
-using support::onlyFilename;
-
-namespace frontend {
-
-
-ControlShowFile::ControlShowFile(Dialog & parent)
- : Controller(parent)
-{}
-
-
-bool ControlShowFile::initialiseParams(string const & data)
-{
- filename_ = FileName(data);
- return true;
-}
-
-
-void ControlShowFile::clearParams()
-{
- filename_.erase();
-}
-
-
-string ControlShowFile::getFileContents()
-{
- return support::getFileContents(filename_);
-}
-
-
-string ControlShowFile::getFileName()
-{
- return onlyFilename(filename_.absFilename());
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \file ControlShowFile.h
- *
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-#ifndef CONTROLSHOWFILE_H
-#define CONTROLSHOWFILE_H
-
-#include "Dialog.h"
-
-#include "support/FileName.h"
-
-namespace lyx {
-namespace frontend {
-
-/** A controller for the ShowFile dialog. */
-
-class ControlShowFile : public Controller {
-public:
- ///
- ControlShowFile(Dialog &);
- ///
- virtual bool initialiseParams(std::string const & data);
- ///
- virtual void clearParams();
- ///
- virtual void dispatchParams() {}
- ///
- virtual bool isBufferDependent() const { return false; }
- ///
- std::string getFileContents();
- ///
- std::string getFileName();
-
-private:
- ///
- support::FileName filename_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLSHOWFILE_H
ControlPrint.cpp \
ControlSearch.cpp \
ControlSendto.cpp \
- ControlShowFile.cpp \
ControlSpellchecker.cpp \
ControlTabular.cpp \
ControlTabularCreate.cpp \
ControlPrint.h \
ControlSearch.h \
ControlSendto.h \
- ControlShowFile.h \
ControlSpellchecker.h \
ControlTabular.h \
ControlTabularCreate.h \
} else if (name == "external") {
dialog = new GuiExternalDialog(lyxview_);
} else if (name == "file") {
- dialog = new GuiShowFileDialog(lyxview_);
+ dialog = createGuiShowFile(lyxview_);
} else if (name == "findreplace") {
dialog = new GuiSearchDialog(lyxview_);
} else if (name == "float") {
* 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>
namespace lyx {
namespace frontend {
-GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
- : GuiDialog(lv, "file")
+using support::FileName;
+using support::onlyFilename;
+
+GuiShowFile::GuiShowFile(LyXView & lv)
+ : GuiDialog(lv, "file"), Controller(this)
{
setupUi(this);
setViewTitle(_("Show File"));
- setController(new ControlShowFile(*this));
+ setController(this, false);
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
}
-ControlShowFile & GuiShowFileDialog::controller()
-{
- return static_cast<ControlShowFile &>(GuiDialog::controller());
-}
-
-
-void GuiShowFileDialog::closeEvent(QCloseEvent * e)
+void GuiShowFile::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
}
-void GuiShowFileDialog::updateContents()
+void GuiShowFile::updateContents()
{
- setWindowTitle(toqstr(controller().getFileName()));
+ setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
- std::string contents = controller().getFileContents();
- if (contents.empty()) {
+ std::string contents = support::getFileContents(filename_);
+ if (contents.empty())
contents = "Error -> Cannot load file!";
- }
textTB->setPlainText(toqstr(contents));
}
+
+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); }
+
+
} // namespace frontend
} // namespace lyx
* Licence details can be found in the file COPYING.
*
* \author John Levon
+ * \author Herbert Voß
*
* Full author contact details are available in file CREDITS.
*/
#define GUISHOWFILE_H
#include "GuiDialog.h"
-#include "ControlShowFile.h"
#include "ui_ShowFileUi.h"
+#include "support/FileName.h"
+
namespace lyx {
namespace frontend {
-class GuiShowFileDialog : public GuiDialog, public Ui::ShowFileUi
+class GuiShowFile : public GuiDialog, public Ui::ShowFileUi, public Controller
{
Q_OBJECT
public:
- GuiShowFileDialog(LyXView & lv);
+ GuiShowFile(LyXView & lv);
private:
///
void closeEvent(QCloseEvent * e);
/// parent controller
- ControlShowFile & controller();
+ Controller & controller() { return *this; }
/// update
void updateContents();
+ ///
+ bool initialiseParams(std::string const & data);
+ ///
+ void clearParams();
+ ///
+ void dispatchParams() {}
+ ///
+ bool isBufferDependent() const { return false; }
+
+ ///
+ support::FileName filename_;
};
} // namespace frontend