~ubuntu-branches/ubuntu/precise/mupen64plus/precise

« back to all changes in this revision

Viewing changes to main/gui_qt4/rommodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2009-09-08 22:17:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090908221700-yela0ckgc1xwiqtn
Tags: upstream-1.5+dfsg1
ImportĀ upstreamĀ versionĀ 1.5+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
2
 *   Mupen64plus - rommodel.h                                              *
 
3
 *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
 
4
 *   Copyright (C) 2008 Slougi                                             *
 
5
 *                                                                         *
 
6
 *   This program is free software; you can redistribute it and/or modify  *
 
7
 *   it under the terms of the GNU General Public License as published by  *
 
8
 *   the Free Software Foundation; either version 2 of the License, or     *
 
9
 *   (at your option) any later version.                                   *
 
10
 *                                                                         *
 
11
 *   This program is distributed in the hope that it will be useful,       *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU General Public License for more details.                          *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU General Public License     *
 
17
 *   along with this program; if not, write to the                         *
 
18
 *   Free Software Foundation, Inc.,                                       *
 
19
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 
20
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
21
 
 
22
#ifndef __ROMMODEL_H__
 
23
#define __ROMMODEL_H__
 
24
 
 
25
#include <QAbstractItemModel>
 
26
#include <QStringList>
 
27
#include <QPixmap>
 
28
#include <QPair>
 
29
#include <QChar>
 
30
 
 
31
extern "C" {
 
32
    namespace core {
 
33
        #include "../romcache.h"
 
34
    }
 
35
}
 
36
 
 
37
class RomModel : public QAbstractItemModel
 
38
{
 
39
    Q_OBJECT
 
40
    Q_ENUMS(Columns)
 
41
    Q_ENUMS(Role)
 
42
    public:
 
43
        enum Columns {
 
44
            Country = 0,
 
45
            GoodName,
 
46
            Status,
 
47
            UserComments,
 
48
            FileName,
 
49
            MD5Hash,
 
50
            InternalName,
 
51
            CRC1,
 
52
            CRC2,
 
53
            SaveType,
 
54
            Players,
 
55
            Size,
 
56
            CompressionType,
 
57
            ImageType,
 
58
            CICChip,
 
59
            Rumble,
 
60
            COLUMNS_SENTINEL, // keep this as the last entry
 
61
            LAST_VISIBLE_COLUMN = FileName // except this one may come after!
 
62
        };
 
63
        enum Role {
 
64
            Sort = Qt::UserRole,
 
65
            FullPath,
 
66
            ArchiveFile
 
67
        };
 
68
 
 
69
        RomModel(QObject* parent = 0);
 
70
 
 
71
        static RomModel* self();
 
72
        void update(unsigned int roms, unsigned short clear);
 
73
 
 
74
        // Model method implementations
 
75
        virtual QModelIndex index(int row, int column,
 
76
                           const QModelIndex& parent = QModelIndex()) const;
 
77
        virtual QModelIndex parent(const QModelIndex& index) const;
 
78
        virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
79
        virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
 
80
        virtual QVariant data(const QModelIndex& index,
 
81
                               int role = Qt::DisplayRole) const;
 
82
        virtual bool setData(const QModelIndex& index,
 
83
                             const QVariant& value,
 
84
                             int role = Qt::EditRole);
 
85
        virtual QVariant headerData(int section, Qt::Orientation orientation,
 
86
                                     int role = Qt::DisplayRole) const;
 
87
        void settingsChanged();
 
88
 
 
89
    private:
 
90
        QPixmap countryFlag(QChar c) const;
 
91
        QString countryName(QChar c) const;
 
92
 
 
93
        QList<core::cache_entry*> m_romList;
 
94
 
 
95
        bool m_showFullPath;
 
96
        QStringList m_romDirectories;
 
97
        QMap<QChar, QPair<QString, QPixmap> > m_countryInfo;
 
98
};
 
99
 
 
100
#endif // __ROMMODEL_H__
 
101