mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Restore docked View source widget.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20142 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
779220a03b
commit
f044fc3dd0
@ -15,7 +15,6 @@
|
||||
|
||||
#include "ButtonController.h"
|
||||
#include "DockView.h"
|
||||
#include "GuiView.h"
|
||||
#include "GuiAbout.h"
|
||||
#include "GuiBibitem.h"
|
||||
#include "GuiBibtex.h"
|
||||
@ -38,7 +37,6 @@
|
||||
#include "GuiNomencl.h"
|
||||
#include "GuiListings.h"
|
||||
#include "GuiLog.h"
|
||||
#include "GuiViewSource.h"
|
||||
#include "GuiNote.h"
|
||||
#include "GuiParagraph.h"
|
||||
#include "GuiPrefs.h"
|
||||
@ -52,6 +50,8 @@
|
||||
#include "GuiTabularCreate.h"
|
||||
#include "GuiTexinfo.h"
|
||||
#include "GuiToc.h"
|
||||
#include "GuiView.h"
|
||||
#include "GuiViewSource.h"
|
||||
#include "TocWidget.h"
|
||||
#include "GuiURL.h"
|
||||
#include "GuiVSpace.h"
|
||||
@ -115,6 +115,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
BOOST_ASSERT(isValidName(name));
|
||||
|
||||
Dialog * dialog = 0;
|
||||
GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
|
||||
|
||||
if (name == "aboutlyx") {
|
||||
dialog = new GuiAboutDialog(lyxview_);
|
||||
@ -161,7 +162,8 @@ Dialog * Dialogs::build(string const & name)
|
||||
} else if (name == "log") {
|
||||
dialog = new GuiLogDialog(lyxview_);
|
||||
} else if (name == "view-source") {
|
||||
dialog = new GuiViewSourceDialog(lyxview_);
|
||||
dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
|
||||
guiview, name, Qt::BottomDockWidgetArea);
|
||||
} else if (name == "mathdelimiter") {
|
||||
dialog = new GuiDelimiterDialog(lyxview_);
|
||||
} else if (name == "mathmatrix") {
|
||||
|
@ -13,43 +13,45 @@
|
||||
#define DOCK_VIEW_H
|
||||
|
||||
#include "controllers/Dialog.h"
|
||||
#include "GuiView.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QMainWindow>
|
||||
#include <string>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/*
|
||||
/// Dock Widget container for LyX dialogs.
|
||||
/// This template class that encapsulates a given Widget inside a
|
||||
/// DockWidget and presents a Dialog::View interface
|
||||
template<class Controller, class Widget>
|
||||
class DockView : public QDockWidget, public Dialog::View
|
||||
/// QDockWidget and presents a Dialog interface
|
||||
template<class MyController, class MyWidget>
|
||||
class DockView : public QDockWidget, public Dialog
|
||||
{
|
||||
public:
|
||||
DockView(
|
||||
Dialog & dialog, ///< The (one) parent Dialog class.
|
||||
Controller * form, ///< Associated model/controller
|
||||
QMainWindow * parent, ///< the main window where to dock.
|
||||
docstring const & title, ///< Window title (shown in the top title bar).
|
||||
GuiViewBase & parent, ///< the main window where to dock.
|
||||
std::string const & title, ///< Window title (shown in the top title bar).
|
||||
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
||||
Qt::WindowFlags flags = 0
|
||||
)
|
||||
: QDockWidget(toqstr(title), parent, flags),
|
||||
Dialog::View(dialog, title)
|
||||
: QDockWidget(toqstr(title), &parent, flags),
|
||||
Dialog(parent, title)
|
||||
{
|
||||
if (flags & Qt::Drawer)
|
||||
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
widget_.reset(new Widget(form));
|
||||
MyController * controller = new MyController(*this);
|
||||
setController(controller);
|
||||
widget_.reset(new MyWidget(*controller));
|
||||
setWidget(widget_.get());
|
||||
parent->addDockWidget(area, this);
|
||||
parent.addDockWidget(area, this);
|
||||
}
|
||||
|
||||
/// Dialog::View inherited methods
|
||||
/// Dialog inherited methods
|
||||
//@{
|
||||
void applyView() {}
|
||||
void hideView() { QDockWidget::hide(); }
|
||||
@ -58,17 +60,16 @@ public:
|
||||
void redrawView() {}
|
||||
void updateView()
|
||||
{
|
||||
widget_->update();
|
||||
widget_->updateView();
|
||||
QDockWidget::update();
|
||||
}
|
||||
//@}
|
||||
private:
|
||||
/// The encapsulated widget.
|
||||
boost::scoped_ptr<Widget> widget_;
|
||||
boost::scoped_ptr<MyWidget> widget_;
|
||||
};
|
||||
*/
|
||||
|
||||
} // frontend
|
||||
} // lyx
|
||||
|
||||
#endif // TOC_WIDGET_H
|
||||
#endif // DOCK_VIEW_H
|
||||
|
@ -24,16 +24,11 @@
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiViewSourceDialog::GuiViewSourceDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "view-source"),
|
||||
document_(new QTextDocument(this)),
|
||||
GuiViewSourceDialog::GuiViewSourceDialog(ControlViewSource & controller)
|
||||
: controller_(controller), document_(new QTextDocument(this)),
|
||||
highlighter_(new LaTeXHighlighter(document_))
|
||||
{
|
||||
setupUi(this);
|
||||
setController(new ControlViewSource(*this));
|
||||
|
||||
// GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
|
||||
// *dialog, qvs, &gui_view, _("LaTeX Source"), Qt::BottomDockWidgetArea));
|
||||
|
||||
connect(viewFullSourceCB, SIGNAL(clicked()),
|
||||
this, SLOT(update()));
|
||||
@ -57,14 +52,6 @@ GuiViewSourceDialog::GuiViewSourceDialog(LyXView & lv)
|
||||
viewSourceTV->setFont(font);
|
||||
// again, personal taste
|
||||
viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
|
||||
|
||||
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
||||
}
|
||||
|
||||
|
||||
ControlViewSource & GuiViewSourceDialog::controller() const
|
||||
{
|
||||
return static_cast<ControlViewSource &>(Dialog::controller());
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +61,7 @@ void GuiViewSourceDialog::updateView()
|
||||
update(viewFullSourceCB->isChecked());
|
||||
|
||||
int beg, end;
|
||||
boost::tie(beg, end) = controller().getRows();
|
||||
boost::tie(beg, end) = controller_.getRows();
|
||||
QTextCursor c = QTextCursor(viewSourceTV->document());
|
||||
c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
|
||||
c.select(QTextCursor::BlockUnderCursor);
|
||||
@ -86,7 +73,7 @@ void GuiViewSourceDialog::updateView()
|
||||
|
||||
void GuiViewSourceDialog::update(bool full_source)
|
||||
{
|
||||
document_->setPlainText(toqstr(controller().updateContent(full_source)));
|
||||
document_->setPlainText(toqstr(controller_.updateContent(full_source)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,12 +44,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class GuiViewSourceDialog : public GuiDialog, public Ui::ViewSourceUi
|
||||
class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiViewSourceDialog(LyXView & lv);
|
||||
GuiViewSourceDialog(ControlViewSource &);
|
||||
|
||||
public Q_SLOTS:
|
||||
// update content
|
||||
@ -61,7 +61,7 @@ public Q_SLOTS:
|
||||
|
||||
private:
|
||||
///
|
||||
ControlViewSource & controller() const;
|
||||
ControlViewSource & controller_;
|
||||
///
|
||||
QTextDocument * document_;
|
||||
/// LaTeX syntax highlighter
|
||||
|
Loading…
Reference in New Issue
Block a user