Gui: expose some more methods of MDIView to Python

This commit is contained in:
wmayer
2021-11-21 14:32:36 +01:00
parent bd530b9070
commit ac05ae3637
2 changed files with 83 additions and 0 deletions

View File

@@ -55,6 +55,13 @@ void MDIViewPy::init_type()
behaviors().supportSetattr();
behaviors().set_tp_new(extension_object_new);
add_varargs_method("printView",&MDIViewPy::printView,"printView()");
add_varargs_method("printPdf",&MDIViewPy::printPdf,"printPdf()");
add_varargs_method("printPreview",&MDIViewPy::printPreview,"printPreview()");
add_varargs_method("undoActions",&MDIViewPy::undoActions,"undoActions()");
add_varargs_method("redoActions",&MDIViewPy::redoActions,"redoActions()");
add_varargs_method("message",&MDIViewPy::sendMessage,"deprecated: use sendMessage");
add_varargs_method("sendMessage",&MDIViewPy::sendMessage,"sendMessage(str)");
add_varargs_method("supportMessage",&MDIViewPy::supportMessage,"supportMessage(str)");
@@ -104,6 +111,69 @@ Py::Object MDIViewPy::repr()
return Py::String(s_out.str());
}
Py::Object MDIViewPy::printView(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
if (_view)
_view->print();
return Py::None();
}
Py::Object MDIViewPy::printPdf(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
if (_view)
_view->printPdf();
return Py::None();
}
Py::Object MDIViewPy::printPreview(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
if (_view)
_view->printPreview();
return Py::None();
}
Py::Object MDIViewPy::undoActions(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
Py::List list;
if (_view) {
QStringList undo = _view->undoActions();
for (const auto& it : undo)
list.append(Py::String(it.toStdString()));
}
return list;
}
Py::Object MDIViewPy::redoActions(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
Py::List list;
if (_view) {
QStringList redo = _view->redoActions();
for (const auto& it : redo)
list.append(Py::String(it.toStdString()));
}
return list;
}
Py::Object MDIViewPy::sendMessage(const Py::Tuple& args)
{
const char **ppReturn = 0;

View File

@@ -46,6 +46,19 @@ public:
Py::Object repr();
/** @name Printing */
//@{
Py::Object printView(const Py::Tuple&);
Py::Object printPdf(const Py::Tuple&);
Py::Object printPreview(const Py::Tuple&);
//@}
/** @name Undo/Redo actions */
//@{
Py::Object undoActions(const Py::Tuple&);
Py::Object redoActions(const Py::Tuple&);
//@}
Py::Object sendMessage(const Py::Tuple&);
Py::Object supportMessage(const Py::Tuple&);
Py::Object fitAll(const Py::Tuple&);