File indexing completed on 2024-04-21 15:08:03
0001 // Copyright (c) 2002 Rob Kaper <cap@capsi.com> 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 #ifndef TRADEWIDGET_H 0018 #define TRADEWIDGET_H 0019 0020 #include <QDialog> 0021 #include <QMap> 0022 0023 #include "libatlantikui_export.h" 0024 0025 class QComboBox; 0026 class QLabel; 0027 class QGroupBox; 0028 class QPushButton; 0029 class QSpinBox; 0030 class QTreeWidget; 0031 class QTreeWidgetItem; 0032 0033 class AtlanticCore; 0034 class Card; 0035 class Estate; 0036 class Player; 0037 class Trade; 0038 class TradeItem; 0039 0040 class LIBATLANTIKUI_EXPORT TradeDisplay : public QDialog 0041 { 0042 Q_OBJECT 0043 0044 public: 0045 TradeDisplay(Trade *trade, AtlanticCore *atlanticCore, QWidget *parent=nullptr); 0046 0047 Trade *trade() const { return m_trade; } 0048 0049 protected: 0050 void closeEvent(QCloseEvent *e) override; 0051 0052 private Q_SLOTS: 0053 void tradeItemAdded(TradeItem *); 0054 void tradeItemRemoved(TradeItem *); 0055 void tradeItemChanged(TradeItem *); 0056 void tradeChanged(); 0057 void playerChanged(Player *player); 0058 void tradeRejected(Player *); 0059 void slotPlayerAdded(Player *player); 0060 void slotPlayerRemoved(Player *player); 0061 void slotAcceptChanged(Player *player, bool accept); 0062 0063 void setTypeCombo(int); 0064 void setEstateCombo(int); 0065 void setCardCombo(int); 0066 void setCombos(QTreeWidgetItem *i); 0067 0068 void updateComponent(); 0069 void reject() override; 0070 void accept() override; 0071 0072 void contextMenu(const QPoint& pos); 0073 void contextMenuClickedRemove(); 0074 0075 Q_SIGNALS: 0076 void updateEstate(Trade *trade, Estate *estate, Player *to); 0077 void updateMoney(Trade *trade, unsigned int money, Player *from, Player *to); 0078 void updateCard(Trade *trade, Card *card, Player *to); 0079 void reject(Trade *trade); 0080 void accept(Trade *trade); 0081 0082 private: 0083 QGroupBox *m_updateComponentBox; 0084 QLabel *m_status, *m_fromLabel, *m_toLabel; 0085 QSpinBox *m_moneyBox; 0086 0087 QComboBox *m_editTypeCombo, *m_playerFromCombo, *m_playerTargetCombo, *m_estateCombo, *m_cardCombo; 0088 QTreeWidget *m_componentList; 0089 QPushButton *m_updateButton, *m_rejectButton, *m_acceptButton; 0090 QTreeWidget *m_participantsList; 0091 0092 AtlanticCore *m_atlanticCore; 0093 Trade *m_trade; 0094 TradeItem *m_contextTradeItem; 0095 0096 // TODO: Wouldn't QPair make more sense here? 0097 QMap<TradeItem *, QTreeWidgetItem *> m_componentMap; 0098 QMap<QTreeWidgetItem *, TradeItem *> m_componentRevMap; 0099 QMap<int, Estate *> m_estateMap; 0100 QMap<Estate *, int> m_estateRevMap; 0101 QMap<int, Player *> m_playerFromMap, m_playerTargetMap; 0102 QMap<Player *, int> m_playerFromRevMap, m_playerTargetRevMap; 0103 QMap<int, Card *> m_cardMap; 0104 QMap<Card *, int> m_cardRevMap; 0105 QMap<Player *, QTreeWidgetItem *> m_playerListMap; 0106 }; 0107 0108 #endif