本文整理汇总了C++中QTextStream::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextStream::readLine方法的具体用法?C++ QTextStream::readLine怎么用?C++ QTextStream::readLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextStream
的用法示例。
在下文中一共展示了QTextStream::readLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import
bool RSFImporter::import (
ImporterContext &context
) {
QTextStream stream (&(context.getStream ()));
QString line, graphname="Graph";
GraphOperations graphOp (context.getGraph ());
ReadNodesStore readNodes;
bool edgeOrientedDefault = false;
bool edgeOrientedDefaultForce = false;
Data::Type *edgeType = NULL;
Data::Type *nodeType = NULL;
context.getGraph ().setName (graphname);
(void)graphOp.addDefaultTypes (edgeType, nodeType);
int i = 0;
//citanie vstupneho suboru
while ( !stream.atEnd() ) {
line = stream.readLine();
QStringList words;
words = line.split (QRegExp (QString ("[ \t]+")));
int size = words.size ();
Data::Type *newNodeType = NULL;
osg::ref_ptr<Data::Node> node1, node2;
osg::ref_ptr<Data::Edge> edge;
if (size!=3) {
printf("%d",size);
context.getInfoHandler ().reportError ("Zvoleny subor nie je validny RSF subor.");
return false;
}
else {
if (words[0]=="tagged")
{
} else
{
QString edgeName = words[0];
QString srcNodeName = words[1];
QString dstNodeName = words[2];
// vytvorenie pociatocneho uzla
if (!readNodes.contains(srcNodeName))
{
node1 = context.getGraph().addNode(srcNodeName, nodeType);
readNodes.addNode(srcNodeName, node1);
} else {
node1=readNodes.get(srcNodeName);
}
//vytvorenie koncoveho uzla
if (!readNodes.contains(dstNodeName))
{
node2 = context.getGraph ().addNode(dstNodeName, nodeType);
readNodes.addNode(dstNodeName, node2);
} else {
node2=readNodes.get(dstNodeName);
}
//vytvorenie celej hyperhrany
osg::ref_ptr<Data::Node> hyperEdgeNode;
QMap<qlonglong, osg::ref_ptr<Data::Edge> > *mapa = context.getGraph().getEdges();
hyperEdgeNode=RSFImporter().getHyperEdge(srcNodeName,edgeName,mapa);
if (!hyperEdgeNode.valid ()) {
hyperEdgeNode = context.getGraph ().addHyperEdge (edgeName);
context.getGraph ().addEdge (QString (""), node1, hyperEdgeNode, edgeType, true);
}
//pridanie hyperhrany do grafu
context.getGraph ().addEdge (QString (""), hyperEdgeNode, node2, edgeType, true);
}
}
}
return true;
}
示例2: file
// This function will be called only once.
static const FontSets &getPreferedFontSets() {
static FontSets font_sets;
const QString &res_path = getPath(RESOURCE);
QString filename = res_path + "default_font.conf";
if (!QFile::exists(filename)) {
filename = res_path + "/dict/" + "default_font.conf";
}
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
FQ_TRACE("font", 0) << "Failed to open the default font configurations file:"
<< filename;
return font_sets;
}
QTextStream is;
is.setDevice(&file);
is.setCodec(QTextCodec::codecForName("UTF-8"));
#if defined(WIN32)
QString expected_section = "Windows";
#elif defined(__APPLE__)
QString expected_section = "Apple";
#else
QString expected_section = "Linux";
#endif
QString line;
QString current_section;
while (!is.atEnd()) {
line = is.readLine().trimmed();
if (line.isEmpty() || line[0] == '#') {
continue;
}
if (line.left(1) == "[" && line.right(1) == "]") {
current_section = line.mid(1, line.length() - 2);
continue;
}
if (current_section == expected_section) {
QString en_font = line.section('=', 0, 0).trimmed().toLower();
QString fonts_for_lang = line.section('=', 1).trimmed();
map<Font::Language, QStringList> &font_set = font_sets[en_font];
QString lang = fonts_for_lang.section(":", 0, 0).trimmed();
QString fonts = fonts_for_lang.section(":", 1).trimmed();
QStringList font_list = fonts.split(",", QString::SkipEmptyParts);
for (int i = 0; i < font_list.size(); ++i) {
font_list[i] = font_list[i].trimmed();
}
font_set[Font::getLanguageByName(lang)] = font_list;
}
}
return font_sets;
}
示例3: parse
bool FASTADocParser::parse(DesignerModelComponent* model, QTextStream& fin)
{
QScriptValue FASTAs=model->getEngine()->newArray();
model->getEngine()->globalObject().setProperty("model",FASTAs);
int c=0,p=0;
QScriptValue content;
QScriptValue newFASTA;
QScriptValue partregisty;
QString tsq="";
while(!fin.atEnd())
{
QString line=fin.readLine();
if(line.startsWith(">"))
{
if(newFASTA.property("part_name").toString()!="")
{
partregisty.setProperty("partsequence",DesignerPartDocParser::generateSequence(tsq));
newFASTA.setProperty("part_length",DesignerPartDocParser::generateSequence(tsq).length());
newFASTA.setProperty("content",content);
FASTAs.setProperty(p,partregisty);
partregisty.setProperty("*partsregistry.org*",newFASTA);
p++;
}
newFASTA = model->getEngine()->newObject();
partregisty=model->getEngine()->newObject();
content=model->getEngine()->newArray();
tsq="";c=0;
{
int t=line.indexOf("acc=",0);
if(t>0)
newFASTA.setProperty("part_name",line.mid(t+4,line.indexOf("|",t)-t-4).trimmed());
t=line.indexOf("descr=",0);
if(t>0)
newFASTA.setProperty("part_descr",line.mid(t+6,line.indexOf("|",t)-t-6).trimmed());
t=line.indexOf("type=",0);
if(t>0)
newFASTA.setProperty("part_type",line.mid(t+5,line.indexOf("|",t)-t-5).trimmed());
else if(t==-1)
newFASTA.setProperty("part_type","other");
}
if(line.indexOf("=")==-1)
{
int t=1;
newFASTA.setProperty("part_name",this->readWord(line,t));
newFASTA.setProperty("part_status",this->readWord(line,t));
newFASTA.setProperty("part_id",this->readWord(line,t));
newFASTA.setProperty("part_type",this->readWord(line,t));
t=line.indexOf('"');
newFASTA.setProperty("part_descr",line.mid(t+1,line.indexOf('"',t+1)-t-1).trimmed());
}
}
else
tsq+=line;
if(fin.atEnd())
{
if(!newFASTA.isNull())
{
partregisty.setProperty("partsequence",DesignerPartDocParser::generateSequence(tsq));
newFASTA.setProperty("part_length",DesignerPartDocParser::generateSequence(tsq).length());
newFASTA.setProperty("content",content);
FASTAs.setProperty(p,partregisty);
partregisty.setProperty("*partsregistry.org*",newFASTA);
}
}
if(!line.isEmpty())
{
content.setProperty(c,line);
c++;
}
}
if(FASTAs.property("length").toInteger()==0)
return false;
else
return true;
}
示例4: loadGlyphset
bool Loader::loadGlyphset()
{
QString glyphsetname = m_fileName.path();
QFile glyphsetfile( glyphsetname );
if ( !glyphsetfile.open( QIODevice::ReadOnly ) )
{
qCritical( "glyphset file unreadable" );
}
QTextStream gts( &glyphsetfile );
//TODO: Will windows have a problem with this?
QString trunk = QFileInfo( glyphsetname ).path();
//glyphsetfile has three lines: 1: nifti (skip), 2: surfaceset(s), 3: connectivity matrix
//1: TODO: skip nifti for now
QString gnl = gts.readLine();
qDebug() << "skipping: " << gnl;
//2: load surfaceset
gnl = gts.readLine();
QStringList datasetNames = gnl.split( " " );
bool two = ( datasetNames.length() > 1 );
QString datasetName = datasetNames.at( 0 );
gnl = gts.readLine();
QStringList sl2 = gnl.split( " " );
QString connectivityName;
if ( sl2.at( 0 ).startsWith( "http" ) )
{
connectivityName = sl2.at( 0 );
}
else
{
connectivityName = trunk + QDir::separator() + sl2.at( 0 );
}
float mt = 0.8;
if ( sl2.length() > 1 )
{
mt = sl2.at( 1 ).toFloat();
qDebug() << "minimum threshold: " << mt;
}
else
{
qDebug() << "no minimum threshold in glyphset file, default of " << mt << " used.";
}
float maxt = 1.0;
if ( sl2.length() > 2 )
{
maxt = sl2.at( 2 ).toFloat();
}
DatasetGlyphset* dataset = new DatasetGlyphset( glyphsetname, mt, maxt );
qDebug() << "loading glyph set: " << datasetName;
if ( two )
{
qDebug() << "...and loading glyph set: " << datasetNames.at( 1 );
if ( datasetNames.length() > 2 )
{
qCritical() << "only two hemispheres supported";
}
}
QFile setfile( trunk + QDir::separator() + datasetName );
if ( !setfile.open( QIODevice::ReadOnly ) )
{
qCritical( "set file unreadable" );
}
QTextStream ts( &setfile );
QString nl;
QString onl;
QTextStream* ots;
std::vector<QString> others;
if ( two )
{
QFile othersetfile( trunk + QDir::separator() + datasetNames.at( 1 ) );
if ( !othersetfile.open( QIODevice::ReadOnly ) )
{
qCritical( "second set file unreadable" );
}
ots = new QTextStream( &othersetfile );
qDebug() << "ots initialized";
while ( !ots->atEnd() )
{
onl = ots->readLine();
others.push_back( onl );
}
}
int k = 0;
while ( !ts.atEnd() )
{
nl = ts.readLine();
qDebug() << "!" << nl;
if ( two )
{
onl = others.at( k );
//.........这里部分代码省略.........
示例5: file
Mesh *loadOBJ(
const char * path,
std::string objectName
){
Mesh *out = new Mesh();
qDebug("Loading OBJ file %s", path);
std::vector<unsigned short> vertexIndices, uvIndices, normalIndices;
std::vector<glm::vec3> temp_vertices;
std::vector<glm::vec2> temp_uvs;
std::vector<glm::vec3> temp_normals;
QFile file(path);
if (!file.open (QIODevice::ReadOnly)) qDebug("File %s not found", path);
QTextStream stream ( &file );
char *line;
char currentObjectName[128] = "";
bool foundObjectName = !objectName.size()?true:false;
bool progressObject = !objectName.size()?true:false;
while( !stream.atEnd() ) {
line = NoLimitsRenderer::toChar(stream.readLine());
char lineHeader[128];
char tmps[128];
sscanf(line, "%s", &lineHeader);
if ( objectName.size() && strcmp( lineHeader, "o" ) == 0 ){
sscanf(line, "%s %s\n", &tmps, ¤tObjectName);
QRegExp rx(objectName.c_str());
if (rx.indexIn(std::string(currentObjectName).c_str()) < 0) progressObject = false;
else progressObject = foundObjectName = true;
continue;
}
if ( strcmp( lineHeader, "v" ) == 0 ){
glm::vec3 vertex;
sscanf(line, "%s %f %f %f\n", &tmps, &vertex.x, &vertex.y, &vertex.z);
temp_vertices.push_back(vertex);
} else if ( strcmp( lineHeader, "vt" ) == 0 ){
glm::vec2 uv;
sscanf(line, "%s %f %f\n", &tmps, &uv.x, &uv.y );
//uv.y = -uv.y; // Invert V coordinate since we will only use DDS texture, which are inverted. Remove if you want to use TGA or BMP loaders.
temp_uvs.push_back(uv);
} else if ( strcmp( lineHeader, "vn" ) == 0 ){
glm::vec3 normal;
sscanf(line, "%s %f %f %f\n", &tmps, &normal.x, &normal.y, &normal.z );
temp_normals.push_back(normal);
}
if(!progressObject) continue;
if ( strcmp( lineHeader, "f" ) == 0 ){
unsigned int vertexIndex[3], uvIndex[3], normalIndex[3];
int matches = sscanf(line, "%s %d/%d/%d %d/%d/%d %d/%d/%d\n", &tmps, &vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[2], &uvIndex[2], &normalIndex[2] );
if (matches != 10){
qDebug("File can't be read by our simple parser :-( Try exporting with other options\n");
return out;
}
vertexIndices.push_back(vertexIndex[0]);
vertexIndices.push_back(vertexIndex[1]);
vertexIndices.push_back(vertexIndex[2]);
uvIndices .push_back(uvIndex[0]);
uvIndices .push_back(uvIndex[1]);
uvIndices .push_back(uvIndex[2]);
normalIndices.push_back(normalIndex[0]);
normalIndices.push_back(normalIndex[1]);
normalIndices.push_back(normalIndex[2]);
}
}
file.close(); // when your done.
if(!foundObjectName) return out;
// For each vertex of each triangle
for( unsigned int i=0; i<vertexIndices.size(); i++ ){
// Get the indices of its attributes
unsigned int vertexIndex = vertexIndices[i];
unsigned int uvIndex = uvIndices[i];
unsigned int normalIndex = normalIndices[i];
// Get the attributes thanks to the index
glm::vec3 vertex = temp_vertices[ vertexIndex-1 ];
glm::vec2 uv = temp_uvs[ uvIndex-1 ];
glm::vec3 normal = temp_normals[ normalIndex-1 ];
out->addVertex(vertex, normal, uv);
}
return out;
}
示例6: loadFromLex
bool kvoctrainDoc::loadFromLex (QTextStream& is)
{
langs.clear();
vocabulary.clear();
QString version,
info1,
s_dummy,
title,
f_keys,
ident,
orgID,
transID;
int i_dummy,
type,
f_grade,
t_grade,
lesson;
int lines = 10000000;
version = is.readLine();
info1 = is.readLine();
ident = extract (info1);
orgID = extract (info1);
if (orgID.isEmpty())
orgID = "original";
transID = extract (info1);
if (transID.isEmpty())
transID = "translation";
if (ident != "LEX" || version != LEX_IDENT_50) {
errorLex (1, "invalid file format");
return false;
}
// first two chars usually give language code:
// english ==> en
// Deutsch ==> de
// italano ==> it
langs.push_back (orgID.left(2).lower());
langs.push_back (transID.left(2).lower());
QTextStream params (info1, IO_ReadOnly);
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> i_dummy;
params >> lines;
s_dummy = is.readLine(); // Font
s_dummy = is.readLine(); // Font
title = is.readLine();
setTitle (title);
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
s_dummy = is.readLine();
if (!loadTypeNameLex (is))
return false;
if (!loadLessonLex (is))
return false;
f_keys = is.readLine();
int ent_percent = (int) lines / 100;
float f_ent_percent = (int) lines / 100.0;
emit progressChanged(this, 0);
for (int i = 0; !is.eof() && i < lines; i++) {
if (ent_percent != 0 && (i % ent_percent) == 0 ) {
emit progressChanged(this, int(i / f_ent_percent));
}
is >> type;
is >> i_dummy;
is >> i_dummy;
is >> i_dummy;
//.........这里部分代码省略.........
示例7: readHandshake
/*!
\internal
*/
void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream)
{
m_isValid = false;
clear();
if (Q_UNLIKELY(textStream.status() != QTextStream::Ok))
return;
const QString requestLine = textStream.readLine();
const QStringList tokens = requestLine.split(' ', QString::SkipEmptyParts);
if (Q_UNLIKELY(tokens.length() < 3)) {
m_isValid = false;
clear();
return;
}
const QString verb(tokens.at(0));
const QString resourceName(tokens.at(1));
const QString httpProtocol(tokens.at(2));
bool conversionOk = false;
const float httpVersion = httpProtocol.midRef(5).toFloat(&conversionOk);
if (Q_UNLIKELY(!conversionOk)) {
clear();
m_isValid = false;
return;
}
QString headerLine = textStream.readLine();
m_headers.clear();
while (!headerLine.isEmpty()) {
const QStringList headerField = headerLine.split(QStringLiteral(": "),
QString::SkipEmptyParts);
if (Q_UNLIKELY(headerField.length() < 2)) {
clear();
return;
}
m_headers.insertMulti(headerField.at(0).toLower(), headerField.at(1));
headerLine = textStream.readLine();
}
const QString host = m_headers.value(QStringLiteral("host"), QString());
m_requestUrl = QUrl::fromEncoded(resourceName.toLatin1());
if (m_requestUrl.isRelative())
m_requestUrl.setHost(host);
if (m_requestUrl.scheme().isEmpty()) {
const QString scheme = isSecure() ? QStringLiteral("wss") : QStringLiteral("ws");
m_requestUrl.setScheme(scheme);
}
const QStringList versionLines = m_headers.values(QStringLiteral("sec-websocket-version"));
for (QStringList::const_iterator v = versionLines.begin(); v != versionLines.end(); ++v) {
const QStringList versions = (*v).split(QStringLiteral(","), QString::SkipEmptyParts);
for (QStringList::const_iterator i = versions.begin(); i != versions.end(); ++i) {
bool ok = false;
(void)(*i).toUInt(&ok);
if (!ok) {
clear();
return;
}
const QWebSocketProtocol::Version ver =
QWebSocketProtocol::versionFromString((*i).trimmed());
m_versions << ver;
}
}
//sort in descending order
std::sort(m_versions.begin(), m_versions.end(), std::greater<QWebSocketProtocol::Version>());
m_key = m_headers.value(QStringLiteral("sec-websocket-key"), QString());
//must contain "Upgrade", case-insensitive
const QString upgrade = m_headers.value(QStringLiteral("upgrade"), QString());
//must be equal to "websocket", case-insensitive
const QString connection = m_headers.value(QStringLiteral("connection"), QString());
const QStringList connectionLine = connection.split(QStringLiteral(","),
QString::SkipEmptyParts);
QStringList connectionValues;
for (QStringList::const_iterator c = connectionLine.begin(); c != connectionLine.end(); ++c)
connectionValues << (*c).trimmed();
//optional headers
m_origin = m_headers.value(QStringLiteral("sec-websocket-origin"), QString());
const QStringList protocolLines = m_headers.values(QStringLiteral("sec-websocket-protocol"));
for (QStringList::const_iterator pl = protocolLines.begin(); pl != protocolLines.end(); ++pl) {
QStringList protocols = (*pl).split(QStringLiteral(","), QString::SkipEmptyParts);
for (QStringList::const_iterator p = protocols.begin(); p != protocols.end(); ++p)
m_protocols << (*p).trimmed();
}
const QStringList extensionLines = m_headers.values(QStringLiteral("sec-websocket-extensions"));
for (QStringList::const_iterator el = extensionLines.begin();
el != extensionLines.end(); ++el) {
QStringList extensions = (*el).split(QStringLiteral(","), QString::SkipEmptyParts);
for (QStringList::const_iterator e = extensions.begin(); e != extensions.end(); ++e)
m_extensions << (*e).trimmed();
}
//TODO: authentication field
m_isValid = !(host.isEmpty() ||
resourceName.isEmpty() ||
m_versions.isEmpty() ||
m_key.isEmpty() ||
(verb != QStringLiteral("GET")) ||
//.........这里部分代码省略.........
示例8: run
void FindApiThread::run()
{
QFile f(m_fileName);
if (!f.open(QFile::ReadOnly)) {
return;
}
QTextStream *stream = new QTextStream(&f);
QRegExp reg("^pkg\\s([\\w\\-\\.\\/]+)(\\s\\(([\\w\\-]+)\\))?,\\s(\\w+)");
QRegExp regm("\\(\\*?([\\w\\-]+)\\)\\s*(\\w+)");
while (!stream->atEnd()) {
QString line = stream->readLine();
int pos = reg.indexIn(line);
if (pos < 0) {
continue;
}
// 1 pkgname
// 2 ? (system)
// 3 ? system
// 4 const|func|method|var|type
QString pkgName = reg.cap(1);
// if (!reg.cap(3).isEmpty()) {
// pkg = reg.cap(2)+"."+pkg;
// }
// if (!lastPkg || lastPkg->name != pkgName) {
// lastPkg = m_pkgs.findPackage(pkgName);
// if (!lastPkg) {
// lastPkg = new Package(pkgName);
// m_pkgs.pkgList.append(lastPkg);
// lastType = 0;
// }
// }
QString right = line.mid(reg.cap().length()).trimmed();
QString findText;
QStringList findUrl;
QString flag = reg.cap(4);
if (flag == "var") {
///pkg archive/tar, var ErrFieldTooLong error
int pos = right.indexOf(" ");
QString name = right.left(pos);
if (pos != -1) {
findText = pkgName+"."+name+" "+right.mid(pos+1);
findUrl << pkgName+"#variables"<< name;
}
//if (pos != -1 && lastPkg->findValue(name) == 0) {
// lastPkg->valueList.append(new Value(VarApi,name,right.mid(pos+1)));
//}
} else if (flag == "const") {
//pkg syscall (windows-amd64), const ECOMM Errno
int pos = right.indexOf(" ");
QString name = right.left(pos);
if (pos != -1) {
QString exp = right.mid(pos+1);
findText = pkgName+"."+name+" "+exp;
//if (exp.startsWith("ideal-") || exp == "uint16") {
findUrl << pkgName+"#constants" << name;
// } else {
// findUrl << pkgName+"."+name;
// }
}
// if (pos != -1 && lastPkg->findValue(name) == 0) {
// lastPkg->valueList.append(new Value(ConstApi,name,right.mid(pos+1)));
// }
} else if (flag == "func") {
//pkg bytes, func FieldsFunc([]byte, func(rune) bool) [][]byte
int pos = right.indexOf("(");
QString name = right.left(pos);
if (pos != -1) {
findText = pkgName+"."+name+" "+right.mid(pos);
findUrl << pkgName+"#"+name;
}
// if (pos != -1 && lastPkg->findValue(name) == 0) {
// lastPkg->valueList.append(new Value(FuncApi,name,right.mid(pos)));
// }
} else if (flag == "method") {
//pkg archive/tar, method (*Reader) Next() (*Header, error)
//pkg archive/zip, method (*File) Open() (io.ReadCloser, error)
//pkg bufio, method (ReadWriter) Available() int
int pos = regm.indexIn(right);
if (pos != -1) {
QString typeName = regm.cap(1);
QString name = regm.cap(2);
QString exp = right.mid(regm.cap().length()).trimmed();
findText = pkgName+"."+typeName+"."+name+" "+exp;
findUrl << pkgName+"#"+typeName+"."+name;
// if (lastType == 0 || lastType->name != typeName || lastType->typ == StructApi) {
// lastType = lastPkg->findType(typeName);
// if (!lastType) {
// lastType = new Type(StructApi,typeName,"struct");
// lastPkg->typeList.append(lastType);
// }
// }
// if (lastType->findValue(name) == 0) {
// lastType->valueList.append(new Value(TypeMethodApi,name,exp));
// }
}
} else if (flag == "type") {
//pkg go/ast, type ObjKind int
//pkg archive/tar, type Header struct
//pkg archive/tar, type Header struct, AccessTime time.Time
//pkg container/heap, type Interface interface { Len, Less, Pop, Push, Swap }
//.........这里部分代码省略.........
示例9: fichier
Model::Model()
{
this->background = new QList<Background *>;
this->floors = new QList<Floor *>;
this->safes = new QList<Safe*>;
this->mushroom = new QList<Mushroom *>;
this->golds = new QList<Gold *>;
this->flames = new QList<Flame *>;
this->splashScreen = new SplashScreen(330, 170, ":images/go2.png");
this->darkEater=new QList<DarkEater *>;
this->background = new QList<Background *>;
this->header = new Header();
this->compteur = new QList<Brick*> ;
this->mysticTrees = new QList<MysticTree *>;
this->mario = new Mario(200, 340);
this->blood = new Blood(0,0);
this->shock = new Shock(0,0);
this->encart = new Encart(0,0, "");
getEncart()->setType(EncartType::NONE);
QFile fichier(":ModelMap.txt");
if(fichier.open(QIODevice::ReadOnly))
{
QTextStream in (&fichier);
while(!in.atEnd())
{
QString stock = in.readLine();
if (stock.left(6)=="LIGNEa")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne1.append(stock.at(i));
}
}
}
else if (stock.left(6)=="LIGNEb")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne2.append(stock.at(i));
}
}
}
else if (stock.left(6)=="LIGNEc")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne3.append(stock.at(i));
}
}
}
else if (stock.left(6)=="LIGNEd")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne4.append(stock.at(i));
}
}
}
else if (stock.left(6)=="LIGNEe")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne5.append(stock.at(i));
}
}
}
else if (stock.left(6)=="LIGNEf")
{
for(int i=0;i<stock.size();++i){
if(stock.at(i).isDigit() || stock.at(i).isLetter()){
ligne6.append(stock.at(i));
}
}
}
}
fichier.close();
}
for (int i=0; i<NbrBrickVisible; i++) {
Floor *k= new Floor(i*brickSize, Hauteur-brickSize, QString(":images/floor_bottom.jpg"));
floors->append(k);
Floor *k2= new Floor(i*brickSize, Hauteur-2*brickSize, QString(":images/floor_grass.png"));
floors->append(k2);
}
for (int i=0; i<NbrBrickVisible; i++) {
Brick *b=new Brick(i*brickSize,Hauteur+brickSize);
compteur->append(b);
}
for (int i=0; i<2; i++) {
Background* b = new Background(i*Model::Longueur, 0);
background->append(b);
}
}
示例10: exportToDBMS
//.........这里部分代码省略.........
errors.push_back(e);
}
if(!export_canceled)
{
//Connects to the new created database to create the other objects
progress=20;
new_db_conn=conn;
new_db_conn.setConnectionParam(Connection::PARAM_DB_NAME, db_model->getName());
emit s_progressUpdated(progress,
trUtf8("Connecting to database `%1'...").arg(Utf8String::create(db_model->getName())));
new_db_conn.connect();
progress=30;
//Creating the other object types
emit s_progressUpdated(progress, trUtf8("Creating objects on database `%1'...").arg(Utf8String::create(db_model->getName())));
//Generates the sql from entire model
sql_buf=db_model->getCodeDefinition(SchemaParser::SQL_DEFINITION, false);
/* Extract each SQL command from the buffer and execute them separately. This is done
to permit the user, in case of error, identify what object is wrongly configured. */
ts.setString(&sql_buf);
unsigned aux_prog=0, curr_size=0, buf_size=sql_buf.size();
progress+=(sql_gen_progress/progress);
sql_cmd.clear();
while(!ts.atEnd() && !export_canceled)
{
try
{
//Cleanup single line comments
lin=ts.readLine();
curr_size+=lin.size();
aux_prog=progress + ((curr_size/static_cast<float>(buf_size)) * 70);
ddl_tk_found=(lin.indexOf(ParsersAttributes::DDL_END_TOKEN) >= 0);
lin.remove(QRegExp("^(--)+(.)+$"));
//If the line isn't empty after cleanup it will be included on sql command
if(!lin.isEmpty())
sql_cmd += lin + "\n";
//If the ddl end token is found
if(ddl_tk_found || (!sql_cmd.isEmpty() && ts.atEnd()))
{
//Regexp used to extract the object being created
QRegExp reg=QRegExp("(CREATE)(.)+(\n)", Qt::CaseSensitive);
sql_cmd.simplified();
//Check if the regex matches the sql command
if(reg.exactMatch(sql_cmd))
{
QString obj_type, obj_name;
QRegExp reg_aux;
unsigned obj_id;
ObjectType obj_types[]={ OBJ_FUNCTION, OBJ_TRIGGER, OBJ_INDEX,
OBJ_RULE, OBJ_TABLE, OBJ_VIEW, OBJ_DOMAIN,
OBJ_SCHEMA, OBJ_AGGREGATE, OBJ_OPFAMILY,
OBJ_OPCLASS, OBJ_OPERATOR, OBJ_SEQUENCE,
OBJ_CONVERSION, OBJ_CAST, OBJ_LANGUAGE,
OBJ_COLLATION, OBJ_EXTENSION, OBJ_TYPE };
unsigned count=sizeof(obj_types)/sizeof(ObjectType);
int pos=0;
示例11: cleanupXML
void cleanupXML(QTextStream &input, QTextStream &output) {
QRegExp
filenameRegExp("filename=\"[^\"]*\""),
nameRegExp("name=\"[^\"]*\""),
tagRegExp("^\\s*<([a-zA-Z]+) "),
leadingSpaces("^ *"),
closeTag("^\\s*</");
bool inComment = false, hasContents = false;
while (!input.atEnd()) {
QString line = input.readLine();
bool startComment = line.contains("<!--");
bool endComment = line.contains("-->");
if (startComment)
inComment = true;
if (endComment)
inComment = false;
if (inComment || endComment) {
if (startComment) {
/* Turn leading spaces into tabs */
if (leadingSpaces.indexIn(line) == 0)
line = QString('\t').repeated(leadingSpaces.matchedLength()) +
line.mid(leadingSpaces.matchedLength());
}
output << line << endl;
continue;
}
/* Make sure that the name attribute is always the first one */
int tagMatch = tagRegExp.indexIn(line),
tagLength = tagRegExp.matchedLength();
int nameMatch = nameRegExp.indexIn(line),
filenameMatch = filenameRegExp.indexIn(line),
nameLength = nameRegExp.matchedLength();
if (tagMatch != -1 && nameMatch != -1 && filenameMatch == -1) {
QString a = line.mid(tagLength, nameMatch-tagLength).trimmed(),
b = line.mid(nameMatch+nameLength).trimmed();
line = line.left(tagLength) + line.mid(nameMatch, nameLength);
if (a.length() > 0)
line += " " + a;
if (b.length() > 0)
line += " " + b;
}
/* Add an extra newline if this is an object tag, and if there
have been siblings before it */
if (tagMatch != -1) {
const QString &el = tagRegExp.cap(1);
bool isObject = true;
isObject &= (el != "string");
isObject &= (el != "integer");
isObject &= (el != "float");
isObject &= (el != "boolean");
isObject &= (el != "vector");
isObject &= (el != "point");
isObject &= (el != "transform");
isObject &= (el != "spectrum");
isObject &= (el != "rgb");
isObject &= (el != "scale");
isObject &= (el != "translate");
isObject &= (el != "rotate");
isObject &= (el != "lookAt");
isObject &= (el != "matrix");
if (isObject && hasContents) {
output << endl;
hasContents = false;
}
if (!isObject)
hasContents = true;
}
/* Turn leading spaces into tabs */
if (leadingSpaces.indexIn(line) == 0)
line = QString('\t').repeated(leadingSpaces.matchedLength()) +
line.mid(leadingSpaces.matchedLength());
/* Remove ugly spaces */
if (line.endsWith(" />")) {
line = line.left(line.size()-4) + QString("/>");
hasContents = true;
} else if (line.endsWith(" />")) {
line = line.left(line.size()-3) + QString("/>");
hasContents = true;
} else if (line.endsWith("/>")) {
hasContents = true;
} else if (line.endsWith(" >")) {
line = line.left(line.size()-2) + QString(">");
} else if (line.endsWith("?>")) {
hasContents = true;
}
if (closeTag.indexIn(line) == 0)
hasContents = true;
//.........这里部分代码省略.........
示例12: sectionRe
bool Wizard::IniSettings::writeFile(const QString &path, QTextStream &stream)
{
// Look for a square bracket, "'\\["
// that has one or more "not nothing" in it, "([^]]+)"
// and is closed with a square bracket, "\\]"
QRegExp sectionRe(QLatin1String("^\\[([^]]+)\\]"));
// Find any character(s) that is/are not equal sign(s), "[^=]+"
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
// and one or more periods, "(.+)"
QRegExp keyRe(QLatin1String("^([^=]+)\\s*=\\s*(.+)$"));
const QStringList keys(mSettings.keys());
QString currentSection;
QString buffer;
while (!stream.atEnd()) {
const QString line(stream.readLine());
if (line.isEmpty() || line.startsWith(QLatin1Char(';'))) {
buffer.append(line + QLatin1String("\n"));
continue;
}
if (sectionRe.exactMatch(line)) {
buffer.append(line + QLatin1String("\n"));
currentSection = sectionRe.cap(1);
} else if (keyRe.indexIn(line) != -1) {
QString key(keyRe.cap(1).trimmed());
QString lookupKey(key);
// Append the section, but only if there is one
if (!currentSection.isEmpty())
lookupKey = currentSection + QLatin1Char('/') + key;
buffer.append(key + QLatin1Char('=') + mSettings[lookupKey].toString() + QLatin1String("\n"));
mSettings.remove(lookupKey);
}
}
// Add the new settings to the buffer
QHashIterator<QString, QVariant> i(mSettings);
while (i.hasNext()) {
i.next();
QStringList fullKey(i.key().split(QLatin1Char('/')));
QString section(fullKey.at(0));
section.prepend(QLatin1Char('['));
section.append(QLatin1Char(']'));
QString key(fullKey.at(1));
int index = buffer.lastIndexOf(section);
if (index != -1) {
// Look for the next section
index = buffer.indexOf(QLatin1Char('['), index + 1);
if (index == -1 ) {
// We are at the last section, append it to the bottom of the file
buffer.append(QString("\n%1=%2").arg(key, i.value().toString()));
mSettings.remove(i.key());
continue;
} else {
// Not at last section, add the key at the index
buffer.insert(index - 1, QString("\n%1=%2").arg(key, i.value().toString()));
mSettings.remove(i.key());
}
} else {
// Add the section to the end of the file, because it's not found
buffer.append(QString("\n%1\n").arg(section));
i.previous();
}
}
// Now we reopen the file, this time we write
QFile file(path);
if (file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
QTextStream in(&file);
in.setCodec(stream.codec());
// Write the updated buffer to an empty file
in << buffer;
file.flush();
file.close();
} else {
return false;
}
return true;
}
示例13: readFromText
void MindMap::readFromText(QTextStream& in)
{
clear();
m_roots.clear();
// m_root = nullptr;
Node* current=nullptr;
int currentD = 0;
QList<Node*> m_listOfAncestor;
Node* parent = nullptr;
while(!in.atEnd())
{
//if(i==90)
// return;
QString line=in.readLine();
int depth = getDepth(line);
QString data = line.trimmed();
// qDebug() << "depth:" <<depth << "data:" <<data << "currentD:" <<currentD << "ancestor count:" <<m_listOfAncestor.size();
if((depth==0)&&(data.isEmpty()))//&&(currentD==0)
{
continue;
}
else
{
if(nullptr!=current)
{
if(depth>currentD)//on level under
{
parent = current;
//current = addNodeAt(QPoint(parent->childItems().count()*20,currentD*40));
current = addNodeAt(QPoint(currentD*100,parent->childItems().count()*40));
m_listOfAncestor.append(current);
currentD = depth;
}
else if(depth==currentD)// previous d == current d
{
// qDebug() << "$$$$$$$$$$$$$$" << "parent:" << (parent==nullptr ? "null" : parent->getText());
m_listOfAncestor.removeLast();
//current = addNodeAt(QPoint(parent->childItems().count()*20,currentD*40));
current = addNodeAt(QPoint(currentD*100,parent->childItems().count()*40));
m_listOfAncestor.append(current);
}
else if(depth<currentD)//many level above
{
while(m_listOfAncestor.size()>depth)
m_listOfAncestor.removeLast();
if(!m_listOfAncestor.isEmpty())
{
parent = m_listOfAncestor.last();
}
else
{
parent = nullptr;
}
// qDebug() << "////////////////" << "parent:" << (parent==nullptr ? "null" : parent->getText());
//current = addNodeAt(QPoint(0,currentD*40));
current = addNodeAt(QPoint(currentD*100,currentD*40));
if(nullptr==parent)
{
m_listOfAncestor.clear();
m_listOfAncestor.append(current);
m_roots.append(current);
}
m_listOfAncestor.append(current);
currentD = depth;
}
else
{
// qDebug() << ";;;;;;;;;;;;;;;;;;;;;;;;;";
}
current->setText(data);
linkItem(parent,current);
}
else
{
current = addNodeAt(QPoint(sceneRect().width()/2,sceneRect().height()/2));
current->setText(data);
m_roots.append(current);
qDebug() << "add roots" << current;
currentD = depth;
parent = current;
m_listOfAncestor.clear();
m_listOfAncestor.append(current);
}
}
}
}
示例14: load_model_data
bool Loader_obj::load_model_data(Model& mdl, QString path){
qDebug("Parsing obj file...");
QStringList pathlist = path.split("/",QString::KeepEmptyParts); //KeepEmptyParts
QString model_name = pathlist.last();
qDebug("Model name: " + model_name.toUtf8());
//LOAD MESH DATA
QFile file(path);
if (!file.open (QIODevice::ReadOnly))
{
qDebug("Model import: Error 1: Model file could not be loaded...");
return false;
}
QTextStream stream ( &file );
QString line;
QString mtllib;
QString current_mesh;
QMap<QString,QVector<int> >mesh_faces;
QMap<QString,QString> mesh_mtl;
QMap<QString,Material* > mtln_mtl;
QVector<Vector3> model_vertices;
QVector<Vector3> model_vertex_normals;
QVector<Vector3> model_vertex_texture_coordinates;
while( !stream.atEnd() ) {
line = stream.readLine();
QStringList list = line.split(QRegExp("\\s+"),QString::SkipEmptyParts); //SkipEmptyParts
if(!list.empty()){
if(list.first() == "mtllib"){
mtllib = list.last();
}
else if(list.first() == "v"){
model_vertices.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "vn"){
model_vertex_normals.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "vt"){
model_vertex_texture_coordinates.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "g"){
current_mesh = list.value(1);
}
else if(list.first() == "usemtl"){
mesh_mtl[current_mesh] = list.value(1);
}
else if(list.first() == "f"){
QStringList face_part_1_list = list.value(1).split("/",QString::SkipEmptyParts); //SkipEmptyParts
QStringList face_part_2_list = list.value(2).split("/",QString::SkipEmptyParts); //SkipEmptyParts
QStringList face_part_3_list = list.value(3).split("/",QString::SkipEmptyParts); //SkipEmptyParts
mesh_faces[current_mesh].append(face_part_1_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_1_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_1_list.value(2).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(2).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(2).toInt());
}
}
}
file.close();
//LOAD MTL DATA
pathlist.removeAt(pathlist.length()-1);
QString mtl_path = pathlist.join("/") + "/" + mtllib;
QString tex_path = pathlist.join("/") + "/";
QFile mtlfile(mtl_path);
if (!mtlfile.open (QIODevice::ReadOnly))
{
qDebug("Model import: Error 2: Model material file could not be loaded...");
return false;
}
QTextStream mtlstream ( &mtlfile );
QString mtlline;
//.........这里部分代码省略.........
示例15: tr
KicadModule2Svg::PadLayer KicadModule2Svg::convertPad(QTextStream & stream, QString & pad, QList<int> & numbers) {
PadLayer padLayer = UnableToTranslate;
QStringList padStrings;
while (true) {
QString line = stream.readLine();
if (line.isNull()) {
throw QObject::tr("unexpected end of file");
}
if (line.contains("$EndPAD")) {
break;
}
padStrings.append(line);
}
QString shape;
QString drill;
QString attributes;
QString position;
foreach (QString string, padStrings) {
if (string.startsWith("Sh")) {
shape = string;
}
else if (string.startsWith("Po")) {
position = string;
}
else if (string.startsWith("At")) {
attributes = string;
}
else if (string.startsWith("Dr")) {
drill = string;
}
}
if (drill.isEmpty()) {
throw QObject::tr("pad missing drill");
}
if (attributes.isEmpty()) {
throw QObject::tr("pad missing attributes");
}
if (position.isEmpty()) {
throw QObject::tr("pad missing position");
}
if (shape.isEmpty()) {
throw QObject::tr("pad missing shape");
}
QStringList positionStrings = position.split(" ");
if (positionStrings.count() < 3) {
throw QObject::tr("position missing params");
}
int posX = positionStrings.at(1).toInt();
int posY = positionStrings.at(2).toInt();
QStringList drillStrings = drill.split(" ");
if (drillStrings.count() < 4) {
throw QObject::tr("drill missing params");
}
int drillX = drillStrings.at(1).toInt();
int drillXOffset = drillStrings.at(2).toInt();
int drillYOffset = drillStrings.at(3).toInt();
int drillY = drillX;
if (drillXOffset != 0 || drillYOffset != 0) {
throw QObject::tr("drill offset not implemented");
}
if (drillStrings.count() > 4) {
if (drillStrings.at(4) == "O") {
if (drillStrings.count() < 7) {
throw QObject::tr("drill missing ellipse params");
}
drillY = drillStrings.at(6).toInt();
}
}
QStringList attributeStrings = attributes.split(" ");
if (attributeStrings.count() < 4) {
throw QObject::tr("attributes missing params");
}
bool ok;
int layerMask = attributeStrings.at(3).toInt(&ok, 16);
if (!ok) {
throw QObject::tr("bad layer mask parameter");
}
QString padType = attributeStrings.at(1);
if (padType == "MECA") {
// seems to be the same thing
padType = "STD";
}
if (padType == "STD") {
padLayer = ToCopper0;
}
//.........这里部分代码省略.........