File indexing completed on 2024-05-12 16:35:45
0001 /* This file is part of the KDE project 0002 Copyright 2006 - Robert Knight <robertknight@gmail.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef CALLIGRA_SHEETS_HEADERITEMS 0021 #define CALLIGRA_SHEETS_HEADERITEMS 0022 0023 #include <QGraphicsWidget> 0024 #include "Headers.h" 0025 0026 #include "sheets_common_export.h" 0027 0028 0029 0030 namespace Calligra 0031 { 0032 namespace Sheets 0033 { 0034 class CanvasItem; 0035 0036 /** 0037 * The widget above the cells showing the column headers. 0038 */ 0039 class CALLIGRA_SHEETS_COMMON_EXPORT ColumnHeaderItem : public QGraphicsWidget, public ColumnHeader 0040 { 0041 Q_OBJECT 0042 public: 0043 ColumnHeaderItem(QGraphicsItem *_parent, CanvasItem *_canvas); 0044 ~ColumnHeaderItem() override; 0045 0046 void updateColumns(int from, int to) override; 0047 void update() override { QGraphicsWidget::update(); } 0048 0049 private Q_SLOTS: 0050 //void slotAutoScroll(const QPoint& distance); 0051 0052 protected: 0053 void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) override; 0054 void mousePressEvent(QGraphicsSceneMouseEvent* _ev) override; 0055 void mouseReleaseEvent(QGraphicsSceneMouseEvent* _ev) override; 0056 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _ev) override; 0057 void mouseMoveEvent(QGraphicsSceneMouseEvent* _ev) override; 0058 void wheelEvent(QGraphicsSceneWheelEvent*) override; 0059 void focusOutEvent(QFocusEvent* ev) override; 0060 void resizeEvent(QGraphicsSceneResizeEvent * _ev) override; 0061 0062 void paintSizeIndicator(int mouseX) override; 0063 void removeSizeIndicator() override; 0064 0065 QSizeF size() const override { return QGraphicsWidget::size(); } 0066 void setCursor(const QCursor& cursor) override { QGraphicsWidget::setCursor(cursor); } 0067 void scroll(qreal x, qreal y) override; 0068 QPalette palette() const override { return QGraphicsWidget::palette(); } 0069 /*private */public Q_SLOTS: 0070 void toolChanged(const QString& toolId); 0071 }; 0072 0073 0074 0075 /** 0076 * The widget left to the cells showing the row headers. 0077 */ 0078 class CALLIGRA_SHEETS_COMMON_EXPORT RowHeaderItem : public QGraphicsWidget, public RowHeader 0079 { 0080 Q_OBJECT 0081 public: 0082 RowHeaderItem(QGraphicsItem *_parent, CanvasItem *_canvas); 0083 ~RowHeaderItem() override; 0084 0085 void updateRows(int from, int to) override; 0086 void update() override { QGraphicsWidget::update(); } 0087 0088 private Q_SLOTS: 0089 //void slotAutoScroll(const QPoint& distance); 0090 0091 protected: 0092 void paint (QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) override; 0093 void mousePressEvent(QGraphicsSceneMouseEvent* _ev) override; 0094 void mouseReleaseEvent(QGraphicsSceneMouseEvent* _ev) override; 0095 void mouseMoveEvent(QGraphicsSceneMouseEvent* _ev) override; 0096 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _ev) override; 0097 void wheelEvent(QGraphicsSceneWheelEvent*) override; 0098 void focusOutEvent(QFocusEvent* ev) override; 0099 0100 void paintSizeIndicator(int mouseY) override; 0101 void removeSizeIndicator() override; 0102 0103 QSizeF size() const override { return QGraphicsWidget::size(); } 0104 void setCursor(const QCursor& cursor) override { QGraphicsWidget::setCursor(cursor); } 0105 void scroll(qreal x, qreal y) override { QGraphicsWidget::scroll(x, y); } 0106 QPalette palette() const override { return QGraphicsWidget::palette(); } 0107 0108 /*private */public Q_SLOTS: 0109 void toolChanged(const QString& toolId); 0110 }; 0111 0112 0113 0114 /** 0115 * The widget in the top left corner of the canvas, 0116 * responsible for selecting all cells in a sheet. 0117 */ 0118 class CALLIGRA_SHEETS_COMMON_EXPORT SelectAllButtonItem : public QGraphicsWidget, public SelectAllButton 0119 { 0120 Q_OBJECT 0121 public: 0122 explicit SelectAllButtonItem(QGraphicsItem *_parent, CanvasBase* canvasBase); 0123 ~SelectAllButtonItem() override; 0124 0125 protected: 0126 void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) override; 0127 void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 0128 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 0129 void wheelEvent(QGraphicsSceneWheelEvent *event) override; 0130 0131 private Q_SLOTS: 0132 void toolChanged(const QString& toolId); 0133 }; 0134 0135 } // namespace Sheets 0136 } // namespace Calligra 0137 0138 #endif