本文整理汇总了C++中QPtrList::first方法的典型用法代码示例。如果您正苦于以下问题:C++ QPtrList::first方法的具体用法?C++ QPtrList::first怎么用?C++ QPtrList::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPtrList
的用法示例。
在下文中一共展示了QPtrList::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char **argv)
{
QApplication app(argc,argv);
QPtrList<int> list;
for (int i=0;i<3;i++)
{
list.append(new int(i)); // 插入資料
}
list.first(); // 先跳到第一個元素
for (int i=0;i<3;i++,list.next())
{
cout << *(list.current()) << endl;
}
list.first();
list.next();
list.remove();
list.remove();
list.remove();
cout << *(list.current()) << endl;
// 由這一個例子可以知道,刪掉一個成員後,指標會跑到下一個.但若刪掉後沒有下一個時,指標會跑到前一個
return 0;
}
示例2: if
static PyObject *wpParty_getAttr(wpParty *self, char *name)
{
cParty *party = self->party;
if (!strcmp(name, "leader"))
{
return party->leader()->getPyObject();
}
else if (!strcmp(name, "members"))
{
QPtrList<cPlayer> members = party->members();
PyObject *list = PyList_New(0);
for (P_PLAYER member = members.first(); member; member = members.next())
PyList_Append(list, member->getPyObject());
return list;
}
else if (!strcmp(name, "canidates"))
{
QPtrList<cPlayer> canidates = party->canidates();
PyObject *list = PyList_New(0);
for (P_PLAYER canidate = canidates.first(); canidate; canidate = canidates.next())
PyList_Append(list, canidate->getPyObject());
return list;
}
else if (!strcmp(name, "lootingallowed"))
{
QPtrList<cPlayer> lootlist = party->lootingAllowed();
PyObject *list = PyList_New(0);
for (P_PLAYER member = lootlist.first(); member; member = lootlist.next())
PyList_Append(list, member->getPyObject());
return list;
}
return Py_FindMethod(wpPartyMethods, (PyObject*)self, name);
}
示例3: dlg
Resource *ResourceSelectDialog::getResource(AddressBook *ab, QWidget *parent)
{
QPtrList< Resource > resources = ab->resources();
if(resources.count() == 1)
return resources.first();
Resource *found = 0;
Resource *r = resources.first();
while(r)
{
if(!r->readOnly())
{
if(found)
{
found = 0;
break;
}
else
{
found = r;
}
}
r = resources.next();
}
if(found)
return found;
ResourceSelectDialog dlg(ab, parent);
if(dlg.exec() == KDialog::Accepted)
return dlg.resource();
else
return 0;
}
示例4: O
void
QueueManager::addItems( QListViewItem *after )
{
/*
HACK!!!!! We can know which items where dragged since they should still be selected
I do this, because:
- Dragging items from the playlist provides urls
- Providing urls, requires iterating through the entire list in order to find which
item was selected. Possibly a very expensive task - worst case: O(n)
- After a drag, those items are still selected in the playlist, so we can find out
which PlaylistItems were dragged by selectedItems();
*/
if( !after )
after = m_listview->lastChild();
QPtrList<QListViewItem> list = Playlist::instance()->selectedItems();
for( QListViewItem *item = list.first(); item; item = list.next() )
{
#define item static_cast<PlaylistItem*>(item)
QValueList<PlaylistItem*> current = m_map.values();
if( current.find( item ) == current.end() ) //avoid duplication
{
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
after = new QueueItem( m_listview, after, title );
m_map[ after ] = item;
}
#undef item
}
}
示例5: setSocketNotifierPending
void QEventLoop::setSocketNotifierPending( QSocketNotifier *notifier )
{
int sockfd = notifier->socket();
int type = notifier->type();
if ( sockfd < 0 || 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;
QSockNot *sn;
if ( ! list )
return;
sn = list->first();
while ( sn && !(sn->obj == notifier && sn->fd == sockfd) )
sn = list->next();
if ( ! sn ) { // not found
return;
}
// We choose a random activation order to be more fair under high load.
// If a constant order is used and a peer early in the list can
// saturate the IO, it might grab our attention completely.
// Also, if we're using a straight list, the callback routines may
// delete other entries from the list before those other entries are
// processed.
if ( ! FD_ISSET( sn->fd, sn->queue ) ) {
d->sn_pending_list.insert( (rand() & 0xff) %
(d->sn_pending_list.count()+1), sn );
FD_SET( sn->fd, sn->queue );
}
}
示例6: loadFrames
void TLFrameSequenceLayout::loadFrames( QPtrList<Layer> layers )
{
number_of_frame_sequences = 0;
max_used_frames = 0;
delete current_frame_sequence;
list_of_frame_sequences.clear();
Layer *l_it;
for ( l_it = layers.first(); l_it; l_it = layers.next() )
{
QPtrList<KeyFrame> keyframes = l_it -> keyFrames();
number_of_frame_sequences++;
TLFrameSequence *new_frame_sequence = new TLFrameSequence( number_of_frame_sequences, viewport(), this );
if ( l_it == layers.getFirst() )
current_frame_sequence = new_frame_sequence;
addChild( new_frame_sequence, 0, ( number_of_frame_sequences - 1 ) * new_frame_sequence -> height() );
connect( new_frame_sequence, SIGNAL( frameInserted() ), SLOT( slotUpdateMaxUsedFrames() ) );
connect( new_frame_sequence, SIGNAL( frameRemoved() ), SLOT( slotUpdateMaxUsedFrames() ) );
connect( new_frame_sequence, SIGNAL( keyframeRemoved( int ) ), SIGNAL( keyframeRemovedToES( int ) ) );
connect( new_frame_sequence, SIGNAL( motionTweenCreated( int ) ), SIGNAL( motionTweenCreatedToES( int ) ) );
connect( new_frame_sequence, SIGNAL( motionTweenRemoved( int ) ), SIGNAL( motionTweenRemovedToES( int ) ) );
list_of_frame_sequences.append( new_frame_sequence );
last_frame_sequence = new_frame_sequence;
updateContentSize();
new_frame_sequence -> loadFrames( keyframes );
}
}
示例7: EnumFormatEtc
STDMETHODIMP QOleDataObject::EnumFormatEtc( DWORD dwDir, IEnumFORMATETC **ppenumFormatEtc )
{
if ( dwDir == DATADIR_SET )
return E_NOTIMPL;
int count = 0;
while ( m_dragObj->format( count ) )
count++;
int *formats = new int[ count ];
for ( int i = 0; i < count; i++ ) {
const char *mime = m_dragObj->format( i );
QPtrList<QWindowsMime> all = QWindowsMime::all();
for ( QWindowsMime * c = all.first(); c ; c = all.next() ) {
int cf = c->cfFor( mime );
if ( cf ) {
formats[ i ] = cf;
break;
}
}
}
qIEnumFORMATETC *pEnum = new qIEnumFORMATETC( formats, count );
pEnum->AddRef();
*ppenumFormatEtc = pEnum;
delete[] formats;
return ResultFromScode( S_OK );
}
示例8: GetDataHere
STDMETHODIMP QOleDataObject::GetDataHere( FORMATETC *pformatetc, STGMEDIUM *pmedium )
{
// is data is in our format?
HRESULT hr = QueryGetData( pformatetc );
if ( hr != S_OK )
return hr;
if ( pmedium->tymed != TYMED_HGLOBAL )
return DV_E_TYMED;
if ( !pmedium->hGlobal )
return STG_E_MEDIUMFULL;
HGLOBAL hGlobal = pmedium->hGlobal;
uint size = GlobalSize( hGlobal );
int cf = pformatetc->cfFormat;
QPtrList<QWindowsMime> all = QWindowsMime::all();
for ( QWindowsMime * c = all.first(); c ; c = all.next() ) {
const char * mime = c->mimeFor( cf );
if ( mime && m_dragObj->provides( mime ) ) {
QByteArray ba = m_dragObj->encodedData( mime );
if ( ba.size() > size )
return STG_E_MEDIUMFULL;
memcpy ( GlobalLock ( hGlobal ), ba.data(), ba.size() );
GlobalUnlock ( hGlobal );
return S_OK;
}
}
return E_UNEXPECTED;
}
示例9: provides
bool QDropEvent::provides( const char * mimeType ) const
{
#ifdef DEBUG_QDND_WIN
qDebug( "QDropEvent::provides ( %s )", mimeType );
#endif
if ( !pIDataObject )
return false;
FORMATETC fmtMemory = { 0,
NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL };
/* Search all available mimes for mimeType and look if pIDataObject
can give us data in this clipboard format */
QPtrList<QWindowsMime> all = QWindowsMime::all();
for ( QWindowsMime * c = all.first(); c ; c = all.next() ) {
int cf = c->cfFor( mimeType );
if ( c->canConvert( mimeType, cf ) ) {
fmtMemory.cfFormat = cf;
if ( pIDataObject->QueryGetData( &fmtMemory ) == S_OK ) {
return true;
}
}
}
return false;
}
示例10: isTagTextValid
bool Engine::isTagTextValid(TagNode* parent, QString& text, bool ignoreExifTag) const
{
// a maintag must not be named 'EXIF' (if ignoreExifTag is false)
if (!ignoreExifTag && parent == 0 && text.upper() == "EXIF") {
return false;
}
QPtrList<TagNode>* siblings = m_tagForest;
if (parent) {
siblings = parent->children();
}
if (siblings) {
TagNode* sibling;
for ( sibling = siblings->first(); sibling; sibling = siblings->next() ) {
if (*sibling->text() == text) {
// sibling with the same name already exists!
return false;
}
}
}
// no sibling with the same name found
return true;
}
示例11: initUI
void AccountSelector::initUI()
{
kdDebug(14010) << k_funcinfo << endl;
(new QVBoxLayout(this))->setAutoAdd(true);
d->lv = new KListView(this);
d->lv->setFullWidth(true);
d->lv->addColumn(QString::fromLatin1(""));
d->lv->header()->hide();
if(d->proto != 0)
{
kdDebug(14010) << k_funcinfo << "creating list for a certain protocol" << endl;
QDict<Kopete::Account> accounts = Kopete::AccountManager::self()->accounts(d->proto);
QDictIterator<Kopete::Account> it(accounts);
for(; Kopete::Account *account = it.current(); ++it)
{
new AccountListViewItem(d->lv, account);
}
}
else
{
kdDebug(14010) << k_funcinfo << "creating list of all accounts" << endl;
QPtrList<Kopete::Account> accounts = Kopete::AccountManager::self()->accounts();
Kopete::Account *account = 0;
for(account = accounts.first(); account; account = accounts.next())
{
new AccountListViewItem(d->lv, account);
}
}
connect(d->lv, SIGNAL(selectionChanged(QListViewItem *)),
this, SLOT(slotSelectionChanged(QListViewItem *)));
}
示例12: slotRefreshWindowMenu
void App::slotRefreshWindowMenu()
{
QWidget* widget;
int id = 0;
QPtrList <QWidget> wl = workspace()->windowList();
m_windowMenu->clear();
m_windowMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/view_sidetree.png")),
"Cascade", this, SLOT(slotWindowCascade()),
0, ID_WINDOW_CASCADE);
m_windowMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/view_left_right.png")),
"Tile", this, SLOT(slotWindowTile()),
0, ID_WINDOW_TILE);
m_windowMenu->insertSeparator();
for (widget = wl.first(); widget != NULL; widget = wl.next())
{
m_windowMenu->insertItem(widget->caption(), id);
if (widget->isVisible() == true)
{
m_windowMenu->setItemChecked(id, true);
}
id++;
}
connect(m_windowMenu, SIGNAL(activated(int)),
this, SLOT(slotWindowMenuCallback(int)));
}
示例13: load
/**
* Load settings from file
*/
void Settings::load()
{
// Search for a file from user's home directory
QString path = QString(getenv("HOME")) +
QString("/") + QString(KQLCUserDir);
QString fileName = path + QString("/") + QString(KConfigFile);
QPtrList <QString> list;
if (FileHandler::readFileToList(fileName, list) == true)
{
for (QString* s = list.first(); s != NULL; s = list.next())
{
if (*s == QString("Entry"))
{
if (*(list.next()) == QString("General"))
{
createContents(list);
}
}
}
}
while (!list.isEmpty())
{
delete list.take(0);
}
}
示例14: setProperty
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
{
DOMString ppPropertyString = preprocess(propertyString.string(),true);
QPtrList<CSSProperty> *props = parseProperties(ppPropertyString.unicode(),
ppPropertyString.unicode()+ppPropertyString.length());
if(!props || !props->count())
return;
props->setAutoDelete(false);
if(!m_lstValues) {
m_lstValues = new QPtrList<CSSProperty>;
m_lstValues->setAutoDelete( true );
}
CSSProperty *prop = props->first();
while( prop ) {
removeProperty(prop->m_id, false);
m_lstValues->append(prop);
prop = props->next();
}
delete props;
setChanged();
}
示例15: consumeWriteBuf
/*!
\internal
Removes from internal read buffer \a nbytes.
Returns true if successfull or false if there were not enought bytes in buffer to fullfill
the request.
*/
bool cAsyncNetIOPrivate::consumeWriteBuf( Q_ULONG nbytes )
{
if ( nbytes > wsize )
{
wsize = 0;
return false;
}
if ( nbytes <= 0 || nbytes > wsize )
return false;
wsize -= nbytes;
for ( ; ; )
{
QByteArray* a = ewba.first();
if ( windex + nbytes >= a->size() )
{
nbytes -= a->size() - windex;
ewba.remove();
windex = 0;
if ( nbytes == 0 )
break;
}
else
{
windex += nbytes;
break;
}
}
return false;
}