File indexing completed on 2024-04-28 05:38:14

0001 /***************************************************************************
0002  *  Copyright (C) 2009 by Renaud Guezennec                                 *
0003  *   https://rolisteam.org/contact                   *
0004  *                                                                         *
0005  *   rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #ifndef MAP_FRAME_H
0022 #define MAP_FRAME_H
0023 
0024 #include <QAction>
0025 #include <QImage>
0026 #include <QMouseEvent>
0027 #include <QPaintEvent>
0028 #include <QPoint>
0029 #include <QPointer>
0030 #include <QWidget>
0031 #include <memory>
0032 
0033 #include "docks/vmaptoolbar.h"
0034 #include "mediacontainers/mediacontainer.h"
0035 #include "rwidgets/customs/rgraphicsview.h"
0036 #include "rwidgets/customs/vmap.h"
0037 #include "rwidgets/rwidgets_global.h"
0038 #include "toolbars/vtoolbar.h"
0039 class VectorialMapController;
0040 
0041 /**
0042  * @brief displays, stores and manages a map and its items
0043  *
0044  */
0045 class RWIDGET_EXPORT VMapFrame : public MediaContainer
0046 {
0047     Q_OBJECT
0048     Q_PROPERTY(VMap* map READ map CONSTANT)
0049     Q_PROPERTY(ToolBox* toolBox READ toolBox CONSTANT)
0050     Q_PROPERTY(VmapTopBar* topBar READ topBar CONSTANT)
0051 public:
0052     VMapFrame(VectorialMapController* ctrl, QWidget* parent= nullptr);
0053     virtual ~VMapFrame() override;
0054     bool openFile(const QString& file);
0055 
0056     ToolBox* toolBox() const;
0057     VmapTopBar* topBar() const;
0058     VMap* map() const;
0059 
0060     QPointF mapFromScene(const QPointF& point);
0061 
0062 protected:
0063     virtual void keyPressEvent(QKeyEvent* event) override;
0064 
0065 private: // functions
0066     void setupUi();
0067 
0068 private:
0069     QPointer<VectorialMapController> m_ctrl;
0070     std::unique_ptr<VMap> m_vmap;
0071     std::unique_ptr<RGraphicsView> m_graphicView;
0072     std::unique_ptr<ToolBox> m_toolbox;
0073     std::unique_ptr<VmapTopBar> m_topBar;
0074 };
0075 #endif