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


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

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


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

示例1: draw

void QSvgTinyDocument::draw(QPainter *p, const QString &id,
                            const QRectF &bounds)
{
    QSvgNode *node = scopeNode(id);

    if (!node) {
        qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id));
        return;
    }
    if (m_time.isNull()) {
        m_time.start();
    }

    if (node->displayMode() == QSvgNode::NoneMode)
        return;

    p->save();

    const QRectF elementBounds = node->transformedBounds();

    mapSourceToTarget(p, bounds, elementBounds);
    QTransform originalTransform = p->worldTransform();

    //XXX set default style on the painter
    QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    pen.setMiterLimit(4);
    p->setPen(pen);
    p->setBrush(Qt::black);
    p->setRenderHint(QPainter::Antialiasing);
    p->setRenderHint(QPainter::SmoothPixmapTransform);

    QStack<QSvgNode*> parentApplyStack;
    QSvgNode *parent = node->parent();
    while (parent) {
        parentApplyStack.push(parent);
        parent = parent->parent();
    }

    for (int i = parentApplyStack.size() - 1; i >= 0; --i)
        parentApplyStack[i]->applyStyle(p, m_states);

    // Reset the world transform so that our parents don't affect
    // the position
    QTransform currentTransform = p->worldTransform();
    p->setWorldTransform(originalTransform);

    node->draw(p, m_states);

    p->setWorldTransform(currentTransform);

    for (int i = 0; i < parentApplyStack.size(); ++i)
        parentApplyStack[i]->revertStyle(p, m_states);

    //p->fillRect(bounds.adjusted(-5, -5, 5, 5), QColor(0, 0, 255, 100));

    p->restore();
}
开发者ID:wpbest,项目名称:copperspice,代码行数:57,代码来源:qsvgtinydocument.cpp

示例2: indentationLevel

int ScCodeEditor::indentationLevel(const QTextCursor & cursor)
{
    QTextDocument *doc = QPlainTextEdit::document();
    int startBlockNum = doc->findBlock(cursor.selectionStart()).blockNumber();

    QStack<int> stack;
    int level = 0;
    int blockNum = 0;
    QTextBlock block = QPlainTextEdit::document()->begin();
    while (block.isValid()) {
        if (level > 0) {
            stack.push(level);
            level = 0;
        }

        TextBlockData *data = static_cast<TextBlockData*>(block.userData());
        if (data) {
            int count = data->tokens.size();
            for (int idx = 0; idx < count; ++idx) {
                const Token & token = data->tokens[idx];
                switch (token.type) {
                case Token::OpeningBracket:
                    if (token.character != '(' || stack.size() || token.positionInBlock)
                        level += 1;
                    break;

                case Token::ClosingBracket:
                    if (level)
                        level -= 1;
                    else if(!stack.isEmpty()) {
                        stack.top() -= 1;
                        if (stack.top() <= 0)
                            stack.pop();
                    }
                    break;

                default:
                    ;
                }
            }
        }

        if (blockNum == startBlockNum)
            return stack.size();

        block = block.next();
        ++blockNum;
    }

    return -1;
}
开发者ID:vanhuman,项目名称:supercollider-rvh,代码行数:51,代码来源:sc_editor.cpp

示例3: Calc

QString Calc(QString p)
{
    QStack <QString> stack;
    QString temp , r1 , r2 , r3 ;
    QStringList phrase = p.split(" ");
    QString l[4]={"+" , "-" , "*" , "/" };
    for (int i=0 ; i<phrase.size() ; i++)
    {
        for (int j=0 ; j<4 ; j++)
        {
            if (phrase.at(i)!= l[j] && j==3)
                stack.push(phrase.at(i));

            else if (phrase.at(i)==l[j])
            {
                if (stack.size()<2)
                    return "";

                r1=stack.pop();
                r2=stack.pop();
                stack.push(Ecal(r2 , r1 ,phrase.at(i)));
                break;
            }

        }
   }
   return stack.pop();
}
开发者ID:QHossein,项目名称:calc,代码行数:28,代码来源:Function.cpp

示例4: Post_to_Pre

