当前位置: 首页>>代码示例>>C++>>正文


C++ QStack::count方法代码示例

本文整理汇总了C++中QStack::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QStack::count方法的具体用法?C++ QStack::count怎么用?C++ QStack::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStack的用法示例。


在下文中一共展示了QStack::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hasContext

// traverses to the top to check all of the parent contexes.
bool XLIFFHandler::hasContext(XliffContext ctx) const
{
    for (int i = m_contextStack.count() - 1; i >= 0; --i) {
        if (m_contextStack.at(i) == ctx)
            return true;
    }
    return false;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:xliff.cpp

示例2: stream

void
BookmarkModel::setBookmarks(const QByteArray &bookmarks)
{
    beginResetModel();

    delete rootItem;
    folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
    bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png"));

    rootItem = new BookmarkItem(DataVector() << tr("Name") << tr("Address")
        << true);

    QStack<BookmarkItem*> parents;
    QDataStream stream(bookmarks);

    qint32 version;
    stream >> version;
    if (version < VERSION) {
        stream.device()->seek(0);
        BookmarkItem* toolbar = new BookmarkItem(DataVector() << tr("Toolbar Menu")
            << QLatin1String("Folder") << true);
        rootItem->addChild(toolbar);

        BookmarkItem* menu = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
            << QLatin1String("Folder") << true);
        rootItem->addChild(menu);
        parents.push(menu);
    } else {
        parents.push(rootItem);
    }

    qint32 depth;
    bool expanded;
    QString name, url;
    while (!stream.atEnd()) {
        stream >> depth >> name >> url >> expanded;
        while ((parents.count() - 1) != depth)
            parents.pop();

        BookmarkItem *item = new BookmarkItem(DataVector() << name << url << expanded);
        if (url == QLatin1String("Folder")) {
            parents.top()->addChild(item);
            parents.push(item);
        } else {
            parents.top()->addChild(item);
        }
    }

    cache.clear();
    setupCache(index(0,0, QModelIndex().parent()));
    endResetModel();
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:52,代码来源:bookmarkmodel.cpp

示例3: load

void StandardTreeModel::load(const QString &filename)
{
    if (!filename.isEmpty())
        m_filename = filename;
    if (m_filename.isEmpty())
        throw AQP::Error(tr("no filename specified"));
    QFile file(m_filename);
    if (!file.open(QIODevice::ReadOnly))
        throw AQP::Error(file.errorString());

    clear();

    QStack<QStandardItem*> stack;
    stack.push(invisibleRootItem());
    QXmlStreamReader reader(&file);
    while (!reader.atEnd()) {
        reader.readNext();
        if (reader.isStartElement()) {
            if (reader.name() == TaskTag) {
                const QString name = reader.attributes()
                        .value(NameAttribute).toString();
                bool done = reader.attributes().value(DoneAttribute)
                            == "1";
                StandardItem *nameItem = createNewTask(stack.top(),
                                                       name, done);
                stack.push(nameItem);
            }
            else if (reader.name() == WhenTag) {
                const QDateTime start = QDateTime::fromString(
                        reader.attributes().value(StartAttribute)
                            .toString(), Qt::ISODate);
                const QDateTime end = QDateTime::fromString(
                        reader.attributes().value(EndAttribute)
                            .toString(), Qt::ISODate);
                StandardItem *nameItem = static_cast<StandardItem*>(
                        stack.top());
                nameItem->addDateTime(start, end);
            }
        }
        else if (reader.isEndElement()) {
            if (reader.name() == TaskTag)
                stack.pop();
        }
    }
    if (reader.hasError())
        throw AQP::Error(reader.errorString());
    if (stack.count() != 1 || stack.top() != invisibleRootItem())
        throw AQP::Error(tr("loading error: possibly corrupt file"));

    calculateTotalsFor(invisibleRootItem());
}
开发者ID:JustFFunny,项目名称:WorkSpace,代码行数:51,代码来源:standardtreemodel.cpp

示例4: powerSeek

void Seeker::powerSeek( QString path ) {
    this->flag = false ;
    this->result.clear() ;
    Node* node = this->seek( path ) ;
    if ( node ) {
        if ( node->record.count() ) {
            //qDebug() << "get" << path ;
            this->result.append( node ) ;
            this->flag = true ;
        }
        else {
            //qDebug() << "power seek" ;
            QStack<Node*> current;
            QStack<Node*> deeper;
            current.push( this->current ) ;
            while( current.count() > 0 && this->result.count() < 1 ) {
                while( current.count() > 0 ) {
                    node = current.pop() ;
                    //qDebug() << QString( node->code ) ;
                    if ( node->record.count() )
                        this->result.append( node ) ;
                    else {
                        if ( this->result.count() < 1 ) {
                            for ( int i = 0; i < node->child.count(); i++ ) {
                                deeper.append( node->child[i] ) ;
                            }
                        }
                    }
                }
                current = deeper ;
                deeper.clear() ;
            }
        }
    }
    //return this->result ;
}
开发者ID:foolegg,项目名称:cute-input-method,代码行数:36,代码来源:seeker.cpp

示例5: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
	QStack<QString> files;

	// Command Line setup
	QCommandLineParser parser;
	// Process options
	parser.process( a );

	int incorrectFiles = 0;
	// Files were passed
	for ( const QString & arg : parser.positionalArguments() ) {
		QFileInfo finfo( arg );

		QRegularExpression ext( "^(bsa|ba2)$", QRegularExpression::CaseInsensitiveOption );
		if ( finfo.exists() && finfo.suffix().contains( ext ) ) {
			files.push( arg );
		} else {
			incorrectFiles++;
		}
	}

    MainWindow w;

	a.setApplicationName( "Bethesda Archive Extractor" );
	a.setApplicationDisplayName( "B.A.E." );

	QDir::setCurrent( qApp->applicationDirPath() );

    w.show();

	if ( files.count() && !incorrectFiles ) {
		w.openFile( files.pop() );

		while ( !files.isEmpty()  ) {
			w.appendFile( files.pop() );
		}
	} else if ( incorrectFiles ) {
		// Incorrect files passed
		return 0;
	}

    return a.exec();
}
开发者ID:jonwd7,项目名称:bae,代码行数:45,代码来源:main.cpp

