Seite 1 von 1

[gelöst] und wieder XML problem :)

Verfasst: 29. April 2005 13:05
von ChMaster
moin zusammen,

habe da mal wieder ein problemchen :roll:

wenn ich hier ein Item auswähle, liest er die endsprechende datei, funktioniert auch aber,

Code: Alles auswählen

QString log, dart, exc, pryd, car, orc, ava, broc, lyo, sto, ys, cam;
     
log.append("keep-xml/de/logres/keeps.xml");
dart.append("keep-xml/de/dartmoor/keeps.xml");     
exc.append("keep-xml/en/excalibur/keeps.xml");
pryd.append("keep-xml/en/prydwen/keeps.xml");     
car.append("keep-xml/fr/carnac/keeps.xml");
orc.append("keep-xml/fr/orcanie/keeps.xml");     
ava.append("keep-xml/full/avalon/keeps.xml");
broc.append("keep-xml/full/broceliande/keeps.xml");
lyo.append("keep-xml/full/lyonesse/keeps.xml");
sto.append("keep-xml/full/stonehenge/keeps.xml");
ys.append("keep-xml/full/ys/keeps.xml");     
cam.append("keep-xml/pvp/keeps.xml");
     
QListViewItemIterator it( listView_Server );
	while( it.current() ){
		if ( listView_Server->currentItem()->text(0) == de_logres ){
			slotListViewFill( log );
		}else if ( listView_Server->currentItem()->text(0) == de_dartmoor ){
			slotListViewFill( dart );
		}else if ( listView_Server->currentItem()->text(0) == en_excalibur ){
			slotListViewFill( exc );
		}else if ( listView_Server->currentItem()->text(0) == en_prydwen ){
			slotListViewFill( pryd );
		}else if ( listView_Server->currentItem()->text(0) == fr_carnac ){
			slotListViewFill( car );
		}else if ( listView_Server->currentItem()->text(0) == fr_orcanie ){
			slotListViewFill( orc );
		}else if ( listView_Server->currentItem()->text(0) == full_avalon ){
			slotListViewFill( ava );
		}else if ( listView_Server->currentItem()->text(0) == full_broceliande ){
			slotListViewFill( broc );
		}else if ( listView_Server->currentItem()->text(0) == full_lyonesse ){
			slotListViewFill( lyo );
		}else if ( listView_Server->currentItem()->text(0) == full_stonehenge ){
			slotListViewFill( sto );
		}else if ( listView_Server->currentItem()->text(0) == full_ys ){
			slotListViewFill( ys );
		}else if ( listView_Server->currentItem()->text(0) == pvp_camlann ){
			slotListViewFill( cam );
		}else{
			++it;
		}
	}
hier mag er anscheinend mich nicht, warum? ist doch soweit alles in ordnung oder doch nicht? (genau hier hängt mein Programm , ich weiss
nicht warum :()

Code: Alles auswählen

QListViewItem *item;
item = new QListViewItem( listView_KeepInfo );

item->setOpen( true );

QFile xmlKeep( fileName );
QDomDocument doc;
doc.setContent( &xmlKeep );
xmlKeep.close();

QDomNode node = doc.documentElement().firstChild();
while ( !node.isNull() ) {
         if ( node.toElement().tagName() == "keep" ){
            item->setText( 0, node.toElement().attribute( "id" ) );
            item->setText( 1, node.toElement().attribute( "guild" ) );
            item->setText( 2, node.toElement().attribute( "guildname" ) );
            item->setText( 3, node.toElement().attribute( "orig_realm" ) );
            item->setText( 4, node.toElement().attribute( "realm" ) );
            item->setText( 5, node.toElement().attribute( "relic" ) );
	 }
	 node = node.nextSibling();
}

Re: und wieder XML problem :)

Verfasst: 29. April 2005 15:34
von Goos
ChMaster hat geschrieben:hier mag er anscheinend mich nicht
Hehe, das ist ja mal ne schnuckelige Fehlermeldung. Dein Compiler hat dir wirklich gesagt, dass er dich nicht mag? :D :D :D
Vielleicht solltest doch etwas naeher darauf eingehen, was genau nicht funktioniert und welche Fehlermeldungen du bekommst.

Goos

Verfasst: 29. April 2005 15:37
von ChMaster
ja so in etwa (ist mein gedanke-keine fehlermeldung)

mein programm hängt sich einfach auf, das öffnen der jeweiligen datei
funktioniert (mit QMessageBox getestet), also liegt es nicht am öffnen
der datei. sondern beim auslesen :(, ich weiss nicht woran das liegen
könnte??

Verfasst: 29. April 2005 15:55
von Goos
Ok, was hast schon so alles probiert?
Deine item->setText() Zeilen mal rausgenommen?
Ueberprueft, ob dein XML-File auch passt?
Evtl. nen Zaehler ueber deine Nodes eingebaut und mal ausgegeben?

Goos

Verfasst: 29. April 2005 15:57
von ChMaster
die datei stimmt (name) und die datei ist auch vorhanden.
item->setText() rausgenommen und hängt sich drotzdem auf??
zähler? ich versteh, aber wie :(

Verfasst: 29. April 2005 15:59
von Goos
Ok, dann mach hinne ;)

Goos

Verfasst: 29. April 2005 16:39
von ChMaster
Goos hat geschrieben:Ok, dann mach hinne ;)

Goos
bin ja schon dabei sieh oben :)
habs net so mit zähl schleifen :roll:
habs so gemacht neues item in der schleife angelegt:
funktioniert drotzdem net ... (habe auch das item->setText() rusgenommen, siehe post oben)

