bool QInstall::check_id(int id)
{
- VLPEntry *node;
QListIterator<VLPEntry *> nodesIterator(Nodes);
+ VLPEntry *node = NULL;
while (nodesIterator.hasNext()) {
node = nodesIterator.next();
if (node->ID == id)
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-bool QInstall::check_addr(char *addr)
+bool QInstall::check_addr(QString addr)
{
- VLPEntry *node;
QListIterator<VLPEntry *> nodesIterator(Nodes);
+ VLPEntry *node = NULL;
while (nodesIterator.hasNext()) {
node = nodesIterator.next();
- if (strcmp(node->addr, addr) == 0)
- return FALSE;
+ if (node->addr == addr)
+ return false;
}
- return TRUE;
+ return true;
}
void QInstall::AddNode()
{
dialog::AddNodeDialog dialog(this);
- VLPEntry *pom;
-
if (dialog.exec()) {
- pom = new VLPEntry;
- pom->ID = dialog.getNodeNumber();
- if (check_id(pom->ID)) {
- strcpy(pom->addr, dialog.getIPAddress().toStdString().c_str());
- if (check_addr(pom->addr)) {
+ int nodeId = dialog.getNodeNumber();
+ QString ipAddress = dialog.getIPAddress();
+ if (check_id(nodeId)) {
+ if (check_addr(ipAddress)) {
+
+ VLPEntry *pom = new VLPEntry;
+ pom->ID = nodeId;
if (dialog.getConnectionType() == "Explicit") {
- pom->type=0;
+ pom->type = 0;
}
+ strcpy(pom->addr, ipAddress.toStdString().c_str());
strcpy(pom->progdir, dialog.getProgramsDirectory().toStdString().c_str());
strcpy(pom->homedir, dialog.getVLPDirectory().toStdString().c_str());
- Nodes.append(pom);
QString info;
info.sprintf("Node: %d\tAddr: %s\tHome dir: %s",
- pom->ID, pom->addr, pom->homedir
+ 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");
+
+ nodelist->insertItem(info);
+ Nodes.append(pom);
}
- } else {
- QMessageBox::warning(this, "Error!", "ID must be unique!", "Ok");
+ else {
+ QMessageBox::warning(this, "Error!", "Only one VLP on a single computer!", QMessageBox::Ok);
+ }
+ }
+ else {
+ QMessageBox::warning(this, "Error!", "ID must be unique!", QMessageBox::Ok);
}
}
}
void QInstall::DelNode()
{
- char pom[255];
- VLPEntry *vpom;
-
if (nodelist->currentItem() >= 0) {
- strcpy(pom, nodelist->text(nodelist->currentItem()).toStdString().c_str());
+ VLPEntry *node = NULL;
+ QString currentNodeInfo = nodelist->text(nodelist->currentItem());
QListIterator<VLPEntry *> nodesIterator(Nodes);
while (nodesIterator.hasNext()) {
- vpom = nodesIterator.next();
- if (strcmp(pom, vpom->item) == 0)
+ node = nodesIterator.next();
+ if (currentNodeInfo == node->item) {
break;
+ }
}
- if (vpom != NULL)
- if (QMessageBox::question(this, "Delete VLP", "Are you sure?", "Yes", "No")) {
+
+ if (node != NULL) {
+ if (QMessageBox::question(this,
+ "Delete VLP",
+ "Are you sure?",
+ QMessageBox::Ok | QMessageBox::Cancel
+ ) == QMessageBox::Ok) {
nodelist->removeItem(nodelist->currentItem());
- Nodes.removeOne(vpom);
+ Nodes.removeOne(node);
}
+ }
}
}
if (dlg.exec()) {
if (!Nodes.isEmpty()) {
QListIterator<VLPEntry *> nodesIterator(Nodes);
-
+
while (nodesIterator.hasNext()) {
pom = nodesIterator.next();
i = Nodes.indexOf(pom);