QString Post_to_Pre(QString p)
{
    QStack <QString> stack;
    QStringList phrase=p.split(" ");
    QString r1,r2;
    QString l[4]={"+" , "-" , "*" , "/" };

    for (int i=0; i<phrase.size(); i++)
        for (int j=0 ; j<4 ; j++)
        {
            if (phrase.at(i)!=l[j] && j==3)
                stack.push(phrase.at(i));

            else if ( phrase.at(i)==l[j] )
            {
                if (stack.size()<2)
                    return "";

                r1=stack.pop();
                r2=stack.pop();
                stack.push( phrase.at(i) + " " + r2 + " " + r1 );
                break;
            }
        }
    return stack.top();
}
开发者ID:QHossein,项目名称:calc,代码行数:26,代码来源:Function.cpp

示例5: transformedBounds

QRectF QSvgNode::transformedBounds() const
{
    if (!m_cachedBounds.isEmpty())
        return m_cachedBounds;

    QImage dummy(1, 1, QImage::Format_RGB32);
    QPainter p(&dummy);
    QSvgExtraStates states;

    QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::SvgMiterJoin);
    pen.setMiterLimit(4);
    p.setPen(pen);

    QStack<QSvgNode*> parentApplyStack;
    QSvgNode *parent = m_parent;
    while (parent) {
        parentApplyStack.push(parent);
        parent = parent->parent();
    }

    for (int i = parentApplyStack.size() - 1; i >= 0; --i)
        parentApplyStack[i]->applyStyle(&p, states);
    
    p.setWorldTransform(QTransform());

    m_cachedBounds = transformedBounds(&p, states);
    return m_cachedBounds;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:28,代码来源:qsvgnode.cpp

示例6: getRowNumber

int ChannelsModel::getRowNumber(int find_channelid) const
{
    if(m_rootchannelid == find_channelid)
        return 0;

    int row = 0;
    QStack<int> channels;
    channels.push(m_rootchannelid);

    while(channels.size())
    {
        int channelid = channels.pop();
        channels_t::const_iterator ite = m_channels.find(channelid);
        Q_ASSERT(ite != m_channels.end());
        const subchannels_t& subs = ite.value();
        subchannels_t::const_iterator sub_ite = subs.begin();
        while(sub_ite != subs.end())
        {
            row++;
            if(sub_ite->nChannelID == find_channelid)
                return row;
            channels.push(sub_ite->nChannelID);
            sub_ite++;
        }
        users_t::const_iterator p_ite = m_users.find(channelid);
        Q_ASSERT(p_ite != m_users.end());
        const chanusers_t& users = p_ite.value();
        row += users.size();
    }
    return -1;
}
开发者ID:CowPanda,项目名称:TeamTalk5,代码行数:31,代码来源:channelsmodel.cpp

示例7: findBindingLoops

void QmlProfilerRangeModel::findBindingLoops()
{
    typedef QPair<int, int> CallStackEntry;
    QStack<CallStackEntry> callStack;

    for (int i = 0; i < count(); ++i) {
        int potentialParent = callStack.isEmpty() ? -1 : callStack.top().second;

        while (potentialParent != -1 && !(endTime(potentialParent) > startTime(i))) {
            callStack.pop();
            potentialParent = callStack.isEmpty() ? -1 : callStack.top().second;
        }

        // check whether event is already in stack
        for (int ii = 0; ii < callStack.size(); ++ii) {
            if (callStack.at(ii).first == typeId(i)) {
                m_data[i].bindingLoopHead = callStack.at(ii).second;
                break;
            }
        }

        CallStackEntry newEntry(typeId(i), i);
        callStack.push(newEntry);
    }

}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:26,代码来源:qmlprofilerrangemodel.cpp

示例8: zoom

void PlotZoomer::zoom(int up)
{
  // FIXME: Save the current zoom window in case it's been panned.
  int zoomIndex = zoomRectIndex();
  if (zoomIndex > 0)
  {
    QStack<QRectF> stack = zoomStack();
    if (zoomIndex < stack.size())
    {
      QRectF r = scaleRect();
      stack[zoomIndex] = r;
      setZoomStack(stack, zoomIndex);
    }
  }

  Super::zoom(up);
  if (zoomRectIndex() == 0)
  {
    if (QwtPlot *plotter = plot())
    {
      plotter->setAxisAutoScale(AxisX);
      plotter->setAxisAutoScale(AxisY);
      plotter->updateAxes();
    }
  }
}
开发者ID:KazNX,项目名称:ocurves,代码行数:26,代码来源:plotzoomer.cpp

示例9: equilibrar

