mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20765 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
58296b3994
commit
f3d1cf3ca1
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* \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
|
@ -1,49 +0,0 @@
|
||||
// -*- 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
|
@ -31,7 +31,6 @@ SOURCEFILES = \
|
||||
ControlPrint.cpp \
|
||||
ControlSearch.cpp \
|
||||
ControlSendto.cpp \
|
||||
ControlShowFile.cpp \
|
||||
ControlSpellchecker.cpp \
|
||||
ControlTabular.cpp \
|
||||
ControlTabularCreate.cpp \
|
||||
@ -64,7 +63,6 @@ HEADERFILES = \
|
||||
ControlPrint.h \
|
||||
ControlSearch.h \
|
||||
ControlSendto.h \
|
||||
ControlShowFile.h \
|
||||
ControlSpellchecker.h \
|
||||
ControlTabular.h \
|
||||
ControlTabularCreate.h \
|
||||
|
@ -185,7 +185,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
} 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") {
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Herbert Voß
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -12,8 +13,8 @@
|
||||
|
||||
#include "GuiShowFile.h"
|
||||
|
||||
#include "ControlShowFile.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QPushButton>
|
||||
@ -23,12 +24,15 @@
|
||||
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()));
|
||||
|
||||
@ -37,31 +41,41 @@ GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Herbert Voß
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,26 +14,38 @@
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user