Spreadsheet: Remove unnecessary functions & files
Remove functions from they Python code for ViewProviderSpreadsheet that are now in SheetView, and eliminate the unneded files for SheetView now that it's being generated by hand to facilitate pseudo-inheritance.
This commit is contained in:
@@ -8,12 +8,10 @@ include_directories(
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
generate_from_xml(SpreadsheetViewPy)
|
||||
generate_from_xml(ViewProviderSpreadsheetPy)
|
||||
|
||||
# The XML files
|
||||
set(SpreadsheetGui_XML_SRCS
|
||||
SpreadsheetViewPy.xml
|
||||
ViewProviderSpreadsheetPy.xml
|
||||
)
|
||||
|
||||
@@ -77,7 +75,6 @@ SET(SpreadsheetGui_SRCS
|
||||
Resources/Spreadsheet.qrc
|
||||
SpreadsheetView.cpp
|
||||
SpreadsheetView.h
|
||||
SpreadsheetViewPyImp.cpp
|
||||
SpreadsheetDelegate.h
|
||||
SpreadsheetDelegate.cpp
|
||||
SheetTableView.cpp
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "SpreadsheetViewPy.h"
|
||||
#include "SpreadsheetViewPy.cpp"
|
||||
#include "ui_Sheet.h"
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -15,32 +15,6 @@
|
||||
<Author Licence="LGPL" Name="Jose Luis Cercos Pita" EMail="jlcercos@gmail.com" />
|
||||
<UserDocu>ViewProviderSheet class</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="selectedRanges">
|
||||
<Documentation>
|
||||
<UserDocu>returns a list with the selected ranges of cells</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="selectedCells">
|
||||
<Documentation>
|
||||
<UserDocu>returns a list with the selected cells</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="select">
|
||||
<Documentation>
|
||||
<UserDocu>select(index, flags): Select the specified cell using the given QItemSelectionModel.SelectionFlag set
|
||||
select(topLeft, bottomRight, flags): Select the specified range using the given QItemSelectionModel.SelectionFlag set</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="currentIndex">
|
||||
<Documentation>
|
||||
<UserDocu>Get the current active cell</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setCurrentIndex">
|
||||
<Documentation>
|
||||
<UserDocu>Set the current active cell</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getView">
|
||||
<Documentation>
|
||||
<UserDocu>Get access to the sheet view</UserDocu>
|
||||
|
||||
@@ -14,83 +14,6 @@ std::string ViewProviderSpreadsheetPy::representation(void) const
|
||||
return std::string("<ViewProviderSpreadsheet object>");
|
||||
}
|
||||
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::selectedRanges(PyObject* /*obj*/)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView *sheetView = vp->getView();
|
||||
std::vector<App::Range> ranges = sheetView->selectedRanges();
|
||||
Py::List list;
|
||||
for (const auto &range : ranges)
|
||||
{
|
||||
list.append(Py::String(range.rangeString()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::selectedCells(PyObject* /*obj*/)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView *sheetView = vp->getView();
|
||||
QModelIndexList cells = sheetView->selectedIndexes();
|
||||
Py::List list;
|
||||
for (const auto &cell : cells) {
|
||||
list.append(Py::String(App::CellAddress(cell.row(), cell.column()).toString()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::select(PyObject* _args)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView* sheetView = vp->getView();
|
||||
|
||||
Py::Sequence args(_args);
|
||||
|
||||
const char* cell;
|
||||
const char* topLeft;
|
||||
const char* bottomRight;
|
||||
int flags = 0;
|
||||
if (args.size() == 2 && PyArg_ParseTuple(_args, "si", &cell, &flags)) {
|
||||
sheetView->select(App::CellAddress(cell), static_cast<QItemSelectionModel::SelectionFlags>(flags));
|
||||
}
|
||||
else if (args.size() == 3 && PyArg_ParseTuple(_args, "ssi", &topLeft, &bottomRight, &flags)) {
|
||||
sheetView->select(App::CellAddress(topLeft), App::CellAddress(bottomRight), static_cast<QItemSelectionModel::SelectionFlags>(flags));
|
||||
}
|
||||
else {
|
||||
if (args.size() == 2)
|
||||
throw Base::TypeError("Expects the arguments to be a cell name (e.g. 'A1') and QItemSelectionModel.SelectionFlags");
|
||||
else if (args.size() == 3)
|
||||
throw Base::TypeError("Expects the arguments to be a cell name (e.g. 'A1'), a second cell name (e.g. 'B5'), and QItemSelectionModel.SelectionFlags");
|
||||
else
|
||||
throw Base::TypeError("Wrong arguments to select: specify either a cell, or two cells (for a range), and QItemSelectionModel.SelectionFlags");
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::currentIndex(PyObject* /*_args*/)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView* sheetView = vp->getView();
|
||||
auto index = sheetView->currentIndex();
|
||||
Py::String str(App::CellAddress(index.row(), index.column()).toString());
|
||||
return Py::new_reference_to(str);
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::setCurrentIndex(PyObject* args)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView* sheetView = vp->getView();
|
||||
|
||||
const char* cell;
|
||||
if (PyArg_ParseTuple(args, "s", &cell)) {
|
||||
sheetView->setCurrentIndex(App::CellAddress(cell));
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::getView(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
Reference in New Issue
Block a user