diff --git a/src/Mod/Spreadsheet/Gui/DlgSettings.ui b/src/Mod/Spreadsheet/Gui/DlgSettings.ui index 061f302aef..710fcc1c19 100644 --- a/src/Mod/Spreadsheet/Gui/DlgSettings.ui +++ b/src/Mod/Spreadsheet/Gui/DlgSettings.ui @@ -20,6 +20,64 @@ Spreadsheet + + + + Display Settings + + + + + + If checked, use the custom presentation to display cell string. + + + Show alias in cell with format + + + showAliasName + + + Mod/Spreadsheet + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + %V = %A + + + The format of the custom cell string presentation. +Defaults to: %V = %A + +%A - alias name +%V - cell value + + + DisplayAliasFormatString + + + Mod/Spreadsheet + + + + + + @@ -150,7 +208,7 @@ - + Qt::Vertical @@ -177,6 +235,11 @@ QLineEdit
Gui/PrefWidgets.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
diff --git a/src/Mod/Spreadsheet/Gui/DlgSettingsImp.cpp b/src/Mod/Spreadsheet/Gui/DlgSettingsImp.cpp index ff8908dcc4..1e15ce0184 100644 --- a/src/Mod/Spreadsheet/Gui/DlgSettingsImp.cpp +++ b/src/Mod/Spreadsheet/Gui/DlgSettingsImp.cpp @@ -59,6 +59,8 @@ void DlgSettingsImp::saveSettings() hGrp->SetASCII("ImportExportDelimiter", delimiter.toStdString().c_str()); ui->quoteCharLineEdit->onSave(); ui->escapeCharLineEdit->onSave(); + ui->formatString->onSave(); + ui->checkBoxShowAlias->onSave(); } void DlgSettingsImp::loadSettings() @@ -89,6 +91,8 @@ void DlgSettingsImp::loadSettings() ui->quoteCharLineEdit->onRestore(); ui->escapeCharLineEdit->onRestore(); + ui->formatString->onRestore(); + ui->checkBoxShowAlias->onRestore(); } /** diff --git a/src/Mod/Spreadsheet/Gui/SheetModel.cpp b/src/Mod/Spreadsheet/Gui/SheetModel.cpp index ce358e202b..70ff2ea0cd 100644 --- a/src/Mod/Spreadsheet/Gui/SheetModel.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetModel.cpp @@ -23,8 +23,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -43,18 +43,22 @@ using namespace Spreadsheet; using namespace App; namespace bp = boost::placeholders; -SheetModel::SheetModel(Sheet *_sheet, QObject *parent) - : QAbstractTableModel(parent) - , sheet(_sheet) +SheetModel::SheetModel(Sheet* _sheet, QObject* parent) : QAbstractTableModel(parent), sheet(_sheet) { - cellUpdatedConnection = sheet->cellUpdated.connect(bind(&SheetModel::cellUpdated, this, bp::_1)); - rangeUpdatedConnection = sheet->rangeUpdated.connect(bind(&SheetModel::rangeUpdated, this, bp::_1)); + cellUpdatedConnection = + sheet->cellUpdated.connect(bind(&SheetModel::cellUpdated, this, bp::_1)); + rangeUpdatedConnection = + sheet->rangeUpdated.connect(bind(&SheetModel::rangeUpdated, this, bp::_1)); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Spreadsheet"); - aliasBgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e"))); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Spreadsheet"); + aliasBgColor = + QColor(Base::Tools::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e"))); textFgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("TextColor", "#000000"))); - positiveFgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("PositiveNumberColor", "#000000"))); - negativeFgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("NegativeNumberColor", "#000000"))); + positiveFgColor = + QColor(Base::Tools::fromStdString(hGrp->GetASCII("PositiveNumberColor", "#000000"))); + negativeFgColor = + QColor(Base::Tools::fromStdString(hGrp->GetASCII("NegativeNumberColor", "#000000"))); } SheetModel::~SheetModel() @@ -63,25 +67,44 @@ SheetModel::~SheetModel() rangeUpdatedConnection.disconnect(); } -int SheetModel::rowCount(const QModelIndex &parent) const +int SheetModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return 16384; } -int SheetModel::columnCount(const QModelIndex &parent) const +int SheetModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); return 26 * 26 + 26; } - -QVariant SheetModel::data(const QModelIndex &index, int role) const +namespace { - static const Cell * emptyCell = new Cell(CellAddress(0, 0), nullptr); +QVariant formatCellDisplay(QString value, const Cell* cell) +{ + std::string alias; + static auto hGrpSpreadsheet = + App::GetApplication().GetUserParameter().GetGroup("BaseApp/Preferences/Mod/Spreadsheet"); + if (cell->getAlias(alias) && hGrpSpreadsheet->GetBool("showAliasName", false)) { + QString formatStr = QString::fromStdString( + hGrpSpreadsheet->GetASCII("DisplayAliasFormatString", "%V = %A")); + if (formatStr.contains(QLatin1String("%V")) || formatStr.contains(QLatin1String("%A"))) { + formatStr.replace(QLatin1String("%A"), QString::fromStdString(alias)); + formatStr.replace(QLatin1String("%V"), value); + return QVariant(formatStr); + } + } + return QVariant(value); +} +}// namespace + +QVariant SheetModel::data(const QModelIndex& index, int role) const +{ + 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)); + const Cell* cell = sheet->getCell(CellAddress(row, col)); if (!cell) cell = emptyCell; @@ -104,7 +127,8 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const } if (provides.size() > 0) { v += QString::fromUtf8("Used by:"); - for (std::set::const_iterator i = provides.begin(); i != provides.end(); ++i) + for (std::set::const_iterator i = provides.begin(); i != provides.end(); + ++i) v += QString::fromUtf8("\n\t") + Tools::fromStdString(*i); v += QString::fromUtf8("\n"); } @@ -120,26 +144,27 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const if (cell->hasException()) { switch (role) { - case Qt::ToolTipRole: { - QString txt(Base::Tools::fromStdString(cell->getException()).toHtmlEscaped()); - return QVariant(QString::fromLatin1("
%1
").arg(txt)); - } - case Qt::DisplayRole: { + case Qt::ToolTipRole: { + QString txt(Base::Tools::fromStdString(cell->getException()).toHtmlEscaped()); + return QVariant(QString::fromLatin1("
%1
").arg(txt)); + } + case Qt::DisplayRole: { #ifdef DEBUG_DEPS - return QVariant::fromValue(QString::fromUtf8("#ERR: %1").arg(Tools::fromStdString(cell->getException()))); + return QVariant::fromValue( + QString::fromUtf8("#ERR: %1").arg(Tools::fromStdString(cell->getException()))); #else - std::string str; - if(cell->getStringContent(str)) - return QVariant::fromValue(QString::fromUtf8(str.c_str())); - return QVariant::fromValue(QString::fromUtf8("#ERR")); + std::string str; + if (cell->getStringContent(str)) + return QVariant::fromValue(QString::fromUtf8(str.c_str())); + return QVariant::fromValue(QString::fromUtf8("#ERR")); #endif - } - case Qt::ForegroundRole: - return QVariant::fromValue(QColor(255.0, 0, 0)); - case Qt::TextAlignmentRole: - return QVariant(Qt::AlignVCenter | Qt::AlignLeft); - default: - break; + } + case Qt::ForegroundRole: + return QVariant::fromValue(QColor(255.0, 0, 0)); + case Qt::TextAlignmentRole: + return QVariant(Qt::AlignVCenter | Qt::AlignLeft); + default: + break; } } @@ -155,13 +180,14 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const // Get display value as computed property std::string address = CellAddress(row, col).toString(); - Property * prop = sheet->getPropertyByName(address.c_str()); + Property* prop = sheet->getPropertyByName(address.c_str()); if (role == Qt::BackgroundRole) { Color color; if (cell->getBackground(color)) - return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); + return QVariant::fromValue( + QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); else { std::string alias; if (cell->getAlias(alias)) { @@ -207,134 +233,140 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const } auto dirtyCells = sheet->getCells()->getDirty(); - auto dirty = (dirtyCells.find(CellAddress(row,col)) != dirtyCells.end()); + auto dirty = (dirtyCells.find(CellAddress(row, col)) != dirtyCells.end()); if (!prop || dirty) { switch (role) { - case Qt::ForegroundRole: { - return QColor(0, 0, 255.0); // TODO: Remove this hardcoded color, replace with preference - } - case Qt::TextAlignmentRole: { - qtAlignment = Qt::AlignHCenter | Qt::AlignVCenter; - return QVariant::fromValue(qtAlignment); - } - case Qt::DisplayRole: - if(cell->getExpression()) { - std::string str; - if (cell->getStringContent(str)) - if (!str.empty() && str[0] == '=') - // If this is a real computed value, indicate that a recompute is - // needed before we can display it - return QVariant(QLatin1String("#PENDING")); + case Qt::ForegroundRole: { + return QColor(0, 0, + 255.0);// TODO: Remove this hardcoded color, replace with preference + } + case Qt::TextAlignmentRole: { + qtAlignment = Qt::AlignHCenter | Qt::AlignVCenter; + return QVariant::fromValue(qtAlignment); + } + case Qt::DisplayRole: + if (cell->getExpression()) { + std::string str; + if (cell->getStringContent(str)) + if (!str.empty() && str[0] == '=') + // If this is a real computed value, indicate that a recompute is + // needed before we can display it + return QVariant(QLatin1String("#PENDING")); + else + // If it's just a simple value, display the new value, but still + // format it as a pending value to indicate to the user that + // a recompute is needed + return QVariant(QString::fromUtf8(str.c_str())); else - // If it's just a simple value, display the new value, but still - // format it as a pending value to indicate to the user that - // a recompute is needed - return QVariant(QString::fromUtf8(str.c_str())); + return QVariant(); + } else return QVariant(); - } - else + default: return QVariant(); - default: - return QVariant(); } - } else if (prop->isDerivedFrom(App::PropertyString::getClassTypeId())) { + } + else if (prop->isDerivedFrom(App::PropertyString::getClassTypeId())) { /* String */ - const App::PropertyString * stringProp = static_cast(prop); + const App::PropertyString* stringProp = static_cast(prop); switch (role) { - case Qt::ForegroundRole: { - Color color; + case Qt::ForegroundRole: { + Color color; - if (cell->getForeground(color)) - return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); - else - return QVariant(QColor(textFgColor)); - } - case Qt::DisplayRole: - return QVariant(QString::fromUtf8(stringProp->getValue())); - case Qt::TextAlignmentRole: { - if (alignment & Cell::ALIGNMENT_HIMPLIED) { - qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); - qtAlignment |= Qt::AlignLeft; + if (cell->getForeground(color)) + return QVariant::fromValue( + QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); + else + return QVariant(QColor(textFgColor)); } - if (alignment & Cell::ALIGNMENT_VIMPLIED) { - qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); - qtAlignment |= Qt::AlignVCenter; + case Qt::DisplayRole: { + QString v = QString::fromUtf8(stringProp->getValue()); + return formatCellDisplay(v, cell); } - return QVariant::fromValue(qtAlignment); - } - default: - return QVariant(); + case Qt::TextAlignmentRole: { + if (alignment & Cell::ALIGNMENT_HIMPLIED) { + qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); + qtAlignment |= Qt::AlignLeft; + } + if (alignment & Cell::ALIGNMENT_VIMPLIED) { + qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); + qtAlignment |= Qt::AlignVCenter; + } + return QVariant::fromValue(qtAlignment); + } + default: + return QVariant(); } } else if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) { /* Number */ - const App::PropertyQuantity * floatProp = static_cast(prop); + const App::PropertyQuantity* floatProp = static_cast(prop); switch (role) { - case Qt::ForegroundRole: { - Color color; + case Qt::ForegroundRole: { + Color color; - if (cell->getForeground(color)) - return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); - else { - if (floatProp->getValue() < 0) - return QVariant::fromValue(QColor(negativeFgColor)); - else - return QVariant::fromValue(QColor(positiveFgColor)); + if (cell->getForeground(color)) + return QVariant::fromValue( + QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); + else { + if (floatProp->getValue() < 0) + return QVariant::fromValue(QColor(negativeFgColor)); + else + return QVariant::fromValue(QColor(positiveFgColor)); + } } - } - case Qt::TextAlignmentRole: { - if (alignment & Cell::ALIGNMENT_HIMPLIED) { - qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); - qtAlignment |= Qt::AlignRight; + case Qt::TextAlignmentRole: { + if (alignment & Cell::ALIGNMENT_HIMPLIED) { + qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); + qtAlignment |= Qt::AlignRight; + } + if (alignment & Cell::ALIGNMENT_VIMPLIED) { + qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); + qtAlignment |= Qt::AlignVCenter; + } + return QVariant::fromValue(qtAlignment); } - if (alignment & Cell::ALIGNMENT_VIMPLIED) { - qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); - qtAlignment |= Qt::AlignVCenter; - } - return QVariant::fromValue(qtAlignment); - } - case Qt::DisplayRole: { - QString v; - const Base::Unit & computedUnit = floatProp->getUnit(); - DisplayUnit displayUnit; + case Qt::DisplayRole: { + QString v; + const Base::Unit& computedUnit = floatProp->getUnit(); + DisplayUnit displayUnit; - // Display locale specific decimal separator (#0003875,#0003876) - if (cell->getDisplayUnit(displayUnit)) { - if (computedUnit.isEmpty() || computedUnit == displayUnit.unit) { - QString number = QLocale().toString(floatProp->getValue() / displayUnit.scaler,'f',Base::UnitsApi::getDecimals()); - //QString number = QString::number(floatProp->getValue() / displayUnit.scaler); - v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); + // Display locale specific decimal separator (#0003875,#0003876) + if (cell->getDisplayUnit(displayUnit)) { + if (computedUnit.isEmpty() || computedUnit == displayUnit.unit) { + QString number = + QLocale().toString(floatProp->getValue() / displayUnit.scaler, 'f', + Base::UnitsApi::getDecimals()); + //QString number = QString::number(floatProp->getValue() / displayUnit.scaler); + v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); + } + else { + v = QString::fromUtf8("#ERR: unit"); + } } else { - v = QString::fromUtf8("#ERR: unit"); + + // When displaying a quantity then use the globally set scheme + // See: https://forum.freecadweb.org/viewtopic.php?f=3&t=50078 + Base::Quantity value = floatProp->getQuantityValue(); + v = value.getUserString(); } + return formatCellDisplay(v, cell); } - else { - - // When displaying a quantity then use the globally set scheme - // See: https://forum.freecadweb.org/viewtopic.php?f=3&t=50078 - Base::Quantity value = floatProp->getQuantityValue(); - v = value.getUserString(); - } - - return QVariant(v); - } - default: - return QVariant(); + default: + return QVariant(); } } else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) - || prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) - { + || prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) { /* Number */ double d; long l; bool isInteger = false; - if(prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) + if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) d = static_cast(prop)->getValue(); else { isInteger = true; @@ -343,92 +375,100 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const } switch (role) { - case Qt::ForegroundRole: { - Color color; + case Qt::ForegroundRole: { + Color color; - if (cell->getForeground(color)) - return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); - else { - if (d < 0) - return QVariant::fromValue(QColor(negativeFgColor)); + if (cell->getForeground(color)) + return QVariant::fromValue( + QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); + else { + if (d < 0) + return QVariant::fromValue(QColor(negativeFgColor)); + else + return QVariant::fromValue(QColor(positiveFgColor)); + } + } + case Qt::TextAlignmentRole: { + if (alignment & Cell::ALIGNMENT_HIMPLIED) { + qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); + qtAlignment |= Qt::AlignRight; + } + if (alignment & Cell::ALIGNMENT_VIMPLIED) { + qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); + qtAlignment |= Qt::AlignVCenter; + } + return QVariant::fromValue(qtAlignment); + } + case Qt::DisplayRole: { + QString v; + DisplayUnit displayUnit; + + // Display locale specific decimal separator (#0003875,#0003876) + if (cell->getDisplayUnit(displayUnit)) { + QString number = QLocale().toString(d / displayUnit.scaler, 'f', + Base::UnitsApi::getDecimals()); + //QString number = QString::number(d / displayUnit.scaler); + v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); + } + else if (!isInteger) { + v = QLocale::system().toString(d, 'f', Base::UnitsApi::getDecimals()); + //v = QString::number(d); + } else - return QVariant::fromValue(QColor(positiveFgColor)); + v = QString::number(l); + return formatCellDisplay(v, cell); } - } - case Qt::TextAlignmentRole: { - if (alignment & Cell::ALIGNMENT_HIMPLIED) { - qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); - qtAlignment |= Qt::AlignRight; - } - if (alignment & Cell::ALIGNMENT_VIMPLIED) { - qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); - qtAlignment |= Qt::AlignVCenter; - } - return QVariant::fromValue(qtAlignment); - } - case Qt::DisplayRole: { - QString v; - DisplayUnit displayUnit; - - // Display locale specific decimal separator (#0003875,#0003876) - if (cell->getDisplayUnit(displayUnit)) { - QString number = QLocale().toString(d / displayUnit.scaler,'f',Base::UnitsApi::getDecimals()); - //QString number = QString::number(d / displayUnit.scaler); - v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); - } - else if (!isInteger) { - v = QLocale::system().toString(d,'f',Base::UnitsApi::getDecimals()); - //v = QString::number(d); - } else - v = QString::number(l); - return QVariant(v); - } - default: - return QVariant(); + default: + return QVariant(); } } else if (prop->isDerivedFrom(App::PropertyPythonObject::getClassTypeId())) { auto pyProp = static_cast(prop); switch (role) { - case Qt::ForegroundRole: { - Color color; + case Qt::ForegroundRole: { + Color color; - if (cell->getForeground(color)) - return QVariant::fromValue(QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); - else - return QVariant(QColor(textFgColor)); - } - case Qt::TextAlignmentRole: { - if (alignment & Cell::ALIGNMENT_HIMPLIED) { - qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); - qtAlignment |= Qt::AlignHCenter; + if (cell->getForeground(color)) + return QVariant::fromValue( + QColor(255.0 * color.r, 255.0 * color.g, 255.0 * color.b, 255.0 * color.a)); + else + return QVariant(QColor(textFgColor)); } - if (alignment & Cell::ALIGNMENT_VIMPLIED) { - qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); - qtAlignment |= Qt::AlignVCenter; + case Qt::TextAlignmentRole: { + if (alignment & Cell::ALIGNMENT_HIMPLIED) { + qtAlignment &= ~(Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight); + qtAlignment |= Qt::AlignHCenter; + } + if (alignment & Cell::ALIGNMENT_VIMPLIED) { + qtAlignment &= ~(Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom); + qtAlignment |= Qt::AlignVCenter; + } + return QVariant::fromValue(qtAlignment); } - return QVariant::fromValue(qtAlignment); - } - case Qt::DisplayRole: { - Base::PyGILStateLocker lock; - std::string value; - try { - value = pyProp->getValue().as_string(); - } catch (Py::Exception &) { - Base::PyException e; - value = "#ERR: "; - value += e.what(); - } catch (Base::Exception &e) { - value = "#ERR: "; - value += e.what(); - } catch (...) { - value = "#ERR: unknown exception"; + case Qt::DisplayRole: { + Base::PyGILStateLocker lock; + std::string value; + try { + value = pyProp->getValue().as_string(); + } + catch (Py::Exception&) { + Base::PyException e; + value = "#ERR: "; + value += e.what(); + } + catch (Base::Exception& e) { + value = "#ERR: "; + value += e.what(); + } + catch (...) { + value = "#ERR: unknown exception"; + } + QString v = QString::fromUtf8(value.c_str()); + return formatCellDisplay(v, cell); } - return QVariant(QString::fromUtf8(value.c_str())); - } - default: - return QVariant(); + default: + return QVariant(); } } @@ -436,12 +476,14 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const } QVariant SheetModel::headerData(int section, Qt::Orientation orientation, int role) const - { +{ if (role == Qt::SizeHintRole) { if (orientation == Qt::Horizontal) - return QVariant(QSize(sheet->getColumnWidth(section), PropertyRowHeights::defaultHeight)); + return QVariant( + QSize(sheet->getColumnWidth(section), PropertyRowHeights::defaultHeight)); else - return QVariant(QSize(PropertyColumnWidths::defaultHeaderWidth, sheet->getRowHeight(section))); + return QVariant( + QSize(PropertyColumnWidths::defaultHeaderWidth, sheet->getRowHeight(section))); } if (role == Qt::DisplayRole) { if (orientation == Qt::Horizontal) { @@ -480,7 +522,7 @@ void SheetModel::setCellData(QModelIndex index, QString str) } } -bool SheetModel::setData(const QModelIndex & index, const QVariant & value, int role) +bool SheetModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (role == Qt::DisplayRole) { // Nothing to do, it will get updated by the sheet in the application logic @@ -505,9 +547,9 @@ bool SheetModel::setData(const QModelIndex & index, const QVariant & value, int return true; } -Qt::ItemFlags SheetModel::flags(const QModelIndex & /*index*/) const +Qt::ItemFlags SheetModel::flags(const QModelIndex& /*index*/) const { - return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; + return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; } void SheetModel::cellUpdated(CellAddress address) @@ -517,7 +559,7 @@ void SheetModel::cellUpdated(CellAddress address) Q_EMIT dataChanged(i, i); } -void SheetModel::rangeUpdated(const Range &range) +void SheetModel::rangeUpdated(const Range& range) { QModelIndex i = index(range.from().row(), range.from().col()); QModelIndex j = index(range.to().row(), range.to().col());