/**
 * Search for the first item in the appearance order, which matches text.
 */
QTreeWidgetItem* AnnotationDialog::CompletableLineEdit::findItemInListView(const QString& text)
{
    for (QTreeWidgetItemIterator itemIt(m_listView); *itemIt; ++itemIt) {
        // Hide the "untagged image" tag from the auto-completion
        if ((*itemIt)->isHidden()) {
            continue;
        }

        if (itemMatchesText(*itemIt, text)) {
            return *itemIt;
        }
    }

    return nullptr;
}
    inline QTreeWidgetItem* createWidgetItem( ParentItemT _parent, SiblingT _sibling, const QString& _name, const std::string& _fullPath, int _stateLen, const std::string& _states, int _defaultState )
    {
        QTreeWidgetItem* item = NULL;
        /// check if item already been created
        if ( _sibling ) {
            for ( QTreeWidgetItemIterator itemIt( _sibling ); ( *itemIt ); ++itemIt ) {
                if ( ( *itemIt )->text( 0 ) == _name ) {
                    item = ( *itemIt );
                }
            }
        }

        /// create new one if not exists
        if ( !item ) {
            int itemIndex( static_cast< int >( items_.size() ) );

            /// if not found, the root item has not been created yet
            item = new QTreeWidgetItem( ( ParentItemT )0, QStringList( _name ) );
            item->setFlags( item->flags() | Qt::ItemIsUserCheckable );

            widget_->setAbsIndex( item, itemIndex );

            addItemToParent( _parent, item );

            indexMap_[ _fullPath + "/" + _name.toStdString() ] = itemIndex;

            bool state( itemIndex < _stateLen ? int( char( _states[ static_cast< std::size_t >( itemIndex ) ] - '0' ) ) : _defaultState );
            if ( state ) {
                item->setCheckState( 0, Qt::Checked );
            } else {
                item->setCheckState( 0, Qt::Unchecked );
            }

            items_.push_back( std::make_pair( _name.toStdString(), _fullPath + "/" + _name.toStdString() ) );
            allStatesStr_.push_back( state ? '1' : '0' );
        }

        return item;
    }
示例#3
0
void checkFieldEffects( UI32 currenttime, P_CHAR pc, char timecheck )
{

	VALIDATEPC(pc);

	if ( (timecheck && !(nextfieldeffecttime<=currenttime)) ) //changed by Luxor
		return;
#ifdef SPAR_NEW_WR_SYSTEM
	pItemVectorIt itemIt( pc->nearbyItems->begin() ), itemEnd( pc->nearbyItems->end() );

	for( ; itemIt != itemEnd; ++itemIt ) {

		P_ITEM pi= (*itemIt);
#else
	NxwItemWrapper si;
	si.fillItemsNearXYZ( pc->getPosition(), 2, false );
	for( si.rewind(); !si.isEmpty(); si++ )
	{
		P_ITEM pi=si.getItem();
#endif
		if(ISVALIDPI(pi) ) {

			if ( pi->getPosition().x == pc->getPosition().x && pi->getPosition().y == pc->getPosition().y )

				//Luxor: added new field damage handling
				switch( pi->getId() )
				{
					case 0x3996:
					case 0x398C: //Fire Field
						if (!pc->resistsFire())
							tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, (UI08)(pi->morex/100.0), DAMAGE_FIRE, 0, 0,1);
						return;
					case 0x3915:
					case 0x3920: //Poison Field
						if ((pi->morex<997)) {
							tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 2, DAMAGE_POISON, 0, 0,2);
							pc->applyPoison(POISON_WEAK);
						} else {
							tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 3, DAMAGE_POISON, 0, 0,2); // gm mages can cast greater poison field, LB
							pc->applyPoison(POISON_NORMAL);
						}
						return;
					case 0x3979:
					case 0x3967: //Para Field
						if (chance(50)) {
							tempfx::add(pc, pc, tempfx::SPELL_PARALYZE, 0, 0, 0, 0,3);
							pc->playSFX( 0x0204 );
						}
						return;
				}
		}
	}
}

void checktimers() // Check shutdown timers
{

	overflow = (lclock > uiCurrentTime);
	if (endtime)
	{
		if ( endtime <= uiCurrentTime ) keeprun=false;
	}
	lclock = uiCurrentTime;

}