Fix problems from porting Qt3->Qt4, which were caused by introducing takeFirst()...
[vlp.git] / src / lgconfig / lgconfig.cpp
index 2ef36eddd25110516cf910af07609691b98f880f..58872ca4c0d5e8f2fdec39e213acc758abb1263d 100644 (file)
@@ -86,12 +86,12 @@ QInstall::QInstall()
 bool QInstall::check_id(int id)
 {
        VLPEntry *pom;
+       QListIterator<VLPEntry *> nodesIterator(Nodes);
 
-       pom = Nodes.first();
-       while (pom != NULL) {
+       while (nodesIterator.hasNext()) {
+               pom = nodesIterator.next();
                if (pom->ID == id)
                        return FALSE;
-               pom = Nodes.takeFirst();
        }
        return TRUE;
 }
@@ -99,12 +99,12 @@ bool QInstall::check_id(int id)
 bool QInstall::check_addr(char *addr)
 {
        VLPEntry *pom;
+       QListIterator<VLPEntry *> nodesIterator(Nodes);
 
-       pom = Nodes.first();
-       while (pom != NULL) {
+       while (nodesIterator.hasNext()) {
+               pom = nodesIterator.next();
                if (strcmp(pom->addr, addr) == 0)
                        return FALSE;
-               pom = Nodes.takeFirst();
        }
        return TRUE;
 }
@@ -213,11 +213,13 @@ void QInstall::DelNode()
 
        if (nodelist->currentItem() >= 0) {
                strcpy(pom, nodelist->text(nodelist->currentItem()).toStdString().c_str());
-               vpom = Nodes.first();
-               while (vpom != NULL) {
+
+               QListIterator<VLPEntry *> nodesIterator(Nodes);
+               
+               while (nodesIterator.hasNext()) {
+                       vpom = nodesIterator.next();
                        if (strcmp(pom, vpom->item) == 0)
                                break;
-                       vpom = Nodes.takeFirst();
                }
                if (vpom != NULL)
                        if (QMessageBox::question(this, "Delete VLP", "Are you sure?", "Yes", "No")) {
@@ -268,8 +270,10 @@ void QInstall::SetOptions()
 
        if (dlg.exec()) {
                if (!Nodes.isEmpty()) {
-                       pom = Nodes.first();
-                       while (pom != NULL) {
+                       QListIterator<VLPEntry *> nodesIterator(Nodes);
+                       
+                       while (nodesIterator.hasNext()) {
+                               pom = nodesIterator.next();
                                j = Nodes.indexOf(pom);
                                sprintf(pomstr, "%s.cfg", pom->addr);
 
@@ -320,7 +324,6 @@ void QInstall::SetOptions()
                                config_destroy(&cfg);
 
                                pom = Nodes.at(j);
-                               pom = Nodes.takeFirst();
                        }
                }
        }