示例6: stream

void
BookmarkModel::setBookmarks(const QByteArray &bookmarks)
{
    beginResetModel();

    delete rootItem;
    folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
    bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png"));

    rootItem = new BookmarkItem(DataVector() << tr("Name") << tr("Address")
        << true);
    BookmarkItem* item = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
        << QLatin1String("Folder") << true);
    rootItem->addChild(item);

    QStack<BookmarkItem*> parents;
    parents.push(item);

    qint32 depth;
    bool expanded;
    QString name, url;
    QDataStream stream(bookmarks);
    while (!stream.atEnd()) {
        stream >> depth >> name >> url >> expanded;

        while ((parents.count() - 1) != depth)
            parents.pop();

        item = new BookmarkItem(DataVector() << name << url << expanded);
        if (url == QLatin1String("Folder")) {
            parents.top()->addChild(item);
            parents.push(item);
        } else {
            parents.top()->addChild(item);
        }
    }

    cache.clear();
    const QModelIndex &root = index(0,0, QModelIndex());

    setupCache(root);
    cache.insert(static_cast<BookmarkItem*> (root.internalPointer()), root);

    endResetModel();
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:45,代码来源:bookmarkmodel.cpp

示例7: expire

int Repository::expire()
{
    unsigned current = time(0L);
    if (current < head_time)
	return 0;

    unsigned t;
    QStack<QByteArray> keys;
    head_time = (unsigned) -1;
    RepoIterator it;
    for (it=repo.begin(); it!=repo.end(); ++it)
    {
	t = it.value().timeout;
	if (t <= current)
	    keys.push(it.key());
	else
	    head_time = qMin(head_time, t);
    }

    int n = keys.count();
    while (!keys.isEmpty())
	remove(keys.pop());
    return n;
}
开发者ID:KDE,项目名称:kdesu,代码行数:24,代码来源:repo.cpp

