1 /**************************************************************
3 Copyright (C) 2013 Rafał Długołęcki
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 NOTE: This software is using the free software license of
23 the QT library v.1.30 from Troll Tech AS.
24 See the file LICENSE.QT.
26 ************************************************************/
28 #ifndef VLP_OPTIONS_DIALOG_H
29 #define VLP_OPTIONS_DIALOG_H
31 #include <QtGui/QDialog>
32 #include <QtCore/QString>
35 #include "ui/dialogs/options.h"
39 * Class responsible for displaying dialog with VLP configuration
41 class OptionsDialog : public QDialog, private Ui::optionsDialog {
45 * Constructs an OptionsDialog with parent 'parent'.
46 * The widget flags f are passed on to the QWidget constructor.
48 * @param parent parent widget of this dialog
49 * @param flags QDialog flags of this dialog
51 OptionsDialog(QWidget * parent = 0, Qt::WindowFlags flags = 0) :
52 QDialog(parent, flags)
55 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
56 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
60 * Returns entered in dialog node number
61 * @return node number from this dialog textfield
65 return atoi(nodeNumber->text().toAscii().data());
69 * Sets default node number
70 * @param number node number which will be set in textfield
72 void setDefaultNodeNumber(int number)
74 QString str = QString::number(number);
75 nodeNumber->setText(str);
79 * Returns entered in dialog message
80 * @return message from this dialog textarea
82 QString getConnectionType()
84 /* QtDesigner 4.5 does not have QButtonGroup. This is temporary
85 * code to check correct setting
87 return explicit_2->isChecked() ?
88 explicit_2->text() : registration->text();
92 * Returns entire widget QListView containing connections list.
93 * Use it for get entered by user connections
94 * @return QListView pointer containing list of connections
96 QListWidget * getConnectionList()
102 * Returns entered in dialog Programs Directory
103 * @return programs directory
105 QString getProgramsDirectory()
107 return programsDirectory->text();
111 * Sets default node number
112 * @param directory programs direcotry which will be set in textfield
114 void setDefaultProgramsDirectory(QString directory)
116 programsDirectory->setText(directory);
120 * Adds given ConnectEntry data to the dialog QListView
121 * @param entry ConnectEntry to add to list of connections
123 void addConnection(ConnectEntry *entry) {
124 connections->addItem(entry->addr);
129 * Adds IP address to the configuration.
130 * Additional window is displayed to add address to the list
132 void on_addConnection_clicked()
134 QDialog dialog(this, Qt::Dialog);
135 QLabel lab("IP Address:", &dialog);
136 QLineEdit ed("", &dialog);
137 QPushButton ok("Ok", &dialog);
138 QPushButton cancel("Cancel", &dialog);
140 ok.setGeometry(30, 60, 80, 30);
142 lab.setGeometry(10, 10, 60, 30);
143 ed.setGeometry(70, 10, 140, 30);
144 cancel.setGeometry(130, 60, 80, 30);
145 dialog.resize(240, 100);
147 connect(&ok, SIGNAL(clicked()), &dialog, SLOT(accept()));
148 connect(&cancel, SIGNAL(clicked()), &dialog, SLOT(reject()));
151 if (strcmp(ed.text().toAscii().data(), "") != 0) {
152 connections->addItem(ed.text());
159 * Deletes current address from available connections.
161 void on_deleteConnection_clicked()
163 int row = connections->currentRow();
165 delete connections->item(row);
171 #endif /* VLP_OPTIONS_DIALOG_H */