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


C++ QValueVector类代码示例

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


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

示例1: reduceSpike

/**
 * Does spike-reduction on the given point-array's stack-top.
 *
 * Spikes are path segments of which one goes forward, and the sucessor
 * goes backward on the predecessor's segment:
 *
 * 2      0      1
 * x------x<-----x
 * (0 is stack-top in point-array)
 *
 * This will be reduced to
 * 1      0
 * x------x
 *
 * Preconditions:
 * - No other spikes exist in the whole point-array except at most
 *   one at the end
 * - No two succeeding points are ever equal
 * - For each two succeeding points either p1.x == p2.x or p1.y == p2.y holds
 *   true
 * - No such spike exists where 2 is situated between 0 and 1.
 *
 * Postcondition:
 * - No spikes exist in the whole point-array
 *
 * If no spike is found, the point-array is left unchanged.
 * @return \c true if an actual reduction was done
 */
inline static bool reduceSpike(QValueVector< QPoint > &pointArray)
{
    if(pointArray.size() < 3)
        return false;
    QValueVector< QPoint >::Iterator it = pointArray.end();
    QPoint p0 = *--it;
    QPoint p1 = *--it;
    QPoint p2 = *--it;

    bool elide = false;

    if((p0.x() == p1.x() && p1.x() == p2.x() && ((p1.y() < p0.y() && p0.y() < p2.y()) || (p2.y() < p0.y() && p0.y() < p1.y())
                                                || (p1.y() < p2.y() && p2.y() < p0.y()) || (p0.y() < p2.y() && p2.y() < p1.y())
                                                || (elide = p2.y() == p0.y() && p0.y() < p1.y()) || (elide = p1.y() < p0.y() && p0.y() == p2.y())))
       || (p0.y() == p1.y() && p1.y() == p2.y() && ((p1.x() < p0.x() && p0.x() < p2.x()) || (p2.x() < p0.x() && p0.x() < p1.x())
                                                   || (p1.x() < p2.x() && p2.x() < p0.x()) || (p0.x() < p2.x() && p2.x() < p1.x())
                                                   || (elide = p2.x() == p0.x() && p0.x() < p1.x()) || (elide = p1.x() < p0.x() && p0.x() == p2.x()))))
    {
        //     kdDebug(6040) << "spikered p2" << (elide ? " (elide)" : "") << ": " << p2 << " p1: " << p1 << " p0: " << p0 << endl;
        pointArray.pop_back();
        pointArray.pop_back();
        if(!elide)
            pointArray.push_back(p0);
        return true;
    }
    return false;
}
开发者ID:,项目名称:,代码行数:55,代码来源:

示例2: style

