File indexing completed on 2022-12-06 18:50:22

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com>
0004 */
0005 
0006 #ifndef RESULTITEM_H
0007 #define RESULTITEM_H
0008 
0009 /*
0010  * This is a common superclass of all result items. Unfortunately this class
0011  * cannot inherit QGraphicsItem or QObject, because the subclasses inherit
0012  * these from an other source (TextResultItem inherits WorksheetTextItem, for
0013  * example). Therefore this class mainly offers the interface, and the
0014  * implementations are done in each subclasses, even when the code is literally
0015  * the same for them.
0016  */
0017 
0018 namespace Cantor {
0019     class Result;
0020 }
0021 
0022 class CommandEntry;
0023 class WorksheetEntry;
0024 
0025 class QMenu;
0026 class QObject;
0027 class QPointF;
0028 class QGraphicsObject;
0029 
0030 class ResultItem
0031 {
0032   public:
0033     ResultItem(Cantor::Result* result);
0034     virtual ~ResultItem() = default;
0035 
0036     static ResultItem* create(WorksheetEntry* parent, Cantor::Result* result);
0037 
0038     virtual double setGeometry(double x, double y, double w) = 0;
0039     virtual void populateMenu(QMenu* menu, QPointF pos) = 0;
0040 
0041     virtual void update() = 0;
0042 
0043     virtual void deleteLater() = 0;
0044 
0045     virtual double width() const = 0;
0046     virtual double height() const = 0;
0047 
0048     QGraphicsObject* graphicsObject();
0049     Cantor::Result* result();
0050     CommandEntry* parentEntry();
0051 
0052   protected:
0053     void addCommonActions(QObject* self, QMenu* menu);
0054     void needRemove();
0055 
0056   protected:
0057     Cantor::Result* m_result;
0058 };
0059 
0060 #endif // RESULTITEM_H