QElectroTech  0.70
helpercell.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TITLEBLOCK_SLASH_HELPER_CELL_H
19 #define TITLEBLOCK_SLASH_HELPER_CELL_H
20 #include <QtWidgets>
21 #include "qet.h"
22 
27 class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
28  Q_OBJECT
29  Q_INTERFACES(QGraphicsLayoutItem)
30 
31  // constructor, destructor
32  public:
33  HelperCell(QGraphicsItem * = nullptr);
34  ~HelperCell() override;
35  private:
36  HelperCell(const HelperCell &);
37 
38  // attributes
39  public:
42  QString label;
43  Qt::Orientation orientation;
44  int index;
45 
46  // methods
47  public:
48  void setGeometry(const QRectF &) override;
49  QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) const override;
50  QRectF boundingRect() const override;
51  void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
53  virtual void setActions(const QList<QAction *> &);
54  virtual QList<QAction *> actions() const;
55  virtual void setLabel(const QString &text, bool = true);
56 
57  protected:
58  void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override;
59  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
60 
61  signals:
63  void doubleClicked(HelperCell *);
64 
65  private:
66  QList<QAction *> actions_;
67 };
68 #endif
~HelperCell() override
Definition: helpercell.cpp:40
QSizeF sizeHint(Qt::SizeHint, const QSizeF &=QSizeF()) const override
Definition: helpercell.cpp:59
TitleBlockColumnLength
enum used to specify the type of a length
Definition: qet.h:143
void contextMenuTriggered(HelperCell *)
QColor background_color
Background color when rendering this cell.
Definition: helpercell.h:40
int index
Index of this cell.
Definition: helpercell.h:44
virtual QList< QAction * > actions() const
Definition: helpercell.cpp:117
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
Definition: helpercell.cpp:77
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override
Definition: helpercell.cpp:150
QRectF boundingRect() const override
Definition: helpercell.cpp:67
virtual void setActions(const QList< QAction *> &)
Definition: helpercell.cpp:110
virtual void setType(QET::TitleBlockColumnLength)
Definition: helpercell.cpp:94
Qt::Orientation orientation
Orientation of this cell.
Definition: helpercell.h:43
QColor foreground_color
Text color when rendering this cell.
Definition: helpercell.h:41
virtual void setLabel(const QString &text, bool=true)
Definition: helpercell.cpp:125
HelperCell(QGraphicsItem *=nullptr)
Definition: helpercell.cpp:24
void doubleClicked(HelperCell *)
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override
Definition: helpercell.cpp:136
void setGeometry(const QRectF &) override
Definition: helpercell.cpp:48
QString label
Label displayed in this cell.
Definition: helpercell.h:42
QList< QAction * > actions_
List of actions displayed by the context menu.
Definition: helpercell.h:66