File indexing completed on 2024-05-12 03:47:26

0001 /*
0002     File                 : AbstractPart.h
0003     Project              : LabPlot
0004     Description          : Base class of Aspects with MDI windows as views.
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2012-2024 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef ABSTRACT_PART_H
0011 #define ABSTRACT_PART_H
0012 
0013 #include "AbstractAspect.h"
0014 
0015 class ContentDockWidget;
0016 class QMenu;
0017 
0018 class AbstractPart : public AbstractAspect {
0019     Q_OBJECT
0020 
0021 public:
0022     AbstractPart(const QString& name, AspectType type);
0023     ~AbstractPart() override;
0024 
0025     virtual QWidget* view() const = 0;
0026     void deleteView() const;
0027 
0028     ContentDockWidget* dockWidget() const;
0029     bool dockWidgetExists() const;
0030     bool hasMdiSubWindow() const;
0031 
0032     QMenu* createContextMenu() override;
0033     virtual bool exportView() const = 0;
0034     virtual bool printView() = 0;
0035     virtual bool printPreview() const = 0;
0036 
0037     bool isDraggable() const override;
0038     QVector<AspectType> dropableOn() const override;
0039 
0040     // TODO: move these functions to a new class AbstractPartView
0041     virtual void registerShortcuts(){};
0042     virtual void unregisterShortcuts(){};
0043 
0044     void suppressDeletion(bool suppress);
0045 
0046 private:
0047     mutable ContentDockWidget* m_dockWidget{nullptr};
0048     bool m_suppressDeletion{false};
0049 
0050 protected:
0051     mutable QWidget* m_partView{nullptr};
0052 
0053 Q_SIGNALS:
0054     void showRequested();
0055     void importFromFileRequested();
0056     void importFromSQLDatabaseRequested();
0057     void exportRequested();
0058     void printRequested();
0059     void printPreviewRequested();
0060     void viewAboutToBeDeleted() const;
0061 };
0062 
0063 #endif // ifndef ABSTRACT_PART_H