void RenderInline::paintOutlines(QPainter *p, int _tx, int _ty)
{
    if(style()->outlineWidth() == 0 || style()->outlineStyle() <= BHIDDEN)
        return;
    int offset = style()->outlineOffset();

    // We may have to draw more than one outline path as they may be
    // disjoint.
    for(InlineRunBox *curr = firstLineBox(); curr; curr = curr->nextLineBox())
    {
        QValueVector< QPoint > path;

        // collect topmost outline
        collectHorizontalBoxCoordinates(curr, path, false, offset);
        // collect right outline
        collectVerticalBoxCoordinates(curr, path, false, offset, &curr);
        // collect bottommost outline
        collectHorizontalBoxCoordinates(curr, path, true, offset);
        // collect left outline
        collectVerticalBoxCoordinates(curr, path, true, offset);

        if(path.size() < 3)
            continue;

        const QPoint *begin = linkEndToBegin(path);

        // paint the outline
        paintOutlinePath(p, _tx, _ty, begin, path.end(), BSLeft, -1, BSTop);
    }
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: collectVerticalBoxCoordinates

/**
 * Traverses the vertical outer borders of the given render flow's line
 * boxes and appends the point coordinates to the given point array.
 * @param line line box to begin traversal
 * @param pointArray point array
 * @param left \c true, traverse the left vertical coordinates,
 *	\c false, traverse the right vertical coordinates.
 * @param lastline if not 0, returns the pointer to the last line box traversed
 */
static void collectVerticalBoxCoordinates(InlineRunBox *line, QValueVector< QPoint > &pointArray, bool left, int offset, InlineRunBox **lastline = 0)
{
    InlineRunBox *last = 0;
    offset = left ? -offset : offset;
    for(InlineRunBox *curr = line; curr && !last; curr = left ? curr->prevLineBox() : curr->nextLineBox())
    {
        InlineBox *root = curr;

        bool isLast = lineBoxesDisjoint(curr, kAbs(offset), left);
        if(isLast)
            last = curr;

        if(root != line && !isLast)
            while(root->parent())
                root = root->parent();
        QPoint newPnt(curr->xPos() + !left * curr->width() + offset, (left ? root->topOverflow() : root->bottomOverflow()) + offset);
        if(!pointArray.isEmpty())
        {
            QPoint lastPnt = pointArray.back();
            if(newPnt.x() > lastPnt.x() && !left)
                pointArray.back().setY(kMin(lastPnt.y(), root->topOverflow() - offset));
            else if(newPnt.x() < lastPnt.x() && left)
                pointArray.back().setY(kMax(lastPnt.y(), root->bottomOverflow() + offset));
            QPoint insPnt(newPnt.x(), pointArray.back().y());
            //         kdDebug(6040) << "left: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl;
            appendPoint(pointArray, insPnt);
        }
        appendPoint(pointArray, newPnt);
    }
    if(lastline)
        *lastline = last;
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例4: DynTile

Q_UINT16 DynTile( const Coord_cl& pos )
{
	RegionIterator4Items ri( pos );
	for ( ri.Begin(); !ri.atEnd(); ri++ )
	{
		P_ITEM mapitem = ri.GetData();
		if ( mapitem )
		{
			if ( mapitem->isMulti() )
			{
				MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
				if ( !def )
					return 0;
				QValueVector<multiItem_st> multi = def->getEntries();
				for ( Q_UINT32 j = 0; j < multi.size(); ++j )
				{
					if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
					{
						return multi[j].tile;
					}
				}
			}
			else if ( mapitem->pos() == pos )
				return mapitem->id();
		}
	}
	return ( Q_UINT16 ) - 1;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:walking.cpp

示例5: parse_dn

/* Parse a DN and return an array-ized one.  This is not a validating
   parser and it does not support any old-stylish syntax; gpgme is
   expected to return only rfc2253 compatible strings. */
static Kleo::DN::Attribute::List
parse_dn( const unsigned char * string ) {
  if ( !string )
    return QValueVector<Kleo::DN::Attribute>();

  QValueVector<Kleo::DN::Attribute> result;
  while (*string)
    {
      while (*string == ' ')
        string++;
      if (!*string)
        break; /* ready */

      DnPair pair = { 0, 0 };
      string = parse_dn_part (&pair, string);
      if (!string)
	goto failure;
      if ( pair.key && pair.value )
	result.push_back( Kleo::DN::Attribute( QString::fromUtf8( pair.key ),
					       QString::fromUtf8( pair.value ) ) );
      free( pair.key );
      free( pair.value );

      while (*string == ' ')
        string++;
      if (*string && *string != ',' && *string != ';' && *string != '+')
        goto failure; /* invalid delimiter */
      if (*string)
        string++;
    }
  return result;

failure:
  return QValueVector<Kleo::DN::Attribute>();
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例6: convertFlags

QValueVector<KInetInterface> KInetInterface::getAllInterfaces(bool includeLoopback) {
	struct kde_ifaddrs *ads;
	struct kde_ifaddrs *a;
	QValueVector<KInetInterface> r;
	if (kde_getifaddrs(&ads))
		return r;

	a = ads;
	while (a) {
		if ((a->ifa_flags & IFF_LOOPBACK) && !includeLoopback) {
			a = a->ifa_next;
			continue;
		}
		r.push_back(KInetInterface(QString::fromUtf8(a->ifa_name),
					   convertFlags(a->ifa_flags),
					   createAddress(a->ifa_addr),
					   createAddress(a->ifa_netmask),
					   (a->ifa_flags & IFF_BROADCAST) ?
					   createAddress(a->ifa_broadaddr) : 0,
					   (a->ifa_flags & IFF_POINTOPOINT) ? 
					   createAddress(a->ifa_dstaddr) : 0));
		a = a->ifa_next;
	}
	
	kde_freeifaddrs(ads);
	return r;
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:27,代码来源:kinetinterface.cpp

示例7: DynTile

Q_UINT16 DynTile( const Coord& pos )
{
	MapItemsIterator ri = MapObjects::instance()->listItemsInCircle( pos, 18 );
	for ( P_ITEM mapitem = ri.first(); mapitem; mapitem = ri.next() )
	{
		if ( mapitem->isMulti() )
		{
			MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
			if ( !def )
				return 0;

			QValueVector<multiItem_st> multi = def->getEntries();
			for ( Q_UINT32 j = 0; j < multi.size(); ++j )
			{
				if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
				{
					return multi[j].tile;
				}
			}
		}
		else if ( mapitem->pos() == pos )
		{
			return mapitem->id();
		}
	}
	return ( Q_UINT16 ) - 1;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:27,代码来源:walking.cpp

示例8: getSpecialData

void DocCHMPlugin::createTOC(DocumentationCatalogItem* item)
{
    QStringList lines = QStringList::split("\n", getSpecialData("catalog", item->url()) );
    if(lines.count() % 4 != 0) { kdDebug(9002) << "DocCHMPlugin::createTOC: wrong count of strings"; return;}
    
    QValueVector<DocumentationItem*> items;
    items.push_back(item);
    for(QStringList::Iterator it = lines.begin(); it != lines.end();) {
        bool ok1 = true, ok2 = true;
        int parent = (*it).toInt(&ok1);
        ++it;
        int current = (*it).toInt(&ok2);
        ++it;
        if(int(items.size()) != current || !ok1 || !ok2 || parent < 0 || parent >= int(items.size()) || current < 0 || current != int(items.size())) {
            kdDebug(9002) << "DocCHMPlugin::createTOC error while parsing output of ioslave" << endl;
            break;
        }
        
        QString& name(*it);
        ++it;
        KURL url(*it);
        ++it;
        
        items.push_back(new DocumentationItem(
                DocumentationItem::Document, items[parent], chainEnd(items[parent]), decodeHTML(name)));
        items[current]->setURL(url);
        if(parent != 0) items[parent]->setType(DocumentationItem::Book);
    }
    

    return;
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:32,代码来源:docchmplugin.cpp

示例9: setFinishEnabled

void ConnectWizard::projectReady( const Project & p )
{
    bool any_selected = 0;

    d->project = p;

    setFinishEnabled( SelectViewPage, false );

    m_viewList->clear();
    d->viewMap.clear();

    QValueVector<QString> vv = p.views().keys();
    for( unsigned i = 0; i < vv.count(); i++ ) {

        QListBoxText* item = new QListBoxText( m_viewList,
                p.localizator()->localizedMessage( vv[ i ] ) );
        d->viewMap.insert( item, vv[ i ] );

        // preselect view in listbox
        if( d->viewId == vv[ i ] ) {
            m_viewList->setSelected( item, true );
            any_selected = true;
        }
    }

    if( ! any_selected && p.views().count() > 0 ) {
        m_viewList->setSelected( 0, true );
    }
}
开发者ID:acassis,项目名称:lintouch,代码行数:29,代码来源:ConnectWizard.cpp

示例10: inMulti

bool cMulti::inMulti( const Coord_cl& pos )
{
	// Seek tiles with same x,y as pos
	// Seek for tile which z value <= pos.z + 5 && z value >= pos.z - 5
	MultiDefinition* multi = MultiCache::instance()->getMulti( id_ - 0x4000 );

	if ( !multi )
	{
		return false;
	}

	QValueVector<multiItem_st> items = multi->getEntries();
	QValueVector<multiItem_st>::iterator it;
	for ( it = items.begin(); it != items.end(); ++it )
	{
		if ( !it->visible )
		{
			continue;
		}

		if ( pos_.x + it->x != pos.x || pos_.y + it->y != pos.y )
		{
			continue;
		}

		if ( pos_.z + it->z >= pos.z - 5 && pos_.z + it->z <= pos.z + 5 )
		{
			return true;
		}
	}

	return false;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:33,代码来源:multi.cpp

示例11: setData

void KImportDialog::setData(uint row, uint col, const QString &value)
{
    QString val = value;
    val.replace("\\n", "\n");

    if(row >= mData.count())
    {
        mData.resize(row + 1);
    }

    QValueVector<QString> *rowVector = mData[ row ];
    if(!rowVector)
    {
        rowVector = new QValueVector<QString>;
        mData.insert(row, rowVector);
    }
    if(col >= rowVector->size())
    {
        rowVector->resize(col + 1);
    }

    KImportColumn *c = mColumnDict.find(col);
    if(c)
        rowVector->at(col) = c->preview(val, findFormat(col));
    else
        rowVector->at(col) = val;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:27,代码来源:kimportdialog.cpp

示例12: s

QValueVector<Move> Board::possibleMoves(bool bluePlays) const
{
  QValueVector<Move> res;
#else
QVector<Move> Board::possibleMoves(bool bluePlays) const
{
  QVector<Move> res;
#endif
  for (int i=0; i<sizeX_; ++i)
    for (int j=0; j<sizeY_; ++j)
      {
	const QPoint s(i,j);
	if (stateOf(s) == Board::blueColor(bluePlays))
	  {
	    for (int ii=-2; ii<=2; ++ii)
	      for (int jj=-2; jj<=2; ++jj)
		{
		  const QPoint e(s.x()+ii,s.y()+jj);
		  if (isValid(e) && stateOf(e) == Board::EMPTY)
		    res.append(Move(s, e));
		}
	  }
      }
  return res;
}
开发者ID:nhatson1987,项目名称:libQGLViewer-2.5.2,代码行数:25,代码来源:board.cpp

示例13: call

	void call()
	{
		QValueVector<fnCleanupHandler>::iterator it;
		for ( it = cleanupHandler.begin(); it != cleanupHandler.end(); ++it )
		{
			( *it ) ();
		}
	}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:engine.cpp

示例14: serialise

static QString
serialise( const QValueVector<Kleo::DN::Attribute> & dn ) {
  QStringList result;
  for ( QValueVector<Kleo::DN::Attribute>::const_iterator it = dn.begin() ; it != dn.end() ; ++it )
    if ( !(*it).name().isEmpty() && !(*it).value().isEmpty() )
      result.push_back( (*it).name().stripWhiteSpace() + '=' + (*it).value().stripWhiteSpace() );
  return result.join( "," );
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例15: collectHorizontalBoxCoordinates

/**
 * Traverses the horizontal inline boxes and appends the point coordinates to
 * the given array.
 * @param box inline box
 * @param pointArray array collecting coordinates
 * @param bottom \c true, collect bottom coordinates, \c false, collect top
 * 	coordinates.
 * @param limit lower limit that an y-coordinate must at least reach. Note
 *	that limit designates the highest y-coordinate for \c bottom, and
 *	the lowest for !\c bottom.
 */
static void collectHorizontalBoxCoordinates(InlineBox *box, QValueVector< QPoint > &pointArray, bool bottom, int offset, int limit = -500000)
{
    //   kdDebug(6000) << "collectHorizontalBoxCoordinates: " << endl;
    offset = bottom ? offset : -offset;
    int y = box->yPos() + bottom * box->height() + offset;
    if(limit != -500000 && (bottom ? y < limit : y > limit))
        y = limit;
    int x = box->xPos() + bottom * box->width() + offset;
    QPoint newPnt(x, y);
    // Add intersection point if point-array not empty.
    if(!pointArray.isEmpty())
    {
        QPoint lastPnt = pointArray.back();
        QPoint insPnt(newPnt.x(), lastPnt.y());
        if(offset && ((bottom && lastPnt.y() > y) || (!bottom && lastPnt.y() < y)))
        {
            insPnt.rx() = lastPnt.x();
            insPnt.ry() = y;
        }
        //         kdDebug(6040) << "left: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl;
        appendPoint(pointArray, insPnt);
    }
    // Insert starting point of box
    appendPoint(pointArray, newPnt);

    newPnt.rx() += (bottom ? -box->width() : box->width()) - 2 * offset;

    if(box->isInlineFlowBox())
    {
        InlineFlowBox *flowBox = static_cast< InlineFlowBox * >(box);
        for(InlineBox *b = bottom ? flowBox->lastChild() : flowBox->firstChild(); b; b = bottom ? b->prevOnLine() : b->nextOnLine())
        {
            // Don't let boxes smaller than this flow box' height influence
            // the vertical position of the outline if they have a different
            // x-coordinate
            int l2;
            if(b->xPos() != box->xPos() && b->xPos() + b->width() != box->xPos() + box->width())
                l2 = y;
            else
                l2 = limit;
            collectHorizontalBoxCoordinates(b, pointArray, bottom, kAbs(offset), l2);
        }

        // Add intersection point if flow box contained any children
        if(flowBox->firstChild())
        {
            QPoint lastPnt = pointArray.back();
            QPoint insPnt(lastPnt.x(), newPnt.y());
            //             kdDebug(6040) << "right: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl;
            appendPoint(pointArray, insPnt);
        }
    }

    // Insert ending point of box
    appendPoint(pointArray, newPnt);

    //     kdDebug(6000) << "collectHorizontalBoxCoordinates: " << "ende" << endl;
}
开发者ID:,项目名称:,代码行数:69,代码来源:


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