File indexing completed on 2024-04-28 04:42:10
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 // 0020 // Class ReportCanvas 0021 // 0022 // Overrides the drawForeground() method to do the grid. 0023 // 0024 0025 #ifndef KREPORTDESIGNERSECTIONSCENE_H 0026 #define KREPORTDESIGNERSECTIONSCENE_H 0027 0028 #include <QGraphicsScene> 0029 0030 #include "KReportUnit.h" 0031 0032 typedef QList<QGraphicsItem*> QGraphicsItemList; 0033 class KReportDesigner; 0034 class QGraphicsSceneContextMenuEvent; 0035 class QGraphicsSceneMouseEvent; 0036 class KReportDesignerItemRectBase; 0037 0038 class KReportDesignerSectionScene : public QGraphicsScene 0039 { 0040 Q_OBJECT 0041 public: 0042 KReportDesignerSectionScene(qreal w, qreal h, KReportDesigner* rd); 0043 ~KReportDesignerSectionScene() override; 0044 KReportDesigner* document() const { 0045 return m_rd; 0046 } 0047 QPointF gridPoint(const QPointF&); 0048 void raiseSelected(); 0049 void lowerSelected(); 0050 QGraphicsItemList itemsOrdered() const; 0051 qreal gridSize() const { 0052 return m_pixelIncrementX; 0053 } 0054 0055 protected: 0056 void drawBackground(QPainter *painter, const QRectF &clip) override; 0057 void mousePressEvent(QGraphicsSceneMouseEvent *e) override; 0058 void focusOutEvent(QFocusEvent *focusEvent) override; 0059 void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) override; 0060 0061 Q_SIGNALS: 0062 void clicked(); 0063 void lostFocus(); 0064 0065 private: 0066 qreal lowestZValue(); 0067 qreal highestZValue(); 0068 void exitInlineEditingModeInItems(KReportDesignerItemRectBase *rectUnderCursor); 0069 0070 KReportDesigner * m_rd; 0071 0072 KReportUnit m_unit; 0073 qreal m_majorX = 0.0; 0074 qreal m_majorY = 0.0; 0075 qreal m_pixelIncrementX = 0.0; 0076 qreal m_pixelIncrementY = 0.0; 0077 int m_dpiX; 0078 int m_dpiY; 0079 }; 0080 0081 #endif