Spreadsheet: Minor code cleanup

This commit is contained in:
Chris Hennes
2021-11-12 13:31:05 -06:00
parent 6c63bc3acf
commit 23370d3ba1

View File

@@ -7,10 +7,6 @@
using namespace SpreadsheetGui;
#if PY_MAJOR_VERSION >= 2
#define PyString_FromString PyUnicode_FromString
#endif
// returns a string which represents the object e.g. when printed in python
std::string ViewProviderSpreadsheetPy::representation(void) const
{
@@ -24,10 +20,9 @@ PyObject* ViewProviderSpreadsheetPy::selectedRanges(PyObject* /*obj*/)
SheetView *sheetView = vp->getView();
std::vector<App::Range> ranges = sheetView->selectedRanges();
PyObject *out = PyList_New(0);
std::vector<App::Range>::const_iterator i = ranges.begin();
for (; i != ranges.end(); ++i)
for (const auto &range : ranges)
{
PyObject *py_str = PyString_FromString(i->rangeString().c_str());
PyObject *py_str = PyUnicode_FromString(range.rangeString().c_str());
PyList_Append(out, py_str);
}
@@ -40,9 +35,9 @@ PyObject* ViewProviderSpreadsheetPy::selectedCells(PyObject* /*obj*/)
SheetView *sheetView = vp->getView();
QModelIndexList cells = sheetView->selectedIndexes();
PyObject *out = PyList_New(0);
for (auto it : cells) {
PyObject *py_str = PyString_FromString(
App::CellAddress(it.row(), it.column()).toString().c_str());
for (const auto &cell : cells) {
PyObject *py_str = PyUnicode_FromString(
App::CellAddress(cell.row(), cell.column()).toString().c_str());
PyList_Append(out, py_str);
}
@@ -51,7 +46,7 @@ PyObject* ViewProviderSpreadsheetPy::selectedCells(PyObject* /*obj*/)
PyObject *ViewProviderSpreadsheetPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
return nullptr;
}