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; }
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); } }
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; }
/** * 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; }
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; }
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( "," ); }
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; }
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; }
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; } }
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; }
/** * 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; }
// 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()); }
Kleo::DN::const_iterator Kleo::DN::end() const { return d ? d->attributes.end() : empty.end() ; }
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; } } */ }
// 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; }
void cSpeech::talking( P_PLAYER pChar, const QString &lang, const QString &speech, QValueVector< UINT16 > &keywords, UINT16 color, UINT16 font, 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; // not allowed to talk if( pChar->isMuted() ) { socket->sysMessage( tr( "You re squelched and cannot talk" ) ); return; } pChar->unhide(); // Check for Bogus Color if( !isNormalColor( color ) ) color = 0x2; if( type == 0 || type == 2) pChar->setSaycolor( color ); if( SrvParams->speechLog() ) { QFile lFile( "speech.log" ); if( lFile.open( IO_Append ) ) { QString logMessage( "[%1] %2: %3 [%4, 0x%5]" ); logMessage = logMessage.arg( QDateTime::currentDateTime().toString() ).arg( pChar->name() ).arg( speech ).arg( pChar->account()->login() ).arg( pChar->serial(), 8, 16 ); lFile.writeBlock( logMessage.latin1(), logMessage.length() ); lFile.close(); } } 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 // 0x0007 -> Speech-id for "Guards" for( QValueVector< UINT16 >::const_iterator iter = keywords.begin(); iter != keywords.end(); ++iter ) { UINT16 keyword = *iter; if( keyword == 0x07 ) pChar->callGuards(); } // well,i had a strange problem with duplicate speech input // its quite easy to understand.... // the former loop searched for the tiller man and when it // was found, the speechInput method of that boat was called. // in this method the tiller had been removed from the mapregion // and appended to the end of the cell vector... hence, the // tiller was found twice... // therefore we produce a QPtrList of cBoat* pointers and // then go through it for applying speech --- sereg RegionIterator4Items rj( pChar->pos() ); QPtrList< cBoat > pboats; for( rj.Begin(); !rj.atEnd(); rj++ ) { P_ITEM pi = rj.GetData(); if( !pi ) continue; if( pi->type() == 117 && pi->tags().get( "tiller" ).toInt() == 1 ) { cBoat* pBoat = dynamic_cast< cBoat* >(FindItemBySerial( pi->tags().get("boatserial").toInt() )); if( pBoat ) pboats.append( pBoat ); } } QPtrListIterator< cBoat > pit( pboats ); while( pit.current() ) { pit.current()->speechInput( socket, speechUpr ); ++pit; } // this makes it so npcs do not respond to isDead people - HEALERS ?? if( pChar->isDead() ) return; /* 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; } } */ }
//BEGIN DocumentObserver inherited methods void ThumbnailList::notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged ) { // if there was a widget selected, save its pagenumber to restore // its selection (if available in the new set of pages) int prevPage = -1; if ( !documentChanged && m_selected ) { prevPage = m_selected->page()->number(); } // delete all the Thumbnails QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end(); for ( ; tIt != tEnd; ++tIt ) delete *tIt; m_thumbnails.clear(); m_visibleThumbnails.clear(); m_selected = 0; if ( pages.count() < 1 ) { resizeContents( 0, 0 ); return; } // show pages containing hilighted text or bookmarked ones //RESTORE THIS int flags = Settings::filterBookmarks() ? KPDFPage::Bookmark : KPDFPage::Highlight; // if no page matches filter rule, then display all pages QValueVector< KPDFPage * >::const_iterator pIt = pages.begin(), pEnd = pages.end(); bool skipCheck = true; for ( ; pIt != pEnd ; ++pIt ) //if ( (*pIt)->attributes() & flags ) if ( (*pIt)->hasHighlights( SW_SEARCH_ID ) ) skipCheck = false; // generate Thumbnails for the given set of pages int width = clipper()->width(), totalHeight = 0; for ( pIt = pages.begin(); pIt != pEnd ; ++pIt ) //if ( skipCheck || (*pIt)->attributes() & flags ) if ( skipCheck || (*pIt)->hasHighlights( SW_SEARCH_ID ) ) { ThumbnailWidget * t = new ThumbnailWidget( viewport(), *pIt, this ); t->setFocusProxy( this ); // add to the scrollview addChild( t, 0, totalHeight ); // add to the internal queue m_thumbnails.push_back( t ); // update total height (asking widget its own height) t->resizeFitWidth( width ); totalHeight += t->heightHint() + 4; if ( (*pIt)->number() == prevPage ) { m_selected = t; m_selected->setSelected( true ); } t->show(); } // update scrollview's contents size (sets scrollbars limits) resizeContents( width, totalHeight ); // request for thumbnail generation delayedRequestVisiblePixmaps( 200 ); }
// public void kpMainWindow::pasteText (const QString &text, bool forceNewTextSelection, const QPoint &newTextSelectionTopLeft) { #if DEBUG_KP_MAIN_WINDOW && 1 kdDebug () << "kpMainWindow::pasteText(" << text << ",forceNewTextSelection=" << forceNewTextSelection << ",newTextSelectionTopLeft=" << newTextSelectionTopLeft << ")" << endl; #endif if (text.isEmpty ()) return; // sync: restoreOverrideCursor() in all exit paths QApplication::setOverrideCursor (Qt::waitCursor); if (toolHasBegunShape ()) tool ()->endShapeInternal (); QValueVector <QString> textLines (1, QString::null); for (int i = 0; i < (int) text.length (); i++) { if (text [i] == '\n') textLines.push_back (QString::null); else textLines [textLines.size () - 1].append (text [i]); } if (!forceNewTextSelection && m_document && m_document->selection () && m_document->selection ()->isText () && m_commandHistory && m_viewManager) { #if DEBUG_KP_MAIN_WINDOW && 1 kdDebug () << "\treusing existing Text Selection" << endl; #endif kpMacroCommand *macroCmd = new kpMacroCommand (i18n ("Text: Paste"), this); for (int i = 0; i < (int) textLines.size (); i++) { if (i > 0) { macroCmd->addCommand ( new kpToolTextEnterCommand ( QString::null/*uninteresting child of macroCmd*/, m_viewManager->textCursorRow (), m_viewManager->textCursorCol (), this)); } macroCmd->addCommand ( new kpToolTextInsertCommand ( QString::null/*uninteresting child of macroCmd*/, m_viewManager->textCursorRow (), m_viewManager->textCursorCol (), textLines [i], this)); } m_commandHistory->addCommand (macroCmd, false/*no exec*/); } else { #if DEBUG_KP_MAIN_WINDOW && 1 kdDebug () << "\tcreating Text Selection" << endl; #endif const kpTextStyle ts = textStyle (); const QFontMetrics fontMetrics = ts.fontMetrics (); int height = textLines.size () * fontMetrics.height (); if (textLines.size () >= 1) height += (textLines.size () - 1) * fontMetrics.leading (); int width = 0; for (QValueVector <QString>::const_iterator it = textLines.begin (); it != textLines.end (); it++) { const int w = fontMetrics.width (*it); if (w > width) width = w; } const int selWidth = QMAX (kpSelection::minimumWidthForTextStyle (ts), width + kpSelection::textBorderSize () * 2); const int selHeight = QMAX (kpSelection::minimumHeightForTextStyle (ts), height + kpSelection::textBorderSize () * 2); kpSelection sel (QRect (0, 0, selWidth, selHeight), textLines, ts); if (newTextSelectionTopLeft != KP_INVALID_POINT) { sel.moveTo (newTextSelectionTopLeft); paste (sel, true/*force topLeft*/); } else { paste (sel); } } QApplication::restoreOverrideCursor (); }