Spreadsheet: modernize C++11

* use nullptr
This commit is contained in:
wmayer
2022-03-23 19:10:37 +01:00
parent 80ca13c667
commit 2c229d3bc0
28 changed files with 157 additions and 157 deletions

View File

@@ -77,7 +77,7 @@ private:
Py::Object open(const Py::Tuple& args)
{
char* Name;
const char* DocName=0;
const char* DocName=nullptr;
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
throw Py::Exception();
std::string EncodedName = std::string(Name);
@@ -112,7 +112,7 @@ PyMOD_INIT_FUNC(SpreadsheetGui)
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
PyMOD_Return(0);
PyMOD_Return(nullptr);
}
// instantiating the commands

View File

@@ -37,7 +37,7 @@ class DlgBindSheet : public QDialog
Q_OBJECT
public:
explicit DlgBindSheet(Spreadsheet::Sheet *sheet, const std::vector<App::Range> &range, QWidget *parent = 0);
explicit DlgBindSheet(Spreadsheet::Sheet *sheet, const std::vector<App::Range> &range, QWidget *parent = nullptr);
~DlgBindSheet();
void accept();

View File

@@ -40,7 +40,7 @@ class DlgSettingsImp : public Gui::Dialog::PreferencePage
Q_OBJECT
public:
DlgSettingsImp( QWidget* parent = 0 );
DlgSettingsImp( QWidget* parent = nullptr );
~DlgSettingsImp();
protected:

View File

@@ -150,7 +150,7 @@ App::Property *DlgSheetConf::prepare(CellAddress &from, CellAddress &to,
}
}
}
return 0;
return nullptr;
}
void DlgSheetConf::accept()

View File

@@ -37,7 +37,7 @@ class DlgSheetConf : public QDialog
Q_OBJECT
public:
explicit DlgSheetConf(Spreadsheet::Sheet *sheet, App::Range range, QWidget *parent = 0);
explicit DlgSheetConf(Spreadsheet::Sheet *sheet, App::Range range, QWidget *parent = nullptr);
~DlgSheetConf();
void accept();

View File

