File indexing completed on 2024-10-13 03:46:00
0001 /* 0002 This file is part of the KDE games lskat program 0003 SPDX-FileCopyrightText: 2006 Martin Heni <kde@heni-online.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef CONFIG_TWO_H 0009 #define CONFIG_TWO_H 0010 0011 // Qt includes 0012 #include <QHash> 0013 0014 // KF includes 0015 #include <KConfig> 0016 0017 // local includes 0018 #include "abstractinput.h" 0019 #include "lskat_debug.h" 0020 #include "player.h" 0021 0022 // Forward declaration 0023 0024 using namespace InputDevice; 0025 0026 /** 0027 * LSkat game configuration 0028 */ 0029 class ConfigTwo : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 /** 0035 * Constructor for the config 0036 * @param parent The parent object 0037 */ 0038 explicit ConfigTwo(QObject *parent); 0039 0040 /** 0041 * Destructor 0042 */ 0043 ~ConfigTwo() override; 0044 0045 /** 0046 * Reset the config data. 0047 */ 0048 void reset(); 0049 0050 /** 0051 * Retrieve hash iterator over players. 0052 * @return The iterator. 0053 */ 0054 QHashIterator<int, Player *> playerIterator(); 0055 0056 /** 0057 * Retrieve a player. 0058 * @param no The player number 0059 * @return The player. 0060 */ 0061 Player *player(int no); 0062 0063 /** 0064 * Retrieve input type of given player. 0065 * @param no The player number 0066 * @return The input type. 0067 */ 0068 InputDeviceType inputType(int no); 0069 0070 /** 0071 * Set the input type for a given players. 0072 * @param no The player number 0073 * @param type The input type 0074 */ 0075 void setInputType(int no, InputDeviceType type); 0076 0077 /** 0078 * Saves the properties 0079 * @param cfg The config object. 0080 */ 0081 void save(KConfig *cfg); 0082 0083 /** 0084 * Read properties. 0085 * @param cfg The config object. 0086 */ 0087 void load(KConfig *cfg); 0088 0089 Q_SIGNALS: 0090 /** 0091 * Signal emitted when input type changes. 0092 * @param no The player number 0093 * @param type The input type 0094 */ 0095 void signalInputType(int no, InputDeviceType type); 0096 0097 private: 0098 // Current player 0099 QHash<int, Player *> mPlayers; 0100 // Input types 0101 QHash<int, InputDeviceType> mInputTypes; 0102 }; 0103 0104 #endif