当前位置: 首页>>代码示例>>C++>>正文


C++ QPtrList::insert方法代码示例

本文整理汇总了C++中QPtrList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ QPtrList::insert方法的具体用法?C++ QPtrList::insert怎么用?C++ QPtrList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPtrList的用法示例。


在下文中一共展示了QPtrList::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: registerSocketNotifier

/*****************************************************************************
 QEventLoop implementations for UNIX
 *****************************************************************************/
void QEventLoop::registerSocketNotifier( QSocketNotifier *notifier )
{
    int sockfd = notifier->socket();
    int type = notifier->type();
    if ( sockfd < 0 || sockfd >= FD_SETSIZE || type < 0 || type > 2 || notifier == 0 ) {
#if defined(QT_CHECK_RANGE)
	qWarning( "QSocketNotifier: Internal error" );
#endif
	return;
    }

    QPtrList<QSockNot>  *list = d->sn_vec[type].list;
    fd_set *fds  = &d->sn_vec[type].enabled_fds;
    QSockNot *sn;

    if ( ! list ) {
	// create new list, the QSockNotType destructor will delete it for us
	list = new QPtrList<QSockNot>;
	Q_CHECK_PTR( list );
	list->setAutoDelete( TRUE );
	d->sn_vec[type].list = list;
    }

    sn = new QSockNot;
    Q_CHECK_PTR( sn );
    sn->obj = notifier;
    sn->fd = sockfd;
    sn->queue = &d->sn_vec[type].pending_fds;

    if ( list->isEmpty() ) {
	list->insert( 0, sn );
    } else {				// sort list by fd, decreasing
	QSockNot *p = list->first();
	while ( p && p->fd > sockfd )
	    p = list->next();
#if defined(QT_CHECK_STATE)
	if ( p && p->fd == sockfd ) {
	    static const char *t[] = { "read", "write", "exception" };
	    qWarning( "QSocketNotifier: Multiple socket notifiers for "
		      "same socket %d and type %s", sockfd, t[type] );
	}
#endif
	if ( p )
	    list->insert( list->at(), sn );
	else
	    list->append( sn );
    }

    FD_SET( sockfd, fds );
    d->sn_highest = QMAX( d->sn_highest, sockfd );
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:54,代码来源:qeventloop_unix.cpp

示例2: ungetch

/*!
    Prepends the character \a ch to the read buffer so that the next
    read returns this character as the first character of the output.

	\sa getch()
*/
int cAsyncNetIOPrivate::ungetch( int ch )
{
    if ( rba.isEmpty() || rindex==0 ) {
		// we need a new QByteArray
		QByteArray *ba = new QByteArray( 1 );
		rba.insert( 0, ba );
		rsize++;
		ba->at( 0 ) = ch;
    } else {
		// we can reuse a place in the buffer
		QByteArray *ba = rba.first();
		rindex--;
		rsize++;
		ba->at( rindex ) = ch;
    }
    return ch;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:23,代码来源:asyncnetio.cpp

示例3: loadPlugins

void MainWindow::loadPlugins()
{
  QPtrList<Plugin> plugins;
  QPtrList<KParts::Part> loadDelayed;

  uint i;
  KPluginInfo::List::ConstIterator it;
  for ( it = mPluginInfos.begin(); it != mPluginInfos.end(); ++it ) {
    if ( !(*it)->isPluginEnabled() )
      continue;
    if ( isPluginLoaded( *it ) ) {
      Plugin *plugin = pluginFromInfo( *it );
      if ( plugin )
        plugin->configUpdated();
      continue;
    }

    kdDebug(5600) << "Loading Plugin: " << (*it)->name() << endl;
    Kontact::Plugin *plugin =
      KParts::ComponentFactory::createInstanceFromService<Kontact::Plugin>(
          (*it)->service(), this );

    if ( !plugin )
      continue;

    plugin->setIdentifier( (*it)->pluginName() );
    plugin->setTitle( (*it)->name() );
    plugin->setIcon( (*it)->icon() );

    QVariant libNameProp = (*it)->property( "X-KDE-KontactPartLibraryName" );
    QVariant exeNameProp = (*it)->property( "X-KDE-KontactPartExecutableName" );
    QVariant loadOnStart = (*it)->property( "X-KDE-KontactPartLoadOnStart" );
    QVariant hasPartProp = (*it)->property( "X-KDE-KontactPluginHasPart" );

    if ( !loadOnStart.isNull() && loadOnStart.toBool() )
      mDelayedPreload.append( plugin );

    kdDebug(5600) << "LIBNAMEPART: " << libNameProp.toString() << endl;

    plugin->setPartLibraryName( libNameProp.toString().utf8() );
    plugin->setExecutableName( exeNameProp.toString() );
    if ( hasPartProp.isValid() )
      plugin->setShowInSideBar( hasPartProp.toBool() );

    for ( i = 0; i < plugins.count(); ++i ) {
      Plugin *p = plugins.at( i );
      if ( plugin->weight() < p->weight() )
        break;
    }

    plugins.insert( i, plugin );
  }

  for ( i = 0; i < plugins.count(); ++ i ) {
    Plugin *plugin = plugins.at( i );

    KAction *action;
    QPtrList<KAction> *actionList = plugin->newActions();

    for ( action = actionList->first(); action; action = actionList->next() ) {
      kdDebug(5600) << "Plugging " << action->name() << endl;
      action->plug( mNewActions->popupMenu() );
    }

    if ( mSyncActionsEnabled ) {
      actionList = plugin->syncActions();
      for ( action = actionList->first(); action; action = actionList->next() ) {
        kdDebug(5600) << "Plugging " << action->name() << endl;
        action->plug( mSyncActions->popupMenu() );
      }
    }
    addPlugin( plugin );
  }

  mNewActions->setEnabled( mPlugins.size() != 0 );
  if ( mSyncActionsEnabled )
    mSyncActions->setEnabled( mPlugins.size() != 0 );
}
开发者ID:,项目名称:,代码行数:78,代码来源:

示例4: registerSocketNotifier

/*****************************************************************************
 QEventLoopEx implementations for Windows (for synchronous socket calls)
 *****************************************************************************/
void QEventLoopEx::registerSocketNotifier( QSocketNotifier *notifier )
{
    int sockfd = notifier->socket();
    int type = notifier->type();
    u_long	n;
    DWORD dw;
#ifdef _DEBUG_EVENTLOOPEX
    qDebug( "QSocketNotifier::registerSocketNotifier %p", notifier );
#endif
    if(ioctlsocket(sockfd,FIONREAD,&n) == SOCKET_ERROR)
    {
#ifdef _DEBUG_EVENTLOOPEX
        qDebug( "QSocketNotifier::registerSocketNotifier %p not a socket", notifier );
#endif
        dw = WSAGetLastError();
        QEventLoop::registerSocketNotifier(notifier);
        return;
    }

    if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 )
    {
#if defined(QT_CHECK_RANGE)
        qWarning( "QSocketNotifier: Internal error" );
#endif
        return;
    }

    EnterCriticalSection(&d->m_csVec);

    QPtrList<QSockNotEx>  *list = d->sn_vec[type].list;
    fd_set *fds  = &d->sn_vec[type].enabled_fds;
    QSockNotEx *sn;

    if ( ! list ) {
        // create new list, the QSockNotType destructor will delete it for us
        list = new QPtrList<QSockNotEx>;
        Q_CHECK_PTR( list );
        list->setAutoDelete( TRUE );
        d->sn_vec[type].list = list;
    }

    sn = new QSockNotEx;
    Q_CHECK_PTR( sn );
    sn->obj = notifier;
    sn->fd = sockfd;
    sn->queue = &d->sn_vec[type].pending_fds;

    if ( list->isEmpty() ) {
        list->insert( 0, sn );
    } else { // sort list by fd, decreasing
        QSockNotEx *p = list->first();
        while ( p && p->fd > sockfd )
            p = list->next();
        if ( p )
            list->insert( list->at(), sn );
        else
            list->append( sn );
    }

    FD_SET( sockfd, fds );

    d->sn_highest = QMAX( d->sn_highest, sockfd );
    LeaveCriticalSection(&d->m_csVec);

#ifdef _DEBUG_EVENTLOOPEX
    qDebug( "QSocketNotifier::signal update socket");
#endif
    closesocket(d->m_sockUpdate);
}
开发者ID:,项目名称:,代码行数:72,代码来源:

示例5: tableEIT


//.........这里部分代码省略.........
						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;
}
开发者ID:iegor,项目名称:kdesktop,代码行数:101,代码来源:dvbevents.cpp


注:本文中的QPtrList::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。