QElectroTech  0.70
splittedhelpercell.cpp
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 #include "splittedhelpercell.h"
19 
25  HelperCell(parent),
26  split_background_color(background_color),
27  split_foreground_color(foreground_color),
28  split_size(0)
29 {
30 }
31 
36 }
37 
44 void SplittedHelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget) {
45  if (!split_size) {
46  HelperCell::paint(painter, option, widget);
47  return;
48  }
49  QRectF first_drawing_rectangle(QPointF(0, 0), geometry().adjusted(0, 0, -split_size, 0).size());
50  QRectF second_drawing_rectangle(first_drawing_rectangle.topRight(), QSize(split_size, first_drawing_rectangle.height()));
51 
52  painter -> setPen(Qt::black);
53  painter -> setBrush(background_color);
54  painter -> drawRect(first_drawing_rectangle);
55  painter -> setBrush(split_background_color);
56  painter -> drawRect(second_drawing_rectangle);
57 
58  painter -> setPen(foreground_color);
59  painter -> drawText(first_drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, label);
60  painter -> setPen(split_foreground_color);
61  painter -> drawText(second_drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, split_label);
62 }
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
QString split_label
Text displayed on the split side.
int split_size
Length of the split side.
QColor background_color
Background color when rendering this cell.
Definition: helpercell.h:40
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
Definition: helpercell.cpp:77
QColor split_background_color
Background color on the split side.
QColor foreground_color
Text color when rendering this cell.
Definition: helpercell.h:41
QColor split_foreground_color
Text color on the split side.
SplittedHelperCell(QGraphicsItem *=nullptr)
QString label
Label displayed in this cell.
Definition: helpercell.h:42