File indexing completed on 2024-05-19 04:44:33

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
0003  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef KREPORTDESIGNERITEMLABEL_H
0020 #define KREPORTDESIGNERITEMLABEL_H
0021 
0022 #include "KReportItemLabel.h"
0023 #include "KReportDesignerItemRectBase.h"
0024 #include "KReportBoundedTextItem.h"
0025 
0026 #include <QGraphicsRectItem>
0027 #include <QGraphicsItem>
0028 #include <QGraphicsItemGroup>
0029 #include <KPropertySet>
0030 
0031 class KReportDesignerItemLabel : public KReportItemLabel, public KReportDesignerItemRectBase
0032 {
0033   Q_OBJECT
0034 public:
0035     KReportDesignerItemLabel(KReportDesigner *designer, QGraphicsScene *scene, const QPointF &pos);
0036     KReportDesignerItemLabel(const QDomNode &element, KReportDesigner *designer,
0037                              QGraphicsScene *scene);
0038     ~KReportDesignerItemLabel() override;
0039 
0040     void buildXML(QDomDocument *doc, QDomElement *parent) override;
0041     void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
0042     KReportDesignerItemLabel* clone() override;
0043 
0044 public Q_SLOTS:
0045     void enterInlineEditingMode() override;
0046     void exitInlineEditingMode() override;
0047 
0048 protected:
0049     void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event ) override;
0050     void keyReleaseEvent ( QKeyEvent * event ) override;
0051 
0052 private:
0053     void init(QGraphicsScene *scene);
0054     QRectF getTextRect() const;
0055     BoundedTextItem *m_inlineEdit;
0056 
0057 private Q_SLOTS:
0058     void slotPropertyChanged(KPropertySet &, KProperty &);
0059 
0060 };
0061 
0062 #endif