Ilya Moiseenko | 18c8a13 | 2013-10-24 01:52:52 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * @copyright See LICENCE for copyright and license information. |
| 4 | * |
| 5 | * @author Ilya Moiseenko <iliamo@ucla.edu> |
| 6 | */ |
| 7 | |
| 8 | #include "fib-input-dialog.h" |
| 9 | #include <QVBoxLayout> |
| 10 | #include <QHBoxLayout> |
| 11 | |
| 12 | FibInputDialog::FibInputDialog(QWidget *parent) |
| 13 | : QDialog(parent) |
| 14 | { |
| 15 | prefixLabel = new QLabel(tr("NDN name (prefix): ")); |
| 16 | prefixTextField = new QLineEdit; |
| 17 | prefixLabel->setBuddy(prefixTextField); |
| 18 | |
| 19 | tunnelLabel = new QLabel(tr("Tunnel type: ")); |
| 20 | tunnelComboBox = new QComboBox; |
| 21 | tunnelComboBox->addItem(tr("TCP")); |
| 22 | tunnelComboBox->addItem(tr("UDP")); |
| 23 | tunnelComboBox->setEditable(false); |
| 24 | tunnelComboBox->setCurrentIndex(0); |
| 25 | |
| 26 | endpointLabel = new QLabel(tr("Endpoint (IP address): ")); |
| 27 | endpointTextField = new QLineEdit; |
| 28 | endpointLabel->setBuddy(endpointTextField); |
| 29 | |
| 30 | okButton = new QPushButton(tr("&Ok")); |
| 31 | cancelButton = new QPushButton(tr("&Cancel")); |
| 32 | |
| 33 | connect(okButton,SIGNAL(pressed()), parent, SLOT(addFibEntry())); |
| 34 | connect(cancelButton,SIGNAL(pressed()), this, SLOT(hide())); |
| 35 | |
| 36 | buttonBox = new QDialogButtonBox(Qt::Horizontal); |
| 37 | buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole); |
| 38 | buttonBox->addButton(okButton, QDialogButtonBox::ActionRole); |
| 39 | |
| 40 | QHBoxLayout *hlayout = new QHBoxLayout; |
| 41 | hlayout->addWidget(tunnelLabel); |
| 42 | hlayout->addWidget(tunnelComboBox); |
| 43 | |
| 44 | QVBoxLayout *layout = new QVBoxLayout; |
| 45 | layout->addWidget(prefixLabel); |
| 46 | layout->addWidget(prefixTextField); |
| 47 | layout->addLayout(hlayout); |
| 48 | layout->addWidget(endpointLabel); |
| 49 | layout->addWidget(endpointTextField); |
| 50 | layout->addWidget(buttonBox); |
| 51 | |
| 52 | setLayout(layout); |
| 53 | |
| 54 | setWindowTitle(tr("NDNx Control Center")); |
| 55 | } |
| 56 | |
| 57 | QString |
| 58 | FibInputDialog::getPrefixName() |
| 59 | { |
| 60 | return prefixTextField->text(); |
| 61 | } |
| 62 | |
| 63 | QString |
| 64 | FibInputDialog::getEndpoint() |
| 65 | { |
| 66 | return endpointTextField->text(); |
| 67 | } |
| 68 | |
| 69 | QString |
| 70 | FibInputDialog::getTunnelType() |
| 71 | { |
| 72 | return tunnelComboBox->currentText(); |
| 73 | } |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 74 | |
Ilya Moiseenko | 69abb97 | 2013-11-04 16:02:20 -0800 | [diff] [blame] | 75 | void |
| 76 | FibInputDialog::clear() |
| 77 | { |
| 78 | prefixTextField->setText(""); |
| 79 | tunnelComboBox->setCurrentIndex(0); |
| 80 | endpointTextField->setText(""); |
| 81 | } |
| 82 | |
Alexander Afanasyev | a822b57 | 2013-11-04 12:36:34 -0800 | [diff] [blame] | 83 | #if WAF |
| 84 | #include "fib-input-dialog.moc" |
| 85 | #include "fib-input-dialog.cpp.moc" |
| 86 | #endif |