1 /*****************************************************************************
2 * PokerTH - The open source texas holdem engine *
3 * Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU Affero General Public License as *
7 * published by the Free Software Foundation, either version 3 of the *
8 * 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 Affero General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Affero General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 * *
18 * *
19 * Additional permission under GNU AGPL version 3 section 7 *
20 * *
21 * If you modify this program, or any covered work, by linking or *
22 * combining it with the OpenSSL project's OpenSSL library (or a *
23 * modified version of that library), containing parts covered by the *
24 * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
25 * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
26 * permission to convey the resulting work. *
27 * Corresponding Source for a non-source form of such a combination *
28 * shall include the source code for the parts of OpenSSL used as well *
29 * as that of the covered work. *
30 *****************************************************************************/
31 #include "manualblindsorderdialogimpl.h"
32 #include "configfile.h"
33 #include "mymessagebox.h"
34 #include <iostream>
35
36
manualBlindsOrderDialogImpl(QWidget * parent,ConfigFile * c)37 manualBlindsOrderDialogImpl::manualBlindsOrderDialogImpl(QWidget *parent, ConfigFile *c)
38 : QDialog(parent), myConfig(c), settingsCorrect(true)
39 {
40 #ifdef __APPLE__
41 setWindowModality(Qt::ApplicationModal);
42 setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
43 #endif
44 setupUi(this);
45 #ifdef ANDROID
46 this->setWindowState(Qt::WindowFullScreen);
47 #endif
48 connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) );
49 connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) );
50
51 }
52
exec()53 int manualBlindsOrderDialogImpl::exec()
54 {
55 return QDialog::exec();
56 }
57
58
addBlindValueToList()59 void manualBlindsOrderDialogImpl::addBlindValueToList()
60 {
61
62 if(listWidget_blinds->count() == 30) {
63 MyMessageBox::warning(this, tr("Manual Blinds Order"),
64 tr("You cannot set more than 30 manual blinds."),
65 QMessageBox::Close);
66 } else {
67 listWidget_blinds->addItem(QString::number(spinBox_input->value(),10));
68 sortBlindsList();
69 }
70 }
71
removeBlindFromList()72 void manualBlindsOrderDialogImpl::removeBlindFromList()
73 {
74
75 listWidget_blinds->takeItem(listWidget_blinds->currentRow());
76 sortBlindsList();
77 }
78
sortBlindsList()79 void manualBlindsOrderDialogImpl::sortBlindsList()
80 {
81
82 int i;
83 QList<int> tempIntList;
84 QStringList tempStringList;
85 bool ok = true;
86
87 for(i=0; i<listWidget_blinds->count(); i++) {
88 // std::cout << listWidget_blinds->item(i)->text().toInt(&ok,10) << "\n";
89 tempIntList << listWidget_blinds->item(i)->text().toInt(&ok,10);
90 }
91
92 qStableSort(tempIntList.begin(), tempIntList.end());
93 //
94 for(i=0; i<tempIntList.count(); i++) {
95 //
96 // std::cout << tempIntList[i] << "\n";
97 tempStringList << QString::number(tempIntList[i],10);
98 }
99 //
100 listWidget_blinds->clear();
101 listWidget_blinds->addItems(tempStringList);
102 }
103