File indexing completed on 2024-12-01 06:51:46
0001 /*************************************************************************** 0002 cmapzone.h 0003 ------------------- 0004 begin : Sat Mar 10 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 CMAPZONE_H 0019 #define CMAPZONE_H 0020 0021 #include <qcolor.h> 0022 #include <QStandardItemModel> 0023 #include "cmapelement.h" 0024 0025 #include "kmemconfig.h" 0026 0027 class CMapLevel; 0028 class CMapText; 0029 class CMapManager; 0030 0031 /** The zone holds a list of levels in the zone. There's only one per map. 0032 *@author Kmud Developer Team 0033 */ 0034 class KMUDDY_EXPORT CMapZone : public CMapElement 0035 { 0036 public: 0037 enum labelPosTyp { NORTH , SOUTH , WEST , EAST , NORTHWEST, NORTHEAST, SOUTHEAST , SOUTHWEST, HIDE, CUSTOM }; 0038 0039 public: 0040 CMapZone(CMapManager *manager); 0041 ~CMapZone() override; 0042 0043 elementTyp getElementType(void) override { return ZONE ; } 0044 void setLevel(CMapLevel *level) override; 0045 0046 void setLabel(QString zoneLabel); 0047 QString getLabel(void) { return label; } 0048 void setDescription (QString str) { description = str; } 0049 QString getDescription (void) { return description; } 0050 0051 void setUseDefaultCol(bool b); 0052 bool getUseDefaultCol(void); 0053 void setUseDefaultBackground(bool b); 0054 bool getUseDefaultBackground(void); 0055 void setColor(QColor col); 0056 QColor getColor(void); 0057 void setBackgroundColor(QColor col); 0058 QColor getBackgroundColor(void); 0059 0060 QStandardItemModel *levelsModel() { return &mapLevelModel; } 0061 unsigned int levelCount() const; 0062 CMapLevel *firstLevel() const { return getLevel(0); }; 0063 CMapLevel *getLevel(int idx) const; 0064 int levelIndex(const CMapLevel *level) const; 0065 void addLevel(CMapLevel *level); 0066 void insertLevel(CMapLevel *level, int pos); 0067 void setLevelName(CMapLevel *level, const QString &name); 0068 /** Removes a level, doesn't delete it */ 0069 void removeLevel(CMapLevel *level); 0070 0071 //void paint(QPainter *p,CMapZone *zone); 0072 void dragPaint(QPoint offset,QPainter *p,CMapZone *zone) override; 0073 void lowerPaint(QPainter *p,CMapZone *zone) override; 0074 void higherPaint(QPainter *p,CMapZone *zone) override; 0075 0076 /** This is used to get a unique ID for the zone */ 0077 unsigned int getZoneID(void) { return m_ID; } 0078 0079 CMapElement *copy(void) override; 0080 0081 labelPosTyp getLabelPosition(void) { return labelPosition; } 0082 void setLabelPosition(labelPosTyp pos); 0083 void setLabelPosition(labelPosTyp pos,CMapText *text); 0084 0085 void textRemove(void); 0086 0087 /** Used to load the properties of the element from a list of properties */ 0088 void loadProperties(KConfigGroup properties) override; 0089 /** Used to save the properties of the element to a list of properties */ 0090 void saveProperties(KConfigGroup properties) override; 0091 /** Used to save the element as an XML object 0092 * @param properties The XML object to save the properties too 0093 * @param doc The XML Document */ 0094 void saveQDomElement(QDomDocument *doc,QDomElement *properties) override; 0095 /** Used to load the properties from a XML object 0096 * @param properties The XML object to load the properties too */ 0097 void loadQDomElement(QDomElement *properties) override; 0098 0099 void setZoneID(unsigned int id); 0100 0101 protected: 0102 void geometryChanged(void); 0103 /** Used to paint the element at a given location and size 0104 * @param p The painer to paint the element to 0105 * @param pos The position to paint the elmenet 0106 * @param size The size the element should be draw 0107 * @param zone The current zone being viewed */ 0108 void paintElementResize(QPainter *p,QPoint pos,QSize size,CMapZone *zone) override; 0109 0110 unsigned int m_ID; 0111 0112 private: 0113 /** This is used to paint the sub boxes displayed when the element is painted */ 0114 void paintSubBox(QPainter *p,int x,int y,int width,int height); 0115 0116 public: 0117 unsigned int m_room_id_count; 0118 unsigned int m_text_id_count; 0119 0120 private: 0121 labelPosTyp labelPosition; 0122 0123 bool useDefaultCol,useDefaultBackground; 0124 /** The zone name */ 0125 QString label; 0126 QString description; 0127 0128 QColor color; 0129 QColor backgroundCol; 0130 0131 /** This is a list of all the map levels for this zone */ 0132 QStandardItemModel mapLevelModel; 0133 }; 0134 0135 #endif