Spreadsheet: Expose currentIndex to Python
This commit is contained in:
@@ -439,6 +439,11 @@ QModelIndex SheetView::currentIndex() const
|
||||
return ui->cells->currentIndex();
|
||||
}
|
||||
|
||||
void SpreadsheetGui::SheetView::setCurrentIndex(App::CellAddress cell) const
|
||||
{
|
||||
ui->cells->setCurrentIndex(model->index(cell.row(), cell.col()));
|
||||
}
|
||||
|
||||
PyObject *SheetView::getPyObject()
|
||||
{
|
||||
if (!pythonObject)
|
||||
|
||||
@@ -79,6 +79,8 @@ public:
|
||||
|
||||
QModelIndex currentIndex() const;
|
||||
|
||||
void setCurrentIndex(App::CellAddress cell) const;
|
||||
|
||||
void deleteSelection();
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "SpreadsheetViewPy.h"
|
||||
#include "SpreadsheetViewPy.cpp"
|
||||
#include "ui_Sheet.h"
|
||||
|
||||
#include <Mod/Spreadsheet/App/SheetPy.h>
|
||||
|
||||
|
||||
@@ -27,10 +27,19 @@
|
||||
</Methode>
|
||||
<Methode Name="select">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
select(index, flags): Select the specified cell using the given QItemSelectionModel.SelectionFlag set
|
||||
<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>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
</GenerateModel>
|
||||
@@ -48,7 +48,6 @@ PyObject* ViewProviderSpreadsheetPy::select(PyObject* _args)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView* sheetView = vp->getView();
|
||||
Spreadsheet::Sheet* sheet = sheetView->getSheet();
|
||||
|
||||
Py::Sequence args(_args);
|
||||
|
||||
@@ -73,6 +72,28 @@ PyObject* ViewProviderSpreadsheetPy::select(PyObject* _args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::currentIndex(PyObject* _args)
|
||||
{
|
||||
ViewProviderSheet* vp = this->getViewProviderSheetPtr();
|
||||
SheetView* sheetView = vp->getView();
|
||||
auto index = sheetView->currentIndex();
|
||||
PyObject* py_str = PyUnicode_FromString(
|
||||
App::CellAddress(index.row(), index.column()).toString().c_str());
|
||||
return py_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));
|
||||
}
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject *ViewProviderSpreadsheetPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user