コード例 #1
1
ファイル: configs.cpp プロジェクト: iBeacons/NTUMEMSOpenVPN
void Configs::searchLinkedConfigs()
{
    QFile linkedOvpn (AppFunc::getAppSavePath() + QLatin1String ("/configs.txt"));

    if (linkedOvpn.exists()) {
        if (!linkedOvpn.open(QIODevice::ReadOnly | QIODevice::Text)) {
            return;
        }
        // Offen einlesen
        QTextStream in (&linkedOvpn);
        while (!in.atEnd()) {
            QString line = in.readLine();            
            if (!this->isConfigInList(line)) {
                // Add to list
                QFile linkFileExists (line.trimmed());
                if (linkFileExists.exists()) {
                    int _id (this->id++);
                    QString configName = line.trimmed().right(line.trimmed().size() - line.trimmed().lastIndexOf("/") - 1);
                    configName = configName.left(configName.size()-5);
                    OpenVpn* myObj = new OpenVpn();
                    myObj->setConfigStable(false);
                    myObj->setConfigLinked(true);
                    myObj->setConfigName(configName);
                    myObj->setConfigPath(line.trimmed().left(line.lastIndexOf("/")));
                    myObj->setId(_id);
                    // An die Liste anfügen
                    this->myList.append(qMakePair(_id, myObj));
                }
            }
        }
        linkedOvpn.close();
    }
}
コード例 #2
0
bool Wizard::loadComsolData(QTextStream& stream, QString* error)
{
    int nodes = 0;
    int expre = 0;
    if(!readTo(stream, "% Nodes:")) {*error = QString("\"% Nodes:\" tag missing"); return false;}
    stream >> nodes;
    if(nodes <= 0) {*error = QString("Nodes number incorrect"); return false;}
    if(!readTo(stream, "% Expressions:")) {*error = QString("\"% Expressions:\" tag missing"); return false;}
    stream >> expre;
    if(expre < 6 || (expre % 3 != 0)) {*error = QString("Expressions number incorrect"); return false;}
    expre /= 3;

    if(!readTo(stream, "% x")) {*error = QString("\"% x\" tag missing"); return false;}

    double t[3];
    for(int e = 0; e < expre; e++)
    {
        for(int d = 0; d < 3; d++)
        {
            if(!readTo(stream, "@ t=")) {*error = QString("\"@ t=\" tag missing - node %1, coordinate %2").arg(e).arg(d); return false;}
            stream >> t[d];
            if(stream.atEnd()) {*error = QString("Unexpected end of file"); return false;}
        }
        if(t[0] != t[1] || t[1] != t[2]) {*error = QString("Time indicators differ - node %1").arg(e); return false;}
        if(e == 0 && t[0] > 0.0) {*error = QString("Nonzero start time"); return false;}
    }
    double step = t[0] / (expre - 1);
    if(step <= 0.0) {*error = QString("Incorrect step"); return false;}

    trajectories.stepTime = step;
    trajectories.maxSteps = expre;
    trajectories.setNumber(nodes);
    for(int n = 0; n < nodes; n++)
    {
        int nn;
        stream >> nn;
        if(nn != n+1) {*error = QString("Index mismatch at line %1, index %2").arg(n+1).arg(nn); return false;}

        trajectories.setNumber(n, expre);
        for(int e = 0; e < expre; e++)
        {
            for(int d = 0; d < 3; d++)
            {
                stream >> t[d];
                if(stream.atEnd()) {*error = QString("Unexpected end of coordinates").arg(expre); return false;}
                if(stream.status() != 0 || !(t[d] == t[d]))
                {
                    trajectories.resetNumber(n, e);
                    d = 3; e = expre;
                    readTo(stream, "\n");
                }
            }
            trajectories.setCoordinates(n, e, t);
        }
    }
    return true;
}
コード例 #3
0
bool loginfrm::loadservers()
{
	cmbdb->clear();
	dbserver.clear();
	dbname_local.clear();
	uids.clear();
	pwd.clear();
	port.clear();
	QStringList tmp;
	QFile file ( QDir::homePath() +"/.first4/local.first4.conf" );
	if ( file.open ( QIODevice::ReadOnly ) )
	{
		QString streamline;
		QTextStream stream ( &file );
		while(stream.readLine() != "[SERVERS]" && !stream.atEnd()) ;
		do {
			streamline = stream.readLine();
			if(streamline != "")
			{
				if(streamline.section(":", 0, 0) == "SQLITE")
				{
					streamline = streamline.section(":", 1, 10);
			    	uids.append("");
		    		pwd.append("");
			    	dbserver.append("");
		    		dbname_local.append(streamline);
			    	port.append("");
					cmbdb->addItem(streamline + " (SQLite3)");
				}
				else
				{
					streamline = streamline.section(":", 1, 10);
			    	uids.append(streamline.section("@",0,0).section(":",0,0));
		    		pwd.append(streamline.section("@",0,0).section(":",1,1));
			    	dbserver.append(streamline.section("@",1,1).section("/",0,0));
		    		dbname_local.append(streamline.section("@",1,1).section("/",1,1).section(":",0,0));
			    	port.append(streamline.section("@",1,1).section("/",1,1).section(":",1,1));
		    		cmbdb->addItem(streamline.section("@",0,0).section(":",0,0) + "@"+ streamline.section("@",1,1).section("/",0,0) +"/"+streamline.section("@",1,1).section("/",1,1).section(":",0,0) + " (MySQL)");
				}
			}
		} while (streamline != "" && !stream.atEnd());
		file.close();
	}
    
    if(cmbdb->count()==0)
    	return FALSE;
    else
    	return TRUE;
}
コード例 #4
0
ファイル: vars.cpp プロジェクト: BackupTheBerlios/first4-svn
QStringList vars::loadgeo(QString frmname)
{
    QStringList tmp;
    QString filename;
    if(username != "")
        filename = QDir::homePath() +"/.first4/"+username+".first4.conf";
    else
        filename = QDir::homePath() +"/.first4/local.first4.conf";
    QFile file ( filename );
    if ( file.open ( QIODevice::ReadOnly ) )
    {
        QString line;
        QTextStream stream ( &file );
        while(stream.readLine() != "[WINDOW_POSITIONS]" && !stream.atEnd()) ;
        do {
            line = stream.readLine();
            if(line.section("=",0,0) == frmname)
            {
                tmp << line.section(",",0,0);
                tmp << line.section(",",1,1);
                tmp << line.section(",",2,2);
                tmp << line.section(",",3,3);
                tmp << line.section(",",4,4);
            }
        } while (line != "");
        file.close();
    }
    return tmp;
}
コード例 #5
0
ファイル: text_helper.cpp プロジェクト: BGraco/SmartPlot
bool text_helper::firstColumnIsIncrimental(QTextStream &stream, const QString &delimiter)
{
    qint64 streamStartingPosition = stream.pos();
    double firstColumnValue, prevFirstColumnValue = 0;
    bool firstColumnIsIncrimental = true;
    QString line = QString();
    QStringList strings;
    bool ok;

    //Read out the first line (possibly header)
    line = QString(stream.readLine());

    while (!stream.atEnd()) {
        line = QString(stream.readLine());
        QStringList strings = line.split(delimiter);

        //Lets determine if we can use the first column as an X-axis
        firstColumnValue = strings.value(0).toDouble(&ok);

        if (!ok || (firstColumnValue < prevFirstColumnValue)) {
            firstColumnIsIncrimental = false;
            break;
        }

        prevFirstColumnValue = firstColumnValue;
    }

    //Reposition the stream
    stream.seek(streamStartingPosition);

    return firstColumnIsIncrimental;
}
コード例 #6
0
ファイル: tablemodel.cpp プロジェクト: mimino/math_tool
void TableModel::readFromFile(QString fileName)
{
    QFile file(fileName);

    if (!file.open(QIODevice::ReadOnly))
    {
        return;
    }

    int i = 0;
    QTextStream stream ( &file );
    QString line;
    QSqlQuery q("INSERT INTO authors (id,name,address) VALUES (:id,:name,:address)");

    qDebug() << QTime::currentTime().toString("hh:mm:ss:zzz");
    _model->database().transaction();
    while(!stream.atEnd())
    {
        line = stream.readLine();
        int id = generateRecordId();
        q.bindValue( ":id", id );
        q.bindValue( ":name", line );
        q.bindValue( ":address", "");
        q.exec();
    }
    _model->database().commit();

    qDebug() << QTime::currentTime().toString("hh:mm:ss:zzz");

    file.close(); // when your done.
}
コード例 #7
0
void CCommands :: OnBNETCommand( CBNET *bnet, const QString &user, bool whisper, const CommandData &data )
{
	if( data.GetCommand() == "close" && !data.GetCommand().isEmpty( ) && m_GHost->GetCurrentGame() )
	{
		if( !m_GHost->GetCurrentGame()->GetLocked( ) )
		{
			// close as many slots as specified, e.g. "5 10" closes slots 5 and 10
			
			QTextStream SS;
			SS << data.GetPayload();
			
			while( !SS.atEnd() )
			{
				quint32 SID;
				SS >> SID;
				
				if( SS.status() != QTextStream::Ok )
				{
					//CONSOLE_Print( "[BNET: " + bnet->GetServerAlias() + "] bad input to close command" );
					break;
				}
				else
					m_GHost->GetCurrentGame()->CloseSlot( (unsigned char)( SID - 1 ), true );
			}
		}
		else
		{
コード例 #8
0
ファイル: configs.cpp プロジェクト: iBeacons/NTUMEMSOpenVPN
void Configs::removeConfigFromList(const QString &config)
{
    QString configClean (config);
    configClean = configClean.replace("\\", "/");

    QFile linkedOvpn (AppFunc::getAppSavePath()  + QLatin1String ("/configs.txt"));
    if (linkedOvpn.exists()) {
        if (!linkedOvpn.open(QIODevice::ReadOnly | QIODevice::Text))
            return;
        // Offen einlesen
        QStringList fileContent;
        QTextStream in (&linkedOvpn);
        while (!in.atEnd()) {
            QString line = in.readLine();
            if (line.trimmed() != configClean) {
                fileContent.append(line.trimmed());
            }
        }
        linkedOvpn.close();
        // Datei schreiben
        QFile linkedWriteOvpn (AppFunc::getAppSavePath()  + QLatin1String ("/configs.txt"));
        if (!linkedWriteOvpn.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
            return;
        QTextStream out (&linkedWriteOvpn);
        foreach (QString str, fileContent)
            out << str + QLatin1String ("\n");
        linkedWriteOvpn.close();
    }
}
コード例 #9
0
ファイル: solution.cpp プロジェクト: foradian/FET
bool Solution::read(Rules &r, QTextStream &tis){
	assert(0);

	assert(r.initialized);
	assert(r.internalStructureComputed);

	for(int i=0; i<r.nInternalActivities; i++){
		tis>>this->times[i];
		if(tis.atEnd()){
			//The rules and the solution do not match (1)
			return false;
		}

		if(this->times[i]>=r.nHoursPerWeek && this->times[i]!=UNALLOCATED_TIME){
			//The rules and the solution do not match (2)
			return false;
		}
	}
	
	this->_fitness=-1;
	
	this->changedForMatrixCalculation=true;

	return true;
}
コード例 #10
0
QString ConnectionData::getScript(const QString &type)
{
        QFile scrtiptFile (this->GetDir() + QLatin1String("/scripts.conf"));

        if (scrtiptFile.exists()) {
            // Öffnen und auslesen
            if (!scrtiptFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
                Message::error(QObject::tr("Can't read scriptconfig file!"), QObject::tr("An error occured"), FrmMain::instance());
                return QLatin1String ("");
            }

            // Datei offen
            QTextStream sin (&scrtiptFile);
            while (!sin.atEnd()){
                QString line (sin.readLine());
                if (line.trimmed().left(3).toUpper() == type.toUpper() + QLatin1String(":")) {
                    scrtiptFile.close();
                    return line.right(line.size() - 3);
                }
            }
            scrtiptFile.close();
        }

        return QLatin1String("");
    }
コード例 #11
0
ファイル: modcalcdaylength.cpp プロジェクト: Bugsbane/kstars
void modCalcDayLength::processLines( QTextStream &istream ) {
    QFile fOut( OutputFileBatch->url().toLocalFile() );
    fOut.open(QIODevice::WriteOnly);
    QTextStream ostream(&fOut);

    //Write header
    ostream << "# " << i18nc("%1 is a location on earth", "Almanac for %1", geoBatch->fullName())
    << QString("  [%1, %2]").arg(geoBatch->lng()->toDMSString()).arg(geoBatch->lat()->toDMSString()) << endl
    << "# " << i18n("computed by KStars") << endl
    << "#" << endl
    << "# Date      SRise  STran  SSet     SRiseAz      STranAlt      SSetAz     DayLen    MRise  MTran  MSet      MRiseAz      MTranAlt      MSetAz     LunarPhase" << endl
    << "#" << endl;

    QString line;
    QDate d;

    while ( ! istream.atEnd() ) {
        line = istream.readLine();
        line = line.trimmed();

        //Parse the line as a date, then compute Almanac values
        d = QDate::fromString( line );
        if ( d.isValid() ) {
            updateAlmanac( d, geoBatch );
            ostream << d.toString( Qt::ISODate ) << "  "
            << srTimeString << "  " << stTimeString << "  " << ssTimeString << "  "
            << srAzString << "  " << stAltString << "  " << ssAzString << "  "
            << daylengthString << "    "
            << mrTimeString << "  " << mtTimeString << "  " << msTimeString << "  "
            << mrAzString << "  " << mtAltString << "  " << msAzString << "  "
            << lunarphaseString << endl;
        }
    }
}
コード例 #12
0
bool FormattedTouchstone::ReadRow(FormattedNetworkData &network, QTextStream &snpFile, FormattedComplexMatrix2D &dataRow, double &frequencyPoint) {
    // Begin to read data values
    double wordsToRead = pow(double(network.numberOfPorts()), 2) * 2 + 1;
    QStringList allWords;
    while (wordsToRead > 0 && !snpFile.atEnd()) {
        QStringList words;
        ReadLine(snpFile, words);
        wordsToRead -= words.size();
        allWords.append(words);
    }

    // Check to see if all data was read
    if (wordsToRead != 0)
        return false;

    // Process data
    frequencyPoint = allWords[0].toDouble();
    QStringList::iterator wordIndex = allWords.begin() + 1;
    dataRow.resize(network.numberOfPorts());
    for (FormattedComplexMatrix2D::iterator rowIndex = dataRow.begin(); rowIndex != dataRow.end(); rowIndex++) {
        (*rowIndex).resize(network.numberOfPorts());
        FormattedComplexRowVector::iterator columnIndex = (*rowIndex).begin();
        for (; columnIndex != (*rowIndex).end(); columnIndex++) {
            *columnIndex = (*ReadDatum)(wordIndex->toDouble(), (wordIndex + 1)->toDouble());
            wordIndex += 2;
        }
    }
    return true;
}
コード例 #13
0
ファイル: mainwindow.cpp プロジェクト: zhoutl1106/graduate
void MainWindow::m_loadFile(QString fileName)
{
    QFile file(fileName);
    file.open(QIODevice::ReadOnly);
    QTextStream *in;
    in = new QTextStream(&file);
    delete m_doubleData;
    delete m_data;
    int tempLength = 0;

    while(!in->atEnd())
    {
        in->readLine();
        tempLength ++;
    }
    m_doubleData = new double[tempLength];
    m_data = new int[tempLength];

    delete in;
    file.close();

    file.open(QIODevice::ReadOnly);
    in = new QTextStream(&file);

    for(int i = 0; i < tempLength; i++)
    {
        m_doubleData[i] = in->readLine().toDouble();
        m_data[i] = int(m_doubleData[i] * 50);
    }
    file.close();
}
コード例 #14
0
ファイル: qloggingregistry.cpp プロジェクト: giucam/qtbase
/*!
    \internal
    Parses configuration from \a stream.
*/
void QLoggingSettingsParser::setContent(QTextStream &stream)
{
    _rules.clear();
    while (!stream.atEnd()) {
        QString line = stream.readLine();

        // Remove all whitespace from line
        line = line.simplified();
        line.remove(QLatin1Char(' '));

        // comment
        if (line.startsWith(QLatin1Char(';')))
            continue;

        if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
            // new section
            _section = line.mid(1, line.size() - 2);
            continue;
        }

        if (_section == QLatin1String("Rules")) {
            int equalPos = line.indexOf(QLatin1Char('='));
            if ((equalPos != -1)
                    && (line.lastIndexOf(QLatin1Char('=')) == equalPos)) {
                const QString pattern = line.left(equalPos);
                const QStringRef value = line.midRef(equalPos + 1);
                bool enabled = (value.compare(QLatin1String("true"),
                                              Qt::CaseInsensitive) == 0);
                _rules.append(QLoggingRule(pattern, enabled));
            }
        }
    }
}
コード例 #15
0
ファイル: helper.cpp プロジェクト: MichaelKohler/BackupSoft
QStringList* Helper::readFile(QString aFileName)
{
  // read the data line by line
  QFile *file = new QFile(aFileName);
  QStringList *data = new QStringList();
  if (file->open(QIODevice::ReadOnly) ) {
    // file opened successfully
    QTextStream *tstream = new QTextStream(file);
    while (!tstream->atEnd()) {
      data->append(tstream->readLine());
    }
    file->close();

    // ignore whitespaces
    for (int i = 0; i < data->length(); i++) {
      if (data->value(i) == "") {
        data->removeAt(i);
      }
    }
  }
  else {
    QString msg = tr("Could not open %1.. Please make sure it is existent and readable.").arg(aFileName);
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }

  return data;
}
コード例 #16
0
void modCalcEquinox::processLines( QTextStream &istream ) {
    QFile fOut( OutputFileBatch->url().toLocalFile() );
    fOut.open(QIODevice::WriteOnly);
    QTextStream ostream(&fOut);
    int originalYear = Year->value();

    //Write header to output file
    ostream << i18n("# Timing of Equinoxes and Solstices\n")
    << i18n("# computed by KStars\n#\n")
    << i18n("# Vernal Equinox\t\tSummer Solstice\t\t\tAutumnal Equinox\t\tWinter Solstice\n#\n");

    while ( ! istream.atEnd() ) {
        QString line = istream.readLine();
        bool ok = false;
        int year = line.toInt( &ok );

        //for now I will simply change the value of the Year widget to trigger
        //computation of the Equinoxes and Solstices.
        if ( ok ) {
            //triggers slotCompute(), which sets values of dSpring et al.:
            Year->setValue( year );

            //Write to output file
            ostream << 
                KGlobal::locale()->formatDate( dSpring.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dSummer.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dAutumn.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dWinter.date(), KLocale::LongDate ) << endl;
        }
    }

    if ( Year->value() != originalYear )
        Year->setValue( originalYear );
}
コード例 #17
0
ファイル: dbfileentry.cpp プロジェクト: pitonyak/LinkBackADP
bool DBFileEntry::readLine(QTextStream& stream)
{
  if (stream.status() != QTextStream::Ok || stream.atEnd()) {
    return false;
  }
  stream.skipWhiteSpace();
  QString line = stream.readLine();
  if (line.isNull()) {
    return false;
  }
  //This fails if the path contains a comma.
  //QStringList tokens = line.split(fieldSeparator);
  QStringList tokens = StringHelper::split(fieldSeparator, line, 5);
  if (tokens.count() < 5) {
    return false;
  }
  if (tokens[0].length() > 0) {
    m_linkType = tokens[0].at(0);
  }
  m_time = QDateTime::fromString(tokens[1], dateTimeFormat);
  m_hash = tokens[2];
  m_hash = m_hash.toUpper();
  bool ok;
  m_size = tokens[3].toULongLong(&ok, 10);
  if (!ok) {
    return false;
  }
  m_path = tokens[4];
  return true;
}
コード例 #18
0
ファイル: SwiftReader.cpp プロジェクト: dtamayo/OGRE
void SwiftReader::readResults(QTextStream& stream)
{
    QString line;
    int lineNum = 0;
    while (!stream.atEnd())
    {
        line = stream.readLine();
        ++lineNum;
        if (lineParser.exactMatch(line))
        {
            QStringList decimals = lineParser.capturedTexts();
            Orbit d;
            bool ok = true;
            #define HANDLE_ERROR(index) \
                if (!ok) { \
                std::ostringstream os; \
                os << "Could not decode decimal " << decimals.at(index).toAscii().data(); \
                throw std::runtime_error(os.str()); \
                }
            d.time = decimals.at(1).toDouble(&ok); HANDLE_ERROR(1);
            d.particleID = decimals.at(2).toDouble(&ok); HANDLE_ERROR(2);
            d.axis = decimals.at(3).toDouble(&ok) * 25559; HANDLE_ERROR(3);
            d.e = decimals.at(4).toDouble(&ok); HANDLE_ERROR(4);
            d.i = decimals.at(5).toDouble(&ok); HANDLE_ERROR(5);
            d.Omega = decimals.at(6).toDouble(&ok); HANDLE_ERROR(6);
            d.w = decimals.at(7).toDouble(&ok); HANDLE_ERROR(7);
            d.f = decimals.at(8).toDouble(&ok); HANDLE_ERROR(8);
            d.hasOrbEls = true;
            data[d.particleID].push_back(d);
        }
    }
}
コード例 #19
0
bool LogTransformer::loadFromStream(QTextStream & in)
{
	PatternPtr s = readPattern(in);
	PatternPtr e = readPattern(in);
	if (s && e)
	{
		stimulusStart_ = s;
		stimulusEnd_ = e;
	}
	else
	{
		return false;
	}
	stimulusPatterns_.clear();
	// Read data patterns
	while (!in.atEnd())
	{
		PatternPtr p = readPattern(in);
		if (p)
		{
			stimulusPatterns_.append(p);
		}
		else
		{
			return false;
		}
	}
	return true;
}
コード例 #20
0
void KineBallRunSandbox::readConfigFile()
{   
    QString configFileName = QString("../apps/") + this->myID + QString("/")+ this->myID + QString(".txt");
    QFile config_file(configFileName);
    if (!config_file.open(QIODevice::ReadOnly)){
        cerr<<"*** KineBallRunSandbox Config File *** >> Error with config file"<<endl;
        cerr<<"*** KineBallRunSandbox Config File *** >> File is "<<configFileName.toStdString()<<endl;
        exit(0);
    }

    cerr<<"*** KineBallRunSandbox Config File *** >> Parsing Config File ... "<<endl;
      QTextStream stream ( &config_file );
      while( !stream.atEnd() ) {
        QString line;
        QStringList lineElem;
        line = stream.readLine();
        lineElem = line.split(" ");

        if(lineElem[0] == "ASSET_DIR"){
          this->assetDir = lineElem[1];
          cerr<<this->assetDir.toStdString()<<endl;
        }
        if(lineElem[0] == "IMAGE_DIR"){
          this->imageDir = lineElem[1];
          cerr<<this->imageDir.toStdString()<<endl;
        }
        if(lineElem[0] == "TEX_IMG_DIR"){
          this->texImageDir = lineElem[1];
          cerr<<this->texImageDir.toStdString()<<endl;
        }

    }
}
コード例 #21
0
ファイル: qnstsettings.cpp プロジェクト: edcaraujo/nclstats
void QnstSettings::load(QString location)
{
  QFile* file = new QFile(location);

  if (file->open(QIODevice::ReadOnly)){
    QRegExp regex; regex.setPattern("(.*)=(.*)");

    QTextStream* stream = new QTextStream(file);

    while(!stream->atEnd()){
      QString line = stream->readLine().trimmed();

      if (line.contains(regex)){
        QString name = (regex.cap(1)).trimmed();
        QString value = (regex.cap(2)).trimmed();

        entries.insert(name,value);
      }
    }

    delete stream;
  }

  delete file;
}
コード例 #22
0
QString DeploymentData::addFilesFromDeploymentFile(const QString &deploymentFilePath,
                                                   const QString &sourceDir)
{
    const QString sourcePrefix = sourceDir.endsWith('/') ? sourceDir : sourceDir + '/';
    QFile deploymentFile(deploymentFilePath);
    QTextStream deploymentStream;
    QString deploymentPrefix;

    if (!deploymentFile.open(QFile::ReadOnly | QFile::Text))
        return deploymentPrefix;
    deploymentStream.setDevice(&deploymentFile);
    deploymentPrefix = deploymentStream.readLine();
    if (!deploymentPrefix.endsWith('/'))
        deploymentPrefix.append('/');
    if (deploymentStream.device()) {
        while (!deploymentStream.atEnd()) {
            QString line = deploymentStream.readLine();
            if (!line.contains(':'))
                continue;
            QStringList file = line.split(':');
            QString sourceFile = file.at(0);
            if (QFileInfo(sourceFile).isRelative())
                sourceFile.prepend(sourcePrefix);
            QString targetFile = file.at(1);
            if (QFileInfo(targetFile).isRelative())
                targetFile.prepend(deploymentPrefix);
            addFile(sourceFile, targetFile);
        }
    }
    return deploymentPrefix;
}
コード例 #23
0
ファイル: deck.cpp プロジェクト: m-o-s-t-a-f-a/dana
bool Deck::importFromTxt(QString fileName)
{
    const QChar sep('\t');
    QTextStream s;
    QFile file(fileName);

    file.open(QIODevice::ReadOnly | QIODevice::Text);

    if(!file.isOpen())
        return false;

    s.setDevice(&file);
    s.setCodec("UTF-8");

    QStringList sl;
    QString l = s.readLine();
    while (!s.atEnd()) {
        sl = l.split(sep);

        if(sl.size()>1) {
            Card *card = new Card();

            card->updateFront(sl[0]);
            card->updateBack(sl[1]);

            addCard(card);
        }

        l = s.readLine();
    };
    
    return true;
}
コード例 #24
0
bool CupsdConf::parseLocation(CupsLocation *location, QTextStream &file)
{
    QString line;
    bool done(false);
    bool value(true);
    while(!done && value)
    {
        line = file.readLine().simplifyWhiteSpace();
        if(line.isEmpty())
        {
            if(file.atEnd())
            {
                value = false;
                done = true;
            }
            else
                continue;
        }
        else if(line[0] == '#')
            continue;
        else if(line.lower() == "</location>")
            done = true;
        else
            value = location->parseOption(line);
    }
    return value;
}
コード例 #25
0
ファイル: document.cpp プロジェクト: cdaffara/symbiandump-mw3
bool Document::load(QTextStream &stream)
{
    m_shapeList.clear();

    while (!stream.atEnd()) {
        QString shapeType, shapeName, colorName;
        int left, top, width, height;
        stream >> shapeType >> shapeName >> colorName >> left >> top >> width >> height;
        if (stream.status() != QTextStream::Ok)
            return false;
        bool ok;
        Shape::Type type = Shape::stringToType(shapeType, &ok);
        if (!ok)
            return false;
        QColor color(colorName);
        if (!color.isValid())
            return false;

        Shape shape(type);
        shape.m_name = shapeName;
        shape.m_color = color;
        shape.m_rect = QRect(left, top, width, height);

        m_shapeList.append(shape);
    }

    m_currentIndex = m_shapeList.isEmpty() ? -1 : 0;

    return true;
}
コード例 #26
0
static void parseData(QTextStream &textStream, unsigned int &channels, LogFileData *data, double &minValue, double &maxValue)
{
	while((!textStream.atEnd()) && (textStream.status() == QTextStream::Ok))
	{
		const QString line = textStream.readLine().simplified();
		if(!line.isEmpty())
		{
			const QStringList tokens = line.split(QChar(0x20), QString::SkipEmptyParts);
			if(((unsigned int) tokens.count()) == (channels * 3))
			{
				QStringList::ConstIterator iter = tokens.constBegin();
				for(unsigned int c = 0; c < channels; c++)
				{
					data[c].original.append((iter++)->toDouble());
					data[c].minimal .append((iter++)->toDouble());
					data[c].smoothed.append((iter++)->toDouble());

					minValue = qMin(minValue, data[c].original.back());
					minValue = qMin(minValue, data[c].minimal .back());
					minValue = qMin(minValue, data[c].smoothed.back());

					maxValue = qMax(maxValue, data[c].original.back());
					maxValue = qMax(maxValue, data[c].minimal .back());
					maxValue = qMax(maxValue, data[c].smoothed.back());
				}
			}
		}
	}
}
コード例 #27
0
ファイル: testCFSM.cpp プロジェクト: shinnok/tarsnap-gui
int TestCFSM::processActions(QTextStream &in)
{
    while(!in.atEnd())
    {
        QString line = in.readLine();
        // Blank lines and comments.
        if((line.size() == 0) || (line[0] == QChar('#')))
            continue;
        else if(line == "actions:")
            continue;
        else if(line == "results:")
            break;
        else if(line[0] == QChar('+'))
            _model.setData(getIndex(line), Qt::Checked, Qt::CheckStateRole);
        else if(line[0] == QChar('-'))
            _model.setData(getIndex(line), Qt::Unchecked, Qt::CheckStateRole);
        else
        {
            QTextStream console(stdout);
            console << "ERROR: Scenario file is broken; parsing died on line:"
                    << endl
                    << line << endl;
            // Don't try to recover.
            QApplication::exit(1);
        }
    }
    return (0);
}
コード例 #28
0
ファイル: testCFSM.cpp プロジェクト: shinnok/tarsnap-gui
// Returns 0 if success, 1 if a model error, 2 if an emit error.
int TestCFSM::processResults(QTextStream &in)
{
    while(!in.atEnd())
    {
        QString line = in.readLine();
        // Blank lines and comments.
        if((line.size() == 0) || (line[0] == QChar('#')))
            continue;
        else if(line == "results:")
            continue;
        else if((line[0] == QChar('0')) || line[0] == QChar('1') ||
                (line[0] == QChar('2')))
        {
            QString lineRelname  = getRelname(line);
            int     desiredState = getLineState(line);
            int     modelState   = getCheckedStateInt(line);
            if(desiredState != modelState)
            {
                // Test failed!
                return (1);
            }
        }
        else
        {
            QTextStream console(stdout);
            console << "ERROR: Scenario file is broken; parsing died on line:"
                    << endl
                    << line << endl;
            // Don't try to recover.
            QApplication::exit(1);
        }
    }
    return (0);
}
コード例 #29
0
ファイル: mainwindow.cpp プロジェクト: ThibaudC/BomberMan
void MainWindow::LoadPartySolo()
{   
    // Ouverture du dossier parent de la solution et filtre sur les fichiers de type texte pour sélection fichier à ouvrir
    QString fichier = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "Fichiers texte (*.txt)");

    // Message d'information provisoire indiquant le chemin d'accès au fichier à ouvrir
    QMessageBox::information(this, "Fichier", "Vous avez ouvert le fichier :\n" + fichier);

    // on déclare la variable de type fichier, puis on l'ouvre en mode "lecture seule"
    QFile fichierACharger(fichier);
    fichierACharger.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream flux (&fichierACharger);

    QString ligne;

    // On parcours ensuite le fichier ligne par ligne en y appliquant un traitement : ici affichage d'une messageBox
    while(! flux.atEnd())
    {
        ligne = flux.readLine();

        QMessageBox msg;
        msg.setText(ligne);
        msg.exec();
    }
}
/**
 * @brief initShader Initiate a shader.
 * @return the compiled shader program or 0 if the shader file does not exist
 */
GLuint loadShader(string shader_name)
{
    QOpenGLFunctions* qf = new QOpenGLFunctions(QOpenGLContext::currentContext());
    char* error;

    QFile* file = new QFile((":/shader/" + shader_name + ".vsh").c_str());
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
        return 0;

    string code = "";
    QTextStream* in = new QTextStream(file);
    while (!in->atEnd()) {
        QString line = in->readLine();
        code = code + line.toStdString() + "\n";
    }
    file->close();

    GLuint vs = qf->glCreateShader(GL_VERTEX_SHADER);
    const char* v_str = code.c_str();
    qf->glShaderSource(vs, 1, &v_str, NULL);
    qf->glCompileShader(vs);
    qf->glGetShaderInfoLog(vs, NULL, NULL, error);
    cout << error << "\n";

    code = "";

    delete file;
    delete in;
    file = new QFile((":/shader/" + shader_name + ".fsh").c_str());
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
        return 0;

    in = new QTextStream(file);
    while (!in->atEnd()) {
        QString line = in->readLine();
        code = code + line.toStdString() + "\n";
    }
    file->close();

    GLuint fs = qf->glCreateShader(GL_FRAGMENT_SHADER);
    const char *f_str = code.c_str();
    qf->glShaderSource(fs, 1, &f_str, NULL);
    qf->glCompileShader(fs);
    qf->glGetShaderInfoLog(fs, NULL, NULL, error);
    cout << error << endl;

    GLuint program = qf->glCreateProgram();
    qf->glAttachShader(program, vs);
    qf->glAttachShader(program, fs);
    qf->glLinkProgram(program);
    qf->glGetProgramInfoLog(program, NULL, NULL, error);
    cout << error << endl;
    qf->glUseProgram(program);

    return program;
}