void ViewerCore::loadConfigFile(QString fileName) { QDomDocument XmlDoc("BasicViewerConfig"); QFile configFile(fileName); if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) { ERROR_MSG("Error opening file: " + fileName); return; } if (!XmlDoc.setContent(&configFile)) { configFile.close(); ERROR_MSG("Wrong fileformat"); return; } configFile.close(); QDomElement root = XmlDoc.documentElement(); if (root.tagName() != "BasicViewerConfig") { ERROR_MSG("Cannot find \"BasicViewerConfig\"-element"); return; } QDomElement e = root.firstChildElement("presets"); if (!e.isNull()) this->loadPresets(&e); e = root.firstChildElement("dicomStrings"); if (!e.isNull()) this->loadDicomConfig(&e); }
// -------------------------------------------------------------------------------- // int guTuneInReadStationsThread::AddStations( const wxString &url, guRadioStations * stations, const long minbitrate ) { wxString Content = GetTuneInUrl( url ); //guLogMessage( wxT( "AddStations: %s" ), url.c_str() ); if( !Content.IsEmpty() ) { wxStringInputStream Ins( Content ); wxXmlDocument XmlDoc( Ins ); wxXmlNode * XmlNode = XmlDoc.GetRoot(); if( XmlNode ) { if( XmlNode->GetName() == wxT( "opml" ) ) { XmlNode = XmlNode->GetChildren(); while( XmlNode && !TestDestroy() ) { //guLogMessage( wxT( "XmlNode: '%s'" ), XmlNode->GetName().c_str() ); if( XmlNode->GetName() == wxT( "outline" ) ) { wxString Type; XmlNode->GetAttribute( wxT( "type" ), &Type ); if( Type == wxT( "" ) ) { ReadStations( XmlNode->GetChildren(), stations, minbitrate ); } else { ReadStations( XmlNode, stations, minbitrate ); break; } } else if( XmlNode->GetName() == wxT( "body" ) ) { XmlNode = XmlNode->GetChildren(); continue; } XmlNode = XmlNode->GetNext(); } } } } if( !TestDestroy() ) { SortStations(); wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED ); wxPostEvent( m_RadioPanel, Event ); return stations->Count(); } return 0; }
//сохранение списка в файл void AnimeList::Save() { if(IsEmpty(filename)) { SaveAs(); return; } String xml; for(int i = 0; i < mainArray.GetCount(); i++) xml << XmlTag("item") ( XmlTag("complete").Text(mainArray[i].complete) + XmlTag("name").Text(mainArray[i].name) + XmlTag("russian").Text(mainArray[i].nameRus) + XmlTag("episodes").Text(AsString(mainArray[i].episodes)) + XmlTag("views").Text(AsString(mainArray[i].views)) + XmlTag("Release").Text(AsString(mainArray[i].Release)) + XmlTag("series").Text(mainArray[i].releaseDate) ); if(!SaveFile(filename, XmlDoc("ListView", xml))) Exclamation("Error Saving the File"); status.Set(Format("Items: %d. List Save", mainArray.GetCount())); }
// -------------------------------------------------------------------------------- // void guUserRadioProvider::OnRadioImport( wxCommandEvent &event ) { guRadioStations UserStations; wxFileDialog * FileDialog = new wxFileDialog( m_RadioPanel, wxT( "Select the xml file" ), wxGetHomeDir(), wxEmptyString, wxT( "*.xml;*.xml" ), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( FileDialog ) { if( FileDialog->ShowModal() == wxID_OK ) { wxFileInputStream Ins( FileDialog->GetPath() ); wxXmlDocument XmlDoc( Ins ); wxXmlNode * XmlNode = XmlDoc.GetRoot(); if( XmlNode && XmlNode->GetName() == wxT( "RadioStations" ) ) { ReadXmlRadioStations( XmlNode->GetChildren(), &UserStations ); int Index; int Count; if( ( Count = UserStations.Count() ) ) { for( Index = 0; Index < Count; Index++ ) { m_Db->SetRadioStation( &UserStations[ Index ] ); } // m_RadioPanel->RefreshStations(); } } } FileDialog->Destroy(); } }
//открытие файла после выбора его в системе void AnimeList::OpenFile() { mainArray.Clear(); listName.Clear(); try { String d = LoadFile(filename); XmlParser p(d); while(!p.IsTag()) p.Skip(); p.PassTag("ListView"); while(!p.IsEof()) { if(p.Tag("item")) { while(!p.End()) { if(p.Tag("complete")) { String complete = p.ReadText(); if(complete == "Yes") cell.complete = "Yes"; else if(complete == "No") cell.complete = "No"; else cell.complete = "New"; } else if(p.Tag("name")) cell.name = p.ReadText(); else if(p.Tag("russian")) cell.nameRus = p.ReadText(); else if(p.Tag("episodes")) cell.episodes = StrInt(p.ReadText()); else if(p.Tag("views")) cell.views = StrInt(p.ReadText()); else if(p.Tag("Release")) StrToDate(cell.Release, p.ReadText()); else if(p.Tag("series")) cell.releaseDate = p.ReadText(); else { p.Skip(); continue; } p.PassEnd(); } mainArray.Add(cell); listName.Add(cell.complete, cell.name, cell.nameRus, cell.episodes, cell.views, cell.Release, cell.releaseDate, mainArray.GetCount() - 1); RowColor(listName.GetCount()-1); } else p.Skip(); } } catch(XmlError) { Exclamation("Error Readong the Input File"); } SetupYears(); Title("Anime List | " + filename); String iniFile; iniFile = GetDataFile("AnimeList.xml"); String xmlIni; xmlIni << XmlTag("File").Text(AsString(filename)); SaveFile(iniFile, XmlDoc("FileList", xmlIni)); status.Set(Format("Items: %d. List Open", listName.GetCount())); }
// -------------------------------------------------------------------------------- // int guAmazonCoverFetcher::ExtractImagesInfo( wxString &content ) { int RetVal = 0; wxStringInputStream ins( content ); wxXmlDocument XmlDoc( ins ); wxXmlNode * XmlSubNode; wxXmlNode * XmlNode = XmlDoc.GetRoot(); if( XmlNode && XmlNode->GetName() == wxT( "ItemSearchResponse" ) ) { XmlNode = XmlNode->GetChildren(); while( XmlNode ) { if( XmlNode->GetName() == wxT( "Items" ) ) { XmlNode = XmlNode->GetChildren(); while( XmlNode ) { if( XmlNode->GetName() == wxT( "Request" ) ) { XmlSubNode = XmlNode->GetChildren(); while( XmlSubNode ) { if( XmlSubNode->GetName() == wxT( "IsValid" ) ) { if( XmlSubNode->GetNodeContent() != wxT( "True" ) ) { guLogError( wxT( "There was an error in the amazon search request." ) ); } break; } XmlSubNode = XmlSubNode->GetNext(); } } else if( XmlNode->GetName() == wxT( "Errors" ) ) { XmlSubNode = XmlNode->GetChildren(); while( XmlSubNode ) { if( XmlSubNode->GetName() == wxT( "Error" ) ) { XmlSubNode = XmlSubNode->GetChildren(); while( XmlSubNode ) { if( XmlSubNode->GetName() == wxT( "Message" ) ) { guLogError( wxT( "Error: %s" ), XmlSubNode->GetNodeContent().c_str() ); break; } XmlSubNode = XmlSubNode->GetNext(); } return 0; } XmlSubNode = XmlSubNode->GetNext(); } } else if( XmlNode->GetName() == wxT( "Item" ) ) { wxArrayString CurItem = GetImageInfo( XmlNode ); if( CurItem.Count() ) { m_CoverLinks->Add( CurItem ); RetVal++; } } XmlNode = XmlNode->GetNext(); } break; } XmlNode = XmlNode->GetNext(); } } return RetVal; }