Spreadsheet: fix header uniformity

+ trailing whitespace
This commit is contained in:
luzpaz
2023-01-21 18:55:54 +00:00
committed by Uwe
parent 2226d3a01b
commit d8146c1db8
15 changed files with 65 additions and 65 deletions

View File

@@ -196,7 +196,7 @@ void Cell::setExpression(App::ExpressionPtr &&expr)
}catch(Base::Exception &e) {
e.ReportException();
FC_ERR("Failed to restore style of cell "
<< owner->sheet()->getFullName() << '.'
<< owner->sheet()->getFullName() << '.'
<< address.toString() << ": " << e.what());
}
}
@@ -224,7 +224,7 @@ const App::Expression *Cell::getExpression(bool withFormat) const
| STYLE_SET
| FOREGROUND_COLOR_SET
| BACKGROUND_COLOR_SET
| DISPLAY_UNIT_SET
| DISPLAY_UNIT_SET
| ALIAS_SET
| SPANS_SET)))
{
@@ -273,7 +273,7 @@ bool Cell::getStringContent(std::string & s, bool persistent) const
void Cell::afterRestore() {
auto expr = freecad_dynamic_cast<StringExpression>(expression.get());
if(expr)
if(expr)
setContent(expr->getText().c_str());
}
@@ -638,7 +638,7 @@ bool Cell::getSpans(int &rows, int &columns) const
void Cell::setException(const std::string &e, bool silent)
{
if(!silent && !e.empty() && owner && owner->sheet()) {
FC_ERR(owner->sheet()->getFullName() << '.'
FC_ERR(owner->sheet()->getFullName() << '.'
<< address.toString() << ": " << e);
}
exceptionStr = e;
@@ -648,7 +648,7 @@ void Cell::setException(const std::string &e, bool silent)
void Cell::setParseException(const std::string &e)
{
if(!e.empty() && owner && owner->sheet()) {
FC_ERR(owner->sheet()->getFullName() << '.'
FC_ERR(owner->sheet()->getFullName() << '.'
<< address.toString() << ": " << e);
}
exceptionStr = e;
@@ -658,7 +658,7 @@ void Cell::setParseException(const std::string &e)
void Cell::setResolveException(const std::string &e)
{
if(!e.empty() && owner && owner->sheet()) {
FC_LOG(owner->sheet()->getFullName() << '.'
FC_LOG(owner->sheet()->getFullName() << '.'
<< address.toString() << ": " << e);
}
exceptionStr = e;

View File

@@ -38,7 +38,7 @@ std::string PropertyColumnWidthsPy::representation() const
PyObject *PropertyColumnWidthsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// create a new instance of PropertyColumnWidthsPy and the Twin object
// create a new instance of PropertyColumnWidthsPy and the Twin object
return new PropertyColumnWidthsPy(new PropertyColumnWidths);
}
@@ -55,5 +55,5 @@ PyObject *PropertyColumnWidthsPy::getCustomAttributes(const char* /*attr*/) cons
int PropertyColumnWidthsPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -38,7 +38,7 @@ std::string PropertyRowHeightsPy::representation(void) const
PyObject *PropertyRowHeightsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// create a new instance of PropertyRowHeightsPy and the Twin object
// create a new instance of PropertyRowHeightsPy and the Twin object
return new PropertyRowHeightsPy(new PropertyRowHeights);
}
@@ -55,5 +55,5 @@ PyObject *PropertyRowHeightsPy::getCustomAttributes(const char* /*attr*/) const
int PropertyRowHeightsPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -155,7 +155,7 @@ bool PropertySheet::isValidAlias(const std::string &candidate)
namespace
{
// A utility function that gets the range (the minimum and maximum row and column) out of a
// A utility function that gets the range (the minimum and maximum row and column) out of a
// vector of cell addresses. Note that it's possible that neither cell in the tuple itself
// has data in it, but operating on all cells in the inclusive range specified by the tuple
// is guaranteed to include all cells in the passed-in vector, and no cells exist to the
@@ -851,7 +851,7 @@ void PropertySheet::insertRows(int row, int count)
/* Sort them */
std::sort(keys.begin(), keys.end(), boost::bind(&PropertySheet::rowSortFunc, this, bp::_1, bp::_2));
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
CellAddress(row, CellAddress::MAX_COLUMNS), count, 0);
AtomicPropertyChange signaller(*this);
@@ -921,7 +921,7 @@ void PropertySheet::removeRows(int row, int count)
/* Sort them */
std::sort(keys.begin(), keys.end(), boost::bind(&PropertySheet::rowSortFunc, this, bp::_1, bp::_2));
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
CellAddress(row + count - 1, CellAddress::MAX_COLUMNS), -count, 0);
AtomicPropertyChange signaller(*this);
@@ -979,7 +979,7 @@ void PropertySheet::insertColumns(int col, int count)
/* Sort them */
std::sort(keys.begin(), keys.end());
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
CellAddress(CellAddress::MAX_ROWS, col), 0, count);
AtomicPropertyChange signaller(*this);
@@ -1049,7 +1049,7 @@ void PropertySheet::removeColumns(int col, int count)
/* Sort them */
std::sort(keys.begin(), keys.end(), boost::bind(&PropertySheet::colSortFunc, this, bp::_1, bp::_2));
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
MoveCellsExpressionVisitor<PropertySheet> visitor(*this,
CellAddress(CellAddress::MAX_ROWS, col + count - 1), 0, -count);
AtomicPropertyChange signaller(*this);
@@ -1448,7 +1448,7 @@ void PropertySheet::renamedDocumentObject(const App::DocumentObject * docObj)
void PropertySheet::onRelabeledDocument(const App::Document &doc)
{
RelabelDocumentExpressionVisitor v(doc);
for(auto &c : data)
for(auto &c : data)
c.second->visit(v);
}
@@ -1520,10 +1520,10 @@ void PropertySheet::recomputeDependencies(CellAddress key)
void PropertySheet::hasSetValue()
{
if(updateCount == 0 ||
if(updateCount == 0 ||
!owner || !owner->getNameInDocument() || owner->isRestoring() ||
this!=&owner->cells ||
testFlag(LinkDetached))
testFlag(LinkDetached))
{
PropertyExpressionContainer::hasSetValue();
return;
@@ -1671,7 +1671,7 @@ bool PropertySheet::adjustLink(const std::set<DocumentObject*> &inList) {
return changed;
}
void PropertySheet::updateElementReference(DocumentObject *feature,bool reverse,bool notify)
void PropertySheet::updateElementReference(DocumentObject *feature,bool reverse,bool notify)
{
(void)notify;
if(!feature)
@@ -1695,7 +1695,7 @@ bool PropertySheet::referenceChanged() const {
}
Property *PropertySheet::CopyOnImportExternal(
const std::map<std::string,std::string> &nameMap) const
const std::map<std::string,std::string> &nameMap) const
{
std::map<CellAddress,std::unique_ptr<Expression> > changed;
for(auto &d : data) {
@@ -1709,12 +1709,12 @@ Property *PropertySheet::CopyOnImportExternal(
if(changed.empty())
return nullptr;
std::unique_ptr<PropertySheet> copy(new PropertySheet(*this));
for(auto &change : changed)
for(auto &change : changed)
copy->data[change.first]->setExpression(std::move(change.second));
return copy.release();
}
Property *PropertySheet::CopyOnLabelChange(App::DocumentObject *obj,
Property *PropertySheet::CopyOnLabelChange(App::DocumentObject *obj,
const std::string &ref, const char *newLabel) const
{
std::map<CellAddress,std::unique_ptr<Expression> > changed;
@@ -1729,12 +1729,12 @@ Property *PropertySheet::CopyOnLabelChange(App::DocumentObject *obj,
if(changed.empty())
return nullptr;
std::unique_ptr<PropertySheet> copy(new PropertySheet(*this));
for(auto &change : changed)
for(auto &change : changed)
copy->data[change.first]->setExpression(std::move(change.second));
return copy.release();
}
Property *PropertySheet::CopyOnLinkReplace(const App::DocumentObject *parent,
Property *PropertySheet::CopyOnLinkReplace(const App::DocumentObject *parent,
App::DocumentObject *oldObj, App::DocumentObject *newObj) const
{
std::map<CellAddress,std::unique_ptr<Expression> > changed;
@@ -1749,7 +1749,7 @@ Property *PropertySheet::CopyOnLinkReplace(const App::DocumentObject *parent,
if(changed.empty())
return nullptr;
std::unique_ptr<PropertySheet> copy(new PropertySheet(*this));
for(auto &change : changed)
for(auto &change : changed)
copy->data[change.first]->setExpression(std::move(change.second));
return copy.release();
}
@@ -1765,7 +1765,7 @@ std::map<App::ObjectIdentifier, const App::Expression*> PropertySheet::getExpres
}
void PropertySheet::setExpressions(
std::map<App::ObjectIdentifier, App::ExpressionPtr> &&exprs)
std::map<App::ObjectIdentifier, App::ExpressionPtr> &&exprs)
{
AtomicPropertyChange signaller(*this);
for(auto &v : exprs) {
@@ -1798,7 +1798,7 @@ App::Range PropertySheet::getRange(const char *range, bool silent) const {
assert(range);
const char *sep = strchr(range,':');
CellAddress from,to;
if(!sep)
if(!sep)
from = to = getCellAddress(range,silent);
else {
std::string addr(range,sep);
@@ -1813,7 +1813,7 @@ App::Range PropertySheet::getRange(const char *range, bool silent) const {
for(;;) {
caddr.setRow(caddr.row()+r);
caddr.setCol(caddr.col()+c);
if(!caddr.isValid() || !getValue(caddr))
if(!caddr.isValid() || !getValue(caddr))
break;
}
caddr.setRow(caddr.row()-r);
@@ -1830,7 +1830,7 @@ App::Range PropertySheet::getRange(const char *range, bool silent) const {
if(addr == "-" || addr == "|")
return Range(from, findCell(from,1,1));
to = getCellAddress(addr.c_str(),silent);
}
}
}
if(!from.isValid() || !to.isValid())
@@ -1842,7 +1842,7 @@ bool PropertySheet::isBindingPath(const ObjectIdentifier &path,
CellAddress *from, CellAddress *to, bool *href) const
{
const auto &comps = path.getComponents();
if (comps.size()!=4
if (comps.size()!=4
|| !comps[2].isSimple()
|| !comps[3].isSimple()
|| (comps[1].getName()!="Bind"
@@ -1882,7 +1882,7 @@ PropertySheet::getBinding(const Range &range,
if(href) {
if((expr->getFunction()!=FunctionExpression::HIDDENREF
&& expr->getFunction()!=FunctionExpression::HREF)
|| expr->getArgs().size()!=1
|| expr->getArgs().size()!=1
|| !expr->getArgs().front()->isDerivedFrom(FunctionExpression::getClassTypeId()))
continue;
expr = static_cast<FunctionExpression*>(expr->getArgs().front());
@@ -1921,7 +1921,7 @@ void PropertySheet::setPathValue(const ObjectIdentifier &path, const boost::any
if(pyValue.isSequence()) {
Py::Sequence seq(pyValue);
if(seq.size()==3
if(seq.size()==3
&& PyObject_TypeCheck(seq[0].ptr(),&PropertySheetPy::Type)
&& Py::Object(seq[1].ptr()).isString()
&& Py::Object(seq[2].ptr()).isString())

View File

@@ -38,7 +38,7 @@ std::string PropertySheetPy::representation(void) const
PyObject *PropertySheetPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// create a new instance of PropertySheetPy and the Twin object
// create a new instance of PropertySheetPy and the Twin object
return new PropertySheetPy(new PropertySheet);
}
@@ -60,5 +60,5 @@ PyObject *PropertySheetPy::getCustomAttributes(const char* /*attr*/) const
int PropertySheetPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

View File

@@ -152,7 +152,7 @@ void DlgBindSheet::accept()
if(!doc)
FC_THROWM(Base::RuntimeError, "Cannot find document " << docname);
obj = Base::freecad_dynamic_cast<Sheet>(doc->getObject(sep+1));
} else
} else
obj = Base::freecad_dynamic_cast<Sheet>(sheet->getDocument()->getObject(ref));
if(!obj)
FC_THROWM(Base::RuntimeError, "Cannot find Spreadsheet '" << ref << "'");
@@ -180,13 +180,13 @@ void DlgBindSheet::accept()
checkAddress(fromEnd, fromCellEnd, false);
std::string toStart(ui->lineEditToStart->text().trimmed().toLatin1().constData());
if(boost::starts_with(toStart,"="))
if(boost::starts_with(toStart,"="))
toStart.erase(toStart.begin());
else
checkAddress(toStart, toCellStart, true);
std::string toEnd(ui->lineEditToEnd->text().trimmed().toLatin1().constData());
if(boost::starts_with(toEnd,"="))
if(boost::starts_with(toEnd,"="))
toEnd.erase(toEnd.begin());
else {
checkAddress(toEnd, toCellEnd, true);

View File

@@ -109,12 +109,12 @@ App::Property *DlgSheetConf::prepare(CellAddress &from, CellAddress &to,
e.ReportException();
FC_THROWM(Base::RuntimeError, "Failed to parse expression for property");
}
if(expr->hasComponent() || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId()))
if(expr->hasComponent() || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId()))
FC_THROWM(Base::RuntimeError, "Invalid property expression: " << expr->toString());
path = static_cast<App::VariableExpression*>(expr.get())->getPath();
auto obj = path.getDocumentObject();
if(!obj)
if(!obj)
FC_THROWM(Base::RuntimeError, "Invalid object referenced in: " << expr->toString());
int pseudoType;
@@ -182,7 +182,7 @@ void DlgSheetConf::accept()
std::string exprTxt(ui->lineEditProp->text().trimmed().toUtf8().constData());
App::ExpressionPtr expr(App::Expression::parse(sheet,exprTxt));
if(expr->hasComponent() || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId()))
if(expr->hasComponent() || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId()))
FC_THROWM(Base::RuntimeError, "Invalid property expression: " << expr->toString());
AutoTransaction guard("Setup conf table");

View File

@@ -35,11 +35,11 @@ namespace SpreadsheetGui {
class DlgSheetConf : public QDialog
{
Q_OBJECT
public:
explicit DlgSheetConf(Spreadsheet::Sheet *sheet, App::Range range, QWidget *parent = nullptr);
~DlgSheetConf() override;
void accept() override;
App::Property *prepare(App::CellAddress &from, App::CellAddress &to,

View File

@@ -76,7 +76,7 @@ bool LineEdit::event(QEvent *event)
else if (event && event->type() == QEvent::KeyPress && !completerActive()) {
QKeyEvent * kevent = static_cast<QKeyEvent*>(event);
lastKeyPressed = kevent->key();
lastModifiers = kevent->modifiers();
lastModifiers = kevent->modifiers();
}
return Gui::ExpressionLineEdit::event(event);
}

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -35,11 +35,11 @@ namespace SpreadsheetGui {
class PropertiesDialog : public QDialog
{
Q_OBJECT
public:
explicit PropertiesDialog(Spreadsheet::Sheet *_sheet, const std::vector<App::Range> & _ranges, QWidget *parent = nullptr);
~PropertiesDialog() override;
void apply();
void selectAlias();

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -40,7 +40,7 @@ class SheetModel : public QAbstractTableModel
public:
explicit SheetModel(Spreadsheet::Sheet * _sheet, QObject *parent = nullptr);
~SheetModel() override;
explicit SheetModel(QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -127,7 +127,7 @@ SheetTableView::SheetTableView(QWidget *parent)
The number refers to how many lines are selected and will be inserted. */
auto insertBefore = menu.addAction(tr("Insert %n row(s) above", "", selection.size()));
connect(insertBefore, &QAction::triggered, this, &SheetTableView::insertRows);
if (max < model()->rowCount() - 1) {
auto insertAfter = menu.addAction(tr("Insert %n row(s) below", "", selection.size()));
connect(insertAfter, &QAction::triggered, this, &SheetTableView::insertRowsAfter);
@@ -165,10 +165,10 @@ SheetTableView::SheetTableView(QWidget *parent)
connect(remove, &QAction::triggered, this, &SheetTableView::removeColumns);
menu.exec(horizontalHeader()->mapToGlobal(point));
});
actionProperties = new QAction(tr("Properties..."), this);
addAction(actionProperties);
horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
verticalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -814,7 +814,7 @@ void SheetTableView::finishEditWithMove(int keyPressed, Qt::KeyboardModifiers mo
case Qt::Key_Home:
// Home: row 1, same column
// Ctrl-Home: row 1, column 1
// Ctrl-Home: row 1, column 1
targetRow = 0;
if (modifiers == Qt::ControlModifier)
targetColumn = 0;
@@ -931,7 +931,7 @@ void SheetTableView::finishEditWithMove(int keyPressed, Qt::KeyboardModifiers mo
// With shift down, this motion becomes a block selection command, rather than just simple motion:
ModifyBlockSelection(targetRow, targetColumn);
}
}
void SheetTableView::ModifyBlockSelection(int targetRow, int targetCol)
@@ -989,7 +989,7 @@ void SheetTableView::splitCell() {
}
void SheetTableView::closeEditor(QWidget * editor, QAbstractItemDelegate::EndEditHint hint)
{
{
QTableView::closeEditor(editor, hint);
}

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 *
* Copyright (c) 2015 Eivind Kvedalen <eivind@kvedalen.name> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -35,8 +35,8 @@ namespace SpreadsheetGui {
class SheetViewHeader : public QHeaderView {
Q_OBJECT
public:
SheetViewHeader(QTableView *owner, Qt::Orientation o)
: QHeaderView(o),owner(owner)
SheetViewHeader(QTableView *owner, Qt::Orientation o)
: QHeaderView(o),owner(owner)
{
setSectionsClickable(true);
}
@@ -55,7 +55,7 @@ class SheetTableView : public QTableView
public:
explicit SheetTableView(QWidget *parent = nullptr);
~SheetTableView() override;
void edit(const QModelIndex &index);
void setSheet(Spreadsheet::Sheet *_sheet);
std::vector<App::Range> selectedRanges() const;

View File

@@ -112,13 +112,13 @@ static inline void drawBorder(QPainter *painter, const QStyleOptionViewItem &opt
painter->drawRect(rect.adjusted(0,0,-1,-1));
return;
}
if(flags & Sheet::BorderLeft)
if(flags & Sheet::BorderLeft)
painter->drawLine(rect.topLeft(), rect.bottomLeft());
if(flags & Sheet::BorderTop)
if(flags & Sheet::BorderTop)
painter->drawLine(rect.topLeft(), rect.topRight());
if(flags & Sheet::BorderRight)
if(flags & Sheet::BorderRight)
painter->drawLine(rect.topRight(), rect.bottomRight());
if(flags & Sheet::BorderBottom)
if(flags & Sheet::BorderBottom)
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
}

View File

@@ -1369,7 +1369,7 @@ class SpreadsheetCases(unittest.TestCase):
sheet.set(cell,str(i))
used_range = sheet.getUsedRange()
self.assertEquals(used_range,("C3","Z20"))
for i,cell in enumerate(test_cells):
sheet.set(cell,"")
sheet.setAlignment(cell,"center")
@@ -1400,7 +1400,7 @@ class SpreadsheetCases(unittest.TestCase):
sheet.set(cell,str(i))
non_empty_range = sheet.getNonEmptyRange()
self.assertEquals(non_empty_range,("C3","Z20"))
for i,cell in enumerate(test_cells):
sheet.set(cell,"")
sheet.setAlignment(cell,"center")