Board::Board(const char * filename): _nbGetCandidatesCall(0) { _numbers = new int[NB_CELLS]; std::ifstream inputFile(filename); if (inputFile.is_open()) { std::string line; int index = 0; while (inputFile.good()) { std::getline(inputFile, line); parseLine(line, index); } inputFile.close(); } else { std::cerr << "Error: can't open file " << filename; exit(EXIT_FAILURE); } }
bool Wallet::writeBackupInstructions() { QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html"); QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE); QFile inputFile(inputFilename); QFile outputFile(outputFilename); bool retval = false; if (getKeyFilePath().isEmpty()) { return false; } if (QFile::exists(inputFilename) && inputFile.open(QIODevice::ReadOnly)) { if (outputFile.open(QIODevice::ReadWrite)) { // Read the data from the original file, then close it QByteArray fileData = inputFile.readAll(); inputFile.close(); // Translate the data from the original file into a QString QString text(fileData); // Replace the necessary string text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath()); // Write the new text back to the file outputFile.write(text.toUtf8()); // Close the output file outputFile.close(); retval = true; qCDebug(commerce) << "wrote html file successfully"; } else { qCDebug(commerce) << "failed to open output html file" << outputFilename; } } else { qCDebug(commerce) << "failed to open input html file" << inputFilename; } return retval; }
//Cargo el input, y el result lo pongo a 0 void LRMachine::loadInput(std::string filename) { // std::cout << "I'm loading input with the LRMachine from " << filename << std::endl; std::string line; std::ifstream inputFile(filename.c_str()); if(inputFile.is_open()){ std::getline(inputFile,line); C_input.setInput(Utils::vStovD(Utils::split(line,';'))); std::vector<int> res; res.push_back(0); C_input.setResult(res); inputFile.close(); } else{ std::cout << "Unable to open file" << std::endl; } }
void FeatureStore::load() { QFile inputFile(path); if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) { return; } int minPatternSize = INT_MAX; while (!inputFile.atEnd()) { QByteArray line = inputFile.readLine().trimmed(); QList<QByteArray> lineItems = line.split('\t'); if (line.startsWith("#")) { continue; } assert(lineItems.size() == 3); if (lineItems.size() != 3) { break; } FeaturePattern pattern; pattern.name = lineItems[0].trimmed(); pattern.type = lineItems[1].trimmed(); pattern.sequence = lineItems[2].toUpper(); if (pattern.sequence.length() < minPatternSize) { minPatternSize = pattern.sequence.length(); } features.append(pattern); } if (minPatternSize != INT_MAX) { minFeatureSize = minPatternSize; } }
bool ReadMatrixFromFile(const std::string& fileName, float inputArray[C_MATRIX_SIZE][C_MATRIX_SIZE]) { std::ifstream inputFile(fileName); if (inputFile.is_open()) { for (std::size_t i = 0; i < C_MATRIX_SIZE; i++) { for (std::size_t j = 0; j < C_MATRIX_SIZE; j++) { inputFile >> inputArray[i][j]; } } if (inputFile.fail()) { std::cout << "Incorrect matrix in file!" << std::endl; return false; } } else {
void SplitTheNumber(char * inputName) { std::string line; //std::ifstream inputFile (inputName); std::ifstream inputFile ("inputFile"); if(inputFile){ while(getline(inputFile,line)){ std::vector<int> digits; int index; for(index = 0; index < line.size(); index++){ if(line[index] == ' '){break;} digits.push_back(line[index] - '0'); } ++index; char op; long result(0), number(0); int d(0); for(; index < line.size(); index++){ if(line[index] == '+' || line[index] == '-'){ result = number; op = line[index]; number = 0; continue; } number = 10 * number + digits[d++]; } result = (op == '+') ? (result + number) : (result - number); std::cout << result << std::endl; } } inputFile.close(); }
int main(int argc, char const *argv[]) { if(argc < 3) { cout << "Usage: encryptor InputFileName OutputFileName" << endl << "Terminating..." << endl; return 0; } //Text hiding method by guestgulkan on cplusplus forum HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD mode = 0; GetConsoleMode(hStdin, &mode); SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); string key; string input; string output; FileHandler inputFile(true); if(!inputFile.setFileName(argv[1])) { return 0; } FileHandler outputFile(false); outputFile.setFileName(argv[2]); cout << "Please enter your session key:" << endl; getline(cin, key); input = *inputFile.get(); Encryptor enc(key, input); output = enc.crypt(); outputFile.write(output); return 0; }
// inti provider data from file void CDataProvider::setBufferFromFile(const String& fileName, unsigned headerSize) { ::std::ifstream inputFile(fileName, ::std::ios::binary|::std::ios::in); if (!inputFile) return; inputFile.seekg (0, std::ios::end); std::streamoff end = inputFile.tellg(); inputFile.seekg (headerSize, std::ios::beg); std::streamoff begin = inputFile.tellg(); m_BuffLen = (unsigned) (end - begin); if (m_Buffer) { delete [] m_Buffer; m_Buffer = NULL; } m_Buffer = new Uint8[m_BuffLen]; inputFile.read((char *)m_Buffer, m_BuffLen); inputFile.close(); }
TestCasesHandler::TestCasesHandler(const string outputFileName, GraphBuilder &builder) : m_outputFileName(outputFileName), m_builder(builder) { /* * Get a handle to our global instance * of our arguments */ Arguments *arguments = Arguments::getInstance(); m_output.open(m_outputFileName.c_str()); path filePath(arguments->getResourcesDirectory() + "/testing/header.htm"); boost::filesystem::ifstream inputFile(filePath); //Write the header string line; while (inputFile.is_open() && !inputFile.eof()) { getline (inputFile,line); output(line); } }
bool ReadFile(std::vector<Planet> & fuelPlanet, const std::string & file) { try { std::ifstream inputFile(file); size_t countPlanet; inputFile >> countPlanet; if (!(countPlanet >= MIN_COUNT_PLANETS && countPlanet <= MAX_COUNT_PLANETS)) throw std::out_of_range(""); fuelPlanet.resize(countPlanet); for (size_t i = 0; i < countPlanet; i++) { inputFile >> fuelPlanet[i].typeFuel; } return true; } catch (...) { std::cout << "File not exist or wrong file format." << std::endl; return false; } }
/** * @brief Get the actual filename and possibly folder that will be written to PLA file * This program manages location of songs so, that user can define the 'root' for music * files under which all music files and folders will be copied or referenced. Similarly * user can define the location for Playlist files generated by this program. iRiver * interprets playlist paths so that '/' references to the root of music player. * * If user has checked that 'preserve folder' then playlist references files so that * it adds the immediate folder where song exists beneath the 'music root' so: * 'music root'/'folder'/'song'. The other choice is 'music root'/'song' * * @param fi Input file to be examined * @param outFile Name of the file + one folder level above it if preserveSongFolder is true * @param nameIndex 1 based position in absolutefilepath from which the actual filename starts * @return true if successfully retrieved information, false otherwise */ bool plaPlayList::getFileName(QString song, QString *outFile, qint16 *nameIndex) { QFileInfo inputFile(song); *outFile = ""; *nameIndex = 0; if (inputFile.absoluteFilePath().isEmpty()) return false; QString folderName = ""; QString fileName = ""; if (preserveSongFolder) { folderName = inputFile.absoluteDir().dirName(); } if (preserveSongFolder) { fileName = QString("%1\\%2\\%3").arg(musicFileDestination).arg(folderName).arg(inputFile.fileName()); } else { fileName = QString("%1\\%2").arg(musicFileDestination).arg(inputFile.fileName()); } *outFile = fileName; *nameIndex = (qint16)outFile->indexOf(inputFile.fileName()) + 1; return true; }
void ProtoWindow::onNewFolder(QDir newDir) { /* Altes löschen: */ this->dirVec.clear(); // TODO auch in imageLabel /* Neu aufbauen: */ this->curDir = newDir; setDirVec(); /* Meta-Daten lesen */ QFile inputFile(this->curDir.absoluteFilePath("dexiv.txt")); if (inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); while (!in.atEnd()) { QString line = in.readLine(); this->imageLabel->processLine(line, this->curDir); } inputFile.close(); } }
void MultiplyLists(char * inputName) { std::string line; //std::ifstream inputFile (inputName); std::ifstream inputFile ("inputFile"); if(inputFile){ while(getline(inputFile,line)){ std::stringstream lineStream(line); std::string first; getline(lineStream, first, '|'); std::string second; getline(lineStream, second); if(second[0] == ' '){second = second.substr(1, second.size() - 1);} std::vector<long> firstVec = splitCSV(first, ' '); std::vector<long> secondVec = splitCSV(second, ' '); for(int p = 0; p < firstVec.size(); p++){std::cout << firstVec[p] * secondVec[p] << " ";} std::cout << std::endl; } } inputFile.close(); }
// overload function with only the variable reading (input forcing time series text file) void readTextData(const char* inforcFile, float *&tvar_in, int &nrecords) { ifstream inputFile(inforcFile,ios::in); nrecords = 0; char commentLine[256]; //string to read header line if(!inputFile) { cout<<"Error opening file: "<<inforcFile<<endl; return; } inputFile.getline(commentLine,256,'\n'); //skip first header line //inputFile.getline(commentLine,256,'\n'); //first data line while(!inputFile.eof()) { commentLine[0] = ' '; inputFile.getline(commentLine,256,'\n'); if (commentLine[0] != ' ') //condition to make sure empty line is not read; ++nrecords; }//while //cout<<"number of records in file: "<<inforcFile<<" "<<nrecords<<endl; tvar_in = new float[nrecords]; inputFile.seekg(0L,ios::beg); inputFile.getline(commentLine,256,'\n'); //skip first header line for (int i=0; i<nrecords-1; i++) { inputFile.getline(commentLine,256,'\n'); sscanf(commentLine,"%*d %*d %*d %*d %f \n",&tvar_in[i]); //&tcor_var[i],&tvar_in[i]); } inputFile.close(); //for(int i=0; i< 100; i++) // printf(" %f ", tvar_in[i]); //printf(" \n"); }// __host__ __device__ void readTextData
void NewstuffModel::setRegistryFile( const QString &filename, IdTag idTag ) { QString registryFile = filename; if (registryFile.startsWith(QLatin1Char('~')) && registryFile.length() > 1) { registryFile = QDir::homePath() + registryFile.mid( 1 ); } if ( d->m_registryFile != registryFile ) { d->m_registryFile = registryFile; d->m_idTag = idTag; emit registryFileChanged(); QFileInfo inputFile( registryFile ); if ( !inputFile.exists() ) { QDir::root().mkpath( inputFile.absolutePath() ); d->m_registryDocument = QDomDocument( "khotnewstuff3" ); QDomProcessingInstruction header = d->m_registryDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"utf-8\"" ); d->m_registryDocument.appendChild( header ); d->m_root = d->m_registryDocument.createElement( "hotnewstuffregistry" ); d->m_registryDocument.appendChild( d->m_root ); } else { QFile input( registryFile ); if ( !input.open( QFile::ReadOnly ) ) { mDebug() << "Cannot open newstuff registry " << registryFile; return; } if ( !d->m_registryDocument.setContent( &input ) ) { mDebug() << "Cannot parse newstuff registry " << registryFile; return; } input.close(); d->m_root = d->m_registryDocument.documentElement(); } d->updateModel(); } }
KisImportExportFilter::ConversionStatus KisBMPImport::convert(const QByteArray& from, const QByteArray& to) { dbgFile << "BMP import! From:" << from << ", To:" << to << 0; if (to != "application/x-krita") return KisImportExportFilter::BadMimeType; KisDocument * doc = outputDocument(); if (!doc) return KisImportExportFilter::NoDocumentCreated; QString filename = inputFile(); doc->prepareForImport(); if (!filename.isEmpty()) { QFileInfo fi(filename); if (!fi.exists()) { return KisImportExportFilter::FileNotFound; } QImage img(filename); const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8(); KisImageSP image = new KisImage(doc->createUndoStore(), img.width(), img.height(), colorSpace, "imported from bmp"); KisPaintLayerSP layer = new KisPaintLayer(image, image->nextLayerName(), 255); layer->paintDevice()->convertFromQImage(img, 0, 0, 0); image->addNode(layer.data(), image->rootLayer().data()); doc->setCurrentImage(image); return KisImportExportFilter::OK; } return KisImportExportFilter::StorageCreationError; }
int TestCFSM::runScenario(const int num) { int result = -1; QString scenarioFilename = QString("scenario-%1.txt").arg(num, 2, 10, QChar('0')); QFile inputFile(scenarioFilename); if(inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); processActions(in); result = processResults(in); if(result != 0) { // Test failed! QTextStream console(stdout); console << "--" << endl << "Test failed: " << scenarioFilename << endl; if(result == 1) { console << "Model internal state does not match " << "desired state. Model data:" << endl; printModel(); } console << "--" << endl << endl; } } else { QTextStream console(stdout); console << "ERROR: could not read file: " << scenarioFilename << endl; // Don't try to recover. QApplication::exit(1); } inputFile.close(); return (result); }
// # include "temp.cpp" int main(int argc, char ** argv ){ std::string inputFile("../data/jobs.txt"); if(argc == 3){ std::stringstream argumentSS(argv[1]); std::string param; std::string paramContainer; for (int i = 1; i< argc; i++){ argumentSS.clear(); argumentSS.str(argv[i]); argumentSS>>param; paramContainer = paramContainer + " " + param; }// end of if argumentSS.clear(); argumentSS.str(paramContainer); while(argumentSS>>param){ if(param == "-data"){ // positionMotionRaw argumentSS>>inputFile; }else if(param == "-help"){
void DoubletSolver::parse_dictionary(const std::string& filename) { std::string str; std::ifstream inputFile(filename.c_str()); if (inputFile.is_open()) { // if file opened correctly getline(inputFile,str); dictionary_size = std::stoi(str); str.clear(); while (getline(inputFile,str)) { str.erase(remove_if(str.begin(), str.end(), isspace), str.end()); if (str.length() == word_size){ std::transform(str.begin(), str.end(), str.begin(), ::tolower); if (str != start_word) dictionary.push_back(str); } str.clear(); } inputFile.close(); } else std::cerr << "FILE NOT OPENED\n"; }
QList<QString> DataSeed::ReadPlayersList() { QList<QString> players; QFile inputFile("gierekPlayersLog.xml"); if (inputFile.open(QIODevice::ReadOnly)) { QString temp; QTextStream in(&inputFile); while ( !in.atEnd() ) { temp = in.readLine(); if(temp.indexOf("<Player>")!=-1 && temp.indexOf("</Player>")!=-1) { temp.remove("<Player>"); temp.remove("</Player>"); players.append(temp); } } inputFile.close(); } return players; }
/// /// \brief InsertDeviceModule Вгружает загружаемый модуль устройства в ядро /// \param modulePath Путь к загружаемому модулю /// void DeviceManager::InsertDeviceModule(const std::string& modulePath) { try { std::ifstream inputFile(modulePath.c_str()); if (!inputFile.is_open()) throw FileException("Kernel module with such name doesn't exist!"); inputFile.close(); GetModuleNameFromPath(modulePath); std::string command = "sudo insmod " + modulePath; int returnValue = system(command.c_str()); if (returnValue == -1 || WEXITSTATUS(returnValue) != 0) throw ShellCommandExecuteException("Kernel module has already been loaded!"); emit KernelModuleInsertedSignal(); } catch (std::bad_alloc& exception) { throw AllocMemoryException("Error alloc memory in InsertDeviceModule"); } }
//------------------------------------------------------------------------------ /// \brief Does file conversion //------------------------------------------------------------------------------ bool ProcessorMNW2::impl::DoConvertFile (const char * const a_inputFile, const char * const a_outputFile, const int& /*a_nRow*/, const int& /*a_nCol*/) { bool rval(1); CStr inputFile(a_inputFile), outputFile(a_outputFile); try { std::fstream is; is.open((LPCTSTR)a_inputFile, std::ios_base::in); if (is.bad()) throw ioError(); std::fstream os; os.open((LPCTSTR)a_outputFile, std::ios_base::out); if (os.bad()) throw ioError(); ReadComments(is, os); ReadLn1(is, os); ReadWells(is, os); ReadStressPeriods(is, os); } catch (std::exception&) { CStr msg("Error processing file: "); msg += inputFile; msg += "."; ErrorStack::Get().PutError(msg); rval = false; } return rval; } // ProcessorMNW2::impl::DoConvertFile
void Block::createSeedMapCache() { uint64_t seedMapFileSize = 2048*(256/8); uint8_t seedMap[seedMapFileSize]; std::ifstream inputFile( "seedmap", std::ios::binary ); if(inputFile.fail()) { Bits<256> seedHash; for(size_t i=0 ; i<2048 ; i++) { uint8_t* ptr = &seedMap[i*(256/8)]; memcpy(ptr,seedHash.ptr(),32); Block::epochToSeedMap[i] = Bits<256>(seedHash); Block::seedToEpochMap[seedHash] = i; SHA3_256(seedHash.ptr(), seedHash.ptr(), 32); } std::ofstream outputFile( "seedmap", std::ofstream::out ); outputFile.write((char*)seedMap, seedMapFileSize); outputFile.flush(); outputFile.close(); } else { inputFile.read((char*)seedMap,seedMapFileSize); inputFile.close(); for(size_t i=0 ; i<2048 ; i++) { uint8_t* ptr = &seedMap[i*(256/8)]; Block::epochToSeedMap[i] = Bits<256>(ptr); Block::seedToEpochMap[Bits<256>(ptr)] = i; } } }
void KnownIdentities::fromFile(QString const& filename, bool dryRun) { if (!QFile::exists(filename)) { throw IllegalArgumentException() << QString("Could not open the specified contacts file as it does not exist: %1").arg(filename).toStdString(); } QFile inputFile(filename); if (!inputFile.open(QFile::ReadOnly | QFile::Text)) { throw IllegalArgumentException() << QString("Could not open the specified contacts file for reading: %1").arg(filename).toStdString(); } QRegExp commentRegExp("^\\s*#.*$", Qt::CaseInsensitive, QRegExp::RegExp2); QRegExp identityRegExp("^\\s*([A-Z0-9]{8})\\s*:\\s*([a-fA-F0-9]{64})\\s*(?::\\s*(.*)\\s*)?$", Qt::CaseInsensitive, QRegExp::RegExp2); QTextStream in(&inputFile); while (!in.atEnd()) { QString line = in.readLine(); if (line.trimmed().isEmpty() || commentRegExp.exactMatch(line)) { continue; } else if (identityRegExp.exactMatch(line)) { if (!dryRun) { accessMutex.lock(); identityToPublicKeyHashMap.insert(identityRegExp.cap(1), PublicKey::fromHexString(identityRegExp.cap(2))); if (!identityRegExp.cap(3).trimmed().isEmpty()) { // Nickname given. identityToNicknameHashMap.insert(identityRegExp.cap(1), identityRegExp.cap(3)); } accessMutex.unlock(); } } else { throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\". Problematic line: %2").arg(filename).arg(line).toStdString(); } } inputFile.close(); emit identitiesChanged(); }
void AppDockWidget::loadInfoThread() { QDir dir; QString workPath = mainwindow->GetCurrentWorkDir(); QString ThreadInfoFile = workPath + "/test/info_threadcurrentline.txt"; QFile inputFile(ThreadInfoFile); inputFile.open(QIODevice::ReadOnly); if(inputFile.size() != 0) { QTextStream in(&inputFile); ui.infothreadtableWidget->clearContents(); int j = 0; QTableWidgetItem *item; while (!in.atEnd()) { QString line = in.readLine(); QStringList lineList = line.split(','); int k = 0; while(k < lineList.count()) { item = new QTableWidgetItem(lineList[k]); item->setTextAlignment(Qt::AlignHCenter); item->setFlags(item->flags() & ~Qt::ItemIsEditable); ui.infothreadtableWidget->setItem(j, k, item); k++; } j++; } inputFile.close(); } else { QMessageBox::about(this, tr("notice"), tr("the file is null")); return; } }
int main(int argc, char ** argv ) { std::string inputFile("../benchmarkData/algo1_programming_prob_2sum.txt"); if(argc == 3){ std::stringstream argumentSS(argv[1]); std::string param; std::string paramContainer; for (int i = 1; i< argc; i++){ argumentSS.clear(); argumentSS.str(argv[i]); argumentSS>>param; paramContainer = paramContainer + " " + param; } argumentSS.clear(); argumentSS.str(paramContainer); while(argumentSS>>param){ if(param == "-data"){ // positionMotionRaw argumentSS>>inputFile; }else if(param == "-help"){
void LearnNumbers::test(int nNeuronio, QString nome_arquivo) { QFile inputFile(nome_arquivo); QTextStream in(&inputFile); inputFile.open(QIODevice::ReadOnly); Adaline *aux; aux = (Adaline*)listaAdalines[nNeuronio]; QString line = in.readLine(nEntradas+1); for(int j=0;j<nEntradas;j++){ QString n(line.at(j)); aux->setEntrada(j+1,n.toInt()); } if(aux->getSaida() > 0.5) cout << "O neuronio " << nNeuronio << " Dispara! Valor Saida: " << aux->getSaida() << endl; else cout << "O neuronio " << nNeuronio << " Nao Dispara! Valor Saida: " << aux->getSaida() << endl; inputFile.close(); }
template <typename num_t> void Tensor<num_t>::load(const std::string& fname) { std::ifstream inputFile(fname, std::ios::in | std::ifstream::binary); if(!inputFile) throw "Cannot open the file"; size_t tmpA,tmpB; inputFile.read(reinterpret_cast<char *>(&(tmpA)), 1*sizeof(size_t)); inputFile.read(reinterpret_cast<char *>(&(tmpB)), 1*sizeof(size_t)); _bds_Nb_In = tmpA; _bds_Tot = tmpB; size_t tmpDim; char labC; int labI; dims_t Dims; labels_t Labs; for (size_t i = 0; i < _bds_Tot; ++i) { inputFile.read(reinterpret_cast<char *>(&(tmpDim)), 1*sizeof(size_t)); inputFile.read(reinterpret_cast<char *>(&(labC)), 1*sizeof(char)); inputFile.read(reinterpret_cast<char *>(&(labI)), 1*sizeof(int)); Dims.push_back(tmpDim); Labs.push_back({labC,labI}); } _bds_dims = Dims; _bds_labels = Labs; std::vector<num_t> v; num_t fV; while(inputFile.read(reinterpret_cast<char *>(&fV), sizeof(num_t))) { v.push_back(fV); } all_elem_ = v; // small check : if (all_elem_.size() == getSize()) { std::cout << *this; } return; }
KisImportExportFilter::ConversionStatus KisPPMImport::convert(const QByteArray& from, const QByteArray& to) { Q_UNUSED(from); dbgFile << "Importing using PPMImport!"; if (to != "application/x-krita") return KisImportExportFilter::BadMimeType; KisDocument * doc = outputDocument(); if (!doc) return KisImportExportFilter::NoDocumentCreated; QString filename = inputFile(); if (filename.isEmpty()) { return KisImportExportFilter::FileNotFound; } QUrl url = QUrl::fromLocalFile(filename); if (url.isEmpty()) return KisImportExportFilter::FileNotFound; if (!url.isLocalFile()) { return KisImportExportFilter::FileNotFound; } QFile fp(url.toLocalFile()); if (fp.exists()) { doc->prepareForImport(); return loadFromDevice(&fp, doc); } return KisImportExportFilter::CreationError; }
void QgsRasterTerrainAnalysisDialog::on_mImportColorsButton_clicked() { QString file = QFileDialog::getOpenFileName( 0, tr( "Import Colors and elevations from xml" ), QDir::homePath() ); if ( file.isEmpty() ) { return; } QFile inputFile( file ); if ( !inputFile.open( QIODevice::ReadOnly ) ) { QMessageBox::critical( 0, tr( "Error opening file" ), tr( "The relief color file could not be opened" ) ); return; } QDomDocument doc; if ( !doc.setContent( &inputFile, false ) ) { QMessageBox::critical( 0, tr( "Error parsing xml" ), tr( "The xml file could not be loaded" ) ); return; } mReliefClassTreeWidget->clear(); QDomNodeList reliefColorList = doc.elementsByTagName( "ReliefColor" ); for ( int i = 0; i < reliefColorList.size(); ++i ) { QDomElement reliefColorElem = reliefColorList.at( i ).toElement(); QTreeWidgetItem* newItem = new QTreeWidgetItem(); newItem->setText( 0, reliefColorElem.attribute( "MinElevation" ) ); newItem->setText( 1, reliefColorElem.attribute( "MaxElevation" ) ); newItem->setBackground( 2, QBrush( QColor( reliefColorElem.attribute( "red" ).toInt(), reliefColorElem.attribute( "green" ).toInt(), reliefColorElem.attribute( "blue" ).toInt() ) ) ); mReliefClassTreeWidget->addTopLevelItem( newItem ); } }