/** * 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; }
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); } }
/** * 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; }
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; }
/* 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>(); }
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; }
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; }
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; }
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 ); } }
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; }
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; }
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; }
bool endElement( const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/ ) { cElement* element = elements.pop(); if ( --( levels.back() ) == 0 ) { // Ignore root return true; } if ( element == elements.current() ) { // Ignore include return true; } // Did we complete a parent node? if ( elements.current() == NULL ) { // Find a category node unsigned int i = 0; // Sort it into a category. while ( categories[i].name != 0 ) { if ( element->name() == categories[i].name ) { QString tagId = element->getAttribute( "id" ); // If the element has an id, if ( !tagId.isEmpty() ) { if ( impl->unique[categories[i].key].contains( tagId ) && !Config::instance()->overwriteDefinitions() ) { Console::instance()->log( LOG_WARNING, tr( "Duplicate %1: %2\n[File: %3, Line: %4]\n" ) .arg( element->name() ).arg( tagId ).arg( filenames.back() ).arg( locators.current()->lineNumber() ) ); delete element; } else { impl->unique[categories[i].key].insert( tagId, element, true ); } } else { impl->nonunique[categories[i].key].push_back( element ); } return true; } ++i; } Console::instance()->log( LOG_WARNING, tr( "Unknown element: %1\n[File: %2, Line: %3]\n" ) .arg( element->name() ).arg( filenames.back() ).arg( locators.current()->lineNumber() ) ); delete element; } return true; }
void call() { QValueVector<fnCleanupHandler>::iterator it; for ( it = cleanupHandler.begin(); it != cleanupHandler.end(); ++it ) { ( *it ) (); } }
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( "," ); }
/** * 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; }
/** * Appends the given coordinate-pair to the point-array if it is not * equal to the last element. * @param pointArray point-array * @param pnt point to append * @return \c true if \c pnt has actually been appended */ inline static bool appendIfNew(QValueVector< QPoint > &pointArray, const QPoint &pnt) { // if (!pointArray.isEmpty()) kdDebug(6040) << "appifnew: " << pointArray.back() << " == " << pnt << ": " << (pointArray.back() == pnt) << endl; // else kdDebug(6040) << "appifnew: " << pnt << " (unconditional)" << endl; if(!pointArray.isEmpty() && pointArray.back() == pnt) return false; pointArray.append(pnt); return true; }
///////////////// // 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; }
void PolygonElement::generate(ReportInterp* interp, int offsetX, int offsetY, QValueVector<PageElement>& elements) { PageElement element; element.type = PageElement::POLYGON; setPageElement(element, interp, offsetX, offsetY); element.points = points; elements.clear(); elements.push_back(element); }
QValueVector<KornMailSubject> * KKioDrop::doReadSubjects(bool * ) { _subjects->doReadSubjects( this ); /* * A empty QValueVector is made here. * After that, the size is expanded to the expected number of subjects. * This way, reallocation of memmory is minimized, and thus more efficient. */ QValueVector<KornMailSubject> *vector = new QValueVector<KornMailSubject>( ); vector->reserve( _mailurls->count() ); return vector; }
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; } }
/* \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; }
bool startElement( const QString& /*namespaceURI*/, const QString& localName, const QString& qName, const QXmlAttributes& atts ) { levels.back()++; // Ignore document root if ( levels.back() == 1 ) { if ( levels.isEmpty() ) { // Top level elements.push( NULL ); } else { // Within an include elements.push( elements.current() ); } return true; } // Include another file if ( qName == "include" ) { QString value = atts.value( "file" ); load( value ); elements.push( elements.current() ); return true; } cElement* element = new cElement; element->setName( localName.latin1() ); element->copyAttributes( atts ); // Child Element? if ( elements.current() != NULL ) { cElement* parent = elements.current(); // Pop the potential parent parent->addChild( element ); // Add the child to it's parent element->setParent( parent ); } else { Definitions::instance()->addElement(element); } elements.push( element ); // Push our element (there may be children) return true; }
QValueVector<struct Forward> forwardingPage::getForwards() { QValueVector<struct Forward> forwards; QListViewItem *item = m_forwards->firstChild(); while (item) { struct Forward _item; item->text(0) == i18n("Incoming") ? _item.direction = kiptg::INCOMING : _item.direction = kiptg::OUTGOING; _item.from = item->text(1); _item.to = item->text(2); forwards.append(_item); item = item->nextSibling(); } return forwards; }
// 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); }
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; }
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; }
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)); } } }
/** * 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; }
void load( const QString& filename ) { QFile file( filename ); if ( !file.open( IO_ReadOnly ) ) { Console::instance()->send( tr( "Unable to open %1!\n" ).arg( filename ) ); return; } filenames.push_back( filename ); QXmlInputSource input( &file ); QXmlSimpleReader reader; reader.setFeature( "http://trolltech.com/xml/features/report-whitespace-only-CharData", false ); reader.setContentHandler( this ); reader.setErrorHandler( this ); reader.parse( &input, false ); filenames.pop_back(); }