[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [pairs/frameworks] game: adding new card model
From:       Marco Calignano <marco.calignano () gmail ! com>
Date:       2014-09-15 20:16:51
Message-ID: E1XTchf-00040W-Ge () scm ! kde ! org
[Download RAW message or body]

Git commit 73f6088f16dbc1996b54e170d0b206736f1ad999 by Marco Calignano.
Committed on 14/09/2014 at 16:13.
Pushed by calignano into branch 'frameworks'.

adding new card model

A  +35   -0    game/cardmodel.cpp     [License: GPL (v2/3)]
A  +47   -0    game/cardmodel.h     [License: GPL (v2/3)]

http://commits.kde.org/pairs/73f6088f16dbc1996b54e170d0b206736f1ad999

diff --git a/game/cardmodel.cpp b/game/cardmodel.cpp
new file mode 100644
index 0000000..2968fbf
--- /dev/null
+++ b/game/cardmodel.cpp
@@ -0,0 +1,35 @@
+/*  This file is part of Pairs
+ *
+ *  Copyright (C) <2014>       <Marco Calignano>     <marco.calignano@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License as
+ *  published by the Free Software Foundation; either version 2 of
+ *  the License or (at your option) version 3 or any later version
+ *  accepted by the membership of KDE e.V. (or its successor approved
+ *  by the membership of KDE e.V.), which shall act as a proxy
+ *  defined in Section 14 of version 3 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "cardmodel.h"
+
+QHash<int, QByteArray> CardModel::roleNames() const {
+    QHash<int, QByteArray> roles;
+    roles[FrontRole] = "frontImage";
+    roles[BackRole] = "backImage";
+    roles[TextRole] = "text";
+    roles[FoundRole] = "foundSound";
+    roles[MissedRole] = "missedSound";
+    roles[PostMessageRole] = "postMessage";
+    return roles;
+}
+
diff --git a/game/cardmodel.h b/game/cardmodel.h
new file mode 100644
index 0000000..546e8f3
--- /dev/null
+++ b/game/cardmodel.h
@@ -0,0 +1,47 @@
+/*  This file is part of Pairs
+ *
+ *  Copyright (C) <2014>       <Marco Calignano>     <marco.calignano@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License as
+ *  published by the Free Software Foundation; either version 2 of
+ *  the License or (at your option) version 3 or any later version
+ *  accepted by the membership of KDE e.V. (or its successor approved
+ *  by the membership of KDE e.V.), which shall act as a proxy
+ *  defined in Section 14 of version 3 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CARDMODEL_H
+#define CARDMODEL_H
+
+#include <QStandardItemModel>
+#include "carditem.h"
+
+class CardModel : public QStandardItemModel
+{
+    Q_OBJECT
+public:
+    enum CardRoles {
+        FrontRole = Qt::UserRole + 1,
+        BackRole,
+        TextRole,
+        FoundRole,
+        MissedRole,
+        PostMessageRole
+};
+
+    CardModel(QObject *parent = 0):QStandardItemModel(parent){};
+    virtual ~CardModel(){};
+    virtual QHash<int, QByteArray> roleNames() const;
+    void addCard(CardItem *card){appendRow(card);};
+};
+
+#endif

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic