本文整理汇总了C++中QValueVector::end方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueVector::end方法的具体用法?C++ QValueVector::end怎么用?C++ QValueVector::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueVector
的用法示例。
在下文中一共展示了QValueVector::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onCollide
bool cUObject::onCollide( cUObject* Obstacle )
{
// If we got ANY events process them in order
for( UI08 i = 0; i < scriptChain.size(); i++ )
{
// Items cannot collide with items
if( !isChar() ) // Item, so obstacle has to be character
scriptChain[ i ]->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
else
if( Obstacle->isItem() )
if( scriptChain[ i ]->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle ) )
return true;
else // Character, Character
if( scriptChain[ i ]->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle ) )
return true;
}
// Try to process the hooks then
QValueVector< WPDefaultScript* > hooks;
QValueVector< WPDefaultScript* >::const_iterator it;
hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_COLLIDE );
for( it = hooks.begin(); it != hooks.end(); ++it )
{
// Items cannot collide with items
if( !isChar() ) // Item, so obstacle has to be character
(*it)->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
else
{
if( Obstacle->isItem() )
(*it)->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle );
else
(*it)->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle );
}
}
if( isChar() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_COLLIDE );
for( it = hooks.begin(); it != hooks.end(); ++it )
{
if( Obstacle->isItem() )
(*it)->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle );
else
(*it)->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle );
}
}
if( isItem() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_COLLIDE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
}
return false;
}
示例2: 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);
}
}
示例3: 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;
}
示例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;
}
示例5: onUse
bool cUObject::onUse( cUObject *Target )
{
// If we got ANY events process them in order
for( UI08 i = 0; i < scriptChain.size(); i++ )
{
// If we're the Character pass us as the second param
// if not as the first
bool Handeled = false;
if( !this->isChar() )
Handeled = scriptChain[ i ]->onUse( (P_PLAYER)Target, (P_ITEM)this );
else
Handeled = scriptChain[ i ]->onUse( (P_PLAYER)this, (P_ITEM)Target );
if( Handeled )
return true;
}
// Try to process the hooks then
QValueVector< WPDefaultScript* > hooks;
QValueVector< WPDefaultScript* >::const_iterator it;
hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_USE );
for( it = hooks.begin(); it != hooks.end(); ++it )
{
if( !this->isChar() )
(*it)->onUse( (P_PLAYER)Target, (P_ITEM)this );
else
(*it)->onUse( (P_PLAYER)this, (P_ITEM)Target );
}
if( isChar() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_USE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onUse( (P_PLAYER)this, (P_ITEM)Target );
}
if( isItem() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_USE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onUse( (P_PLAYER)Target, (P_ITEM)this );
}
return false;
}
示例6: call
void call()
{
QValueVector<fnCleanupHandler>::iterator it;
for ( it = cleanupHandler.begin(); it != cleanupHandler.end(); ++it )
{
( *it ) ();
}
}
示例7:
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( "," );
}
示例8: KInetSocketAddress
KInetSocketAddress *KInetInterface::getPublicInetAddress() {
QValueVector<KInetInterface> v = getAllInterfaces(true);
// TODO: first step: take the default route interface
// try to find point-2-point interface, because it may be
// a dial-up connection. Take it.
QValueVector<KInetInterface>::const_iterator it = v.begin();
while (it != v.end()) {
if (((*it).flags() & (PointToPoint | Up | Running)) &&
(!((*it).flags() & Loopback)) &&
(*it).address() &&
((*it).address()->family() == AF_INET))
return new KInetSocketAddress(*(*it).address());
it++;
}
// otherwise, just take the first non-loopback interface
it = v.begin();
while (it != v.end()) {
if (((*it).flags() & (Up | Running)) &&
(!((*it).flags() & Loopback)) &&
(*it).address() &&
((*it).address()->family() == AF_INET))
return new KInetSocketAddress(*(*it).address());
it++;
}
// ok, giving up, try to take loopback
it = v.begin();
while (it != v.end()) {
if (((*it).flags() & (Up | Running)) &&
(*it).address())
return new KInetSocketAddress(*(*it).address());
it++;
}
// not even loopback..
return 0;
}
示例9: onCreate
bool cUObject::onCreate( const QString &definition )
{
// If we got ANY events process them in order
for( UI08 i = 0; i < scriptChain.size(); i++ )
{
// If we're the Character pass us as the second param
// if not as the first
bool Handeled = false;
Handeled = scriptChain[ i ]->onCreate( this, definition );
if( Handeled )
return true;
}
// Try to process the hooks then
QValueVector< WPDefaultScript* > hooks;
QValueVector< WPDefaultScript* >::const_iterator it;
hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_CREATE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onCreate( this, definition );
if( isChar() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_CREATE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onCreate( this, definition );
}
if( isItem() )
{
hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_CREATE );
for( it = hooks.begin(); it != hooks.end(); ++it )
(*it)->onCreate( this, definition );
}
return false;
}
示例10: writeEvent
void KOEditorDetails::writeEvent(Incidence *event)
{
event->clearAttendees();
QValueVector<QListViewItem*> toBeDeleted;
QListViewItem *item;
AttendeeListItem *a;
for (item = mListView->firstChild(); item;
item = item->nextSibling()) {
a = (AttendeeListItem *)item;
Attendee *attendee = a->data();
Q_ASSERT( attendee );
/* Check if the attendee is a distribution list and expand it */
if ( attendee->email().isEmpty() ) {
KPIM::DistributionList list =
KPIM::DistributionList::findByName( KABC::StdAddressBook::self(), attendee->name() );
if ( !list.isEmpty() ) {
toBeDeleted.push_back( item ); // remove it once we are done expanding
KPIM::DistributionList::Entry::List entries = list.entries( KABC::StdAddressBook::self() );
KPIM::DistributionList::Entry::List::Iterator it( entries.begin() );
while ( it != entries.end() ) {
KPIM::DistributionList::Entry &e = ( *it );
++it;
// this calls insertAttendee, which appends
insertAttendeeFromAddressee( e.addressee, attendee );
// TODO: duplicate check, in case it was already added manually
}
}
} else {
bool skip = false;
if ( attendee->email().endsWith( "example.net" ) ) {
if ( KMessageBox::warningYesNo( this, i18n("%1 does not look like a valid email address. "
"Are you sure you want to invite this participant?").arg( attendee->email() ),
i18n("Invalid email address") ) != KMessageBox::Yes ) {
skip = true;
}
}
if ( !skip ) {
event->addAttendee( new Attendee( *attendee ) );
}
}
}
KOAttendeeEditor::writeEvent( event );
// cleanup
QValueVector<QListViewItem*>::iterator it;
for( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
delete *it;
}
}
示例11: processServiceTemplate
QStringList PortListener::processServiceTemplate(const QString &a) {
QStringList l;
QValueVector<KInetInterface> v = KInetInterface::getAllInterfaces(false);
QValueVector<KInetInterface>::Iterator it = v.begin();
while (it != v.end()) {
KInetSocketAddress *address = (*(it++)).address();
if (!address)
continue;
QString hostName = address->nodeName();
KUser u;
QString x = a; // replace does not work in const QString. Why??
l.append(x.replace(QRegExp("%h"), KServiceRegistry::encodeAttributeValue(hostName))
.replace(QRegExp("%p"), QString::number(m_port))
.replace(QRegExp("%u"), KServiceRegistry::encodeAttributeValue(u.loginName()))
.replace(QRegExp("%i"), KServiceRegistry::encodeAttributeValue(m_uuid))
.replace(QRegExp("%f"), KServiceRegistry::encodeAttributeValue(u.fullName())));
}
return l;
}
示例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;
}
示例13: createKeyList
// Construct a list of keys to be connected, sorted highest priority first.
void KAccelBase::createKeyList(QValueVector< struct X > &rgKeys)
{
// kdDebug(125) << "KAccelBase::createKeyList()" << endl;
if(!isEnabledInternal())
return;
// create the list
// For each action
for(uint iAction = 0; iAction < m_rgActions.count(); iAction++)
{
KAccelAction *pAction = m_rgActions.actionPtr(iAction);
if(pAction && pAction->m_pObjSlot && pAction->m_psMethodSlot && pAction != mtemp_pActionRemoving)
{
// For each key sequence associated with action
for(uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++)
{
const KKeySequence &seq = pAction->shortcut().seq(iSeq);
if(seq.count() > 0)
{
KKeyServer::Variations vars;
vars.init(seq.key(0), !m_bNativeKeys);
for(uint iVari = 0; iVari < vars.count(); iVari++)
{
if(vars.key(iVari).code() && vars.key(iVari).sym())
rgKeys.push_back(X(iAction, iSeq, iVari, vars.key(iVari)));
// kdDebug(125) << "\t" << pAction->name() << ": " << vars.key(iVari).toStringInternal() << endl;
}
}
// else
// kdDebug(125) << "\t*" << pAction->name() << ":" << endl;
}
}
}
// sort by priority: iVariation[of first key], iSequence, iAction
qHeapSort(rgKeys.begin(), rgKeys.end());
}
示例14: talking
void Speech::talking( P_PLAYER pChar, const QString& lang, const QString& speech, QValueVector<Q_UINT16>& keywords, Q_UINT16 color, Q_UINT16 font, Q_UINT8 type ) // PC speech
{
// handle things like renaming or describing an item
if ( !pChar->socket() )
return;
cUOSocket* socket = pChar->socket();
if ( InputSpeech( socket, pChar, speech ) )
return;
pChar->unhide();
// Check for Bogus Color
if ( !isNormalColor( color ) )
color = 0x2;
if ( type == 0 )
pChar->setSaycolor( color );
else if ( type == 2 )
pChar->setEmoteColor( color );
if ( pChar->onTalk( type, color, font, speech, lang ) )
return;
if ( ( type == 0x09 ) && ( pChar->mayBroadcast() ) )
{
pChar->talk( speech, color, type );
return;
}
pChar->talk( speech, color, type );
QString speechUpr = speech.upper();
if ( response( socket, pChar, speech, keywords ) )
return; // Vendor responded already
// this makes it so npcs do not respond to isDead people - HEALERS ??
if ( pChar->isDead() )
return;
// 0x0007 -> Speech-id for "Guards"
for ( QValueVector<Q_UINT16>::const_iterator iter = keywords.begin(); iter != keywords.end(); ++iter )
{
Q_UINT16 keyword = *iter;
if ( keyword == 0x07 )
pChar->callGuards();
}
/* P_CHAR pc = NULL; ???
P_CHAR pNpc = NULL;
RegionIterator4Chars ri( pChar->pos() );
for( ri.Begin(); !ri.atEnd(); ri++ )
{
pc = ri.GetData();
if (!pc->isSameAs( pChar )
&& pc->isNpc()
&& pc->dist( pChar ) <= 2)
{
pNpc = pc;
break;
}
}
*/
}
示例15: checkPort
// Check if a service is running on a host with IP address 'ip'
// by checking all the ports in '_ports', using a non-blocking connect.
// Right now -- assume if *any* of these ports are active,
// the service is active.
int LANProtocol::checkPort( QValueVector<int>& _ports, in_addr ip )
{
int _port=0;
struct sockaddr_in to_scan;
to_scan.sin_family = AF_INET;
to_scan.sin_addr = ip;
for (QValueVector<int>::iterator i= _ports.begin(); i != _ports.end(); i++)
{
_port=(*i);
kdDebug(7101)<<"LANProtocol::checkPort: "<<_port<<endl;
to_scan.sin_port = htons(_port);
// open a TCP socket
int mysocket = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (mysocket< 0 )
{
std::cerr << "LanProt::checkPort: Error while opening Socket" << std::endl;
::close( mysocket );
return 0;
}
//make the socket non blocking
long int options = O_NONBLOCK | ::fcntl(mysocket, F_GETFL);
if (::fcntl( mysocket, F_SETFL, options )!=0)
{
std::cerr << "LanProt::checkPort: Error making it nonblocking"<< std::endl;
::close( mysocket );
return 0;
}
int result=connect( mysocket, (struct sockaddr *) &to_scan, sizeof( to_scan ));
//it succeeded immediately
if (result==0)
{
std::cerr<<"LANProtocol::checkPort("<<_port<<") connect succeeded immediately"<<std::endl;
::shutdown( mysocket, SHUT_RDWR );
return 1;
}
//it failed
if ((result<0) && (errno!=EINPROGRESS))
{
// errno was not EINPROGRESS, so there is some serious problem
::shutdown( mysocket, SHUT_RDWR );
// maybe some other port will work
continue;
}
// last errno was EINPROGRESS, so we should select() on socket
// and wait for the final verdict
timeval tv;
tv.tv_sec=5;
tv.tv_usec=0;
fd_set rSet, wSet;
FD_ZERO(&rSet);
FD_SET(mysocket,&rSet);
wSet=rSet;
//timeout or error
result=select(mysocket+1,&rSet,&wSet,0,&tv);
::shutdown( mysocket, SHUT_RDWR );
if (result==1)
return 1;
}
// gosh, no port worked
return 0;
}