// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CFileWriteNumberStatement::ExecuteSelf // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ void CFileWriteNumberStatement::ExecuteSelf( CProgram &ioState) { if (mData.Get()->IsFloat()) UFileManager::FileWriteFloat(mFile(ioState),mData->EvaluateFloat(ioState)); else UFileManager::FileWriteInteger(mFile(ioState),mData(ioState)); }
void Macro::writeFile(QString s) { loc = "macros/"; int i; s.append(".macro"); loc.append(s); QFile mFile(loc); qDebug() << loc; if(!mFile.open(QFile::WriteOnly | QFile::Text)) { qDebug() << "Could not write to file.\n"; return; } QTextStream out(&mFile); i = 0; while(macro[i] != 0) { out << macro[i]; out << "\n"; i++; } mFile.flush(); mFile.close(); }
bool MainWindow::Check_Password(QString Filename, QString username, QString password){ bool flag = 0; // First assume the password is wrong QFile mFile(Filename); QTextStream stream(&mFile); QString line; QStringList parts; if(!mFile.open(QFile::ReadOnly | QFile::Text)){ return 1; } do { line = stream.readLine(); parts = line.split("*"); if (parts[0] == username)//Found a line for that username { break; } }while (!line.isNull()); if(parts[1]==password){ flag=1; //The password matches! } else{ flag=0; } mFile.flush(); mFile.close(); return flag; }
Cloud::Cloud( QString& pFile ){ // TODO Auto-generated constructor stub QFile mFile(pFile); //load file content if(!mFile.open(QIODevice::ReadOnly)) { qWarning()<<"Error opening file"; return; } //work on the file QString lDatas = mFile.readAll(); QStringList lTokens = lDatas.split(QRegExp("[ |\n]"), QString::SkipEmptyParts); QString nbInt = lTokens.at(0); mNbPoints = nbInt.toInt(); //remove first item (size) from the list lTokens.removeFirst(); QStringListIterator lTokIterator(lTokens); while(lTokIterator.hasNext()) { mPointList << lTokIterator.next().toFloat(); } qWarning()<<mPointList.size()<<mNbPoints; glPointSize(5.0f); mGLBatch.Begin(GL_POINTS, mNbPoints); for(int i=0;i<mNbPoints;i++) { mGLBatch.Vertex3f(mPointList[i*3],mPointList[i*3+1], mPointList[i*3+2]); } mGLBatch.End(); }
void HostVector<ValueType>::ReadFile(const std::string filename) { DEBUGLOG(this, "HostVector::ReadFile()", "filename = " << filename, 2); std::ifstream mFile(filename); std::string line; std::getline(mFile, line); if ( !std::regex_match (line, std::regex("^[0-9]+"))) { std::cerr << "Bad syntax line 1" << std::endl; } int size = std::stoi(line); this->Allocate(size); std::getline(mFile, line); int index = 0; if (!regex_match (line, std::regex("^(-?[0-9.]+e(?:\\+|\\-)[0-9]+)"))) { std::cerr << "Bad syntax in line: " << index+2 << std::endl; } GoToLine(mFile, 2); while (std::getline(mFile, line)) { mData[index] = std::stod(line); index++; } DEBUGEND(); }
void Macro::readFile() { loc = QFileDialog::getOpenFileName(0, "/macros", tr("*.macro")); QFile mFile(loc); qDebug() << mFile.fileName(); if(!mFile.open(QFile::ReadOnly | QFile::Text)) { qDebug() << "Could not read from file.\n"; return; } QTextStream in(&mFile); int i = 0; //std::fill_n(macro, 1000, 0); while(!in.atEnd()) { macro[i] = in.readLine().toInt(); i++; } counter = i; mFile.flush(); mFile.close(); }
bool MainWindow::AlreadyInserted(QString Filename, QString username){ bool flag = 0; //assume the name does not exists QFile mFile(Filename); QTextStream stream(&mFile); QString line; if(!mFile.open(QFile::ReadOnly | QFile::Text)){ return 1; } do { line = stream.readLine(); QStringList parts = line.split("*"); if (parts[0] == username)//found the username { flag = 1; break; } }while (!line.isNull()); mFile.flush(); mFile.close(); return flag; //if flag =1, the name exists }
aboutDialog::aboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::aboutDialog) { ui->setupUi(this); #ifdef Q_OS_MAC this->setWindowIcon(QIcon(":/cat_builder.icns")); #endif #ifdef Q_OS_WIN this->setWindowIcon(QIcon(":/cat_builder.ico")); if(QSysInfo::WindowsVersion>=QSysInfo::WV_VISTA) { if(QtWin::isCompositionEnabled()) { this->setAttribute(Qt::WA_TranslucentBackground, true); QtWin::extendFrameIntoClientArea(this, -1,-1,-1, -1); QtWin::enableBlurBehindWindow(this); } else { QtWin::resetExtendedFrame(this); setAttribute(Qt::WA_TranslucentBackground, false); } } #endif SDL_version sdlVer; SDL_GetVersion(&sdlVer); const SDL_version *mixerXVer = Mix_Linked_Version(); ui->About1->setText(ui->About1->text() .arg(V_FILE_VERSION) .arg(V_FILE_RELEASE) .arg(FILE_CPU) .arg(QString("<b>Revision:</b> %1-%2, <b>Build date:</b> <u>%3</u><br/>" "<b>Qt:</b> %4, <b>SDL2:</b> %5.%6.%7, <b>SDL Mixer X:</b> %8.%9.%10") .arg(V_BUILD_VER) .arg(V_BUILD_BRANCH) .arg(V_DATE_OF_BUILD) .arg(qVersion()) .arg(sdlVer.major).arg(sdlVer.minor).arg(sdlVer.patch) .arg(mixerXVer->major).arg(mixerXVer->minor).arg(mixerXVer->patch) ) ); QFile mFile(":/credits.html"); if(!mFile.open(QFile::ReadOnly | QFile::Text)){ return; } QTextStream in(&mFile); in.setCodec("UTF-8"); QString mText = in.readAll(); ui->About2->setText(mText); mFile.close(); }
void FileWriter::clearFile(const QString &fileName) { QFile mFile(fileName); if(!mFile.open(QFile::ReadWrite | QFile::Truncate )){ emit error(mFile.errorString()); m_errorString = mFile.errorString(); return ; } }
bool exporter::Export( string filename, settings &gen, Array3D &_map ) { ofstream mFile( filename ); if( !mFile.good() ) return 1; //Map Size mFile << "size " << gen.sizeX << " " << gen.sizeY << " " << gen.sizeZ << endl; // Map Data for( gSize y = 0; y < gen.sizeY; y++ ){ for( gSize z = 0; z < gen.sizeZ; z++ ){ mFile << "voxline " << y << " " << z; for( gSize x = 0; x < gen.sizeX; x++ ){ mFile << " " << _map.get( x, y, z ); } mFile << endl; } } // Materials for( gSize i = 0; i < gen.materials.size(); i++ ) { mFile << "material " << gen.materials[ i ].name << " " << gen.materials[ i ].sizeX << " " << gen.materials[ i ].sizeY << endl; } // Sky and Sun mFile << "sky mc" << endl; mFile << "sun " << gen.sunlight.dx << " " << gen.sunlight.dy << " " << gen.sunlight.dz << " " << gen.sunlight.r << " " << gen.sunlight.g << " " << gen.sunlight.b << " " << gen.sunlight.ar << " " << gen.sunlight.ag << " " << gen.sunlight.ab << endl; // Player Spawn mFile << "startpos " << gen.player.x << " " << gen.player.y << " " << gen.player.z << " " << gen.player.direction << " " << gen.player.physics << " " << gen.player.torchLevel << " " << gen.player.testLightning << endl; mFile.close(); return 0; }
void TabDialog::writeToFile(const Car &c) { QFile mFile("mycar.txt"); if(!mFile.open(QFile::WriteOnly | QFile::Text | QFile::Append)) { QMessageBox::information(this,tr("Предупреждение"),tr("Не удалось открыть файл")); return; } QTextStream stream(&mFile); stream<<"\n"<<c; mFile.close(); }
void Write(QString Filename) { QFile mFile(Filename); if(!mFile.open(QFile::WriteOnly | QFile::Text)) { qDebug()<<"Could not open file for writing"; return; } QTextStream out(&mFile); out<<"Hello World"; mFile.flush(); mFile.close(); }
void Read(QString fileName) { QFile mFile(fileName); if (!mFile.open(QFile::ReadOnly | QFile::Text)) { qDebug() << "could not open file for read"; return; } QString mText; mText = mFile.readAll(); qDebug() << mText; return; }
/*! * \qmlsignal FileReader::readFile() * * Used in QML to get read the file that one has selected. * */ void FileReader::readFile(QString filename){ QFile mFile(filename); if(!mFile.open(QFile::ReadOnly | QFile::Text )){ qDebug() << "Could not open the File " << filename ; return ; } QTextStream in(&mFile); QString line ; while ( !in.atEnd() ) line = in.readAll(); setOutPut(line); mFile.close(); }
//Metoda zapisująca do pliku void MainWindow::Write_file(QString Filename, double WData) { QFile mFile(Filename); // mFile.open(QIODevice::WriteOnly | QIODevice::Text); if(!mFile.open(QFile::WriteOnly | QFile::Text)) //# Sprawdzenie czy czy można zapisywać do pliku { QMessageBox::information(this,"Debug: write file","Nie mogę otworzyć pliku: "+Filename+" do zapisu"); return; } QTextStream out(&mFile); out << QString::number(WData,'f', 2); mFile.flush(); mFile.close(); }
/** * @brief MainWindow::saveLibToFile speichert die Datenbank in .csv Dateien */ void MainWindow::saveLibToFile(){ QFile lendFile("lendlibLend.csv"); QFile mFile("lendlibMedia.csv"); QFile pFile("lendlibPerson.csv"); /// Schreibe alle Personen if (lendFile.open(QFile::WriteOnly|QFile::Truncate)){ QTextStream stream(&lendFile); QHash<int,int> lendList = lendlib->getLendList(); QHash<int,int>::iterator i; stream << "Medium \t Ausgeliehen an\n"; for(i = lendList.begin(); i != lendList.end(); ++i){ stream << i.key() << "\t" << i.value() << "\n"; } lendFile.close(); } /// Schreibe alle Medien if (mFile.open(QFile::WriteOnly|QFile::Truncate)){ QTextStream stream(&mFile); QMap<int,Medium*> mList = lendlib->getMList(); stream << "ID \t Typ \t Titel\n"; for(auto m: mList.keys()){ QString mDetail; switch (mList.value(m)->getType()){ case book: mDetail = ((Book*)mList.value(m))->getAuthor(); break; case cd: mDetail = ((CD*)mList.value(m))->getInterpret(); break; case dvd: mDetail = ((DVD*)mList.value(m))->getDirector(); break; default: mDetail = ""; } stream << mList.value(m)->getID() << "\t" << mList.value(m)->getType() << "\t" << mList.value(m)->getTitle() << "\t" << mDetail << "\n"; } mFile.close(); } /// Schreibe alle Ausleih-Relationen if (pFile.open(QFile::WriteOnly|QFile::Truncate)){ QTextStream stream(&pFile); QMap<int,Person*> pList = lendlib->getPList(); stream << "ID \t Name\n"; for(auto p: pList.keys()){ stream << pList.value(p)->getID()<< "\t" << pList.value(p)->getFullName() << "\n"; } pFile.close(); } }
void VentanaPrincipal::on_bPuntajes_clicked(){ /**Cierro la Ventana Principal*/ QString mFilemane = "guardar.txt"; QFile mFile(mFilemane); if(mFile.exists()){ /**Llamo a la Ventana de PUNTAJES*/ this->close(); Puntajes *puntajes = new Puntajes(); puntajes->show(); puntajes->setPuntajes(); }else QMessageBox::information(this, "MENSAJE", "No existen Puntajes Guardados","ACEPTAR"); }
void Writeint(QString Filename,qint8 index) { QFile mFile(Filename); if(!mFile.open(QFile::WriteOnly|QFile::Text)) { qDebug()<<"reinstall the software"; return; } QTextStream out(&mFile); out<<index; mFile.flush(); mFile.close(); }
void Read(QString Filename) { QFile mFile(Filename); if(!mFile.open(QFile::ReadOnly | QFile::Text)) { qDebug()<<"Could not open file for writing"; return; } QTextStream in(&mFile); QString mText = in.readAll(); qDebug()<<mText; mFile.close(); }
void Write(QString fileName) { QFile mFile(fileName); if (!mFile.open(QFile::WriteOnly | QFile::Text)) { qDebug() << "could not open file for write"; return; } QTextStream out(&mFile); out << "Hello Qt"; mFile.flush(); mFile.close(); return; }
//SLOT podejmujący akcję na zmianę w pliku, jeśli nastąpiłą zmiana pliku ale plik nie jest pusty to odpala metode Read_clear_file void MainWindow::fileChangedSlot(QString Filename) { //#ifdef QT_DEBUG //qDebug() << "files watched: " << fw->files() << fw->directories(); //#endif //QMessageBox::information(this,"test","Zmiana pliku2: "+Filename); QFile mFile(Filename); mFile.open( QIODevice::WriteOnly|QIODevice::Append); if (mFile.pos() != 0) { //Read_clear_file(Filename); // some data inside //QMessageBox::information(this,"test","Zmiana pliku2: "+Filename); ui->lineEdit_2->setText(Read_file(Wygrany)); ui->pushButton->hide(); ui->pushButton_3->show(); } }
//Metoda odczytująca z pliku centralki QString MainWindow::Read_file(QString Filename) { QFile mFile(Filename); // mFile.open(QIODevice::ReadOnly | QIODevice::Text); if(!mFile.open(QFile::ReadOnly | QFile::Text)) //# Sprawdzenie czy czy można zapisywać do pliku { QMessageBox::information(this,"Debug: open file","5Nie mogę otworzyć pliku: "+Filename+" do odczytu"); //return; } QTextStream in(&mFile); QString mText = in.readAll(); //dData = mText.toDouble(); //ui->lineEdit->setText(QString::number(RData,'f', 2)); return mText; mFile.close(); }
QString Read(QString Filename) { QFile mFile(Filename); if(!mFile.open(QFile::ReadOnly|QFile::Text)) { qDebug()<<"sorry"; return 0; } QTextStream in(&mFile); QString mText=in.readLine(); mFile.close(); return (mText); }
void ClientDataBase::writeToFile() { QFile mFile("infoclient.txt"); if(!mFile.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::information(this,tr("Информация"),tr("Не удалось открыть файл")); return; } QTextStream stream(&mFile); for(int i = 0; i < clientList.size(); i++) { stream<<"\n"<<clientList.at(i); stream.flush(); } mFile.close(); }
aboutDialog::aboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::aboutDialog) { ui->setupUi(this); #ifdef Q_OS_MAC this->setWindowIcon(QIcon(":/cat_builder.icns")); #endif #ifdef Q_OS_WIN this->setWindowIcon(QIcon(":/cat_builder.ico")); if(QSysInfo::WindowsVersion>=QSysInfo::WV_VISTA) { if(QtWin::isCompositionEnabled()) { this->setAttribute(Qt::WA_TranslucentBackground, true); QtWin::extendFrameIntoClientArea(this, -1,-1,-1, -1); QtWin::enableBlurBehindWindow(this); } else { QtWin::resetExtendedFrame(this); setAttribute(Qt::WA_TranslucentBackground, false); } } #endif ui->About1->setText(ui->About1->text() .arg(_FILE_VERSION) .arg(_FILE_RELEASE) .arg(QString("Revision: %1, Build date: <u>%2</u>") .arg(_BUILD_VER) .arg(_DATE_OF_BUILD)) ); QFile mFile(":/credits.html"); if(!mFile.open(QFile::ReadOnly | QFile::Text)){ return; } QTextStream in(&mFile); in.setCodec("UTF-8"); QString mText = in.readAll(); ui->About2->setText(mText); mFile.close(); }
/*! * \qmlsignal FileWriter::writeFile() * used in QML as a signal to write a contents to a file */ void FileWriter::writeFile() { emit running(); QFile mFile(m_FileName); if(!mFile.open(QFile::ReadWrite | QFile::Text )){ emit error(mFile.errorString()); m_errorString = mFile.errorString(); return ; } QTextStream out(&mFile); out << m_Output; emit done(); mFile.flush(); mFile.close(); }
void Dialog::on_comboBox_activated(const QString &arg1) { str = ui->comboBox->currentText(); QFile mFile(str); if(!mFile.open(QFile::ReadOnly | QFile::Text)) { QMessageBox msgBox; msgBox.setText("Error."); msgBox.exec(); return; } QTextStream stream (&mFile); str=stream.readAll(); ui->label_2->setText(str); }
void Caddcollection::OnOK() { // TODO: Add extra validation here CDialog::OnOK(); UpdateData(TRUE); editsave=editsave+"\n"+"ÎÒµÄÆÀÂÛ£º"+"\n"+m_edit; // CString m_strFolderPath=_T("C:\\Users\\Public\\RSSCOLLECTION"); char* path1=new char [10000]; GetCurrentDirectory(20000,path1); path=path1; CString m_strFolderPath=_T(path+"\\RSSCOLLECTION"); if(!PathIsDirectory(m_strFolderPath)) CreateDirectory(m_strFolderPath,NULL); CFile mFile(_T(path+"\\RSSCOLLECTION\\"+titlesave+".txt"), CFile::modeWrite|CFile::modeCreate); mFile.Write(editsave,editsave.GetLength()); mFile.Flush(); mFile.Close(); }
void TabDialog::readToFile() { QFile mFile("mycar.txt"); if(!mFile.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::information(this,tr("Предупреждение"),tr("Не удалось открыть файл. Если Вы запускаете программу впервый раз проигнорируйте это сообщение")); return; } QTextStream stream(&mFile); Car temp; QString str; str = stream.readLine(); while(!stream.atEnd()) { stream>>temp; catalog.push_back(temp); stream.flush(); } mFile.close(); }
void ClientDataBase::readToFile() { QFile mFile("infoclient.txt"); if(!mFile.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::information(this,tr("Информация"),tr("Не удалось открыть файл")); return; } QString str; QTextStream stream(&mFile); str = stream.readLine(); Client temp(0); while(!stream.atEnd()) { stream>>temp; clientList.push_back(temp); stream.flush(); } mFile.close(); }