#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <Qt3Support/q3multilineedit.h>
-#include <QtGui/QMenuBar>
-// #include <qpopmenu.h>
#include <QtGui/QDialog>
#include <QtGui/QButtonGroup>
#include <QtGui/QLabel>
#include <libconfig.h>
#include "lgconfig.h"
+#include "AddNodeDialog.h"
-QApplication *app;
+namespace loglan {
+namespace vlp {
QInstall::QInstall()
{
bool QInstall::check_id(int id)
{
- VLPEntry *pom;
+ VLPEntry *node;
QListIterator<VLPEntry *> nodesIterator(Nodes);
while (nodesIterator.hasNext()) {
- pom = nodesIterator.next();
- if (pom->ID == id)
+ node = nodesIterator.next();
+ if (node->ID == id)
return FALSE;
}
return TRUE;
bool QInstall::check_addr(char *addr)
{
- VLPEntry *pom;
+ VLPEntry *node;
QListIterator<VLPEntry *> nodesIterator(Nodes);
while (nodesIterator.hasNext()) {
- pom = nodesIterator.next();
- if (strcmp(pom->addr, addr) == 0)
+ node = nodesIterator.next();
+ if (strcmp(node->addr, addr) == 0)
return FALSE;
}
return TRUE;
void QInstall::AddNode()
{
- QDialog dlg(this);
- QLabel *tmpQLabel;
- QLineEdit *id, *addr, *progs, *home;
- QPushButton *okbtn, *cancelbtn;
- VLPEntry *pom;
- char pomstr[255];
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(110, 10, 180, 30);
- tmpQLabel->setFrameStyle(49);
- tmpQLabel->setText("Virtual Processor Properties");
-
- id = new QLineEdit(&dlg);
- id->setGeometry(130, 50, 50, 30);
- id->setText("");
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(20, 50, 90, 30);
- tmpQLabel->setText("Node number");
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(20, 90, 80, 30);
- tmpQLabel->setText("IP Address");
-
- addr = new QLineEdit(&dlg);
- addr->setGeometry(130, 90, 120, 30);
- addr->setText("");
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(20, 130, 100, 30);
- tmpQLabel->setText("Connection type");
-
- QComboBox* tmpQComboBox;
- tmpQComboBox = new QComboBox(&dlg);
- tmpQComboBox->setGeometry(130, 130, 100, 30);
- tmpQComboBox->insertItem(0, "Explicit");
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(20, 170, 110, 30);
- tmpQLabel->setText("Programs directory");
+ dialog::AddNodeDialog dialog(this);
- progs = new QLineEdit(&dlg);
- progs->setGeometry(130, 170, 230, 30);
- progs->setText("");
-
- tmpQLabel = new QLabel(&dlg);
- tmpQLabel->setGeometry(20, 210, 100, 30);
- tmpQLabel->setText("VLP directory");
-
- home = new QLineEdit(&dlg);
- home->setGeometry(130, 210, 230, 30);
- home->setText("");
+ VLPEntry *pom;
- okbtn = new QPushButton(&dlg);
- okbtn->setGeometry(80, 250, 100, 30);
- okbtn->setText("Ok");
- connect(okbtn,SIGNAL(clicked()), &dlg, SLOT(accept()));
- cancelbtn = new QPushButton(&dlg);
- cancelbtn->setGeometry(210, 250, 100, 30);
- cancelbtn->setText("Cancel");
- connect(cancelbtn,SIGNAL(clicked()), &dlg, SLOT(reject()));
- dlg.resize(380, 300);
- if (dlg.exec()) {
+ if (dialog.exec()) {
pom = new VLPEntry;
- pom->ID = id->text().toInt();
+ pom->ID = dialog.getNodeNumber();
if (check_id(pom->ID)) {
- strcpy(pom->addr, addr->text().toStdString().c_str());
+ strcpy(pom->addr, dialog.getIPAddress().toStdString().c_str());
if (check_addr(pom->addr)) {
- if (tmpQComboBox->currentText() == "Explicit") {
+ if (dialog.getConnectionType() == "Explicit") {
pom->type=0;
}
- strcpy(pom->progdir, progs->text().toStdString().c_str());
- strcpy(pom->homedir, home->text().toStdString().c_str());
+ strcpy(pom->progdir, dialog.getProgramsDirectory().toStdString().c_str());
+ strcpy(pom->homedir, dialog.getVLPDirectory().toStdString().c_str());
Nodes.append(pom);
- sprintf(pomstr, "Node: %d\t"
- "Addr: %s\t"
- "Home dir: %s", pom->ID, pom->addr, pom->homedir);
- nodelist->insertItem(pomstr);
- strcpy(pom->item, pomstr);
+
+ QString info;
+ info.sprintf("Node: %d\tAddr: %s\tHome dir: %s",
+ pom->ID, pom->addr, pom->homedir
+ );
+
+ nodelist->insertItem(info);
+ strcpy(pom->item, info.toStdString().c_str());
} else {
QMessageBox::warning(this, "Error!", "Only one VLP on a single computer!", "Ok");
}
QApplication::instance()->quit();
}
+}
+}
+
int main(int argc, char **argv)
{
- app = new QApplication(argc,argv);
- QInstall cfg;
+ QApplication *app = new QApplication(argc,argv);
+ loglan::vlp::QInstall cfg;
cfg.show();
return app->exec();
}