示例8: parseTrace

void TraceLoader::parseTrace()
{
    QList<ApiTraceFrame*> frames;
    ApiTraceFrame *currentFrame = 0;
    int frameCount = 0;
    QStack<ApiTraceCall*> groups;
    QVector<ApiTraceCall*> topLevelItems;
    QVector<ApiTraceCall*> allCalls;
    quint64 binaryDataSize = 0;

    int lastPercentReport = 0;

    trace::Call *call = m_parser.parse_call();
    while (call) {
        //std::cout << *call;
        if (!currentFrame) {
            currentFrame = new ApiTraceFrame();
            currentFrame->number = frameCount;
            ++frameCount;
        }
        ApiTraceCall *apiCall =
            apiCallFromTraceCall(call, m_helpHash, currentFrame, groups.isEmpty() ? 0 : groups.top(), this);
        allCalls.append(apiCall);
        if (groups.count() == 0) {
            topLevelItems.append(apiCall);
        }
        if (call->flags & trace::CALL_FLAG_MARKER_PUSH) {
            groups.push(apiCall);
        } else if (call->flags & trace::CALL_FLAG_MARKER_POP) {
            groups.top()->finishedAddingChildren();
            groups.pop();
        }
        if (!groups.isEmpty()) {
            groups.top()->addChild(apiCall);
        }
        if (apiCall->hasBinaryData()) {
            QByteArray data =
                apiCall->arguments()[apiCall->binaryDataIndex()].toByteArray();
            binaryDataSize += data.size();
        }
        if (call->flags & trace::CALL_FLAG_END_FRAME) {
            allCalls.squeeze();
            topLevelItems.squeeze();
            if (topLevelItems.count() == allCalls.count()) {
                currentFrame->setCalls(allCalls, allCalls, binaryDataSize);
            } else {
                currentFrame->setCalls(topLevelItems, allCalls, binaryDataSize);
            }
            allCalls.clear();
            groups.clear();
            topLevelItems.clear();
            frames.append(currentFrame);
            currentFrame = 0;
            binaryDataSize = 0;
            if (frames.count() >= FRAMES_TO_CACHE) {
                emit framesLoaded(frames);
                frames.clear();
            }
            if (m_parser.percentRead() - lastPercentReport >= 5) {
                emit parsed(m_parser.percentRead());
                lastPercentReport = m_parser.percentRead();
            }
        }
        delete call;
        call = m_parser.parse_call();
    }

    //last frames won't have markers
    //  it's just a bunch of Delete calls for every object
    //  after the last SwapBuffers
    if (currentFrame) {
        allCalls.squeeze();
        if (topLevelItems.count() == allCalls.count()) {
            currentFrame->setCalls(allCalls, allCalls, binaryDataSize);
        } else {
            currentFrame->setCalls(topLevelItems, allCalls, binaryDataSize);
        }
        frames.append(currentFrame);
        currentFrame = 0;
    }
    if (frames.count()) {
        emit framesLoaded(frames);
    }
}
开发者ID:is00hcw,项目名称:apitrace,代码行数:84,代码来源:traceloader.cpp

示例9: CDXToCDXML

