void Core::selectEditor(Komposer::Editor *editor) { if(!editor) return; KParts::Part *part = editor->part(); editor->select(); QPtrList<KParts::Part> *partList = const_cast<QPtrList<KParts::Part>*>( m_partManager->parts()); if(partList->find(part) == -1) addPart(part); m_partManager->setActivePart(part); QWidget *view = part->widget(); Q_ASSERT(view); kdDebug() << "Raising view " << view << endl; if(view) { m_stack->raiseWidget(view); view->show(); view->setFocus(); m_currentEditor = editor; } }
void TLFrameSequenceLayout::slotFrameHasDrawing( bool state ) { KeyFrame *ckf = k_toon -> currentStatus() -> currentKeyFrame(); Layer *cl = k_toon -> currentStatus() -> currentLayer(); QPtrList<KeyFrame> kf = cl -> keyFrames(); int kf_pos = kf.find( ckf ) + 1; current_frame_sequence -> setKeyframeHasDrawing( kf_pos, state ); }
void QDockArea::dockWindow( QDockWindow *dockWindow, DockWindowData *data ) { if ( !data ) return; dockWindow->reparent( this, QPoint( 0, 0 ), FALSE ); dockWindow->installEventFilter( this ); dockWindow->dockArea = this; dockWindow->updateGui(); if ( dockWindows->isEmpty() ) { dockWindows->append( dockWindow ); } else { QPtrList<QDockWindow> lineStarts = layout->lineStarts(); int index = 0; if ( (int)lineStarts.count() > data->line ) index = dockWindows->find( lineStarts.at( data->line ) ); if ( index == -1 ) { index = 0; (void)dockWindows->at( index ); } bool firstTime = TRUE; int offset = data->offset; for ( QDockWindow *dw = dockWindows->current(); dw; dw = dockWindows->next() ) { if ( !firstTime && lineStarts.find( dw ) != -1 ) break; if ( offset < point_pos( fix_pos( dw ), orientation() ) + size_extent( dw->size(), orientation() ) / 2 ) break; index++; firstTime = FALSE; } if ( index >= 0 && index < (int)dockWindows->count() && dockWindows->at( index )->newLine() && lineOf( index ) == data->line ) { dockWindows->at( index )->setNewLine( FALSE ); dockWindow->setNewLine( TRUE ); } else { dockWindow->setNewLine( FALSE ); } dockWindows->insert( index, dockWindow ); } dockWindow->show(); dockWindow->setFixedExtentWidth( data->fixedExtent.width() ); dockWindow->setFixedExtentHeight( data->fixedExtent.height() ); updateLayout(); setSizePolicy( QSizePolicy( orientation() == Horizontal ? QSizePolicy::Expanding : QSizePolicy::Minimum, orientation() == Vertical ? QSizePolicy::Expanding : QSizePolicy::Minimum ) ); }
void QDockArea::moveDockWindow( QDockWindow *w, const QPoint &p, const QRect &r, bool swap ) { invalidateFixedSizes(); int mse = -10; bool hasResizable = FALSE; for ( QDockWindow *dw = dockWindows->first(); dw; dw = dockWindows->next() ) { if ( dw->isHidden() ) continue; if ( dw->isResizeEnabled() ) hasResizable = TRUE; if ( orientation() != Qt::Horizontal ) mse = QMAX( QMAX( dw->fixedExtent().width(), dw->width() ), mse ); else mse = QMAX( QMAX( dw->fixedExtent().height(), dw->height() ), mse ); } if ( !hasResizable && w->isResizeEnabled() ) { if ( orientation() != Qt::Horizontal ) mse = QMAX( w->fixedExtent().width(), mse ); else mse = QMAX( w->fixedExtent().height(), mse ); } QDockWindow *dockWindow = 0; int dockWindowIndex = findDockWindow( w ); QPtrList<QDockWindow> lineStarts = layout->lineStarts(); QValueList<QRect> lines = layout->lineList(); bool wasAloneInLine = FALSE; QPoint pos = mapFromGlobal( p ); QRect lr = *lines.at( lineOf( dockWindowIndex ) ); if ( dockWindowIndex != -1 ) { if ( lineStarts.find( w ) != -1 && ( dockWindowIndex < (int)dockWindows->count() - 1 && lineStarts.find( dockWindows->at( dockWindowIndex + 1 ) ) != -1 || dockWindowIndex == (int)dockWindows->count() - 1 ) ) wasAloneInLine = TRUE; dockWindow = dockWindows->take( dockWindowIndex ); if ( !wasAloneInLine ) { // only do the pre-layout if the widget isn't the only one in its line if ( lineStarts.findRef( dockWindow ) != -1 && dockWindowIndex < (int)dockWindows->count() ) dockWindows->at( dockWindowIndex )->setNewLine( TRUE ); layout->layoutItems( QRect( 0, 0, width(), height() ), TRUE ); } } else { dockWindow = w; dockWindow->reparent( this, QPoint( 0, 0 ), TRUE ); if ( swap ) dockWindow->resize( dockWindow->height(), dockWindow->width() ); w->installEventFilter( this ); } lineStarts = layout->lineStarts(); lines = layout->lineList(); QRect rect = QRect( mapFromGlobal( r.topLeft() ), r.size() ); if ( orientation() == Horizontal && QApplication::reverseLayout() ) { rect = QRect( width() - rect.x() - rect.width(), rect.y(), rect.width(), rect.height() ); pos.rx() = width() - pos.x(); } dockWindow->setOffset( point_pos( rect.topLeft(), orientation() ) ); if ( orientation() == Horizontal ) { int offs = dockWindow->offset(); if ( width() - offs < dockWindow->minimumWidth() ) dockWindow->setOffset( width() - dockWindow->minimumWidth() ); } else { int offs = dockWindow->offset(); if ( height() - offs < dockWindow->minimumHeight() ) dockWindow->setOffset( height() - dockWindow->minimumHeight() ); } if ( dockWindows->isEmpty() ) { dockWindows->append( dockWindow ); } else { int dockLine = -1; bool insertLine = FALSE; int i = 0; QRect lineRect; // find the line which we touched with the mouse for ( QValueList<QRect>::Iterator it = lines.begin(); it != lines.end(); ++it, ++i ) { if ( point_pos( pos, orientation(), TRUE ) >= point_pos( (*it).topLeft(), orientation(), TRUE ) && point_pos( pos, orientation(), TRUE ) <= point_pos( (*it).topLeft(), orientation(), TRUE ) + size_extent( (*it).size(), orientation(), TRUE ) ) { dockLine = i; lineRect = *it; break; } } if ( dockLine == -1 ) { // outside the dock... insertLine = TRUE; if ( point_pos( pos, orientation(), TRUE ) < 0 ) // insert as first line dockLine = 0; else dockLine = (int)lines.count(); // insert after the last line ### size_t/int cast } else { // inside the dock (we have found a dockLine) if ( point_pos( pos, orientation(), TRUE ) < point_pos( lineRect.topLeft(), orientation(), TRUE ) + 4 ) { // mouse was at the very beginning of the line insertLine = TRUE; // insert a new line before that with the docking widget } else if ( point_pos( pos, orientation(), TRUE ) > point_pos( lineRect.topLeft(), orientation(), TRUE ) + size_extent( lineRect.size(), orientation(), TRUE ) - 4 ) { // mouse was at the very and of the line insertLine = TRUE; // insert a line after that with the docking widget dockLine++; } } if ( !insertLine && wasAloneInLine && lr.contains( pos ) ) // if we are alone in a line and just moved in there, re-insert it insertLine = TRUE; #if defined(QDOCKAREA_DEBUG) qDebug( "insert in line %d, and insert that line: %d", dockLine, insertLine ); qDebug( " (btw, we have %d lines)", lines.count() ); #endif QDockWindow *dw = 0; if ( dockLine >= (int)lines.count() ) { // insert after last line dockWindows->append( dockWindow ); dockWindow->setNewLine( TRUE ); #if defined(QDOCKAREA_DEBUG) qDebug( "insert at the end" ); #endif } else if ( dockLine == 0 && insertLine ) { // insert before first line dockWindows->insert( 0, dockWindow ); dockWindows->at( 1 )->setNewLine( TRUE ); #if defined(QDOCKAREA_DEBUG) qDebug( "insert at the begin" ); #endif } else { // insert somewhere in between // make sure each line start has a new line for ( dw = lineStarts.first(); dw; dw = lineStarts.next() ) dw->setNewLine( TRUE ); // find the index of the first widget in the search line int searchLine = dockLine; #if defined(QDOCKAREA_DEBUG) qDebug( "search line start of %d", searchLine ); #endif QDockWindow *lsw = lineStarts.at( searchLine ); int index = dockWindows->find( lsw ); if ( index == -1 ) { // the linestart widget hasn't been found, try to find it harder if ( lsw == w && dockWindowIndex <= (int)dockWindows->count()) index = dockWindowIndex; else index = 0; if ( index < (int)dockWindows->count() ) (void)dockWindows->at( index ); // move current to index } #if defined(QDOCKAREA_DEBUG) qDebug( " which starts at %d", index ); #endif if ( !insertLine ) { // if we insert the docking widget in the existing line // find the index for the widget bool inc = TRUE; bool firstTime = TRUE; for ( dw = dockWindows->current(); dw; dw = dockWindows->next() ) { if ( orientation() == Horizontal ) dw->setFixedExtentWidth( -1 ); else dw->setFixedExtentHeight( -1 ); if ( !firstTime && lineStarts.find( dw ) != -1 ) // we are in the next line, so break break; if ( point_pos( pos, orientation() ) < point_pos( fix_pos( dw ), orientation() ) + size_extent( dw->size(), orientation() ) / 2 ) { inc = FALSE; } if ( inc ) index++; firstTime = FALSE; } #if defined(QDOCKAREA_DEBUG) qDebug( "insert at index: %d", index ); #endif // if we insert it just before a widget which has a new line, transfer the newline to the docking widget // but not if we didn't only mave a widget in its line which was alone in the line before if ( !( wasAloneInLine && lr.contains( pos ) ) && index >= 0 && index < (int)dockWindows->count() && dockWindows->at( index )->newLine() && lineOf( index ) == dockLine ) { #if defined(QDOCKAREA_DEBUG) qDebug( "get rid of the old newline and get me one" ); #endif dockWindows->at( index )->setNewLine( FALSE ); dockWindow->setNewLine( TRUE ); } else if ( wasAloneInLine && lr.contains( pos ) ) { dockWindow->setNewLine( TRUE ); } else { // if we are somewhere in a line, get rid of the newline dockWindow->setNewLine( FALSE ); } } else { // insert in a new line, so make sure the dock widget and the widget which will be after it have a newline #if defined(QDOCKAREA_DEBUG) qDebug( "insert a new line" ); #endif if ( index < (int)dockWindows->count() ) { #if defined(QDOCKAREA_DEBUG) qDebug( "give the widget at %d a newline", index ); #endif QDockWindow* nldw = dockWindows->at( index ); if ( nldw ) nldw->setNewLine( TRUE ); } #if defined(QDOCKAREA_DEBUG) qDebug( "give me a newline" ); #endif dockWindow->setNewLine( TRUE ); } // finally insert the widget dockWindows->insert( index, dockWindow ); } } if ( mse != -10 && w->isResizeEnabled() ) { if ( orientation() != Qt::Horizontal ) w->setFixedExtentWidth( QMIN( QMAX( w->minimumWidth(), mse ), w->sizeHint().width() ) ); else w->setFixedExtentHeight( QMIN( QMAX( w->minimumHeight(), mse ), w->sizeHint().height() ) ); } updateLayout(); setSizePolicy( QSizePolicy( orientation() == Horizontal ? QSizePolicy::Expanding : QSizePolicy::Minimum, orientation() == Vertical ? QSizePolicy::Expanding : QSizePolicy::Minimum ) ); }
bool DVBevents::tableEIT( unsigned char* buffer ) { unsigned char* buf = buffer; unsigned int length, loop, sid, tid, eid, tsid, sn, lsn, nid; int i, sec; EventDesc *desc=0, *itdesc=0; EventSid *slist; QPtrList<EventDesc> *currentEvents; bool nodesc, parse; QDateTime start, cur, dt; unsigned int cdt = QDateTime::currentDateTime().toTime_t(); tid = getBits(buf,0,8); length = getBits(buf,12,12); sid = getBits(buf,24,16); sn = getBits(buf,48,8); lsn = getBits(buf,56,8); tsid = getBits(buf,64,16); nid = getBits(buf,80,16); length -=11; buf +=14; slist = currentSrc->getEventSid( nid, tsid, sid ); if ( !slist ) return false; slist->lock(); currentEvents = slist->getEvents(); QPtrListIterator<EventDesc> it( *currentEvents ); while ( length>4 ) { nodesc=parse=false; if ( !safeLen( buf+2 ) ) goto stop; eid = getBits(buf,0,16); if ( !safeLen( buf+2+5 ) ) goto stop; start = getDateTime( buf+2 ); nodesc=parse=true; it.toFirst(); while ( (desc=it.current())!=0 ) { if ( desc->sid==sid ) { if ( desc->startDateTime==start || desc->eid==eid ) { if ( desc->tid==0x4e && tid!=0x4e ) { parse = false; nodesc = false; break; } else { nodesc = false; if ( (cdt-desc->loop)<300 ) { // only reparse events every 300 seconds parse = false; } else { desc->extEvents.clear(); desc->shortEvents.clear(); desc->title=desc->subtitle=""; } break; } } } ++it; } if ( nodesc ) desc = new EventDesc(); if ( parse ) { if ( !safeLen( buf+10 ) ) goto stop; desc->duration = getTime( buf+7 ); if ( !safeLen( buf+11 ) ) goto stop; desc->running = getBits(buf,80,3); desc->sid = sid; desc->tid = tid; desc->tsid = tsid; desc->nid = nid; desc->lsn = lsn; desc->sn = sn; desc->eid = eid; desc->loop = cdt; } if ( desc->sn != sn ) { slist->unlock(); return false; } if ( !safeLen( buf+12 ) ) goto stop; loop = getBits(buf,84,12); buf +=12; length -=(12+loop); while ( loop>0 ) { if ( parse ) { if ( !safeLen( buf+1 ) ) goto stop; switch ( getBits(buf,0,8) ) { case 0x4D : if ( !shortEventDesc( buf, desc ) ) goto stop; break; case 0x4E : if ( !extEventDesc( buf, desc ) ) goto stop; break; default : break; } } if ( !safeLen( buf+2 ) ) goto stop; loop -=( getBits(buf,8,8)+2 ); buf +=( getBits(buf,8,8)+2 ); } //out: if ( parse ) { if ( !nodesc ) { if ( start==desc->startDateTime ) goto ifend; currentEvents->take( currentEvents->find( desc ) ); } desc->startDateTime = start; for ( i=0; i<(int)currentEvents->count(); i++ ) { itdesc = currentEvents->at(i); if ( desc->startDateTime<itdesc->startDateTime ) { currentEvents->insert( i, desc ); break; } itdesc = 0; } if ( !itdesc ) currentEvents->append( desc ); } ifend: if ( parse ) ++(desc->sn); if ( nodesc ) { cur = QDateTime::currentDateTime(); dt = desc->startDateTime; sec = desc->duration.hour()*3600+desc->duration.minute()*60+desc->duration.second(); if ( dt.addSecs( sec )<cur || desc->title.length()<3 ) { currentEvents->remove( desc ); } else desc->source = currentSrc->getSource(); } } slist->unlock(); return true; stop: slist->unlock(); fprintf( stderr, "Stop parsing EIT (%d:%d)\n", adapter, tuner ); if ( nodesc ) delete desc; return false; }