Code: Alles auswählen

    QListViewItem *item;

    //item->setOpen( true );

    QFile xmlKeep( fileName );
    QDomDocument doc;
    doc.setContent( &xmlKeep );
    xmlKeep.close();

    QDomNode node = doc.documentElement().firstChild();
    while ( !node.isNull() ) {
		item = new QListViewItem( listView_KeepInfo );
        if ( node.toElement().tagName() == "keep" ){            
            item->setText( 0, node.toElement().attribute( "id" ) );
            item->setText( 1, node.toElement().attribute( "guild" ) );
            item->setText( 2, node.toElement().attribute( "guildname" ) );
            item->setText( 3, node.toElement().attribute( "orig_realm" ) );
            item->setText( 4, node.toElement().attribute( "realm" ) );
            item->setText( 5, node.toElement().attribute( "relic" ) );
		}
        listView_KeepInfo->insertItem( item );
        node = node.nextSibling();
	}

Verfasst: 29. April 2005 16:41
von Goos
Na einfach mal nen Zaehler in deine while Schleife einbauen und jeweils per Messagebox ausgeben lassen. Dann siehst wenigstens mal ob die Anzahl der Schleifendurchlaeufe mit der deiner Knoten im XML-File uebereinstimmt.

Goos

Verfasst: 29. April 2005 16:43
von Goos
ChMaster hat geschrieben: habs so gemacht neues item in der schleife angelegt:
funktioniert drotzdem net ... (habe auch das item->setText() rusgenommen, siehe post oben)
Wenn das herausnehmen deiner item-> usw. Zeilen nix gebracht hat, dann aendert es sicher auch nichts, wenn du in der Schleife neue Items anlegst ;)

Goos

Verfasst: 29. April 2005 16:45
von Goos
Wieso bist du dir eigentlich so sicher, dass es genau an der von dir geposteten Stelle haengt?

Goos

Verfasst: 29. April 2005 16:55
von ChMaster
Goos hat geschrieben:Wieso bist du dir eigentlich so sicher, dass es genau an der von dir geposteten Stelle haengt?

Goos
bin ich mir nicht, aber so wie ich es jetzt beim debugen erfahren habe
liest er sie immer wieder aus ??? wird wohl beim selectieren der items
in der listview sein ...

Verfasst: 29. April 2005 17:00
von ChMaster
es lag am selectiren der items ... nun funktioniert es :lol:

falsch:

Code: Alles auswählen

QListViewItemIterator it( listView_Server );
   while( it.current() ){
      if ( listView_Server->currentItem()->text(0) == de_logres ){
         slotListViewFill( log );
      }else if ( listView_Server->currentItem()->text(0) == de_dartmoor ){
         slotListViewFill( dart );
      }else if ( listView_Server->currentItem()->text(0) == en_excalibur ){
         slotListViewFill( exc );
      }else if ( listView_Server->currentItem()->text(0) == en_prydwen ){
         slotListViewFill( pryd );
      }else if ( listView_Server->currentItem()->text(0) == fr_carnac ){
         slotListViewFill( car );
      }else if ( listView_Server->currentItem()->text(0) == fr_orcanie ){
         slotListViewFill( orc );
      }else if ( listView_Server->currentItem()->text(0) == full_avalon ){
         slotListViewFill( ava );
      }else if ( listView_Server->currentItem()->text(0) == full_broceliande ){
         slotListViewFill( broc );
      }else if ( listView_Server->currentItem()->text(0) == full_lyonesse ){
         slotListViewFill( lyo );
      }else if ( listView_Server->currentItem()->text(0) == full_stonehenge ){
         slotListViewFill( sto );
      }else if ( listView_Server->currentItem()->text(0) == full_ys ){
         slotListViewFill( ys );
      }else if ( listView_Server->currentItem()->text(0) == pvp_camlann ){
         slotListViewFill( cam );
      }else{
         ++it;
      }
   } 
richtig: (glaube ich) :P

Code: Alles auswählen

if ( listView_Server->currentItem()->text(0) == de_logres ){
				slotListViewFill( log );
           }else if ( listView_Server->currentItem()->text(0) == de_dartmoor ){
				slotListViewFill( dart );
           }else if ( listView_Server->currentItem()->text(0) == en_excalibur ){
				slotListViewFill( exc );
           }else if ( listView_Server->currentItem()->text(0) == en_prydwen ){
				slotListViewFill( pryd );
           }else if ( listView_Server->currentItem()->text(0) == fr_carnac ){
				slotListViewFill( car );
           }else if ( listView_Server->currentItem()->text(0) == fr_orcanie ){
				slotListViewFill( orc );
           }else if ( listView_Server->currentItem()->text(0) == full_avalon ){
				slotListViewFill( ava );
           }else if ( listView_Server->currentItem()->text(0) == full_broceliande ){
				slotListViewFill( broc );
           }else if ( listView_Server->currentItem()->text(0) == full_lyonesse ){
				slotListViewFill( lyo );
           }else if ( listView_Server->currentItem()->text(0) == full_stonehenge ){
				slotListViewFill( sto );
           }else if ( listView_Server->currentItem()->text(0) == full_ys ){
				slotListViewFill( ys );
           }else if ( listView_Server->currentItem()->text(0) == pvp_camlann ){
				slotListViewFill( cam );
           }else{
                 //fehlermeldung ... ;)
           }

Verfasst: 29. April 2005 18:22
von Goos
*lach*....ja ich hab mal wieder aufs falsche Code-Stueck geschaut :)
In deiner ersten version kommst ja bei bekannten Eintraegen nie dazu, deinen Iterator weiterzuschieben. Folglich bist in ner seeehr lange andauernden Schleife :)

Goos