| 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 | |
| 22 | |
| 23 | #include <QtWidgets> |
| 24 | #include "serverlistdialog.h"cxx . . $ `<file>/src/network/serverlistdialog.h`/ |
| 25 | |
| 26 | ServerListDialogcxx . . $ ServerListDialog#::ServerListDialogcxx . . $ ServerListDialog#ServerListDialog(f6882b3a6a0a2305).(stdcxx . . $ std/::vectorcxx . . $ std/vector# <ServerItemcxx . . $ ServerItem# *> serverlist, int current) |
| 27 | { |
| 28 | current_servercxx . . $ ServerListDialog#current_server. = current; |
| 29 | serverListViewcxx . . $ ServerListDialog#serverListView. = constructTreeWidgetcxx . . $ ServerListDialog#constructTreeWidget(7f22af2425832ef1).(serverlistcxx . . $ std/vector#vector(a1201200cf0efa42).); |
| 30 | |
| 31 | connectButtoncxx . . $ ServerListDialog#connectButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ ServerListDialog#tr(75d9f1c324b4579d).("Connect")); |
| 32 | connectButtoncxx . . $ ServerListDialog#connectButton.->setDefaultcxx . . $ QPushButton#setDefault(b45ddcbc8423892c).(true); |
| 33 | |
| 34 | cancelButtoncxx . . $ ServerListDialog#cancelButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ ServerListDialog#tr(75d9f1c324b4579d).("&Cancel")); |
| 35 | cancelButtoncxx . . $ ServerListDialog#cancelButton.->setAutoDefaultcxx . . $ QPushButton#setAutoDefault(b45ddcbc8423892c).(false); |
| 36 | |
| 37 | buttonBoxcxx . . $ ServerListDialog#buttonBox. = new QDialogButtonBoxcxx . . $ QDialogButtonBox#(Qtcxx . . $ Qt/::Horizontalcxx . . $ Qt/Horizontal.); |
| 38 | buttonBoxcxx . . $ ServerListDialog#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(cancelButtoncxx . . $ ServerListDialog#cancelButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.); |
| 39 | buttonBoxcxx . . $ ServerListDialog#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(connectButtoncxx . . $ ServerListDialog#connectButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.); |
| 40 | |
| 41 | connectcxx . . $ QObject#connect(835f87066c895669).(serverListViewcxx . . $ ServerListDialog#serverListView., &QTreeWidgetcxx . . $ QTreeWidget#::itemDoubleClickedcxx . . $ QTreeWidget#itemDoubleClicked(abbf99ae0f1fc9f0)., this, &ServerListDialogcxx . . $ ServerListDialog#::slot_listDoubleClickedcxx . . $ ServerListDialog#slot_listDoubleClicked(abbf99ae0f1fc9f0).); |
| 42 | |
| 43 | connectcxx . . $ QObject#connect(835f87066c895669).(connectButtoncxx . . $ ServerListDialog#connectButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &ServerListDialogcxx . . $ ServerListDialog#::slot_connectcxx . . $ ServerListDialog#slot_connect(49f6e7a06ebc5aa8).); |
| 44 | connectcxx . . $ QObject#connect(835f87066c895669).(cancelButtoncxx . . $ ServerListDialog#cancelButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &ServerListDialogcxx . . $ ServerListDialog#::slot_cancelcxx . . $ ServerListDialog#slot_cancel(49f6e7a06ebc5aa8).); |
| 45 | |
| 46 | QGridLayoutcxx . . $ QGridLayout# * mainLayout = new QGridLayoutcxx . . $ QGridLayout#; |
| 47 | mainLayout->setSizeConstraintcxx . . $ QLayout#setSizeConstraint(2d278d641bf12a66).(QLayoutcxx . . $ QLayout#::SetFixedSizecxx . . $ QLayout#SetFixedSize.); |
| 48 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(serverListViewcxx . . $ ServerListDialog#serverListView., 0, 0); |
| 49 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(buttonBoxcxx . . $ ServerListDialog#buttonBox., 1, 0); |
| 50 | setLayoutcxx . . $ QWidget#setLayout(23396b1058755fec).(mainLayout); |
| 51 | |
| 52 | setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(trcxx . . $ ServerListDialog#tr(75d9f1c324b4579d).("Choose server...")); |
| 53 | } |
| 54 | |
| 55 | ServerListDialogcxx . . $ ServerListDialog#::~cxx . . $ ServerListDialog#`~ServerListDialog`(ced63f7c635d850d).ServerListDialogcxx . . $ ServerListDialog#() |
| 56 | { |
| 57 | delete serverListViewcxx . . $ ServerListDialog#serverListView.; |
| 58 | delete connectButtoncxx . . $ ServerListDialog#connectButton.; |
| 59 | delete cancelButtoncxx . . $ ServerListDialog#cancelButton.; |
| 60 | delete buttonBoxcxx . . $ ServerListDialog#buttonBox.; |
| 61 | } |
| 62 | |
| 63 | QTreeWidgetcxx . . $ QTreeWidget# * ServerListDialogcxx . . $ ServerListDialog#::constructTreeWidgetcxx . . $ ServerListDialog#constructTreeWidget(7f22af2425832ef1).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<ServerItemcxx . . $ ServerItem# *> serverlist) |
| 64 | { |
| 65 | QTreeWidgetcxx . . $ QTreeWidget# * treeWidget = new QTreeWidgetcxx . . $ QTreeWidget#QTreeWidget(108f35f7aa7f3cf9).(this); |
| 66 | QTreeWidgetItemcxx . . $ QTreeWidgetItem# * i; |
| 67 | QStringListcxx . . $ QStringList# stringListcxx . . $ QStringList#QStringList(ced63f7c635d850d).; |
| 68 | int index = 0; |
| 69 | |
| 70 | treeWidget->setRootIsDecoratedcxx . . $ QTreeView#setRootIsDecorated(b45ddcbc8423892c).(false); |
| 71 | treeWidget->setColumnCountcxx . . $ QTreeWidget#setColumnCount(d4f767463ce0a6b3).(2); |
| 72 | stringList <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "Name"cxx . . $ QString#QString(85c52e162fed56f9). <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "IP Address"cxx . . $ QString#QString(85c52e162fed56f9).; |
| 73 | treeWidget->setHeaderLabelscxx . . $ QTreeWidget#setHeaderLabels(631c0101495f0328).(stringList); |
| 74 | stringList.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 75 | |
| 76 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<ServerItem *>::iteratorcxx . . $ std/vector#iterator# itcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 77 | for(it =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(d61c653a35fdd05a). serverlist.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). serverlist.endcxx . . $ std/vector#end(55a6de06420d4903).(); it++cxx . . $ __gnu_cxx/__normal_iterator#operator++(6cefca3db4774be2).) |
| 78 | { |
| 79 | stringList <<cxx . . $ QStringList#`operator<<`(85116071a693d053). (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it)->namecxx . . $ ServerItem#name. <<cxx . . $ QStringList#`operator<<`(85116071a693d053). (cxx . . $ QString#QString(85c52e162fed56f9).*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it)->ipaddresscxx . . $ ServerItem#ipaddress.; |
| 80 | i = new QTreeWidgetItemcxx . . $ QTreeWidgetItem#QTreeWidgetItem(c5673ccef502b3ed).(treeWidget, stringList); |
| 81 | if(index == current_servercxx . . $ ServerListDialog#current_server.) |
| 82 | i->setDisabledcxx . . $ QTreeWidgetItem#setDisabled(b45ddcbc8423892c).(true); |
| 83 | if(it ==cxx . . $ __gnu_cxx/`operator==`(30ee64f2df4eef8b). serverlist.begincxx . . $ std/vector#begin(55a6de06420d4903).()) //ugly but its a short list |
| 84 | treeWidget->setCurrentItemcxx . . $ QTreeWidget#setCurrentItem(7332f4628c1d1841).(i); |
| 85 | stringList.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 86 | index++; |
| 87 | } |
| 88 | return treeWidget; |
| 89 | } |
| 90 | |
| 91 | void ServerListDialogcxx . . $ ServerListDialog#::slot_listDoubleClickedcxx . . $ ServerListDialog#slot_listDoubleClicked(abbf99ae0f1fc9f0).(QTreeWidgetItemcxx . . $ QTreeWidgetItem# * i, int) |
| 92 | { |
| 93 | int index = serverListViewcxx . . $ ServerListDialog#serverListView.->indexOfTopLevelItemcxx . . $ QTreeWidget#indexOfTopLevelItem(c49126e84bb13168).(i); |
| 94 | if(index < 0 || index == current_servercxx . . $ ServerListDialog#current_server.) |
| 95 | return; |
| 96 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(index + 1); |
| 97 | } |
| 98 | |
| 99 | void ServerListDialogcxx . . $ ServerListDialog#::slot_connectcxx . . $ ServerListDialog#slot_connect(49f6e7a06ebc5aa8).(void) |
| 100 | { |
| 101 | QTreeWidgetItemcxx . . $ QTreeWidgetItem# * i = serverListViewcxx . . $ ServerListDialog#serverListView.->currentItemcxx . . $ QTreeWidget#currentItem(faf259b556e61ea0).(); |
| 102 | if(!i) |
| 103 | { |
| 104 | //FIXME error message necessary? |
| 105 | return; |
| 106 | } |
| 107 | int index = serverListViewcxx . . $ ServerListDialog#serverListView.->indexOfTopLevelItemcxx . . $ QTreeWidget#indexOfTopLevelItem(c49126e84bb13168).(i); |
| 108 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(index + 1); |
| 109 | } |
| 110 | |
| 111 | void ServerListDialogcxx . . $ ServerListDialog#::slot_cancelcxx . . $ ServerListDialog#slot_cancel(49f6e7a06ebc5aa8).(void) |
| 112 | { |
| 113 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Cancel"); |
| 114 | deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).(); |
| 115 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(QDialogcxx . . $ QDialog#::Rejectedcxx . . $ QDialog#Rejected.); |
| 116 | } |