File indexing completed on 2024-05-12 15:56:39
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOCANVASOBSERVERBASE_H 0008 #define KOCANVASOBSERVERBASE_H 0009 0010 class KoCanvasBase; 0011 class KoCanvasObserverBasePrivate; 0012 0013 #include "kritaflake_export.h" 0014 #include <QString> 0015 #include <QMainWindow> 0016 0017 /** 0018 * An abstract canvas observer interface class. 0019 * Dockers that want to be notified of active canvas changes 0020 * should implement that interface so that the tool controller 0021 * can give them the active canvas. 0022 */ 0023 class KRITAFLAKE_EXPORT KoCanvasObserverBase 0024 { 0025 public: 0026 KoCanvasObserverBase(); 0027 virtual ~KoCanvasObserverBase(); 0028 0029 virtual QString observerName() { return ""; } 0030 0031 /** 0032 * set observed canvas 0033 * @param canvas canvas to observe. Can be 0. 0034 */ 0035 void setObservedCanvas(KoCanvasBase *canvas); 0036 0037 /** 0038 * notify the observer that canvas is gone 0039 */ 0040 void unsetObservedCanvas(); 0041 0042 /** 0043 * the currently observed canvas 0044 * @return observed canvas, can be 0 0045 */ 0046 KoCanvasBase* observedCanvas() const; 0047 0048 protected: 0049 /** 0050 * re-implement this method in your canvas observer. It will be called 0051 * whenever a canvas becomes active. Note that you are responsible for 0052 * not connecting more than one time to the signals of a canvas or any 0053 * of the QObjects you can access through the canvas. 0054 */ 0055 virtual void setCanvas(KoCanvasBase *canvas) = 0; 0056 0057 /** 0058 * Re-implement to notify the observer that its canvas is no longer 0059 * among the living. The daisies, it is pushing up. This means you 0060 * don't have to unconnect, it's dead. 0061 * 0062 * The old canvas should be deleted already, so if you stored a 0063 * pointer to it, don't touch! 0064 * 0065 * Note that currently there is a bug where in certain specific 0066 * circumstances unsetCanvas can be called when it shouldn't, see for 0067 * example KWStatisticsDocker for a workaround for this problem. 0068 */ 0069 virtual void unsetCanvas() = 0; 0070 0071 private: 0072 KoCanvasObserverBasePrivate * const d; 0073 }; 0074 0075 #endif // KOCANVASOBSERVERBASE_H