File indexing completed on 2023-10-03 03:28:38
0001 /*************************************************************************** 0002 cmaptoolbase.h 0003 ------------------- 0004 begin : Tue May 1 2001 0005 copyright : (C) 2001 by Kmud Developer Team 0006 email : kmud-devel@kmud.de 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef CMAPTOOLBASE_H 0019 #define CMAPTOOLBASE_H 0020 0021 #include <qobject.h> 0022 #include <qstring.h> 0023 #include <qicon.h> 0024 #include <qevent.h> 0025 0026 #include <kaction.h> 0027 #include <ktoggleaction.h> 0028 0029 #include <kmuddy_export.h> 0030 0031 class CMapManager; 0032 class CMapLevel; 0033 0034 class QActionGroup; 0035 class KActionCollection; 0036 0037 /** 0038 *@author Kmud Developer Team 0039 */ 0040 0041 class KMUDDY_EXPORT CMapToolBase : public QObject 0042 { 0043 Q_OBJECT 0044 public: 0045 /** The construtor for the tool */ 0046 CMapToolBase(KActionCollection *actionCollection,QString description,QIcon icon,CMapManager *manager,QString actionName,QActionGroup *group); 0047 ~CMapToolBase() override; 0048 0049 // Mouse events for the tool 0050 virtual void mousePressEvent(QPoint, QMouseEvent *, CMapLevel *) { } 0051 virtual void mouseReleaseEvent(QPoint, QMouseEvent *, CMapLevel *) { } 0052 virtual void mouseMoveEvent(QPoint, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *) { } 0053 virtual void mouseDoubleClickEvent(QPoint, QMouseEvent *, CMapLevel *) { } 0054 virtual void mouseLeaveEvent() { } 0055 virtual void mouseEnterEvent() { } 0056 virtual void keyPressEvent(QKeyEvent *) { } 0057 virtual void keyReleaseEvent(QKeyEvent *) { } 0058 0059 /** Called when painting the widget */ 0060 virtual void paint(QPainter *) { } 0061 0062 /** This function called when a tool is selected */ 0063 virtual void toolSelected(void)=0; 0064 /** This function is called when a tool is unselected */ 0065 virtual void toolUnselected(void) { } 0066 /** Used to tell the tool were to find the map manager */ 0067 void setManager(CMapManager *manager); 0068 /** Used to set the checked state of the tool */ 0069 void setChecked(bool checked); 0070 0071 void plug (QWidget *w); 0072 0073 protected: 0074 /** Used to set the whats this text for the tool */ 0075 void setWhatsThis(QString text); 0076 /** Used to set the toop tip of the tool */ 0077 void setToolTip(QString tip); 0078 0079 protected: 0080 /** A pointer to the map manager */ 0081 CMapManager *mapManager; 0082 0083 0084 0085 0086 signals: 0087 /** This is emited when the tool is selected */ 0088 void actionSelected(CMapToolBase *tool); 0089 0090 private slots: 0091 /** This is called when the tool button is clicked */ 0092 void slotActionSelected(); 0093 0094 private: 0095 /** The action used by the tool */ 0096 KToggleAction *action; 0097 0098 }; 0099 0100 #endif