File indexing completed on 2024-04-21 15:08:00

0001 // Copyright (c) 2015 Pino Toscano <pino@kde.org>
0002 //
0003 // This library is free software; you can redistribute it and/or
0004 // modify it under the terms of the GNU Lesser General Public
0005 // License version 2.1 as published by the Free Software Foundation.
0006 //
0007 // This library is distributed in the hope that it will be useful,
0008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0010 // Lesser General Public License for more details.
0011 //
0012 // You should have received a copy of the GNU Lesser General Public License
0013 // along with this library; see the file COPYING.LIB.  If not, write to
0014 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0015 // Boston, MA 02110-1301, USA.
0016 
0017 #include "card.h"
0018 #include "player.h"
0019 
0020 Card::Card(int cardId)
0021     : QObject()
0022     , m_changed(false)
0023     , m_cardId(cardId)
0024     , m_owner(nullptr)
0025 {
0026 }
0027 
0028 Card::~Card()
0029 {
0030 }
0031 
0032 void Card::setTitle(const QString &title)
0033 {
0034     if (m_title != title)
0035     {
0036         m_title = title;
0037         m_changed = true;
0038     }
0039 }
0040 
0041 void Card::setOwner(Player *player)
0042 {
0043     if (m_owner != player)
0044     {
0045         m_owner = player;
0046         m_changed = true;
0047     }
0048 }
0049 
0050 void Card::update(bool force)
0051 {
0052     if (m_changed || force)
0053     {
0054         Q_EMIT changed(this);
0055         m_changed = false;
0056     }
0057 }
0058 
0059 #include "moc_card.cpp"