[Spreadsheet] Expose SpreadsheetView::getSheet to Python
This commit is contained in:
@@ -8,6 +8,13 @@ include_directories(
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
generate_from_xml(SpreadsheetViewPy)
|
||||
|
||||
# The XML files
|
||||
set(SpreadsheetGui_XML_SRCS
|
||||
SpreadsheetViewPy.xml
|
||||
)
|
||||
|
||||
set(SpreadsheetGui_LIBS
|
||||
Spreadsheet
|
||||
FreeCADGui
|
||||
@@ -54,6 +61,7 @@ endif()
|
||||
|
||||
SET(SpreadsheetGui_SRCS
|
||||
${SpreadsheetGui_QRC_SRCS}
|
||||
${SpreadsheetGui_XML_SRCS}
|
||||
AppSpreadsheetGui.cpp
|
||||
Command.cpp
|
||||
LineEdit.h
|
||||
@@ -63,6 +71,7 @@ SET(SpreadsheetGui_SRCS
|
||||
Resources/Spreadsheet.qrc
|
||||
SpreadsheetView.cpp
|
||||
SpreadsheetView.h
|
||||
SpreadsheetViewPyImp.cpp
|
||||
SpreadsheetDelegate.h
|
||||
SpreadsheetDelegate.cpp
|
||||
SheetTableView.cpp
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "qtcolorpicker.h"
|
||||
|
||||
#include "SpreadsheetView.h"
|
||||
#include "SpreadsheetViewPy.h"
|
||||
#include "SpreadsheetDelegate.h"
|
||||
#include "ui_Sheet.h"
|
||||
|
||||
@@ -444,7 +445,11 @@ QModelIndex SheetView::currentIndex() const
|
||||
|
||||
PyObject *SheetView::getPyObject()
|
||||
{
|
||||
return Gui::MDIView::getPyObject();
|
||||
if (!pythonObject)
|
||||
pythonObject = new SpreadsheetViewPy(this);
|
||||
|
||||
Py_INCREF(pythonObject);
|
||||
return pythonObject;
|
||||
}
|
||||
|
||||
void SheetView::deleteSelf()
|
||||
|
||||
23
src/Mod/Spreadsheet/Gui/SpreadsheetViewPy.xml
Normal file
23
src/Mod/Spreadsheet/Gui/SpreadsheetViewPy.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="PyObjectBase"
|
||||
Name="SpreadsheetViewPy"
|
||||
Twin="SheetView"
|
||||
TwinPointer="SheetView"
|
||||
Include="Mod/Spreadsheet/Gui/SpreadsheetView.h"
|
||||
Namespace="SpreadsheetGui"
|
||||
FatherInclude="Base/PyObjectBase.h"
|
||||
FatherNamespace="Base">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="openBrain" EMail="" />
|
||||
<UserDocu>SpreadsheetView object</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="getSheet">
|
||||
<Documentation>
|
||||
<UserDocu>returns the sheet being displayed</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
31
src/Mod/Spreadsheet/Gui/SpreadsheetViewPyImp.cpp
Normal file
31
src/Mod/Spreadsheet/Gui/SpreadsheetViewPyImp.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "SpreadsheetViewPy.h"
|
||||
#include "SpreadsheetViewPy.cpp"
|
||||
|
||||
#include <Mod/Spreadsheet/App/SheetPy.h>
|
||||
|
||||
using namespace SpreadsheetGui;
|
||||
|
||||
PyObject* SpreadsheetViewPy::getSheet(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
return new Spreadsheet::SheetPy(getSheetViewPtr()->getSheet());
|
||||
}
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string SpreadsheetViewPy::representation(void) const
|
||||
{
|
||||
return std::string("<SheetView object>");
|
||||
}
|
||||
|
||||
PyObject *SpreadsheetViewPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SpreadsheetViewPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user