QTfrontend/model/MapModel.h
author sheepluva
Fri, 27 Apr 2012 22:22:04 +0200
changeset 6939 970389573788
parent 6938 217ed62e872c
child 6943 1fe601a2761b
permissions -rw-r--r--
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6938
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     1
/*
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     3
 * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     4
 * Copyright (c) 2007-2012 Andrey Korotaev <unC0Rr@gmail.com>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     5
 *
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
     9
 *
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    13
 * GNU General Public License for more details.
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    14
 *
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    18
 */
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    19
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    20
/**
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    21
 * @file
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    22
 * @brief MapModel class definition
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    23
 */
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    24
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    25
#ifndef HEDGEWARS_MAPMODEL_H
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    26
#define HEDGEWARS_MAPMODEL_H
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    27
6939
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    28
#include <QStandardItemModel>
6938
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    29
#include <QStringList>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    30
#include <QTextStream>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    31
#include <QMap>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    32
#include <QIcon>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    33
#include <QComboBox>
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    34
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    35
#include "DataManager.h"
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    36
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    37
/**
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    38
 * @brief A model listing available themes
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    39
 *
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    40
 * @author sheepluva
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    41
 * @since 0.9.18
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    42
 */
6939
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    43
class MapModel : public QStandardItemModel
6938
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    44
{
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    45
        Q_OBJECT
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    46
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    47
    public:
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    48
        enum MapType {
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    49
            Invalid,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    50
            GeneratedMap,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    51
            GeneratedMaze,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    52
            HandDrawnMap,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    53
            MissionMap,
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    54
            StaticMap
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    55
        };
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    56
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    57
        struct MapInfo
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    58
        {
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    59
            MapType type;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    60
            QString name;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    61
            QString theme;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    62
            quint32 limit;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    63
            QString scheme;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    64
            QString weapons;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    65
        };
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    66
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    67
        int missionCount() const;
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    68
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    69
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    70
    public slots:
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    71
        /// reloads the maps from the DataManager
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    72
        void loadMaps();
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    73
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    74
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    75
    private:
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    76
        int m_nMissions;
6939
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    77
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    78
        QStandardItem * infoToItem(
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    79
            const QIcon & icon,
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    80
            const QString caption,
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    81
            MapType type = Invalid,
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    82
            QString name = "",
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    83
            QString theme = "",
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    84
            quint32 limit = 0,
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    85
            QString scheme = "",
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    86
            QString weapons = "") const;
6938
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    87
};
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    88
6939
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    89
Q_DECLARE_METATYPE(MapModel::MapInfo)
970389573788 MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents: 6938
diff changeset
    90
6938
217ed62e872c MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff changeset
    91
#endif // HEDGEWARS_MAPMODEL_H