static rpmRC db3_idxdbDel(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexItem rec) { dbiIndexSet set = NULL; rpmRC rc; if (keyp && keylen == 0) { /* XXX "/" fixup */ keyp = ""; keylen++; } rc = idxdbGet(dbi, dbc, keyp, keylen, &set, DBC_NORMAL_SEARCH); if (rc) return rc; if (dbiIndexSetPrune(set, rec, 1, 1)) { /* Nothing was pruned. XXX: Can this actually happen? */ rc = RPMRC_OK; } else { /* If there's data left, update data. Otherwise delete the key. */ if (dbiIndexSetCount(set) > 0) { rc = updateIndex(dbc, keyp, keylen, set); } else { rc = updateIndex(dbc, keyp, keylen, NULL); } }; dbiIndexSetFree(set); return rc; }
bool AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ) { Q_UNUSED( model ); Q_UNUSED( option ); if ( event->type() != QEvent::MouseButtonRelease && event->type() != QEvent::MouseMove && event->type() != QEvent::MouseButtonPress && event->type() != QEvent::Leave ) return false; if ( event->type() == QEvent::MouseMove ) m_hoverIndex = index; if ( m_artistNameRects.contains( index ) ) { QMouseEvent* ev = static_cast< QMouseEvent* >( event ); QRect artistNameRect = m_artistNameRects[ index ]; if ( artistNameRect.contains( ev->pos() ) ) { if ( event->type() == QEvent::MouseMove ) { if ( m_hoveringOver != index ) { QModelIndex old = m_hoveringOver; m_hoveringOver = index; emit updateIndex( old ); emit updateIndex( index ); } event->accept(); return true; } else if ( event->type() == QEvent::MouseButtonRelease ) { AlbumItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) ); if ( !item || item->album().isNull() || item->album()->artist().isNull() ) return false; ViewManager::instance()->show( item->album()->artist() ); event->accept(); return true; } else if ( event->type() == QEvent::MouseButtonPress ) { // Stop the whole album from having a down click action as we just want the artist name to be clicked event->accept(); return true; } } } whitespaceMouseEvent(); return false; }
/* Calculate the new values of a corner */ inline void updateCorners(int Ix, int Iy, int Iz, unsigned char *data, unsigned char *newData, int rank) { int x=1; int y=1;int z=1; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=1;y=1;z=Iz; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=1;y=Iy;z=1; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=1;y=Iy;z=Iz; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=Ix;y=1;z=1; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=Ix;y=1;z=Iz; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=Ix;y=Iy;z=1; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); x=Ix;y=Iy;z=Iz; updateIndex(Ix, Iy, Iz, data, newData, x, y, z); }
Beam::Beam( Vec2 lc, Vec2 at, BEAMTYPE beamtype, int base_index, int ene, int shooter_id, int client_id, int internal_id ) : Char( CAT_BEAM, lc, g_base_deck, g_char_layer, client_id, internal_id ), type(beamtype), ene(ene), shooter_id(shooter_id) { switch(beamtype) { case BEAMTYPE_NORMAL: v = lc.to(at).normalize( BEAM_NORMAL_VEL ); clean_at = 1; setIndex( base_index ); break; case BEAMTYPE_BLASTER: clean_at = 0.5; v = lc.to(at).normalize( BEAM_BLASTER_VEL ); break; } setRot(atan2( v.y, v.x )); setColor(WHITE); updateIndex(); tex_epsilon = DEFAULT_TEX_EPS; hitsz = 3 + (float)(ene/16); if( isLocal() ) realtimeNewBeamSend(this); }
void AlbumItemDelegate::doUpdateIndex( const QPersistentModelIndex& idx ) { if ( !idx.isValid() ) return; emit updateIndex( idx ); }
static rpmRC db3_idxdbPut(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexItem rec) { dbiIndexSet set = NULL; rpmRC rc; if (keyp && keylen == 0) { /* XXX "/" fixup */ keyp = ""; keylen++; } rc = idxdbGet(dbi, dbc, keyp, keylen, &set, DBC_NORMAL_SEARCH); /* Not found means a new key and is not an error. */ if (rc && rc != RPMRC_NOTFOUND) return rc; if (set == NULL) set = dbiIndexSetNew(1); dbiIndexSetAppend(set, rec, 1, 0); rc = updateIndex(dbc, keyp, keylen, set); dbiIndexSetFree(set); return rc; }
void ObjectModel::updateIndex() { for (int i = 0; i < m_pRoot->childCount(); i++) { updateIndex(m_pRoot->child(i), QModelIndex(), i); } }
const ValueBase* Array::set(std::string key, T val) { if (!key.length()) return NULL; const ValueBase* v = push<T>(val, key); if (v) updateIndex(key, v); return v; }
GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyModel* proxy ) : QStyledItemDelegate( (QObject*)parent ) , m_view( parent ) , m_model( proxy ) , m_itemWidth( 0 ) , m_showPosition( false ) , m_showBuyButtons( false ) , m_wordWrapping( false ) , m_margin( TomahawkUtils::DpiScaler::scaledY( parent, 32 ) ) { if ( m_view && m_view->metaObject()->indexOfSignal( "modelChanged()" ) > -1 ) connect( m_view, SIGNAL( modelChanged() ), this, SLOT( modelChanged() ) ); m_font = m_view->font(); m_smallFont = m_font; m_font.setPointSize( TomahawkUtils::defaultFontSize() + 2 ); m_smallFont.setPointSize( TomahawkUtils::defaultFontSize() ); connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) ); connect( proxy, SIGNAL( rowsAboutToBeInserted( QModelIndex, int, int ) ), SLOT( modelChanged() ) ); connect( proxy, SIGNAL( rowsAboutToBeRemoved( QModelIndex, int, int ) ), SLOT( modelChanged() ) ); connect( proxy->playlistInterface().data(), SIGNAL( currentIndexChanged() ), SLOT( onCurrentIndexChanged() ), Qt::UniqueConnection ); connect( m_view, SIGNAL( scrolledContents( int, int ) ), SLOT( onViewChanged() ) ); connect( m_view, SIGNAL( resized() ), SLOT( onViewChanged() ) ); }
void ItemTags::addTag(int id, QString name) { beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_tags[id] = name; updateIndex(); endInsertRows(); }
void CObjectModel::flat() { for ( int i = 0 ; i < m_pRoot->childCount() ; i ++ ) { ObjectItem *pObj = m_pRoot->child(i) ; pObj->flat() ; } updateIndex() ; }
void CObjectModel::updateIndex(ObjectItem *pItem, const QModelIndex &parent, int row) { pItem->setIndex(this->index(row, 0, parent)) ; pItem->setParent(this->getItemFromIndex(parent)) ; for ( int i = 0 ; i < pItem->childCount() ; i ++ ) { updateIndex(pItem->child(i), pItem->getIndex(), i) ; } }
void AlbumItemDelegate::whitespaceMouseEvent() { if ( m_hoveringOver.isValid() ) { QModelIndex old = m_hoveringOver; m_hoveringOver = QPersistentModelIndex(); emit updateIndex( old ); } }
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend ) : mLegend( legend ) { connect( legend, SIGNAL( itemAdded( QModelIndex ) ), this, SIGNAL( itemAdded( QModelIndex ) ) ); connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SLOT( updateIndex( QModelIndex, QModelIndex ) ) ); connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SIGNAL( groupRelationsChanged( ) ) ); connect( legend, SIGNAL( itemMovedGroup( QgsLegendItem *, int ) ), this, SIGNAL( groupRelationsChanged() ) ); // connect( legend, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SIGNAL( groupRelationsChanged() ) ); connect( legend, SIGNAL( itemRemoved() ), this, SIGNAL( itemRemoved() ) ); }
void ItemTags::reload() { if (not m_item.isValid()) { clear(); return; } Tags *tags = dynamic_cast<Tags*>(QObject::parent()); if (tags == NULL) throw new NoTaggingEngine; m_tags = tags->itemTags(item()); updateIndex(); reset(); }
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent ) : QObject( (QObject*) parent ) , m_lastartid( 0 ) , m_lastalbid( 0 ) , m_lasttrkid( 0 ) { QTime t; t.start(); bool schemaUpdated = openDatabase( dbname ); tDebug( LOGVERBOSE ) << "Opened database:" << t.elapsed(); TomahawkSqlQuery query = newquery(); query.exec( "SELECT v FROM settings WHERE k='dbid'" ); if ( query.next() ) { m_dbid = query.value( 0 ).toString(); } else { m_dbid = uuid(); query.exec( QString( "INSERT INTO settings(k,v) VALUES('dbid','%1')" ).arg( m_dbid ) ); } tLog() << "Database ID:" << m_dbid; // make sqlite behave how we want: query.exec( "PRAGMA auto_vacuum = FULL" ); query.exec( "PRAGMA synchronous = ON" ); query.exec( "PRAGMA foreign_keys = ON" ); //query.exec( "PRAGMA temp_store = MEMORY" ); tDebug( LOGVERBOSE ) << "Tweaked db pragmas:" << t.elapsed(); // in case of unclean shutdown last time: query.exec( "UPDATE source SET isonline = 'false'" ); // schemaUpdated = true; // REMOVE ME m_fuzzyIndex = new FuzzyIndex( *this, schemaUpdated ); if ( schemaUpdated ) QTimer::singleShot( 0, this, SLOT( updateIndex() ) ); tDebug( LOGVERBOSE ) << "Loaded index:" << t.elapsed(); if ( qApp->arguments().contains( "--dumpdb" ) ) { dumpDatabase(); ::exit( 0 ); } }
GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyModel* proxy ) : QStyledItemDelegate( (QObject*)parent ) , m_view( parent ) , m_model( proxy ) { if ( m_view && m_view->metaObject()->indexOfSignal( "modelChanged()" ) > -1 ) connect( m_view, SIGNAL( modelChanged() ), this, SLOT( modelChanged() ) ); connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) ); connect( proxy, SIGNAL( rowsAboutToBeInserted( QModelIndex, int, int ) ), SLOT( modelChanged() ) ); connect( proxy, SIGNAL( rowsAboutToBeRemoved( QModelIndex, int, int ) ), SLOT( modelChanged() ) ); connect( proxy->playlistInterface().data(), SIGNAL( currentIndexChanged() ), SLOT( onCurrentIndexChanged() ), Qt::UniqueConnection ); connect( m_view, SIGNAL( scrolledContents( int, int ) ), SLOT( onViewChanged() ) ); connect( m_view, SIGNAL( resized() ), SLOT( onViewChanged() ) ); }
/** * @brief obtain random node. * **/ void obtain_random_node(tree_node_t *node){ int start_lba, end_lba; random_lba_range(&start_lba, &end_lba); node->start_lba = start_lba; node->end_lba = end_lba; node->type = rand()%2; if(next_index[0] + 1 > MAX_NODES){ memset(tree_array, 0, sizeof(tree_array)); obtainEventInexMarker(rootArray[0]); updateIndex(rootArray[0]); next_index[0] = sum(MAX_NODES); } next_index[0]++; node->eventIndex = next_index[0]; }
void ListViewSingleButtonDelegate::clearLastState() { // // Clears the last state of the index // if (this->lastItemIndex.isValid()) { // Reset edit and delete button // Ugly const cast, but it is necessary! QAbstractItemModel *model = const_cast<QAbstractItemModel*>(this->lastItemIndex.model()); // Rest values to normal model->setData(this->lastItemIndex, (int) Normal, Qt::UserRole + 100); // Repaint the index emit updateIndex(this->lastItemIndex); // // Reset last index this->lastItemIndex = QModelIndex (); } }
void AudioFIFO::push(const AudioBus* sourceBus) { // Copy the sourceBus into the FIFO buffer. bool isGood = sourceBus && (m_framesInFifo + sourceBus->length() <= m_fifoLength); if (!isGood) return; size_t sourceLength = sourceBus->length(); size_t part1Length; size_t part2Length; findWrapLengths(m_writeIndex, sourceLength, part1Length, part2Length); size_t numberOfChannels = m_fifoAudioBus->numberOfChannels(); for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) { float* destination = m_fifoAudioBus->channel(channelIndex)->mutableData(); const float* source = sourceBus->channel(channelIndex)->data(); bool isCopyGood = ((m_writeIndex < m_fifoLength) && (m_writeIndex + part1Length) <= m_fifoLength && part2Length < m_fifoLength && part1Length + part2Length <= sourceLength); ASSERT(isCopyGood); if (!isCopyGood) return; memcpy(destination + m_writeIndex, source, part1Length * sizeof(*destination)); // Handle wrap around of the FIFO, if needed. if (part2Length) memcpy(destination, source + part1Length, part2Length * sizeof(*destination)); } m_framesInFifo += sourceLength; ASSERT(m_framesInFifo <= m_fifoLength); m_writeIndex = updateIndex(m_writeIndex, sourceLength); }
void AudioPullFIFO::consume(AudioBus* destination, size_t framesToConsume) { bool isGood = destination && (framesToConsume <= m_fifoLength); ASSERT(isGood); if (!isGood) return; if (framesToConsume > m_framesInFifo) { // We don't have enough data in the FIFO to fulfill the request. Ask for more data. fillBuffer(framesToConsume - m_framesInFifo); } // We have enough data now. Copy the requested number of samples to the destination. size_t part1Length; size_t part2Length; findWrapLengths(m_readIndex, framesToConsume, part1Length, part2Length); size_t numberOfChannels = m_fifoAudioBus.numberOfChannels(); for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) { float* destinationData = destination->channel(channelIndex)->mutableData(); const float* sourceData = m_fifoAudioBus.channel(channelIndex)->data(); bool isCopyGood = ((m_readIndex < m_fifoLength) && (m_readIndex + part1Length) <= m_fifoLength && (part1Length <= destination->length()) && (part1Length + part2Length) <= destination->length()); ASSERT(isCopyGood); if (!isCopyGood) return; memcpy(destinationData, sourceData + m_readIndex, part1Length * sizeof(*sourceData)); // Handle wrap around of the FIFO, if needed. if (part2Length > 0) memcpy(destinationData + part1Length, sourceData, part2Length * sizeof(*sourceData)); } m_readIndex = updateIndex(m_readIndex, framesToConsume); m_framesInFifo -= framesToConsume; ASSERT(m_framesInFifo >= 0); }
void AudioFIFO::consume(AudioBus* destination, size_t framesToConsume) { bool isGood = destination && (framesToConsume <= m_fifoLength) && (framesToConsume <= m_framesInFifo) && (destination->length() >= framesToConsume); ASSERT(isGood); if (!isGood) return; // Copy the requested number of samples to the destination. size_t part1Length; size_t part2Length; findWrapLengths(m_readIndex, framesToConsume, part1Length, part2Length); size_t numberOfChannels = m_fifoAudioBus->numberOfChannels(); for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) { float* destinationData = destination->channel(channelIndex)->mutableData(); const float* sourceData = m_fifoAudioBus->channel(channelIndex)->data(); bool isCopyGood = ((m_readIndex < m_fifoLength) && (m_readIndex + part1Length) <= m_fifoLength && (part1Length <= destination->length()) && (part1Length + part2Length) <= destination->length()); ASSERT(isCopyGood); if (!isCopyGood) return; memcpy(destinationData, sourceData + m_readIndex, part1Length * sizeof(*sourceData)); // Handle wrap around of the FIFO, if needed. if (part2Length) memcpy(destinationData + part1Length, sourceData, part2Length * sizeof(*sourceData)); } m_readIndex = updateIndex(m_readIndex, framesToConsume); ASSERT(m_framesInFifo >= framesToConsume); m_framesInFifo -= framesToConsume; }
void AudioPullFIFO::fillBuffer(size_t numberOfFrames) { // Keep asking the provider to give us data until we have received at least |numberOfFrames| of // data. Stuff the data into the FIFO. size_t framesProvided = 0; while (framesProvided < numberOfFrames) { m_provider.provideInput(&m_tempBus, m_providerSize); size_t part1Length; size_t part2Length; findWrapLengths(m_writeIndex, m_providerSize, part1Length, part2Length); size_t numberOfChannels = m_fifoAudioBus.numberOfChannels(); for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) { float* destination = m_fifoAudioBus.channel(channelIndex)->mutableData(); const float* source = m_tempBus.channel(channelIndex)->data(); bool isCopyGood = (part1Length <= m_providerSize && (part1Length + part2Length) <= m_providerSize && (m_writeIndex < m_fifoLength) && (m_writeIndex + part1Length) <= m_fifoLength && part2Length < m_fifoLength); ASSERT(isCopyGood); if (!isCopyGood) return; memcpy(destination + m_writeIndex, source, part1Length * sizeof(*destination)); // Handle wrap around of the FIFO, if needed. if (part2Length > 0) memcpy(destination, source + part1Length, part2Length * sizeof(*destination)); } m_framesInFifo += m_providerSize; ASSERT(m_framesInFifo <= m_fifoLength); m_writeIndex = updateIndex(m_writeIndex, m_providerSize); framesProvided += m_providerSize; } }
int History::save(QString user, QDateTime date, QString* lpszData) { lmcSettings settings; QString path = historyFile(); QDir dir = QFileInfo(path).dir(); if(!dir.exists()) dir.mkpath(dir.absolutePath()); if(!QFile::exists(path)) create(path); QFile file(path); if(!file.open(QIODevice::ReadWrite)) return -1; QDataStream stream(&file); DBHeader header = readHeader(&stream); if(header.marker.compare(HC_DBMARKER) != 0) { file.close(); return -1; } qint64 dataPos = insertData(&stream, lpszData); qint64 newIndex = insertIndex(&stream, dataPos, user, date); updateIndex(&stream, header.last, newIndex); header.count++; header.first = (header.first == 0) ? newIndex : header.first; header.last = newIndex; writeHeader(&stream, &header); file.close(); return 0; }
bool GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ) { Q_UNUSED( model ); Q_UNUSED( option ); if ( event->type() != QEvent::MouseButtonRelease && event->type() != QEvent::MouseMove && event->type() != QEvent::MouseButtonPress && event->type() != QEvent::Leave ) return false; bool hoveringArtist = false; if ( m_artistNameRects.contains( index ) ) { const QRect artistNameRect = m_artistNameRects[ index ]; const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); hoveringArtist = artistNameRect.contains( ev->pos() ); } if ( event->type() == QEvent::MouseMove ) { if ( hoveringArtist ) m_view->setCursor( Qt::PointingHandCursor ); else m_view->setCursor( Qt::ArrowCursor ); foreach ( const QModelIndex& idx, m_playButton.keys() ) { if ( index != idx ) m_playButton.take( idx )->deleteLater(); } if ( !m_playButton.contains( index ) && !m_spinner.contains( index ) && !m_pauseButton.contains( index ) ) { foreach ( ImageButton* button, m_playButton ) button->deleteLater(); m_playButton.clear(); ImageButton* button = new ImageButton( m_view ); button->setPixmap( RESPATH "images/play-rest.png" ); button->setPixmap( RESPATH "images/play-pressed.png", QIcon::Off, QIcon::Active ); button->setFixedSize( 48, 48 ); button->move( option.rect.center() - QPoint( 23, 23 ) ); button->setContentsMargins( 0, 0, 0, 0 ); button->setFocusPolicy( Qt::NoFocus ); button->installEventFilter( this ); button->show(); NewClosure( button, SIGNAL( clicked( bool ) ), const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); m_playButton[ index ] = button; } if ( m_hoveringOver != index || ( !hoveringArtist && m_hoveringOver.isValid() ) ) { emit updateIndex( m_hoveringOver ); if ( hoveringArtist ) m_hoveringOver = index; else m_hoveringOver = QPersistentModelIndex(); emit updateIndex( index ); } if ( m_hoverIndex != index ) { if ( m_hoverIndex.isValid() ) { QTimeLine* fadeOut = createTimeline( QTimeLine::Forward ); _detail::Closure* c = NewClosure( fadeOut, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) ); c->setAutoDelete( false ); c = NewClosure( fadeOut, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) ); c->setAutoDelete( false ); m_hoverFaders[ m_hoverIndex ] = fadeOut; fadeOut->start(); } emit updateIndex( m_hoverIndex ); m_hoverIndex = index; QTimeLine* fadeIn = createTimeline( QTimeLine::Backward ); _detail::Closure* c = NewClosure( fadeIn, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); c->setAutoDelete( false ); c = NewClosure( fadeIn, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); c->setAutoDelete( false ); m_hoverFaders[ index ] = fadeIn; fadeIn->start(); emit updateIndex( index ); }
void LaTeX::checkAutoRun(int nErrors, int nWarnings) { KILE_DEBUG() << "check for autorun, m_reRun is " << m_reRun << endl; //check for "rerun LaTeX" warnings bool reRan = false; if ( (m_reRun < 2) && (nErrors == 0) && (nWarnings > 0) ) { int sz = manager()->info()->outputInfo()->size(); for (int i = 0; i < sz; ++i ) { if ( (*manager()->info()->outputInfo())[i].type() == LatexOutputInfo::itmWarning && (*manager()->info()->outputInfo())[i].message().contains("Rerun") ) { reRan = true; break; } } } if ( reRan ) m_reRun++; else m_reRun = 0; bool bibs = updateBibs(); bool index = updateIndex(); bool asy = updateAsy(); if ( reRan ) { KILE_DEBUG() << "rerunning LaTeX " << m_reRun << endl; Base *tool = manager()->factory()->create(name()); tool->setSource(source()); manager()->runNext(tool); } if ( bibs || index || asy ) { Base *tool = manager()->factory()->create(name()); tool->setSource(source()); manager()->runNext(tool); if ( bibs ) { KILE_DEBUG() << "need to run BibTeX" << endl; tool = manager()->factory()->create("BibTeX"); tool->setSource(source()); manager()->runNext(tool); } if ( index ) { KILE_DEBUG() << "need to run MakeIndex" << endl; tool = manager()->factory()->create("MakeIndex"); tool->setSource(source()); manager()->runNext(tool); } if ( asy ) { KILE_DEBUG() << "need to run asymptote" << endl; tool = manager()->factory()->create("Asymptote"); tool->setSource(source()); manager()->runNext(tool); } } }
bool Beam::charPoll( double dt ) { // Shifter tile bends beam Cell *c = g_fld->get(loc); if( c->gt == GT_SHIFTER && c->st == ST_NONE && c->bt == BT_AIR ) { Vec2 dv = dirToVec2(c->dir) * PPC* SHIFTER_ACCEL; v += dv * dt; if( v.len() > BEAM_NORMAL_VEL ) { v = v.normalize(BEAM_NORMAL_VEL); } setRot( atan2(v.y,v.x)); // print("v:%f %f dv:%f %f d:%d",v.x,v.y, dv.x, dv.y, c->dir ); } loc += v * dt; // Stronger is bigger float s = PPC; if( ene >= 64 ) s *= 3; else if( ene >= 16 ) s *= 2; else if( ene >= 4 ) s *= 1.5; setScl(s); // Shoot on blocks Vec2 rt,lt,rb,lb; Cell *rtc = g_fld->get( rt = loc + Vec2(hitsz,hitsz)); Cell *ltc = g_fld->get( lt = loc + Vec2(-hitsz,hitsz)); Cell *rbc = g_fld->get( rb = loc + Vec2(hitsz,-hitsz)); Cell *lbc = g_fld->get( lb = loc + Vec2(-hitsz,-hitsz)); Cell *tgtc = NULL; Vec2 tgtat; Vec2 candat[4]; Cell *cands[4]; int candi=0; // if(rtc&&rtc->isBeamHit() && rtc->isImmutableAgainstBeam()==false ) { cands[candi] = rtc; candat[candi] = rt; candi++; } if(rbc&&rbc->isBeamHit() && rbc->isImmutableAgainstBeam()==false ) { cands[candi] = rbc; candat[candi] = rb; candi++; } if(ltc&<c->isBeamHit() && ltc->isImmutableAgainstBeam()==false ) { cands[candi] = ltc; candat[candi] = lt; candi++; } if(lbc&&lbc->isBeamHit() && lbc->isImmutableAgainstBeam()==false ) { cands[candi] = lbc; candat[candi] = lb; candi++; } if( candi > 0 ) { int ind = irange(0,candi); tgtc = cands[ind]; tgtat = candat[ind]; } // Out of the world if(!rtc)return false; if( rtc && rtc->gt == GT_JUNGLE && range(0,100) < 1 ) { createLeafEffect(loc); } updateIndex(); if( isRemote() ) return true; if(tgtc) { int consumed; BLOCKTYPE orig_bt = tgtc->bt; if( g_fld->damage(tgtat,ene,&consumed,this) ) { createSparkEffect(); if( orig_bt == BT_CELL || orig_bt == BT_FLYGEN ) { soundPlayAt(g_wormdamage_sound,loc,1); } else if( orig_bt != BT_SNOW && orig_bt != BT_IVY && orig_bt != BT_TREE && orig_bt != BT_BOMBFLOWER ) { soundPlayAt(g_beamhithard_sound,loc,1); } if( orig_bt == BT_BARRIER && tgtc->hyper_count > 0 ) { Vec2 tgt; if( g_fld->findEnemyAttackTarget(loc,&tgt, MACHINE_SHOOT_DISTANCE ) ) { int n = irange(1,4); for(int i=0;i<n;i++) Bullet::shootAt( BLT_SPARIO, loc, tgt ); } } ene -= consumed; if( ene <= 0 ) return false; else return true; } } else { // Immutable cells Cell *cells[4]; g_fld->getCorner4( loc, 1, &cells[0], &cells[1], &cells[2], &cells[3] ); for(int i=0;i<4;i++) { if(cells[i] && cells[i]->isImmutableAgainstBeam()) { soundPlayAt(g_beamhithard_sound,loc,1); createSparkEffect(); return false; } } } if( type == BEAMTYPE_BLASTER ) { float s = PPC; g_fld->meltSnow(loc + Vec2(-s,-s) ); g_fld->meltSnow(loc + Vec2(-s,s) ); g_fld->meltSnow(loc + Vec2(s,-s) ); g_fld->meltSnow(loc + Vec2(s,s) ); } else { if( range(0,100) < (float)(ene)/2.0 ) { g_fld->meltSnow(loc); } } // Shoot on enemies Char *cur = (Char*) g_char_layer->prop_top; while(cur) { if( cur->isEnemyCategory() ) { Enemy *e = (Enemy*) cur; if( e->hitWithFlyHeight(this,PPC/2) && e->beam_hits ) { int dmg = ene; if( dmg > e->hp ) dmg = e->hp; e->notifyHitBeam(this, dmg); createSparkEffect(); // ene -= dmg; if(ene<=0) to_clean = true; g_fld->meltSnow(loc); } } else if( cur->category == CAT_PC ) { // recharging other player characters PC *pc = (PC*) cur; if( pc->hit(this,PPC/2)) { // print("pcid:%d shooter:%d ene:%d/%d", pc->id, shooter_id, pc->ene, pc->maxene ); if( pc->id != shooter_id && shooter_id == g_pc->id ) { // print("PC:E:%d id:%d max:%d", pc->ene, pc->id, pc->maxene ); int charged = pc->charge(ene); if(charged>0) { pc->energy_chain_heat_count ++; // print("sending E-chain e:%d(%d>%d) to: %d-%d heat:%d", // ene, charged, pc->ene, pc->client_id, pc->internal_id ,pc->energy_chain_heat_count ); realtimeEnergyChainSend(pc,charged); return false; } } } } cur = (Char*) cur->next; } return true; }
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend ) : mLegend( legend ) { connect( legend, SIGNAL( itemMoved( QModelIndex, QModelIndex ) ), this, SLOT( updateIndex( QModelIndex, QModelIndex ) ) ); }
bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) { char filename[128]; Search search(data, size); ExtractMap ids; if (!getExtractionData(g, search, ids)) return false; const int *needList = getNeedList(g); if (!needList) { fprintf(stderr, "ERROR: No entry need list available\n"); return false; } ExtractInformation extractInfo; extractInfo.game = g->game; extractInfo.platform = g->platform; extractInfo.special = g->special; for (ExtractMap::const_iterator i = ids.begin(); i != ids.end(); ++i) { const int id = i->first; extractInfo.lang = i->second.desc.lang; const ExtractFilename *fDesc = getFilenameDesc(id); if (!fDesc) { fprintf(stderr, "ERROR: couldn't find file description for id %d/%s\n", id, getIdString(id)); return false; } filename[0] = 0; if (!getFilename(filename, &extractInfo, id)) { fprintf(stderr, "ERROR: couldn't get filename for id %d/%s\n", id, getIdString(id)); return false; } const ExtractType *tDesc = findExtractType(fDesc->type); if (!tDesc) { fprintf(stderr, "ERROR: couldn't find type description for id %d/%s (%d)\n", id, getIdString(id), fDesc->type); return false; } PAKFile::cFileList *list = out.getFileList(); if (list && list->findEntry(filename) != 0) continue; if (!tDesc->extract(out, &extractInfo, data + i->second.offset, i->second.desc.hint.size, filename, id)) { fprintf(stderr, "ERROR: couldn't extract id %d/%s\n", id, getIdString(id)); return false; } } for (int i = 0; i < 3; ++i) { if (g->lang[i] == -1) continue; extractInfo.lang = g->lang[i]; if (!createIDMap(out, &extractInfo, needList)) return false; if (!updateIndex(out, &extractInfo)) { error("couldn't update INDEX file, stop processing of all files"); return false; } } return true; }
bool GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ) { Q_UNUSED( model ); Q_UNUSED( option ); if ( event->type() != QEvent::MouseButtonRelease && event->type() != QEvent::MouseMove && event->type() != QEvent::MouseButtonPress && event->type() != QEvent::Leave ) return false; const QMouseEvent* ev = static_cast< QMouseEvent* >( event ); bool hoveringArtist = false; bool hoveringAlbum = false; bool hoveringBuyButton = false; if ( m_artistNameRects.contains( index ) ) { const QRect artistNameRect = m_artistNameRects[ index ]; hoveringArtist = artistNameRect.contains( ev->pos() ); } if ( m_albumNameRects.contains( index ) ) { const QRect albumNameRect = m_albumNameRects[ index ]; hoveringAlbum = albumNameRect.contains( ev->pos() ); } if ( m_buyButtonRects.contains( index ) ) { const QRect buyButtonRect = m_buyButtonRects[ index ]; hoveringBuyButton = buyButtonRect.contains( ev->pos() ); } QRect coverRect = m_view->visualRect( index ); coverRect.setHeight( coverRect.width() ); const bool hoveringCover = coverRect.contains( ev->pos() ); if ( event->type() == QEvent::MouseMove ) { if ( hoveringArtist || hoveringAlbum || hoveringBuyButton ) m_view->setCursor( Qt::PointingHandCursor ); else m_view->setCursor( Qt::ArrowCursor ); foreach ( const QModelIndex& idx, m_hoverControls.keys() ) { if ( index != idx ) m_hoverControls.take( idx )->deleteLater(); } if ( hoveringCover && !m_hoverControls.contains( index ) && !m_spinner.contains( index ) ) { foreach ( HoverControls* control, m_hoverControls ) control->deleteLater(); m_hoverControls.clear(); QRect cRect = option.rect; cRect.setHeight( cRect.width() ); HoverControls* controls = new HoverControls( m_view ); controls->setFixedSize( m_margin * 2, m_margin + m_margin / 4 ); controls->move( cRect.center() - QPoint( controls->width() / 2 -1, controls->height() / 2 -1 ) ); controls->setContentsMargins( 0, 0, 0, 0 ); controls->setFocusPolicy( Qt::NoFocus ); controls->installEventFilter( this ); controls->show(); NewClosure( controls, SIGNAL( play() ), const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); m_hoverControls[ index ] = controls; } if ( m_hoveringOverArtist != index || ( !hoveringArtist && m_hoveringOverArtist.isValid() ) ) { emit updateIndex( m_hoveringOverArtist ); if ( hoveringArtist ) m_hoveringOverArtist = index; else m_hoveringOverArtist = QPersistentModelIndex(); emit updateIndex( index ); } if ( m_hoveringOverAlbum != index || ( !hoveringAlbum && m_hoveringOverAlbum.isValid() ) ) { emit updateIndex( m_hoveringOverAlbum ); if ( hoveringAlbum ) m_hoveringOverAlbum = index; else m_hoveringOverAlbum = QPersistentModelIndex(); emit updateIndex( index ); } if ( m_hoveringOverBuyButton != index || ( !hoveringBuyButton && m_hoveringOverBuyButton.isValid() ) ) { emit updateIndex( m_hoveringOverBuyButton ); if ( hoveringBuyButton ) m_hoveringOverBuyButton = index; else m_hoveringOverBuyButton = QPersistentModelIndex(); emit updateIndex( index ); } if ( m_hoverIndex != index || !hoveringCover ) { if ( m_hoverIndex.isValid() ) { int startFrame = 100; if ( m_hoverFaders.contains( m_hoverIndex ) ) { QTimeLine* oldFader = m_hoverFaders.take( m_hoverIndex ); startFrame = oldFader->currentFrame(); oldFader->deleteLater(); } QTimeLine* fadeOut = createTimeline( QTimeLine::Backward, startFrame ); _detail::Closure* c = NewClosure( fadeOut, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) ); c->setAutoDelete( false ); c = NewClosure( fadeOut, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( m_hoverIndex ) ); c->setAutoDelete( false ); m_hoverFaders[ m_hoverIndex ] = fadeOut; fadeOut->start(); } emit updateIndex( m_hoverIndex ); foreach ( HoverControls* controls, m_hoverControls ) controls->deleteLater(); m_hoverControls.clear(); m_hoverIndex = QPersistentModelIndex(); } if ( hoveringCover && m_hoverIndex != index ) { m_hoverIndex = index; int startFrame = 0; if ( m_hoverFaders.contains( index ) ) { QTimeLine* oldFader = m_hoverFaders.take( index ); startFrame = oldFader->currentFrame(); oldFader->deleteLater(); } QTimeLine* fadeIn = createTimeline( QTimeLine::Forward, startFrame ); _detail::Closure* c = NewClosure( fadeIn, SIGNAL( frameChanged( int ) ), this, SLOT( fadingFrameChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); c->setAutoDelete( false ); c = NewClosure( fadeIn, SIGNAL( finished() ), this, SLOT( fadingFrameFinished( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); c->setAutoDelete( false ); m_hoverFaders[ index ] = fadeIn; fadeIn->start(); emit updateIndex( index ); }