void Tree::equilibrar(string tree){
    int qabre = 0;
    int qfecha = 0;
    QStack<char*> *verificador = new QStack<char*>();
    char* abre = "(";
    char* fecha = ")";

    for(int i; i < tree.length();i++){
        if(tree[i] == '('){
            qabre++;
            verificador->push(abre);
        }
        else if(tree[i] == ')'){
            qfecha++;
            if(verificador->size() != 0){
                if(verificador->top() == "("){
                    verificador->pop();
                }
                else{
                    verificador->push(fecha);
                }
            }
            else{
                verificador->push(fecha);
            }
        }
    }
}
开发者ID:matheus013,项目名称:Huffman-in-Cplusplus,代码行数:28,代码来源:Tree.cpp

示例10: validateCodeTreeModel

void Highlighter::validateCodeTreeModel(){

    if( !_blocksDirty ) return;

    QStandardItem *root=_editor->_codeTreeModel->invisibleRootItem();

    int row=0;
    QStandardItem *parent=root;

    QStack<int> rowStack;
    QStack<QStandardItem*> parentStack;

    int indent=0x7fff;

    for( QTextBlock block=_editor->document()->firstBlock();block.isValid();block=block.next() ){

        BlockData *data=dynamic_cast<BlockData*>( block.userData() );
        if( !data ) continue;

        if( !_blocks.contains( data ) ){
            qDebug()<<"Highlighter::validateCodeTreeModel Block error!";
            continue;
        }

        int level=0;
        if( data->indent()<=indent ){
            indent=data->indent();
            level=0;
        }else{
            level=1;
        }
        while( rowStack.size()>level ){
            parent->setRowCount( row );
            parent=parentStack.pop();
            row=rowStack.pop();
        }

        CodeTreeItem *item=dynamic_cast<CodeTreeItem*>( parent->child( row++ ) );
        if( !item ){
            item=new CodeTreeItem;
            parent->appendRow( item );
        }
        item->setData( data );
        item->setText( data->ident() );
        rowStack.push( row );
        parentStack.push( parent );
        row=0;
        parent=item;
    }

    for(;;){
        parent->setRowCount( row );
        if( parent==root ) break;
        parent=parentStack.pop();
        row=rowStack.pop();
    }

    _blocksDirty=false;
}
开发者ID:JochenHeizmann,项目名称:monkey,代码行数:59,代码来源:codeeditor.cpp

示例11: rebuildTree

void Tree::rebuildTree(string maestro){
    QStack<Node*>* arranjador = new QStack<Node*>();
    arranjador->push(root);

    for(int i = 0; i < maestro.length(); i++){

        if(maestro[i] == '$'){
            i++;
            if(arranjador->top()->getqFilhos() == false){
                Node* temp = new Node(0,true,maestro[i]);
                arranjador->top()->setLeftChild(temp);
                arranjador->top()->setqFilhos(true);
            }
            else if(arranjador->top()->getqFilhos() == true){
                Node* temp = new Node(0,true,maestro[i]);
                arranjador->top()->setRightChild(temp);
                arranjador->top()->setqFilhos(false);
            }
        }
        else{
            if(maestro[i] == '('){
                if(arranjador->top()->getqFilhos() == false){
                    Node* temp = new Node(i,false);
                    arranjador->top()->setLeftChild(temp);

                    arranjador->top()->setqFilhos(true);
                    arranjador->push(temp);
                }
                else if(arranjador->top()->getqFilhos() == true){
                    Node* temp = new Node(i,false);
                    arranjador->top()->setRightChild(temp);
                    arranjador->top()->setqFilhos(false);
                    arranjador->push(temp);
                }
            }
            else if(maestro[i] == ')'){
                arranjador->pop();
            }
            else{
                if(arranjador->top()->getqFilhos() == false){
                    Node* temp = new Node(0,true,maestro[i]);
                    arranjador->top()->setLeftChild(temp);
                    arranjador->top()->setqFilhos(true);
                }
                else if(arranjador->top()->getqFilhos() == true){
                    Node* temp = new Node(0,true,maestro[i]);
                    arranjador->top()->setRightChild(temp);
                    arranjador->top()->setqFilhos(false);
                }
            }
        }
    }

    if(arranjador->size()!= 1){
        cout << "TRASH! arvore desequilibrada" << endl;
    }
}
开发者ID:matheus013,项目名称:Huffman-in-Cplusplus,代码行数:57,代码来源:Tree.cpp

