summaryrefslogtreecommitdiffstats
path: root/kbackgammon/engines/fibs/kplayerlist.h
blob: fb0bbd5f2e027ff0188d770b52a8e56b39f03320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/* Yo Emacs, this -*- C++ -*-

  Copyright (C) 1999-2001 Jens Hoefkens
  [email protected]

  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) any later version.

  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, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  $Id$

*/

#ifndef __KPLAYERLIST_H
#define __KPLAYERLIST_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <klistview.h>

class KTabCtl;
class KFibsPlayerListPrivate;

/**
 *
 * A class that keeps track of players on the server. The server is flooding
 * us with user information. At any given time we are able to have an current
 * list of all loged-in players and their status.
 *
 * @short The FIBS backgammon engine player list
 * @author Jens Hoefkens <[email protected]>
 *
 */
class KFibsPlayerList : public KListView
{
    Q_OBJECT
  

public:

    /**
     * Enumerate player status
     */
    enum PStatus {Ready, Away, Blind, MaxStatus};

    /**
     * Enumerate the different columns of the list
     */
    enum {Player, Opponent, Watches, Status, Rating, Experience,
          Idle, Time, Host, Client, Email, LVEnd};

    /**
     * Constructor
     */
    KFibsPlayerList(TQWidget *parent = 0, const char *name = 0);

    /**
     * Destructor
     */
    virtual ~KFibsPlayerList();

    /**
     * Clear the list and reset the client counter
     */
    virtual void clear();

public slots:

    /**
     * Remove the player with the name given by the first word
     */
    void deletePlayer(const TQString &player);

    /**
     * Change/Add the entry for the given player
     */
    void changePlayer(const TQString &line);

    /**
     * Enables list redraws after an update
     */
    void stopUpdate();

    /**
     * Read the UI settings from disk
     */
    void readConfig();

    /**
     * Read the column info from disk
     */
    void readColumns();

    /**
     * Restore settings from previously stored settings
     */
    void saveConfig();

    /**
     * Change the status of a player
     */
    void changePlayerStatus(const TQString &player, int stat, bool flag);

    /**
     * Fills the playerlist page into the notebook
     */
    virtual void getSetupPages(KTabCtl *nb, int space);

    /**
     * Save setting changes
     */
    void setupOk();

    /**
     * Setup changes have been cancelled
     */
    void setupCancel();

    /**
     * Set default settings
     */
    void setupDefault();

    /**
     * Set our own name. This allows us to special case the context
     * menu.
     */
    void setName(const TQString &name);

    /**
     * Return the column index
     */
    int cIndex(int col);

protected:

    /**
     * Catch show events, so the engine's menu can be update.
     */
    virtual void showEvent(TQShowEvent *e);

    /**
     * Catch hide events, so the engine's menu can be update.
     */
    virtual void hideEvent(TQHideEvent *e);

protected slots:

    /**
     * Double click handler, requests information on a player
     */
    void getPlayerInfo(TQListViewItem *i, const TQPoint &p, int col);

    /**
     * Display a popup menu for the current player
     */
    void showContextMenu(KListView *, TQListViewItem *, const TQPoint &);

    /**
     * Reload the whole list
     */
    void slotReload();

    /**
     * Upate the caption
     */
    void updateCaption();

    /**
     * Watch user
     */
    void slotWatch();

    /**
     * Update line of user
     */
    void slotUpdate();

    /**
     * Request information on user
     */
    void slotInfo();

    /**
     * Look at user
     */
    void slotLook();

    /**
     * Send an email to user
     */
    void slotMail();

    /**
     * Stop watching
     */
    void slotUnwatch();

    /**
     * Blind user
     */
    void slotBlind();

    /**
     * Talk to user
     */
    void slotTalk();

    /**
     * Invite using the dialog
     */
    void slotInviteD();

    /**
     * Invite to a 1 point match
     */
    void slotInvite1();

    /**
     * Invite to a 2 point match
     */
    void slotInvite2();

    /**
     * Invite to a 3 point match
     */
    void slotInvite3();

    /**
     * Invite to a 4 point match
     */
    void slotInvite4();

    /**
     * Invite to a 5 point match
     */
    void slotInvite5();

    /**
     * Invite to a 6 point match
     */
    void slotInvite6();

    /**
     * Invite to a 7 point match
     */
    void slotInvite7();

    /**
     * Invite to resume a saved match
     */
    void slotInviteR();

    /**
     * Invite to an unlimited match
     */
    void slotInviteU();

signals:

    /**
     * Send a command to the server
     */
    void fibsCommand(const TQString &);

    /**
     * Initiate an invitation of a player
     */
    void fibsInvite(const TQString &);

    /**
     * Request talking to player user
     */
    void fibsTalk(const TQString &);

    /**
     * Allow the engine's menu to be updated
     */
    void windowVisible(bool);

private:

    KFibsPlayerListPrivate *d;

};

#endif // __KPLAYERLIST_H