serversstatuswidget.h
1 //------------------------------------------------------------------------------
2 // serversstatuswidget.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __SERVERSSTATUSWIDGET_H__
25 #define __SERVERSSTATUSWIDGET_H__
26 
27 #include "serverapi/serverptr.h"
28 #include <QLabel>
29 
30 class EnginePlugin;
31 class MasterClient;
32 class Server;
33 class ServerList;
35 struct ServerListCount;
36 
37 class ServersStatusWidget : public QLabel
38 {
39  Q_OBJECT
40 
41  public:
42  ServersStatusWidget(const EnginePlugin *plugin, const ServerList *serverList);
43 
44  const ServerListCount &count() const;
45 
46  public slots:
54  void setMasterEnabledStatus(bool bEnabled);
55  void updateDisplay();
56 
57  signals:
58  void clicked(const EnginePlugin* plugin);
59  void counterUpdated();
60 
61  private:
62  void mousePressEvent(QMouseEvent* event);
63  void paintEvent(QPaintEvent *event);
64  void registerServer(ServerPtr server);
65  QString refreshedPercentAsText() const;
66 
67  bool enabled;
68  QPixmap icon;
69  QPixmap iconDisabled;
70  ServerListCountTracker *countTracker;
71  const EnginePlugin *plugin;
72  const ServerList *serverList;
73 
74  private slots:
75  void deregisterServerIfSamePlugin(const ServerPtr &server);
76  void registerServerIfSamePlugin(ServerPtr server);
77 };
78 
79 #endif /* __SERVERSSTATUSWIDGET_H__ */
A representation of a server for a given game.
Definition: server.h:93
void setMasterEnabledStatus(bool bEnabled)
Changes the appearance of the widget basing on the boolean value.
Abstract base for all MasterClients.
Definition: masterclient.h:49