GCI2012: Improve Game Configuration Widget
- Refactored mapmodel+datamanager to have two separate map models for static and mission maps, and then three static MapInfos in MapModel for the three special maps (random, maze, drawn).
- Created theme selector dialog.
- Created seed view/edit dialog.
- Enlarged start icon on pagemultiplayer and pagenetgame, and added Start.png.
- Moved "Settings" button on pagemultiplayer and pagenetgame from middle of page to page footer.
- Added "load drawing" button to mapcontainer widget.
- Map preview is no longer the randomize button; The randomize functionality is now in a button of its own.
- Map preview no longer grays out (isn't disabled) when in slave mode.
- Seed is now viewable and copyable when in slave mode -- but not editable.
- You should now use the property master (isMaster() and setMaster()) on gamecfgwidget and mapcontainer instead of the enabled property. This is because some widgets (e.g. "view/edit seed" button and map preview) shouldn't be disabled, when all other widgets should be.
- Added mission map descriptions w/ locale support in INI format in mapname/desc.txt if applicable. Use '|' for line break.
#ifndef PLAYERSLISTMODEL_H
#define PLAYERSLISTMODEL_H
#include <QAbstractListModel>
#include <QHash>
#include <QIcon>
#include <QModelIndex>
#include <QSet>
class PlayersListModel : public QAbstractListModel
{
Q_OBJECT
public:
enum StateFlag {
Ready = Qt::UserRole,
ServerAdmin = Qt::UserRole + 1,
RoomAdmin = Qt::UserRole + 2,
Registered = Qt::UserRole + 3,
Friend = Qt::UserRole + 4,
Ignore = Qt::UserRole + 5,
InGame = Qt::UserRole + 6
};
enum SpecialRoles {
SortRole = Qt::UserRole + 100,
RoomFilterRole = Qt::UserRole + 101
};
explicit PlayersListModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
void setFlag(const QString & nickname, StateFlag flagType, bool isSet);
bool isFlagSet(const QString & nickname, StateFlag flagType);
bool insertRow(int row, const QModelIndex &parent = QModelIndex());
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
public slots:
void addPlayer(const QString & nickname);
void removePlayer(const QString & nickname);
void playerJoinedRoom(const QString & nickname);
void playerLeftRoom(const QString & nickname);
void resetRoomFlags();
void setNickname(const QString & nickname);
private:
QHash<quint32, QIcon> & m_icons();
typedef QHash<int, QVariant> DataEntry;
QList<DataEntry> m_data;
QSet<QString> m_friendsSet, m_ignoredSet;
QString m_nickname;
void updateIcon(const QModelIndex & index);
void updateSortData(const QModelIndex & index);
void loadSet(QSet<QString> & set, const QString & suffix);
void saveSet(const QSet<QString> & set, const QString & suffix);
void checkFriendIgnore(const QModelIndex & mi);
};
#endif // PLAYERSLISTMODEL_H