QTfrontend/ui/widget/mapContainer.h
changeset 8377 869f80966a77
parent 7258 722e8a0d89dc
child 8393 85bd6c7b2641
equal deleted inserted replaced
8376:c11cc7246df7 8377:869f80966a77
    20 #ifndef _HWMAP_CONTAINER_INCLUDED
    20 #ifndef _HWMAP_CONTAINER_INCLUDED
    21 #define _HWMAP_CONTAINER_INCLUDED
    21 #define _HWMAP_CONTAINER_INCLUDED
    22 
    22 
    23 #include <QWidget>
    23 #include <QWidget>
    24 #include <QGridLayout>
    24 #include <QGridLayout>
       
    25 #include <QVBoxLayout>
    25 #include <QComboBox>
    26 #include <QComboBox>
    26 #include <QLabel>
    27 #include <QLabel>
    27 #include <QByteArray>
    28 #include <QByteArray>
    28 #include <QLineEdit>
    29 #include <QLineEdit>
    29 
    30 
    35 
    36 
    36 class QPushButton;
    37 class QPushButton;
    37 class IconedGroupBox;
    38 class IconedGroupBox;
    38 class QListView;
    39 class QListView;
    39 class SeparatorPainter;
    40 class SeparatorPainter;
       
    41 class QListWidget;
    40 
    42 
    41 class MapFileErrorException
    43 class MapFileErrorException
    42 {
    44 {
    43 };
    45 };
    44 
    46 
    45 class HWMapContainer : public QWidget
    47 class HWMapContainer : public QWidget
    46 {
    48 {
    47         Q_OBJECT
    49         Q_OBJECT
       
    50 
       
    51         Q_PROPERTY(bool master READ isMaster WRITE setMaster)
    48 
    52 
    49     public:
    53     public:
    50         HWMapContainer(QWidget * parent=0);
    54         HWMapContainer(QWidget * parent=0);
    51         QString getCurrentSeed() const;
    55         QString getCurrentSeed() const;
    52         QString getCurrentMap() const;
    56         QString getCurrentMap() const;
    60         bool getCurrentIsMission() const;
    64         bool getCurrentIsMission() const;
    61         QByteArray getDrawnMapData();
    65         QByteArray getDrawnMapData();
    62         DrawMapScene * getDrawMapScene();
    66         DrawMapScene * getDrawMapScene();
    63         void mapDrawingFinished();
    67         void mapDrawingFinished();
    64         QLineEdit* seedEdit;
    68         QLineEdit* seedEdit;
       
    69         bool isMaster();
    65 
    70 
    66     public slots:
    71     public slots:
    67         void askForGeneratedPreview();
    72         void askForGeneratedPreview();
    68         void setSeed(const QString & seed);
    73         void setSeed(const QString & seed);
    69         void setMap(const QString & map);
    74         void setMap(const QString & map);
    73         void setMazeSize(int size);
    78         void setMazeSize(int size);
    74         void setDrawnMapData(const QByteArray & ar);
    79         void setDrawnMapData(const QByteArray & ar);
    75         void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl);
    80         void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl);
    76         void updateModelViews();
    81         void updateModelViews();
    77         void onPreviewMapDestroyed(QObject * map);
    82         void onPreviewMapDestroyed(QObject * map);
       
    83         void setMaster(bool master);
    78 
    84 
    79     signals:
    85     signals:
    80         void seedChanged(const QString & seed);
    86         void seedChanged(const QString & seed);
    81         void mapChanged(const QString & map);
    87         void mapChanged(const QString & map);
    82         void themeChanged(const QString & theme);
    88         void themeChanged(const QString & theme);
    87         void drawnMapChanged(const QByteArray & data);
    93         void drawnMapChanged(const QByteArray & data);
    88 
    94 
    89     private slots:
    95     private slots:
    90         void setImage(const QImage newImage);
    96         void setImage(const QImage newImage);
    91         void setHHLimit(int hhLimit);
    97         void setHHLimit(int hhLimit);
    92         void mapChanged(int index);
       
    93         void setRandomSeed();
    98         void setRandomSeed();
    94         void setRandomTheme();
    99         void setRandomTheme();
    95         void setRandomMap();
   100         void setRandomMap();
    96         void themeSelected(const QModelIndex & current, const QModelIndex &);
       
    97         void addInfoToPreview(QPixmap image);
   101         void addInfoToPreview(QPixmap image);
    98         void seedEdited();
   102         void setNewSeed(const QString & newSeed);
       
   103         void mapTypeChanged(int);
       
   104         void showThemePrompt();
       
   105         void updateTheme(const QModelIndex & current);
       
   106         void staticMapChanged(const QModelIndex & map, const QModelIndex & old = QModelIndex());
       
   107         void missionMapChanged(const QModelIndex & map, const QModelIndex & old = QModelIndex());
       
   108         void loadDrawing();
       
   109         void showSeedPrompt();
    99 
   110 
   100     protected:
   111     protected:
   101         virtual void resizeEvent ( QResizeEvent * event );
   112         virtual void resizeEvent ( QResizeEvent * event );
   102 
   113 
   103     private:
   114     private:
   104         QGridLayout mainLayout;
   115         QVBoxLayout mainLayout;
   105         QPushButton* imageButt;
   116         QLabel* mapPreview;
   106         QComboBox* chooseMap;
   117         QComboBox* chooseMap;
   107         MapModel * m_mapModel;
   118         MapModel * m_staticMapModel;
       
   119         MapModel * m_missionMapModel;
   108         IconedGroupBox* gbThemes;
   120         IconedGroupBox* gbThemes;
   109         QListView* lvThemes;
   121         QListView* lvThemes;
   110         ThemeModel * m_themeModel;
   122         ThemeModel * m_themeModel;
   111         HWMap* pMap;
   123         HWMap* pMap;
   112         QString m_seed;
   124         QString m_seed;
   119         QComboBox* cbTemplateFilter;
   131         QComboBox* cbTemplateFilter;
   120         QLabel *maze_size_label;
   132         QLabel *maze_size_label;
   121         QComboBox *cbMazeSize;
   133         QComboBox *cbMazeSize;
   122         MapGenerator mapgen;
   134         MapGenerator mapgen;
   123         DrawMapScene drawMapScene;
   135         DrawMapScene drawMapScene;
       
   136         QComboBox * cType;
       
   137         QListView * staticMapList;
       
   138         QListView * missionMapList;
       
   139         QListWidget * generationStyles;
       
   140         QListWidget * mazeStyles;
       
   141         QLabel * lblMapList;
       
   142         QLabel * lblDesc;
       
   143         QPushButton * btnTheme;
       
   144         QPushButton * btnLoadMap;
       
   145         QPushButton * btnEditMap;
       
   146         QPushButton * btnRandomize;
       
   147         QString selectedTheme;
       
   148         QPushButton * btnSeed;
       
   149         bool m_master;
       
   150         QList<QWidget *> m_childWidgets;
   124 
   151 
   125         void intSetSeed(const QString & seed);
   152         void intSetSeed(const QString & seed);
   126         void intSetMap(const QString & map);
   153         void intSetMap(const QString & map);
   127         void intSetMapgen(MapGenerator m);
   154         void intSetMapgen(MapGenerator m);
   128         void intSetTemplateFilter(int);
   155         void intSetTemplateFilter(int);
   129         void intSetMazeSize(int size);
   156         void intSetMazeSize(int size);
       
   157         void mapChanged(const QModelIndex & map, int type, const QModelIndex & old = QModelIndex());
       
   158         void setMapInfo(MapModel::MapInfo mapInfo);
       
   159         void changeMapType(MapModel::MapType type, const QModelIndex & newMap = QModelIndex());
   130         void updatePreview();
   160         void updatePreview();
   131 
   161 
   132         MapModel::MapInfo m_mapInfo;
   162         MapModel::MapInfo m_mapInfo;
   133         QString m_theme;
   163         QString m_theme;
   134         QString m_curMap;
   164         QString m_curMap;