| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009- by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | #ifndef CONNECTIONWIDGET_H |
| 22 | #define CONNECTIONWIDGET_H |
| 23 | |
| 24 | #include "defines.h" |
| 25 | |
| 26 | #include <QWidget> |
| 27 | #include <QtWidgets> |
| 28 | |
| 29 | class RoomListing; |
| 30 | class NetworkConnection; |
| 31 | class Talk; |
| 32 | class ChannelListing; |
| 33 | class GameDialog; |
| 34 | class PlayerListing; |
| 35 | class Room; |
| 36 | class PlayerListSortFilterProxyModel; |
| 37 | class GamesListSortFilterProxyModel; |
| 38 | |
| 39 | namespace Ui { |
| 40 | class ConnectionWidget; |
| 41 | } |
| 42 | |
| 43 | /* This class should probably be merged into Room */ |
| 44 | class ConnectionWidget : public QWidget |
| 45 | { |
| 46 | Q_OBJECT |
| 47 | |
| 48 | public: |
| 49 | explicit ConnectionWidget(QWidget *parent = 0); |
| 50 | ~ConnectionWidget(); |
| 51 | |
| 52 | void onConnectionError(void); |
| 53 | void set_sessionparameter(QString par, bool val); |
| 54 | |
| 55 | void recvSeekCondition(class SeekCondition * s); |
| 56 | void recvSeekCancel(void); |
| 57 | void recvSeekPlayer(QString player, QString condition); |
| 58 | void recvRoomListing(const RoomListing & room, bool b); |
| 59 | void recvChannelListing(const ChannelListing & channel, bool b); |
| 60 | void changeChannel(const QString & s); |
| 61 | void setNetworkConnection(NetworkConnection *); |
| 62 | |
| 63 | int closeConnection(bool error = false); |
| 64 | |
| 65 | /* Ugly hack, need a unique function |
| 66 | * that is called when connection is established */ |
| 67 | bool isConnected(void); |
| 68 | void setupButtons(void); |
| 69 | |
| 70 | protected: |
| 71 | friend class Room; |
| 72 | Room * room; |
| 73 | PlayerListSortFilterProxyModel * playerListProxyModel; |
| 74 | GamesListSortFilterProxyModel * gamesListProxyModel; |
| 75 | |
| 76 | public: |
| 77 | void loadConnectionSettings(void); |
| 78 | void disconnectFromServer(void); |
| 79 | //void slot_textReceived(const QString &txt); |
| 80 | void slot_message(QString, QColor = Qt::black); |
| 81 | // void slot_message(QString txt); |
| 82 | void slot_createRoom(void); |
| 83 | void slot_changeServer(void); |
| 84 | void set_tn_ready(); |
| 85 | //void slot_sendCommand(const QString &, bool); |
| 86 | // void slot_cmdactivated_int(int); |
| 87 | void slot_cmdactivated(const QString&); |
| 88 | void slot_checkbox(int, bool); |
| 89 | |
| 90 | void slot_roomListClicked(const QString &); |
| 91 | void slot_channelListClicked(const QString &); |
| 92 | void slot_seek(bool); |
| 93 | void slot_seek(QAction *); |
| 94 | void talkOpened(Talk * d); |
| 95 | void setLooking(bool val); |
| 96 | void slot_cbopen(); |
| 97 | void slot_cbquiet(); |
| 98 | |
| 99 | void slot_msgBox(const QString&); |
| 100 | void slot_connexionClosed(); |
| 101 | |
| 102 | private: |
| 103 | void setRankSpreadView(void); |
| 104 | void slot_editFriendsWatchesList(void); |
| 105 | |
| 106 | private: |
| 107 | Ui::ConnectionWidget *ui; |
| 108 | |
| 109 | void cleanupServerData(void); |
| 110 | bool youhavemsg; |
| 111 | bool playerListEmpty; |
| 112 | // bool gamesListEmpty; |
| 113 | bool autoAwayMessage; |
| 114 | // cmd_xx get current cmd number, and, if higher than last, cmd is valid, |
| 115 | // else cmd is from history list |
| 116 | int cmd_count; |
| 117 | bool cmd_valid; |
| 118 | |
| 119 | // telnet ready |
| 120 | bool tn_ready; |
| 121 | bool tn_wait_for_tn_ready; |
| 122 | NetworkConnection * connection; |
| 123 | QMenu *seekMenu; |
| 124 | QList<GameDialog*> matchList; |
| 125 | QList<const RoomListing *> roomList; |
| 126 | QList<const ChannelListing *> channelList; |
| 127 | int seekButtonTimer; |
| 128 | |
| 129 | //players table |
| 130 | void showOpen(bool show); |
| 131 | void setColumnsForExtUserInfo(); |
| 132 | QString rkMax, rkMin; |
| 133 | |
| 134 | // timing aids |
| 135 | void timerEvent(QTimerEvent*); |
| 136 | QDateTime connectionEstablished; // online time |
| 137 | }; |
| 138 | |
| 139 | #endif // CONNECTIONWIDGET_H |