@@ -33,7 +33,7 @@ class LineEdit : public Gui::ExpressionLineEdit
{
Q_OBJECT
public:
explicit LineEdit(QWidget *parent = 0);
explicit LineEdit(QWidget *parent = nullptr);
bool event(QEvent *event);

View File

@@ -52,7 +52,7 @@ PropertiesDialog::PropertiesDialog(Sheet *_sheet, const std::vector<Range> &_ran
Cell * cell = sheet->getNewCell(*range);
assert(cell != 0);
assert(cell != nullptr);
(void)cell->getForeground(foregroundColor);
(void)cell->getBackground(backgroundColor);

View File

@@ -37,7 +37,7 @@ class PropertiesDialog : public QDialog
Q_OBJECT
public:
explicit PropertiesDialog(Spreadsheet::Sheet *_sheet, const std::vector<App::Range> & _ranges, QWidget *parent = 0);
explicit PropertiesDialog(Spreadsheet::Sheet *_sheet, const std::vector<App::Range> & _ranges, QWidget *parent = nullptr);
~PropertiesDialog();
void apply();

View File

@@ -81,12 +81,12 @@ int SheetModel::columnCount(const QModelIndex &parent) const
QVariant SheetModel::data(const QModelIndex &index, int role) const
{
static const Cell * emptyCell = new Cell(CellAddress(0, 0), 0);
static const Cell * emptyCell = new Cell(CellAddress(0, 0), nullptr);
int row = index.row();
int col = index.column();
const Cell * cell = sheet->getCell(CellAddress(row, col));
if (cell == 0)
if (cell == nullptr)
cell = emptyCell;
//#define DEBUG_DEPS

View File

@@ -37,7 +37,7 @@ class SheetModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit SheetModel(Spreadsheet::Sheet * _sheet, QObject *parent = 0);
explicit SheetModel(Spreadsheet::Sheet * _sheet, QObject *parent = nullptr);
~SheetModel();
SheetModel(QObject *parent);

View File

@@ -109,7 +109,7 @@ static std::pair<int, int> selectedMinMaxColumns(QModelIndexList list)
SheetTableView::SheetTableView(QWidget *parent)
: QTableView(parent)
, sheet(0)
, sheet(nullptr)
, tabCounter(0)
{
setHorizontalHeader(new SheetViewHeader(this,Qt::Horizontal));
@@ -276,7 +276,7 @@ std::vector<Range> SheetTableView::selectedRanges() const
void SheetTableView::insertRows()
{
assert(sheet != 0);
assert(sheet != nullptr);
QModelIndexList rows = selectionModel()->selectedRows();
std::vector<int> sortedRows;
@@ -313,7 +313,7 @@ void SheetTableView::insertRows()
void SheetTableView::insertRowsAfter()
{
assert(sheet != 0);
assert(sheet != nullptr);
const auto rows = selectionModel()->selectedRows();
const auto & [min, max] = selectedMinMaxRows(rows);
assert(max - min == rows.size() - 1);
@@ -327,7 +327,7 @@ void SheetTableView::insertRowsAfter()
void SheetTableView::removeRows()
{
assert(sheet != 0);
assert(sheet != nullptr);
QModelIndexList rows = selectionModel()->selectedRows();
std::vector<int> sortedRows;
@@ -348,7 +348,7 @@ void SheetTableView::removeRows()
void SheetTableView::insertColumns()
{
assert(sheet != 0);
assert(sheet != nullptr);
QModelIndexList cols = selectionModel()->selectedColumns();
std::vector<int> sortedColumns;
@@ -386,7 +386,7 @@ void SheetTableView::insertColumns()
void SheetTableView::insertColumnsAfter()
{
assert(sheet != 0);
assert(sheet != nullptr);
const auto columns = selectionModel()->selectedColumns();
const auto& [min, max] = selectedMinMaxColumns(columns);
assert(max - min == columns.size() - 1);
@@ -400,7 +400,7 @@ void SheetTableView::insertColumnsAfter()
void SheetTableView::removeColumns()
{
assert(sheet != 0);
assert(sheet != nullptr);
QModelIndexList cols = selectionModel()->selectedColumns();
std::vector<int> sortedColumns;
@@ -678,7 +678,7 @@ void SheetTableView::pasteClipboard()
}else{
QByteArray res = mimeData->data(_SheetMime);
Base::ByteArrayIStreambuf buf(res);
std::istream in(0);
std::istream in(nullptr);
in.rdbuf(&buf);
Base::XMLReader reader("<memory>", in);
sheet->getCells()->pasteCells(reader,range);

View File

@@ -52,7 +52,7 @@ class SheetTableView : public QTableView
{
Q_OBJECT
public:
explicit SheetTableView(QWidget *parent = 0);
explicit SheetTableView(QWidget *parent = nullptr);
~SheetTableView();
void edit(const QModelIndex &index);

View File

@@ -56,7 +56,7 @@ QWidget *SpreadsheetDelegate::createEditor(QWidget *parent,
App::Range range(addr,addr);
if(sheet && sheet->getCellBinding(range)) {
FC_ERR("Bound cell " << addr.toString() << " cannot be edited");
return 0;
return nullptr;
}
SpreadsheetGui::LineEdit *editor = new SpreadsheetGui::LineEdit(parent);

View File

@@ -37,7 +37,7 @@ class SpreadsheetDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit SpreadsheetDelegate(Spreadsheet::Sheet * sheet, QWidget *parent = 0);
explicit SpreadsheetDelegate(Spreadsheet::Sheet * sheet, QWidget *parent = nullptr);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;

View File

@@ -153,7 +153,7 @@ void ViewProviderSheet::beforeDelete()
if(!view)
return;
if(view==Gui::getMainWindow()->activeWindow())
getDocument()->setActiveView(0,Gui::View3DInventor::getClassTypeId());
getDocument()->setActiveView(nullptr,Gui::View3DInventor::getClassTypeId());
Gui::getMainWindow()->removeWindow(view);
}

View File

@@ -171,7 +171,7 @@ class ColorPickerItem : public QFrame
public:
ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(),
QWidget *parent = 0);
QWidget *parent = nullptr);
~ColorPickerItem();
QColor color() const;
@@ -207,7 +207,7 @@ class ColorPickerPopup : public QFrame
public:
ColorPickerPopup(int width, bool withColorDialog,
QWidget *parent = 0);
QWidget *parent = nullptr);
~ColorPickerPopup();
void insertColor(const QColor &col, const QString &text, int index);
@@ -271,7 +271,7 @@ private:
*/
QtColorPicker::QtColorPicker(QWidget *parent,
int cols, bool enableColorDialog)
: QPushButton(parent), popup(0), withColorDialog(enableColorDialog)
: QPushButton(parent), popup(nullptr), withColorDialog(enableColorDialog)
{
setFocusPolicy(Qt::StrongFocus);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
@@ -562,11 +562,11 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
moreButton->setFrameRect(QRect(2, 2, 20, 17));
connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
} else {
moreButton = 0;
moreButton = nullptr;
}
eventLoop = 0;
grid = 0;
eventLoop = nullptr;
grid = nullptr;
regenerateGrid();
}
@@ -593,7 +593,7 @@ ColorPickerItem *ColorPickerPopup::find(const QColor &col) const
return items.at(i);
}
return 0;
return nullptr;
}
/*! \internal
@@ -659,7 +659,7 @@ void ColorPickerPopup::exec()
QEventLoop e;
eventLoop = &e;
(void) e.exec();
eventLoop = 0;
eventLoop = nullptr;
}
/*! \internal
@@ -669,7 +669,7 @@ void ColorPickerPopup::updateSelected()
{
QLayoutItem *layoutItem;
int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) {
while ((layoutItem = grid->itemAt(i)) != nullptr) {
QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem = reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
@@ -755,7 +755,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
QLayoutItem *layoutItem;
int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) {
while ((layoutItem = grid->itemAt(i)) != nullptr) {
QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem
@@ -775,7 +775,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
QLayoutItem *layoutItem;
int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) {
while ((layoutItem = grid->itemAt(i)) != nullptr) {
QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem
@@ -904,9 +904,9 @@ void ColorPickerPopup::getColorFromDialog()
//QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget());
QColor col;
if (Gui::DialogOptions::dontUseNativeColorDialog()){
col = QColorDialog::getColor(lastSel, parentWidget(), 0, QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
col = QColorDialog::getColor(lastSel, parentWidget(), nullptr, QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
} else {
col = QColorDialog::getColor(lastSel, parentWidget(), 0, QColorDialog::ShowAlphaChannel);
col = QColorDialog::getColor(lastSel, parentWidget(), nullptr, QColorDialog::ShowAlphaChannel);
}
if (!col.isValid())
return;

View File

@@ -79,7 +79,7 @@ class QT_QTCOLORPICKER_EXPORT QtColorPicker : public QPushButton
Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled)
public:
QtColorPicker(QWidget *parent = 0,
QtColorPicker(QWidget *parent = nullptr,
int columns = -1, bool enableColorDialog = true);
~QtColorPicker();