File indexing completed on 2024-04-28 04:42:10
0001 /* This file is part of the KDE project 0002 0003 * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) 0004 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef KREPORTDESIGNERITEMRECTBASE_H 0021 #define KREPORTDESIGNERITEMRECTBASE_H 0022 0023 #include <QGraphicsRectItem> 0024 0025 #include "KReportDesignerItemBase.h" 0026 #include "kreport_export.h" 0027 0028 class KReportDesigner; 0029 0030 class KPropertySet; 0031 0032 const int KREPORT_ITEM_RECT_DEFAULT_WIDTH = 100; 0033 const int KREPORT_ITEM_RECT_DEFAULT_HEIGHT = 100; 0034 0035 /*! 0036 * @brief Base class for rectangular report items used within the designer GUI. 0037 */ 0038 class KREPORT_EXPORT KReportDesignerItemRectBase : public QGraphicsRectItem, public KReportDesignerItemBase 0039 { 0040 public: 0041 explicit KReportDesignerItemRectBase(KReportDesigner *r, KReportItemBase *b); 0042 0043 ~KReportDesignerItemRectBase() override; 0044 0045 QRectF pointRect() const; 0046 0047 virtual void enterInlineEditingMode(); 0048 virtual void exitInlineEditingMode(); 0049 0050 protected: 0051 0052 enum class SceneRectFlag { 0053 UpdateProperty, 0054 DontUpdateProperty 0055 }; 0056 0057 void setSceneRect(const QPointF &topLeft, const QSizeF &size, 0058 SceneRectFlag update = SceneRectFlag::UpdateProperty); 0059 void setSceneRect(const QRectF &rect, 0060 SceneRectFlag update = SceneRectFlag::UpdateProperty); 0061 0062 void drawHandles(QPainter*); 0063 QRectF sceneRect(); 0064 void mousePressEvent(QGraphicsSceneMouseEvent * event) override; 0065 void mouseReleaseEvent(QGraphicsSceneMouseEvent * event) override; 0066 void mouseMoveEvent(QGraphicsSceneMouseEvent * event) override; 0067 void hoverMoveEvent(QGraphicsSceneHoverEvent * event) override; 0068 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; 0069 0070 void propertyChanged(const KPropertySet &s, const KProperty &p); 0071 0072 void move(const QPointF&) override; 0073 QRectF properRect(const KReportDesigner &d, qreal minWidth, qreal minHeight) const; 0074 int dpiX() const; 0075 int dpiY() const; 0076 private: 0077 Q_DISABLE_COPY(KReportDesignerItemRectBase) 0078 int grabHandle(const QPointF &pos); 0079 QPointF properPressPoint(const KReportDesigner &d) const; 0080 0081 class Private; 0082 Private * const d; 0083 }; 0084 0085 #endif