File indexing completed on 2024-05-12 15:56:51
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2006-2010 Thomas Zander <zander@kde.org> 0003 * SPDX-FileCopyrightText: 2010 KO GmbH <boud@valdyas.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KOTOOLBASE_P_H 0009 #define KOTOOLBASE_P_H 0010 0011 #include "KoDocumentResourceManager.h" 0012 #include "KoCanvasResourceProvider.h" 0013 #include "KoCanvasBase.h" 0014 #include "KoShapeController.h" 0015 #include <QHash> 0016 #include <QWidget> 0017 #include <QString> 0018 #include <QPointer> 0019 #include <string.h> // for the qt version check 0020 0021 class QAction; 0022 class KoToolBase; 0023 class KoToolFactoryBase; 0024 0025 class KoToolBasePrivate 0026 { 0027 public: 0028 KoToolBasePrivate(KoToolBase *qq, KoCanvasBase *canvas_) 0029 : currentCursor(Qt::ArrowCursor), 0030 q(qq), 0031 canvas(canvas_), 0032 isInTextMode(false), 0033 isActivated(false) 0034 { 0035 } 0036 0037 virtual ~KoToolBasePrivate() 0038 { 0039 Q_FOREACH (QPointer<QWidget> optionWidget, optionWidgets) { 0040 if (optionWidget) { 0041 optionWidget->setParent(0); 0042 delete optionWidget; 0043 } 0044 } 0045 optionWidgets.clear(); 0046 } 0047 0048 void connectSignals() 0049 { 0050 if (canvas) { // in the case of KoToolManagers dummytool it can be zero :( 0051 KoCanvasResourceProvider * crp = canvas->resourceManager(); 0052 Q_ASSERT_X(crp, "KoToolBase::KoToolBase", "No Canvas KoResourceManager"); 0053 if (crp) 0054 q->connect(crp, SIGNAL(canvasResourceChanged(int, const QVariant &)), 0055 SLOT(canvasResourceChanged(int, const QVariant &))); 0056 0057 // can be 0 in the case of Calligra Sheets 0058 KoDocumentResourceManager *scrm = canvas->shapeController()->resourceManager(); 0059 if (scrm) { 0060 q->connect(scrm, SIGNAL(resourceChanged(int, const QVariant &)), 0061 SLOT(documentResourceChanged(int, const QVariant &))); 0062 } 0063 } 0064 } 0065 0066 QList<QPointer<QWidget> > optionWidgets; ///< the optionwidgets associated with this tool 0067 bool optionWidgetsCreated {false}; 0068 QCursor currentCursor; 0069 KoToolBase *q; 0070 KoToolFactoryBase *factory {0}; 0071 KoCanvasBase *canvas; ///< the canvas interface this tool will work for. 0072 bool isInTextMode; 0073 bool maskSyntheticEvents{false}; ///< Whether this tool masks synthetic events 0074 bool isActivated; 0075 QRectF lastDecorationsRect; 0076 }; 0077 0078 #endif