diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp index 39bc03012a..9ae16867bc 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 * + * Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015-2016 * * * * This file is part of the FreeCAD CAx development system. * * * @@ -99,6 +99,8 @@ SheetView::SheetView(Gui::Document *pcDocument, App::DocumentObject *docObj, QWi columnWidthChangedConnection = sheet->columnWidthChanged.connect(bind(&SheetView::resizeColumn, this, _1, _2)); rowHeightChangedConnection = sheet->rowHeightChanged.connect(bind(&SheetView::resizeRow, this, _1, _2)); + connect( model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(modelUpdated(const QModelIndex &, const QModelIndex &))); + QPalette palette = ui->cells->palette(); palette.setColor(QPalette::Base, QColor(255, 255, 255)); palette.setColor(QPalette::Text, QColor(0, 0, 0)); @@ -246,6 +248,16 @@ void SheetView::rowResizeFinished() newRowSizes.clear(); } +void SheetView::modelUpdated(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + const QModelIndex & current = ui->cells->currentIndex(); + + if (current < topLeft || bottomRight < current) + return; + + updateContentLine(); +} + void SheetView::columnResized(int col, int oldSize, int newSize) { newColumnSizes[col] = newSize; diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.h b/src/Mod/Spreadsheet/Gui/SpreadsheetView.h index b16741ea95..e8d5816690 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.h +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.h @@ -86,6 +86,7 @@ protected Q_SLOTS: void rowResized(int row, int oldSize, int newSize); void columnResizeFinished(); void rowResizeFinished(); + void modelUpdated(const QModelIndex & topLeft, const QModelIndex & bottomRight); protected: void updateContentLine(); void setCurrentCell(QString str);