示例12: if

void stackShow::Post2In(QStringList &phrase)
{
    static QStack <QString> stack;
    QString r,r1,r2;

    QString l[4]={"+" , "-" , "*" , "/" };

    for (int i=0; i<phrase.size(); i++)
        for (int j=0 ; j<4 ; j++)
        {
            if (phrase.at(i)!=l[j] && j==3)
            {
                stack.push(phrase.at(i));
                ui->lneRes->insert(phrase.at(i) + " ");
                phrase.removeFirst();
                r = phrase.join(" ");
                ui->lneExp->setText(r);
                return;

            }

            else if ( phrase.at(i)==l[j] )
            {
                if (stack.size()<2)
                    return ;

                QStringList t = stack.toList();
                t.removeLast();
                t.removeLast();
                r = t.join(" ");

                r1=stack.pop();
                r2=stack.pop();
                stack.push( "( " + r2 + " " + phrase.at(i) + " " + r1 + " ) ");

                ui->lneRes->setText(  "( " + r2 + " " + phrase.at(i) + " " + r1 + " ) ");
                ui->lneStack->setText( r + " "  "( " + r2 + " " + phrase.at(i) + " " + r1 + " ) ");
                phrase.removeFirst();
                r = phrase.join(" ");
                ui->lneExp->setText(r);
                if (phrase.size()==0)
                    stack.clear();

                return;
            }
        }
}
开发者ID:QHossein,项目名称:calc,代码行数:47,代码来源:stackshow.cpp

示例13: rmdir

void CShareMounter::rmdir(const SShare &s)
{
	QStack<QString> removeList;
	QStringList dirs = s.name.split('/', QString::SkipEmptyParts);
	removeList.push( mountPoint_ + dirs.front() + "/");
	dirs.pop_front();
	while(dirs.size())	{
		removeList.push(removeList.top() + dirs.front() + "/");
		dirs.pop_front();
	}
	bool first = true;
	while(removeList.size())	{
		int res = syscall_->rmdir(removeList.pop().toUtf8().constData());
		if(res == -1)	{
			int e = errno;
			if( e == ENOTEMPTY && !first )	// thow if only it is the last folder
				continue;
			throw CMountError(e, strerror(e));
		}
		first = false;
	}
}
开发者ID:Voskrese,项目名称:dlnaplayer,代码行数:22,代码来源:csharemounter.cpp

示例14: parseData