// Convert binary CDX to text CDXML
QString ChemData::CDXToCDXML( QString fn )
{
    QFile f( fn );
    QString wholefile, proptag, stag;

    QStack<QString *> tagstack;
    QString *ts;

    if ( !f.open( QIODevice::ReadOnly ) )
        return wholefile;

    qDebug() << "CDX ChemDraw binary file format.";
    //QMessageBox::warning(r, "Can't read binary format",
    //           "This file is a ChemDraw (CDX) binary file, but this program cannot read it (yet :)");

    // make a QByteArray
    QByteArray cdxfile = f.readAll();

//    for ( int c = 0; c < f.size(); c++ ) {
//        cdxfile[c] = f.getch();
//    }
    bool opentag = false;

    // start reading tags.
    int ptr;

    ptr = 28;                   // theoretically, position 28 is where the Document tag is
    // the Document tag doesn't really matter to us; we ignore most of that
    // stuff anyways...
    wholefile.append( "<CDXML>" );

    if ( ( cdxfile[ptr] == '0' ) && ( cdxfile[ptr + 1] == 'b' ) )
        ptr = 30;
    do {                        // until a <colortable>, <fonttable>, or <page> tag is found
        if ( ( cdxfile[ptr] == '0' ) && ( cdxfile[ptr + 1] == '0' ) ) { // end tag?
            if ( tagstack.count() > 0 ) {
                if ( opentag )
                    wholefile.append( ">" );
                ts = tagstack.top();
                if ( ( *ts == "</t>" ) && ( stag.length() > 1 ) ) {
                    wholefile.append( stag );
                    stag = "";
                }
                ts = tagstack.pop();
                wholefile.append( *ts );
                ptr += 2;
                opentag = false;
            } else {
                ptr += 2;
            }
            continue;
        }
        if ( cdxfile[ptr + 1] >= '0' ) {        // it's a property
            int moveforward = cdxfile[ptr + 3] * 256;   // TODO + cdxfile[ptr+2] + 4;
            QByteArray b( moveforward, '0' );

            for ( int d = 0; d < moveforward; d++ )
                b[d] = cdxfile[ptr + d];
            proptag = ParseProperty( b );
            if ( ( cdxfile[ptr] == '0' ) && ( cdxfile[ptr + 1] == '7' ) ) {
                stag = proptag;
                ptr += moveforward;     // move past data
                continue;
            }
            if ( proptag.length() > 1 ) {
                wholefile.append( " " );
                wholefile.append( proptag );
            }
            ptr += moveforward; // move past data
            continue;
        }
        if ( ( unsigned char ) cdxfile[ptr + 1] == 'c' ) {      // it's an object
            if ( ( tagstack.count() > 0 ) && opentag )
                wholefile.append( ">" );
            opentag = true;
            int local_id = 0;

            local_id = local_id + ( unsigned char ) cdxfile[ptr + 2];
            local_id = local_id + ( unsigned char ) cdxfile[ptr + 3] * 256;
            QString s_id;

            s_id.setNum( local_id );
            if ( cdxfile[ptr] == '1' ) {        // page object
                wholefile.append( "<page " );
                wholefile.append( "id=\"" );
                wholefile.append( s_id );
                wholefile.append( "\"" );
                ts = new QString( "</page>" );
                tagstack.push( ts );
                ptr += 6;       // move past tag and ID
                continue;
            }
            if ( cdxfile[ptr] == '3' ) {        // fragment object
                wholefile.append( "<fragment " );
                wholefile.append( "id=\"" );
                wholefile.append( s_id );
                wholefile.append( "\"" );
                ts = new QString( "</fragment>" );
                tagstack.push( ts );
//.........这里部分代码省略.........
开发者ID:parrondo,项目名称:xdrawchem2,代码行数:101,代码来源:cdx2cdxml.cpp

示例10: parse

void QQuickStyledTextPrivate::parse()
{
    QList<QTextLayout::FormatRange> ranges;
    QStack<QTextCharFormat> formatStack;

    QString drawText;
    drawText.reserve(text.count());

    updateImagePositions = !imgTags->isEmpty();

    int textStart = 0;
    int textLength = 0;
    int rangeStart = 0;
    bool formatChanged = false;

    const QChar *ch = text.constData();
    while (!ch->isNull()) {
        if (*ch == lessThan) {
            if (textLength) {
                appendText(text, textStart, textLength, drawText);
            } else if (prependSpace) {
                drawText.append(space);
                prependSpace = false;
                hasSpace = true;
            }

            if (rangeStart != drawText.length() && formatStack.count()) {
                if (formatChanged) {
                    QTextLayout::FormatRange formatRange;
                    formatRange.format = formatStack.top();
                    formatRange.start = rangeStart;
                    formatRange.length = drawText.length() - rangeStart;
                    ranges.append(formatRange);
                    formatChanged = false;
                } else if (ranges.count()) {
                    ranges.last().length += drawText.length() - rangeStart;
                }
            }
            rangeStart = drawText.length();
            ++ch;
            if (*ch == slash) {
                ++ch;
                if (parseCloseTag(ch, text, drawText)) {
                    if (formatStack.count()) {
                        formatChanged = true;
                        formatStack.pop();
                    }
                }
            } else {
                QTextCharFormat format;
                if (formatStack.count())
                    format = formatStack.top();
                if (parseTag(ch, text, drawText, format)) {
                    formatChanged = true;
                    formatStack.push(format);
                }
            }
            textStart = ch - text.constData() + 1;
            textLength = 0;
        } else if (*ch == ampersand) {
            ++ch;
            appendText(text, textStart, textLength, drawText);
            parseEntity(ch, text, drawText);
            textStart = ch - text.constData() + 1;
            textLength = 0;
        } else if (ch->isSpace()) {
            if (textLength)
                appendText(text, textStart, textLength, drawText);
            if (!preFormat) {
                prependSpace = !hasSpace;
                for (const QChar *n = ch + 1; !n->isNull() && n->isSpace(); ++n)
                    ch = n;
                hasNewLine = false;
            } else  if (*ch == lineFeed) {
                drawText.append(QChar(QChar::LineSeparator));
                hasNewLine = true;
            } else {
                drawText.append(QChar(QChar::Nbsp));
                hasNewLine = false;
            }
            textStart = ch - text.constData() + 1;
            textLength = 0;
        } else {
            ++textLength;
        }
        if (!ch->isNull())
            ++ch;
    }
    if (textLength)
        appendText(text, textStart, textLength, drawText);
    if (rangeStart != drawText.length() && formatStack.count()) {
        if (formatChanged) {
            QTextLayout::FormatRange formatRange;
            formatRange.format = formatStack.top();
            formatRange.start = rangeStart;
            formatRange.length = drawText.length() - rangeStart;
            ranges.append(formatRange);
        } else if (ranges.count()) {
            ranges.last().length += drawText.length() - rangeStart;
        }
//.........这里部分代码省略.........
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:101,代码来源:qquickstyledtext.cpp

示例11: parse

void QDeclarativeStyledTextPrivate::parse()
{
    QList<QTextLayout::FormatRange> ranges;
    QStack<QTextCharFormat> formatStack;

    QString drawText;
    drawText.reserve(text.count());

    int textStart = 0;
    int textLength = 0;
    int rangeStart = 0;
    const QChar *ch = text.constData();
    while (!ch->isNull()) {
        if (*ch == lessThan) {
            if (textLength)
                drawText.append(QStringRef(&text, textStart, textLength));
            if (rangeStart != drawText.length() && formatStack.count()) {
                QTextLayout::FormatRange formatRange;
                formatRange.format = formatStack.top();
                formatRange.start = rangeStart;
                formatRange.length = drawText.length() - rangeStart;
                ranges.append(formatRange);
            }
            rangeStart = drawText.length();
            ++ch;
            if (*ch == slash) {
                ++ch;
                if (parseCloseTag(ch, text)) {
                    if (formatStack.count())
                        formatStack.pop();
                }
            } else {
                QTextCharFormat format;
                if (formatStack.count())
                    format = formatStack.top();
                if (parseTag(ch, text, drawText, format))
                    formatStack.push(format);
            }
            textStart = ch - text.constData() + 1;
            textLength = 0;
        } else if (*ch == ampersand) {
            ++ch;
            drawText.append(QStringRef(&text, textStart, textLength));
            parseEntity(ch, text, drawText);
            textStart = ch - text.constData() + 1;
            textLength = 0;
        } else {
            ++textLength;
        }
        if (!ch->isNull())
            ++ch;
    }
    if (textLength)
        drawText.append(QStringRef(&text, textStart, textLength));
    if (rangeStart != drawText.length() && formatStack.count()) {
        QTextLayout::FormatRange formatRange;
        formatRange.format = formatStack.top();
        formatRange.start = rangeStart;
        formatRange.length = drawText.length() - rangeStart;
        ranges.append(formatRange);
    }

    layout.setText(drawText);
    layout.setAdditionalFormats(ranges);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:65,代码来源:qdeclarativestyledtext.cpp

示例12: file

	_class * readFromXML(QString fileXml) {
		_class *root = NULL;

		// init xml stream
		QFile file(fileXml);
		QXmlStreamReader xmlReader;
	
		//QString line;
		if ( !file.open(QIODevice::ReadOnly) )
			return false;
	
		{
			QTextStream t( &file );
			// stream.setCodec("CP-866");
			xmlReader.addData(t.readAll());
		}	
	
		// start reading
		QStack<_specXMLElement *> stackElements;
		while(!xmlReader.atEnd()) 
		{
			if(xmlReader.isCharacters() && stackElements.count() != 0)
			{
				_specXMLElement *pElemTop = stackElements.top();
				if(pElemTop->hasBody())
				  pElemTop->setBody(xmlReader.readElementText());
			}
		
			if(xmlReader.isStartElement())
			{ 
				QString strName = xmlReader.name().toString();
				_specXMLElement *elem = createElement(strName);
			
				_specXMLElement *parentElem = (stackElements.count() != 0) ? stackElements.top() : NULL;

				if(stackElements.count() == 0)
					root = (_class *)elem;
								
				if(parentElem != NULL)
					parentElem->addChildElement(strName,elem);

				stackElements.push(elem);
			
				for(int i = 0;  i < xmlReader.attributes().count(); i++)
				{
					QXmlStreamAttribute attr = xmlReader.attributes().at(i);
					elem->setAttribute(attr.name().toString(), attr.value().toString());
				}
			}
		
			if(xmlReader.isEndElement())
			{
				stackElements.pop();
			}
			xmlReader.readNext();		

		};
	
		if(xmlReader.hasError())
		{
			return NULL;
			// std::cout << xmlReader.errorString().toStdString();
		}
	
		return root;
	};
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:66,代码来源:seakgXMLInterface.cpp

示例13: loadData

void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd)
{
    clear();

    qint64 qmlTime = 0;
    qint64 lastEndTime = 0;
    QHash <int, QVector<qint64> > durations;

    const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1);

    const QVector<QmlProfilerDataModel::QmlEventData> &eventList
            = d->modelManager->qmlModel()->getEvents();
    const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList
            = d->modelManager->qmlModel()->getEventTypes();

    // used by binding loop detection
    QStack<const QmlProfilerDataModel::QmlEventData*> callStack;
    callStack.push(0); // artificial root

    for (int i = 0; i < eventList.size(); ++i) {
        const QmlProfilerDataModel::QmlEventData *event = &eventList[i];
        const QmlProfilerDataModel::QmlEventTypeData *type = &typesList[event->typeIndex()];

        if (!d->acceptedTypes.contains(type->rangeType))
            continue;

        if (checkRanges) {
            if ((event->startTime() + event->duration() < rangeStart)
                    || (event->startTime() > rangeEnd))
                continue;
        }

        // update stats
        QmlEventStats *stats = &d->data[event->typeIndex()];

        stats->duration += event->duration();
        stats->durationSelf += event->duration();
        if (event->duration() < stats->minTime)
            stats->minTime = event->duration();
        if (event->duration() > stats->maxTime)
            stats->maxTime = event->duration();
        stats->calls++;

        // for median computing
        durations[event->typeIndex()].append(event->duration());

        // qml time computation
        if (event->startTime() > lastEndTime) { // assume parent event if starts before last end
            qmlTime += event->duration();
            lastEndTime = event->startTime() + event->duration();
        }

        //
        // binding loop detection
        //
        const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top();
        while (potentialParent && !(potentialParent->startTime() + potentialParent->duration() >
                    event->startTime())) {
            callStack.pop();
            potentialParent = callStack.top();
        }

        // check whether event is already in stack
        for (int ii = 1; ii < callStack.size(); ++ii) {
            if (callStack.at(ii)->typeIndex() == event->typeIndex()) {
                d->eventsInBindingLoop.insert(event->typeIndex());
                break;
            }
        }

        if (callStack.count() > 1)
            d->data[callStack.top()->typeIndex()].durationSelf -= event->duration();
        callStack.push(event);

        d->modelManager->modelProxyCountUpdated(d->modelId, i, eventList.count()*2);
    }

    // post-process: calc mean time, median time, percentoftime
    int i = d->data.size();
    int total = i * 2;

    for (QHash<int, QmlEventStats>::iterator it = d->data.begin(); it != d->data.end(); ++it) {
        QmlEventStats* stats = &it.value();
        if (stats->calls > 0)
            stats->timePerCall = stats->duration / (double)stats->calls;

        QVector<qint64> eventDurations = durations[it.key()];
        if (!eventDurations.isEmpty()) {
            Utils::sort(eventDurations);
            stats->medianTime = eventDurations.at(eventDurations.count()/2);
        }

        stats->percentOfTime = stats->duration * 100.0 / qmlTime;
        stats->percentSelf = stats->durationSelf * 100.0 / qmlTime;
        d->modelManager->modelProxyCountUpdated(d->modelId, i++, total);
    }

    // set binding loop flag
    foreach (int typeIndex, d->eventsInBindingLoop)
        d->data[typeIndex].isBindingLoop = true;
//.........这里部分代码省略.........
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:101,代码来源:qmlprofilerstatisticsmodel.cpp

示例14: frameContentsLoaded

QVector<ApiTraceCall*>
TraceLoader::fetchFrameContents(ApiTraceFrame *currentFrame)
{
    Q_ASSERT(currentFrame);

    if (currentFrame->isLoaded()) {
        return currentFrame->calls();
    }

    if (m_parser.supportsOffsets()) {
        unsigned frameIdx = currentFrame->number;
        int numOfCalls = numberOfCallsInFrame(frameIdx);

        if (numOfCalls) {
            quint64 binaryDataSize = 0;
            QStack<ApiTraceCall*> groups;
            QVector<ApiTraceCall*> topLevelItems;
            QVector<ApiTraceCall*> allCalls(numOfCalls);
            const FrameBookmark &frameBookmark = m_frameBookmarks[frameIdx];

            m_parser.setBookmark(frameBookmark.start);

            trace::Call *call;
            int parsedCalls = 0;
            while ((call = m_parser.parse_call())) {
                ApiTraceCall *apiCall =
                    apiCallFromTraceCall(call, m_helpHash,
                                         currentFrame, groups.isEmpty() ? 0 : groups.top(), this);
                Q_ASSERT(apiCall);
                Q_ASSERT(parsedCalls < allCalls.size());
                allCalls[parsedCalls++] = apiCall;
                if (groups.count() == 0) {
                    topLevelItems.append(apiCall);
                } else {
                    groups.top()->addChild(apiCall);
                }
                if (call->flags & trace::CALL_FLAG_MARKER_PUSH) {
                    groups.push(apiCall);
                } else if (call->flags & trace::CALL_FLAG_MARKER_POP) {
                    if (groups.count()) {
                        groups.top()->finishedAddingChildren();
                        groups.pop();
                    }
                }
                if (apiCall->hasBinaryData()) {
                    QByteArray data =
                        apiCall->arguments()[
                            apiCall->binaryDataIndex()].toByteArray();
                    binaryDataSize += data.size();
                }

                delete call;

                if (apiCall->flags() & trace::CALL_FLAG_END_FRAME) {
                    break;
                }

            }
            // There can be fewer parsed calls when call in different
            // threads cross the frame boundary
            Q_ASSERT(parsedCalls <= numOfCalls);
            Q_ASSERT(parsedCalls <= allCalls.size());
            allCalls.resize(parsedCalls);
            allCalls.squeeze();

            Q_ASSERT(parsedCalls <= currentFrame->numChildrenToLoad());
            if (topLevelItems.count() == allCalls.count()) {
                emit frameContentsLoaded(currentFrame, allCalls,
                                         allCalls, binaryDataSize);
            } else {
                emit frameContentsLoaded(currentFrame, topLevelItems,
                                         allCalls, binaryDataSize);
            }
            return allCalls;
        }
    }
    return QVector<ApiTraceCall*>();
}
开发者ID:is00hcw,项目名称:apitrace,代码行数:78,代码来源:traceloader.cpp

示例15: parseOutput

void EPSPlug::parseOutput(QString fn, bool eps)
{
	QString tmp, token, params, lasttoken, lastPath, currPath;
	int z, lcap, ljoin, dc, pagecount;
	int failedImages = 0;
	double dcp;
	bool fillRuleEvenOdd = true;
	PageItem* ite;
	QStack<PageItem*> groupStack;
	QStack< QList<PageItem*> > groupStackP;
	QStack<int>  gsStack;
	QStack<uint> gsStackMarks;
	QFile f(fn);
	lasttoken = "";
	pagecount = 1;
	if (f.open(QIODevice::ReadOnly))
	{
		int fProgress = 0;
		int fSize = (int) f.size();
		if (progressDialog) {
			progressDialog->setTotalSteps("GI", fSize);
			qApp->processEvents();
		}
		lastPath = "";
		currPath = "";
		LineW = 0;
		Opacity = 1;
		CurrColor = CommonStrings::None;
		JoinStyle = Qt::MiterJoin;
		CapStyle = Qt::FlatCap;
		DashPattern.clear();
		ScTextStream ts(&f);
		int line_cnt = 0;
		while (!ts.atEnd() && !cancel)
		{
			tmp = "";
			tmp = ts.readLine();
			if (progressDialog && (++line_cnt % 100 == 0)) {
				int fPos = f.pos();
				int progress = static_cast<int>(ceil(fPos / (double) fSize * 100));
				if (progress > fProgress)
				{
					progressDialog->setProgress("GI", fPos);
					qApp->processEvents();
					fProgress = progress;
				}
			}
			token = tmp.section(' ', 0, 0);
			params = tmp.section(' ', 1, -1, QString::SectionIncludeTrailingSep);
			if (lasttoken == "sp"  && !eps && token != "sp" ) //av: messes up anyway: && (!interactive))
			{
				m_Doc->addPage(pagecount);
				m_Doc->view()->addPage(pagecount, true);
				pagecount++;
			}
			if (token == "n")
			{
				Coords.resize(0);
				FirstM = true;
				WasM = false;
				ClosedPath = false;
			}
			else if (token == "m")
				WasM = true;
			else if (token == "c")
			{
				Curve(&Coords, params);
				currPath += params;
			}
			else if (token == "l")
			{
				LineTo(&Coords, params);
				currPath += params;
			}
			else if (token == "fill-winding")
			{
				fillRuleEvenOdd = false;
			}
			else if (token == "fill-evenodd")
			{
				fillRuleEvenOdd = true;
			}
			else if (token == "f")
			{
				//TODO: pattern -> Imageframe + Clip
				if (Coords.size() != 0)
				{
					if ((Elements.count() != 0) && (lastPath == currPath))
					{
						ite = Elements.last();
						ite->setFillColor(CurrColor);
						ite->setFillTransparency(1.0 - Opacity);
						lastPath = "";
					}
					else
					{
						if (ClosedPath)
							z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColor, CommonStrings::None);
						else
							z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColor, CommonStrings::None);
//.........这里部分代码省略.........
开发者ID:gyuris,项目名称:scribus,代码行数:101,代码来源:importps.cpp


注:本文中的QStack::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。