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


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

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


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

示例1: response

/////////////////
// name:	response
// purpose:	tries to get a response from an npc standing around
// history:	heavily revamped/rewritten by Duke, Oct 2001
// remark:	The new logic tries to minimize the # of strstr() calls by *first* checking
//			what kind of npcs are standing around and then checking only those keywords
//			that they might be interested in.
//			This is especially usefull in crowded places.
bool Speech::response( cUOSocket* socket, P_PLAYER pPlayer, const QString& comm, QValueVector<Q_UINT16>& keywords )
{
	if ( !pPlayer->socket() || pPlayer->isDead() )
	{
		return false;
	}

	QString speechUpr = comm.upper();

	MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( pPlayer->pos(), 18 );
	for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
	{
		P_NPC pNpc = dynamic_cast<P_NPC>( pChar );

		// We will only process NPCs here
		if ( !pNpc )
			continue;

		// at least they should be on the screen
		if ( pPlayer->dist( pNpc ) > 16 )
			continue;

		if ( pNpc->canHandleEvent( EVENT_SPEECH ) )
		{
			PyObject* pkeywords = PyTuple_New( keywords.size() );

			// Set Items
			for ( unsigned int i = 0; i < keywords.size(); ++i )
				PyTuple_SetItem( pkeywords, i, PyInt_FromLong( keywords[i] ) );

			PyObject* args = Py_BuildValue( "(NNNO)", pNpc->getPyObject(), pPlayer->getPyObject(), QString2Python( comm ), pkeywords );

			bool result = pNpc->callEventHandler( EVENT_SPEECH, args );

			Py_DECREF( args );
			Py_DECREF( pkeywords );

			if ( result )
				return true;
		}

		if ( pNpc->ai() )
		{
			pNpc->ai()->onSpeechInput( pPlayer, speechUpr );
		}

		if ( QuestionSpeech( socket, pPlayer, pNpc, speechUpr ) )
			return true;
	}

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

示例2: createTOC

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

示例3: 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

示例4: 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,代码来源:

示例5: paintOutlines

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,代码来源:

示例6: 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

示例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: txtStream

// The main method for dropping
KIO::CopyJob *KIO::pasteMimeSource(QMimeSource *data, const KURL &dest_url, const QString &dialogText, QWidget *widget, bool clipboard)
{
    QByteArray ba;

    // Now check for plain text
    // We don't want to display a mimetype choice for a QTextDrag, those mimetypes look ugly.
    QString text;
    if(QTextDrag::canDecode(data) && QTextDrag::decode(data, text))
    {
        QTextStream txtStream(ba, IO_WriteOnly);
        txtStream << text;
    }
    else
    {
        QValueVector< QCString > formats;
        const char *fmt;
        for(int i = 0; (fmt = data->format(i)); ++i)
        {
            if(qstrcmp(fmt, "application/x-qiconlist") == 0) // see QIconDrag
                continue;
            if(qstrcmp(fmt, "application/x-kde-cutselection") == 0) // see KonqDrag
                continue;
            if(strchr(fmt, '/') == 0) // e.g. TARGETS, MULTIPLE, TIMESTAMP
                continue;
            formats.append(fmt);
        }

        if(formats.size() == 0)
            return 0;

        if(formats.size() > 1)
        {
            return chooseAndPaste(dest_url, data, formats, dialogText, widget, clipboard);
        }
        ba = data->encodedData(formats.first());
    }
    if(ba.size() == 0)
    {
        KMessageBox::sorry(0, i18n("The clipboard is empty"));
        return 0;
    }

    return pasteDataAsync(dest_url, ba, dialogText);
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例9: setItems

void MultiDefinition::setItems( const QValueVector<multiItem_st>& items )
{
	// try to sort
	if ( items.empty() )
		return;
	unsigned int i = 0;
	for ( ; i < items.size(); ++i )
	{
		if ( items[i].x < left )
			left = items[i].x;
		else if ( items[i].x > right )
			right = items[i].x;

		if ( items[i].y < top )
			top = items[i].y;
		else if ( items[i].y > bottom )
			bottom = items[i].y;
	}

	// by now we have the dimensions.
	this->width = abs( right - left ) + 1;
	this->height = abs( bottom - top ) + 1;

	// copy into grid
	grid.resize( width * height );
	for ( i = 0; i < items.size(); ++i )
	{
		unsigned int index = ( items[i].y - top ) * width + ( items[i].x - left );
		if ( index < grid.size() )
		{
			grid[index].append( items[i] );
		}
	}

	entries = items;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:36,代码来源:multiscache.cpp

示例10: wpAccount_delete

/*
	\method account.delete
	\description Removes this account and all characters attached to it.
*/
static PyObject* wpAccount_delete( wpAccount* self, PyObject* args )
{
	Q_UNUSED( args );
	if ( self->account == 0 )
		Py_RETURN_FALSE;

	QValueVector<P_PLAYER> chars = self->account->caracterList();
	for ( uint i = 0; i < chars.size(); ++i )
		chars[i]->remove();

	self->account->remove();
	self->account = 0;

	Py_RETURN_TRUE;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:19,代码来源:pyaccount.cpp

示例11: fillTable

void KImportDialog::fillTable()
{
    //  kdDebug(5300) << "KImportDialog::fillTable()" << endl;

    int row, column;

    for(row = 0; row < mTable->numRows(); ++row)
        for(column = 0; column < mTable->numCols(); ++column)
            mTable->clearCell(row, column);

    for(row = 0; row < int(mData.count()); ++row)
    {
        QValueVector<QString> *rowVector = mData[ row ];
        for(column = 0; column < int(rowVector->size()); ++column)
        {
            setCellText(row, column, rowVector->at(column));
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:19,代码来源:kimportdialog.cpp

示例12: reduceSegmentSeparator

/**
 * Reduces segment separators.
 *
 * A segment separator separates a segment into two segments, thus causing
 * two adjacent segment with the same orientation.
 *
 * 2       1     0
 * x-------x---->x
 * (0 means stack-top)
 *
 * Here, 1 is a segment separator. As segment separators not only make
 * the line drawing algorithm inefficient, but also make the spike-reduction
 * fail, they must be eliminated:
 *
 * 1             0
 * x------------>x
 *
 * Preconditions:
 * - No other segment separators 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 segment separators exist in the whole point-array
 *
 * If no segment separator is found at the end of the point-array, it is
 * left unchanged.
 * @return \c true if a segment separator was actually reduced.
 */
inline static bool reduceSegmentSeparator(QValueVector< QPoint > &pointArray)
{
    if(pointArray.size() < 3)
        return false;
    QValueVector< QPoint >::Iterator it = pointArray.end();
    QPoint p0 = *--it;
    QPoint p1 = *--it;
    QPoint p2 = *--it;
    //     kdDebug(6040) << "checking p2: " << p2 << " p1: " << p1 << " p0: " << p0 << endl;

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

示例13: setItems

void MultiDefinition::setItems( QValueVector<multiItem_st> items )
{
	// try to sort
	if ( items.empty() )
		return;
	unsigned int i = 0;
	int max_X = 0, max_Y = 0, min_X = 0, min_Y = 0;
	for (; i < items.size(); ++i)
	{
		if ( items[max_X].x < items[i].x )
			max_X = i;
		if ( items[max_Y].y < items[i].y )
			max_Y = i;
		if ( items[min_X].x > items[i].x )
			min_X = i;
		if ( items[min_Y].y > items[i].y )
			min_Y = i;
	}

	// by now we have the dimensions.
	this->width  = items[max_X].x + abs(items[min_X].x);
	this->height = items[max_Y].y + abs(items[min_Y].y);
	entries = items;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:24,代码来源:multiscache.cpp

示例14: getBlockingItems


//.........这里部分代码省略.........
		if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) )
			continue;

		stBlockItem staticBlock;
		staticBlock.z = staIter->zoff;

		// If we are a surface we can always walk here, otherwise check if
		// we are special
		if ( ( tTile.flag2 & 0x02 ) && !( tTile.flag1 & 0x40 ) )
			staticBlock.walkable = true;
		else
			staticBlock.walkable = checkWalkable( pChar, staIter->itemid );

		// If we are a stair only the half height counts (round up)
		if ( tTile.flag2 & 0x04 )
			staticBlock.height = ( Q_UINT8 ) ( ( tTile.height ) / 2 );
		else
			staticBlock.height = tTile.height;

		blockList.push_back( staticBlock );
		push_heap( blockList.begin(), blockList.end(), compareTiles() );
	}

	// We are only interested in items at pos
	// todo: we could impliment blocking for items on the adjacent sides
	// during a diagonal move here, but this has yet to be decided.

	MapItemsIterator iIter = MapObjects::instance()->listItemsAtCoord( pos );
	for ( P_ITEM pItem = iIter.first(); pItem; pItem = iIter.next() )
	{
		if ( pChar && pChar->isDead() )
		{
			// Doors can be passed by ghosts
			if ( pItem->hasScript( "door" ) )
			{
				continue;
			}
		}

		tile_st tTile = TileCache::instance()->getTile( pItem->id() );

		// See above for what the flags mean
		if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) )
			continue;

		stBlockItem blockItem;
		blockItem.height = ( tTile.flag2 & 0x04 ) ? ( tTile.height / 2 ) : tTile.height;
		blockItem.z = pItem->pos().z;

		// Once again: see above for a description of this part
		if ( ( tTile.flag2 & 0x02 ) && !( tTile.flag1 & 0x40 ) )
			blockItem.walkable = true;
		else
			blockItem.walkable = checkWalkable( pChar, pItem->id() );

		blockList.push_back( blockItem );
		push_heap( blockList.begin(), blockList.end(), compareTiles() );
	}


	// deal with the multis now, or not.
	// 18 has been tested with castle sides and corners...
	MapMultisIterator iter = MapObjects::instance()->listMultisInCircle( pos, 18 );
	for ( cMulti*pMulti = iter.first(); pMulti; pMulti = iter.next() )
	{
		MultiDefinition* def = MultiCache::instance()->getMulti( pMulti->id() - 0x4000 );
		if ( !def )
			continue;

		QValueVector<multiItem_st> multi = def->getEntries();

		for ( unsigned int j = 0; j < multi.size(); ++j )
		{
			if ( multi[j].visible && ( pMulti->pos().x + multi[j].x == pos.x ) && ( pMulti->pos().y + multi[j].y == pos.y ) )
			{
				tile_st tTile = TileCache::instance()->getTile( multi[j].tile );
				if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) )
					continue;

				stBlockItem blockItem;
				blockItem.height = ( tTile.flag2 & 0x04 ) ? ( tTile.height / 2 ) : tTile.height;
				blockItem.z = pMulti->pos().z + multi[j].z;

				if ( ( tTile.flag2 & 0x02 ) && !( tTile.flag1 & 0x40 ) )
					blockItem.walkable = true;
				else
					blockItem.walkable = checkWalkable( pChar, pMulti->id() );

				blockList.push_back( blockItem );
				push_heap( blockList.begin(), blockList.end(), compareTiles() );
			}
		}
		continue;
	}

	// Now we need to evaluate dynamic items [...] (later)  ??
	sort_heap( blockList.begin(), blockList.end(), compareTiles() );

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

示例15: Spawn

SpawnSSH::SpawnSSH(RemoteRebootMaster *master,
                   const QString &localhostname, int localport,
                   const QString &hostname, const QString &user)

    : Spawn(master, localhostname, localport)
{

    QStringList inputList;

    QValueVector<QString> argv = master->getArgv();

    if (hostname == "")
    {
        if (argv.size() > 0)
        {
            this->hostname = argv[0];
        }
        else
        {
            inputList.append("Hostname");
            inputList.append("string");
            inputList.append("");
        }
    }
    else
    {
        this->hostname = hostname;
    }

    if (user == "")
    {
        if (argv.size() > 1)
        {
            this->user = argv[1];
        }
        else
        {
            inputList.append("User");
            inputList.append("string");
            inputList.append("");
        }
    }
    else
    {
        this->user = user;
    }

    if (!inputList.empty())
    {

        const QMap<QString, QString> result = master->getUI()->getUserInputs(inputList);

        if (result["Hostname"] != "")
        {
            this->hostname = result["Hostname"];
        }

        if (result["User"] != "")
        {
            this->user = result["User"];
        }
    }
}
开发者ID:nixz,项目名称:covise,代码行数:63,代码来源:SpawnSSH.cpp


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