// taken from qstardict
QString WordBrowser::parseData(const char *data, int dictIndex, bool htmlSpaces, bool reformatLists)
{
    QString result;
    quint32 dataSize = *reinterpret_cast<const quint32*>(data);
    const char *dataEnd = data + dataSize;
    const char *ptr = data + sizeof(quint32);
    while (ptr < dataEnd)
    {
        switch (*ptr++)
        {
            case 'm':
            case 'l':
            case 'g':
            {
                QString str = QString::fromUtf8(ptr);
                ptr += str.toUtf8().length() + 1;
                result += str;
                break;
            }
            case 'x':
            {
                QString str = QString::fromUtf8(ptr);
                ptr += str.toUtf8().length() + 1;
                xdxf2html(str);
                result += str;
                break;
            }
            case 't':
            {
                QString str = QString::fromUtf8(ptr);
                ptr += str.toUtf8().length() + 1;
                result += "<font class=\"example\">";
                result += str;
                result += "</font>";
                break;
            }
            case 'y':
            {
                ptr += strlen(ptr) + 1;
                break;
            }
            case 'W':
            case 'P':
            {
                ptr += *reinterpret_cast<const quint32*>(ptr) + sizeof(quint32);
                break;
            }
            default:
                ; // nothing
        }
    }


    if (reformatLists)
    {
        int pos = 0;
        QStack<QChar> openedLists;
        while (pos < result.length())
        {
            if (result[pos].isDigit())
            {
                int n = 0;
                while (result[pos + n].isDigit())
                    ++n;
                pos += n;
                if (result[pos] == '&' && result.mid(pos + 1, 3) == "gt;")
                    result.replace(pos, 4, ">");
                QChar marker = result[pos];
                QString replacement;
                if (marker == '>' || marker == '.' || marker == ')')
                {
                    if (n == 1 && result[pos - 1] == '1') // open new list
                    {
                        if (openedLists.contains(marker))
                        {
                            replacement = "</li></ol>";
                            while (openedLists.size() && openedLists.top() != marker)
                            {
                                replacement += "</li></ol>";
                                openedLists.pop();
                            }
                        }
                        openedLists.push(marker);
                        replacement += "<ol>";
                    }
                    else
                    {
                        while (openedLists.size() && openedLists.top() != marker)
                        {
                            replacement += "</li></ol>";
                            openedLists.pop();
                        }
                        replacement += "</li>";
                    }
                    replacement += "<li>";
                    pos -= n;
                    n += pos;
                    while (result[pos - 1].isSpace())
                        --pos;
//.........这里部分代码省略.........
开发者ID:radekp,项目名称:qdictopia,代码行数:101,代码来源:wordbrowser.cpp

示例15: parseTag

bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
{
    skipSpace(ch);

    int tagStart = ch - textIn.constData();
    int tagLength = 0;
    while (!ch->isNull()) {
        if (*ch == greaterThan) {
            if (tagLength == 0)
                return false;
            QStringRef tag(&textIn, tagStart, tagLength);
            const QChar char0 = tag.at(0);
            if (char0 == QLatin1Char('b')) {
                if (tagLength == 1) {
                    format.setFontWeight(QFont::Bold);
                    return true;
                } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
                    textOut.append(QChar(QChar::LineSeparator));
                    hasSpace = true;
                    prependSpace = false;
                    return false;
                }
            } else if (char0 == QLatin1Char('i')) {
                if (tagLength == 1) {
                    format.setFontItalic(true);
                    return true;
                }
            } else if (char0 == QLatin1Char('p')) {
                if (tagLength == 1) {
                    if (!hasNewLine)
                        textOut.append(QChar::LineSeparator);
                    hasSpace = true;
                    prependSpace = false;
                } else if (tag == QLatin1String("pre")) {
                    preFormat = true;
                    if (!hasNewLine)
                        textOut.append(QChar::LineSeparator);
                    format.setFontFamily(QString::fromLatin1("Courier New,courier"));
                    format.setFontFixedPitch(true);
                    return true;
                }
            } else if (char0 == QLatin1Char('u')) {
                if (tagLength == 1) {
                    format.setFontUnderline(true);
                    return true;
                } else if (tag == QLatin1String("ul")) {
                    List listItem;
                    listItem.level = 0;
                    listItem.type = Unordered;
                    listItem.format = Bullet;
                    listStack.push(listItem);
                }
            } else if (char0 == QLatin1Char('h') && tagLength == 2) {
                int level = tag.at(1).digitValue();
                if (level >= 1 && level <= 6) {
                    if (!hasNewLine)
                        textOut.append(QChar::LineSeparator);
                    hasSpace = true;
                    prependSpace = false;
                    setFontSize(7 - level, format);
                    format.setFontWeight(QFont::Bold);
                    return true;
                }
            } else if (tag == QLatin1String("strong")) {
                format.setFontWeight(QFont::Bold);
                return true;
            } else if (tag == QLatin1String("ol")) {
                List listItem;
                listItem.level = 0;
                listItem.type = Ordered;
                listItem.format = Decimal;
                listStack.push(listItem);
            } else if (tag == QLatin1String("li")) {
                if (!hasNewLine)
                    textOut.append(QChar(QChar::LineSeparator));
                if (!listStack.isEmpty()) {
                    int count = ++listStack.top().level;
                    for (int i = 0; i < listStack.size(); ++i)
                        textOut += QString(tabsize, QChar::Nbsp);
                    switch (listStack.top().format) {
                    case Decimal:
                        textOut += QString::number(count) % QLatin1Char('.');
                        break;
                    case LowerAlpha:
                        textOut += toAlpha(count, false) % QLatin1Char('.');
                        break;
                    case UpperAlpha:
                        textOut += toAlpha(count, true) % QLatin1Char('.');
                        break;
                    case LowerRoman:
                        textOut += toRoman(count, false) % QLatin1Char('.');
                        break;
                    case UpperRoman:
                        textOut += toRoman(count, true) % QLatin1Char('.');
                        break;
                    case Bullet:
                        textOut += bullet;
                        break;
                    case Disc:
                        textOut += disc;
//.........这里部分代码省略.........
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:101,代码来源:qquickstyledtext.cpp


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