replace tabs by 4 spaces

This commit is contained in:
Martin Marmsoler
2020-10-16 11:45:17 +02:00
committed by Martin Marmsoler
parent 752f31513c
commit 73b394527d
62 changed files with 18489 additions and 18489 deletions

View File

@@ -1,157 +1,157 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "helpercell.h"
/**
Constructor
@param parent Parent QGraphicsItem
Constructor
@param parent Parent QGraphicsItem
*/
HelperCell::HelperCell(QGraphicsItem *parent) :
QGraphicsObject(parent),
QGraphicsLayoutItem(),
background_color(Qt::white),
foreground_color(Qt::black),
label(),
orientation(Qt::Horizontal),
index(-1)
QGraphicsObject(parent),
QGraphicsLayoutItem(),
background_color(Qt::white),
foreground_color(Qt::black),
label(),
orientation(Qt::Horizontal),
index(-1)
{
setGraphicsItem(this);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setGraphicsItem(this);
setFlag(QGraphicsItem::ItemIsSelectable, false);
}
/**
Destructor
Destructor
*/
HelperCell::~HelperCell()
{
}
/**
Ensure geometry changes are handled for both QGraphicsObject and
QGraphicsLayoutItem.
@param g New geometry
Ensure geometry changes are handled for both QGraphicsObject and
QGraphicsLayoutItem.
@param g New geometry
*/
void HelperCell::setGeometry(const QRectF &g) {
prepareGeometryChange();
QGraphicsLayoutItem::setGeometry(g);
setPos(g.topLeft());
prepareGeometryChange();
QGraphicsLayoutItem::setGeometry(g);
setPos(g.topLeft());
}
/**
@param which Size hint to be modified
@param constraint New value for the size hint
@return the size hint for \a which using the width or height of \a constraint
@param which Size hint to be modified
@param constraint New value for the size hint
@return the size hint for \a which using the width or height of \a constraint
*/
QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(which);
return(constraint);
Q_UNUSED(which);
return(constraint);
}
/**
@return the bounding rect of this helper cell
@return the bounding rect of this helper cell
*/
QRectF HelperCell::boundingRect() const
{
return QRectF(QPointF(0,0), geometry().size());
return QRectF(QPointF(0,0), geometry().size());
}
/**
Handles the helper cell visual rendering
@param painter QPainter to be used for the rendering
@param option Rendering options
@param widget QWidget being painted, if any
Handles the helper cell visual rendering
@param painter QPainter to be used for the rendering
@param option Rendering options
@param widget QWidget being painted, if any
*/
void HelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
QRectF drawing_rectangle(QPointF(0, 0), geometry().size());
painter -> setPen(Qt::black);
painter -> setBrush(background_color);
painter -> drawRect(drawing_rectangle);
painter -> setPen(foreground_color);
painter -> drawText(drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, label);
Q_UNUSED(option);
Q_UNUSED(widget);
QRectF drawing_rectangle(QPointF(0, 0), geometry().size());
painter -> setPen(Qt::black);
painter -> setBrush(background_color);
painter -> drawRect(drawing_rectangle);
painter -> setPen(foreground_color);
painter -> drawText(drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, label);
}
/**
@param type new type of this helper cell -- @see QET::TitleBlockColumnLength
@param type new type of this helper cell -- @see QET::TitleBlockColumnLength
*/
void HelperCell::setType(QET::TitleBlockColumnLength type) {
if (type == QET::Absolute) {
background_color = QColor("#C0FFFF");
foreground_color = Qt::black;
} else if (type == QET::RelativeToTotalLength) {
background_color = QColor("#FFA858");
foreground_color = Qt::black;
} else if (type == QET::RelativeToRemainingLength) {
background_color = QColor("#FFC0C0");
foreground_color = Qt::black;
}
if (type == QET::Absolute) {
background_color = QColor("#C0FFFF");
foreground_color = Qt::black;
} else if (type == QET::RelativeToTotalLength) {
background_color = QColor("#FFA858");
foreground_color = Qt::black;
} else if (type == QET::RelativeToRemainingLength) {
background_color = QColor("#FFC0C0");
foreground_color = Qt::black;
}
}
/**
Set the list of actions displayed by the context menu of this helper cell.
Set the list of actions displayed by the context menu of this helper cell.
*/
void HelperCell::setActions(const QList<QAction *> &actions) {
actions_ = actions;
actions_ = actions;
}
/**
@return the list of actions displayed by the context menu of this helper cell.
@return the list of actions displayed by the context menu of this helper cell.
*/
QList<QAction *> HelperCell::actions() const
{
return actions_;
return actions_;
}
/**
@param text New label displayed by this helper cell
@param set_as_tooltip If true, the text is also used as tooltip.
@param text New label displayed by this helper cell
@param set_as_tooltip If true, the text is also used as tooltip.
*/
void HelperCell::setLabel(const QString &text, bool set_as_tooltip) {
label = text;
if (set_as_tooltip) {
setToolTip(text);
}
label = text;
if (set_as_tooltip) {
setToolTip(text);
}
}
/**
Handle context menu events.
@param event Context menu event.
Handle context menu events.
@param event Context menu event.
*/
void HelperCell::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
if (actions_.isEmpty()) return;
QMenu context_menu;
foreach (QAction *action, actions_) {
context_menu.addAction(action);
}
emit(contextMenuTriggered(this));
context_menu.exec(event -> screenPos());
if (actions_.isEmpty()) return;
QMenu context_menu;
foreach (QAction *action, actions_) {
context_menu.addAction(action);
}
emit(contextMenuTriggered(this));
context_menu.exec(event -> screenPos());
}
/**
Handle double click events.
Handle double click events.
*/
void HelperCell::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
emit(doubleClicked(this));
emit(doubleClicked(this));
}

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TITLEBLOCK_SLASH_HELPER_CELL_H
#define TITLEBLOCK_SLASH_HELPER_CELL_H
@@ -21,48 +21,48 @@
#include "qet.h"
/**
This class implements a helper widget for cells that indicate the length of
columns and rows.
This class implements a helper widget for cells that indicate the length of
columns and rows.
*/
class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
Q_OBJECT
Q_INTERFACES(QGraphicsLayoutItem)
// constructor, destructor
public:
HelperCell(QGraphicsItem * = nullptr);
~HelperCell() override;
private:
HelperCell(const HelperCell &);
// attributes
public:
QColor background_color; ///< Background color when rendering this cell
QColor foreground_color; ///< Text color when rendering this cell
QString label; ///< Label displayed in this cell
Qt::Orientation orientation; ///< Orientation of this cell
int index; ///< Index of this cell
// methods
public:
void setGeometry(const QRectF &) override;
QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) const override;
QRectF boundingRect() const override;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
virtual void setType(QET::TitleBlockColumnLength);
virtual void setActions(const QList<QAction *> &);
virtual QList<QAction *> actions() const;
virtual void setLabel(const QString &text, bool = true);
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
signals:
void contextMenuTriggered(HelperCell *);
void doubleClicked(HelperCell *);
private:
QList<QAction *> actions_; ///< List of actions displayed by the context menu
Q_OBJECT
Q_INTERFACES(QGraphicsLayoutItem)
// constructor, destructor
public:
HelperCell(QGraphicsItem * = nullptr);
~HelperCell() override;
private:
HelperCell(const HelperCell &);
// attributes
public:
QColor background_color; ///< Background color when rendering this cell
QColor foreground_color; ///< Text color when rendering this cell
QString label; ///< Label displayed in this cell
Qt::Orientation orientation; ///< Orientation of this cell
int index; ///< Index of this cell
// methods
public:
void setGeometry(const QRectF &) override;
QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) const override;
QRectF boundingRect() const override;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
virtual void setType(QET::TitleBlockColumnLength);
virtual void setActions(const QList<QAction *> &);
virtual QList<QAction *> actions() const;
virtual void setLabel(const QString &text, bool = true);
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
signals:
void contextMenuTriggered(HelperCell *);
void doubleClicked(HelperCell *);
private:
QList<QAction *> actions_; ///< List of actions displayed by the context menu
};
#endif

View File

@@ -1,45 +1,45 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
#define TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
#include "helpercell.h"
/**
This class is a variant of HelperCell having the ability to display two
labels, with a split line between them.
This class is a variant of HelperCell having the ability to display two
labels, with a split line between them.
*/
class SplittedHelperCell : public HelperCell {
Q_OBJECT
public:
SplittedHelperCell(QGraphicsItem * = nullptr);
~SplittedHelperCell() override;
private:
SplittedHelperCell(const SplittedHelperCell &);
// methods
public:
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
// attributes
QColor split_background_color; ///< Background color on the split side
QColor split_foreground_color; ///< Text color on the split side
QString split_label; ///< Text displayed on the split side
int split_size; ///< Length of the split side
Q_OBJECT
public:
SplittedHelperCell(QGraphicsItem * = nullptr);
~SplittedHelperCell() override;
private:
SplittedHelperCell(const SplittedHelperCell &);
// methods
public:
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
// attributes
QColor split_background_color; ///< Background color on the split side
QColor split_foreground_color; ///< Text color on the split side
QString split_label; ///< Text displayed on the split side
int split_size; ///< Length of the split side
};
#endif