void VCXYPadProperties::slotOKClicked() { QPtrList<XYChannelUnit>* list; // Update the X list list = m_parent->channelsX(); list->setAutoDelete(true); list->clear(); list->setAutoDelete(false); QListViewItemIterator xit(m_listX); while (xit.current()) { list->append(createChannelUnit(*xit)); ++xit; } // Update the Y list list = m_parent->channelsY(); list->setAutoDelete(true); list->clear(); list->setAutoDelete(false); QListViewItemIterator yit(m_listY); while (yit.current()) { list->append(createChannelUnit(*yit)); ++yit; } accept(); }
QPtrList<KAction> *AIMContact::customContextMenuActions() { QPtrList<KAction> *actionCollection = new QPtrList<KAction>(); if ( !m_warnUserAction ) { m_warnUserAction = new KAction( i18n( "&Warn User" ), 0, this, SLOT( warnUser() ), this, "warnAction" ); } m_actionVisibleTo = new KToggleAction(i18n("Always &Visible To"), "", 0, this, SLOT(slotVisibleTo()), this, "actionVisibleTo"); m_actionInvisibleTo = new KToggleAction(i18n("Always &Invisible To"), "", 0, this, SLOT(slotInvisibleTo()), this, "actionInvisibleTo"); bool on = account()->isConnected(); m_warnUserAction->setEnabled( on ); m_actionVisibleTo->setEnabled(on); m_actionInvisibleTo->setEnabled(on); SSIManager* ssi = account()->engine()->ssiManager(); m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE )); m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE )); actionCollection->append( m_warnUserAction ); actionCollection->append(m_actionVisibleTo); actionCollection->append(m_actionInvisibleTo); return actionCollection; }
void CustomPalette::slotAddColor( const QColor &new_color, int alpha ) { if ( cur_row == numRows() - 1 && cur_col == numCols() - 1 ) { //do nothing } else if ( cur_col == numCols() - 1 ) { color_matrix[cur_row][cur_col] = new_color; alpha_matrix[cur_row][cur_col] = alpha; int old_sel_row = sel_row; int old_sel_col = sel_col; sel_row = cur_row; sel_col = cur_col; if ( old_sel_row != -1 && old_sel_col != -1 ) updateCell( old_sel_row, old_sel_col ); updateCell( cur_row, cur_col ); cur_col = 0; cur_row++; QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); Color *n_color = new Color( ( float )new_color.red() / 255.0, ( float )new_color.green() / 255.0, ( float )new_color.blue() / 255.0, ( float )alpha / 100.0 ); try { cl.append( n_color ); k_toon -> document() -> getPalette() -> setColors( cl ); } catch(...) { delete n_color; throw; } } else { color_matrix[cur_row][cur_col] = new_color; alpha_matrix[cur_row][cur_col] = alpha; int old_sel_row = sel_row; int old_sel_col = sel_col; sel_row = cur_row; sel_col = cur_col; if ( old_sel_row != -1 && old_sel_col != -1 ) updateCell( old_sel_row, old_sel_col ); updateCell( cur_row, cur_col ); cur_col++; QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); Color *n_color = new Color( ( float )new_color.red() / 255.0, ( float )new_color.green() / 255.0, ( float )new_color.blue() / 255.0, ( float )alpha / 100.0 ); try { cl.append( n_color ); k_toon -> document() -> getPalette() -> setColors( cl ); } catch(...) { delete n_color; throw; } } }
QPtrList<KAction> KDataToolAction::dataToolActionList( const QValueList<KDataToolInfo> & tools, const QObject *receiver, const char* slot ) { QPtrList<KAction> actionList; if ( tools.isEmpty() ) return actionList; actionList.append( new KActionSeparator() ); QValueList<KDataToolInfo>::ConstIterator entry = tools.begin(); for( ; entry != tools.end(); ++entry ) { QStringList userCommands = (*entry).userCommands(); QStringList commands = (*entry).commands(); Q_ASSERT(!commands.isEmpty()); if ( commands.count() != userCommands.count() ) kdWarning() << "KDataTool desktop file error (" << (*entry).service()->entryPath() << "). " << commands.count() << " commands and " << userCommands.count() << " descriptions." << endl; QStringList::ConstIterator uit = userCommands.begin(); QStringList::ConstIterator cit = commands.begin(); for (; uit != userCommands.end() && cit != commands.end(); ++uit, ++cit ) { //kdDebug() << "creating action " << *uit << " " << *cit << endl; KDataToolAction * action = new KDataToolAction( *uit, *entry, *cit ); connect( action, SIGNAL( toolActivated( const KDataToolInfo &, const QString & ) ), receiver, slot ); actionList.append( action ); } } return actionList; }
void Win32MakefileGenerator::processPrlFiles() { QDict<void> processed; QPtrList<MakefileDependDir> libdirs; libdirs.setAutoDelete(TRUE); { QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { QString r = (*libpathit), l = r; fixEnvVariables(l); libdirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } } for(bool ret = FALSE; TRUE; ret = FALSE) { //read in any prl files included.. QStringList l_out; QString where = "QMAKE_LIBS"; if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) where = project->first("QMAKE_INTERNAL_PRL_LIBS"); QStringList &l = project->variables()[where]; for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { QString opt = (*it); if(opt.startsWith("/")) { if(opt.startsWith("/LIBPATH:")) { QString r = opt.mid(9), l = r; fixEnvVariables(l); libdirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } } else { if(!processed[opt]) { if(processPrlFile(opt)) { processed.insert(opt, (void*)1); ret = TRUE; } else { for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { QString prl = mdd->local_dir + Option::dir_sep + opt; if(processed[prl]) { break; } else if(processPrlFile(prl)) { processed.insert(prl, (void*)1); ret = TRUE; break; } } } } } if(!opt.isEmpty()) l_out.append(opt); } if(ret) l = l_out; else break; } }
void BlockGraph::addBlockNeighbour(PinNode *source, PinNode *target, QPtrList<PinNode> &seen) { if (INSTANCEOF(target->parent()->model(), MuxModel)) { // iterate through output pins QPtrList<PinNode> neighbours = target->neighbours(); for (QPtrListIterator<PinNode> it(neighbours); it != 0; ++it) { Q_ASSERT(target->parent() == (*it)->parent()); if (!seen.contains(*it)) { seen.append(*it); QPtrList<PinNode> neighbours2 = (*it)->neighbours(); for (QPtrListIterator<PinNode> it2(neighbours2); it2 != 0; ++it2) { addBlockNeighbour(source, *it2, seen); } } } } else { // qDebug(QString("added connection %1 -> %2") // .arg(source->parent()->model()->name()) // .arg(target->parent()->model()->name())); source->parent()->addNeighbour(target->parent()); } }
void FolderListView::startDrag() { QListViewItem *item = currentItem(); if (!item) return; if (item == firstChild() && item->listView()->rootIsDecorated()) return;//it's the project folder so we don't want the user to move it QPoint orig = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); QPixmap pix; if (item->rtti() == FolderListItem::ListItemType) pix = QPixmap( folder_closed_xpm ); else pix = *item->pixmap (0); QIconDrag *drag = new QIconDrag(viewport()); drag->setPixmap(pix, QPoint(pix.width()/2, pix.height()/2 ) ); QPtrList<QListViewItem> lst; for (item = firstChild(); item; item = item->itemBelow()) { if (item->isSelected()) lst.append(item); } emit dragItems(lst); drag->drag(); }
QPtrList< modulo > * libkernelinfo::modulo::obtenerLista() { //Obtenemos nombres de todos los modulos disponibles en /proc/modules QPtrList<modulo>* listado = new QPtrList<modulo>(); modulo *actual = NULL; QStringList lines; QFile file("/proc/modules" ); if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); QString line; QRegExp separator("\\s+"); int i = 1; while ( !stream.atEnd() ) { line = stream.readLine(); // line of text excluding '\n' actual = new modulo(); //Obtenemos campo nombres actual->setNombre(line.section(separator,0,0)); actual->setTam(line.section(separator,1,1).toInt()); actual->setDependencia(line.section(separator,3,3)); listado->append(actual); //lines += line; } file.close(); } return listado; // }
QUimInputContext::QUimInputContext( const char *imname, const char *lang ) : QInputContext(), m_imname( imname ), m_lang( lang ), m_uc( 0 ), candwinIsActive( false ) { #ifdef ENABLE_DEBUG qDebug( "QUimInputContext()" ); #endif contextList.append( this ); // must be initialized before createUimContext() call if ( !m_HelperManager ) m_HelperManager = new QUimHelperManager(); if ( imname ) m_uc = createUimContext( imname ); psegs.setAutoDelete( true ); psegs.clear(); cwin = new CandidateWindow( 0 ); cwin->setQUimInputContext( this ); cwin->hide(); #ifdef Q_WS_X11 if ( !mTreeTop ) create_compose_tree(); mCompose = new Compose( mTreeTop, this ); #endif mTextUtil = new QUimTextUtil( this ); // read configuration readIMConf(); }
void QDockArea::setFixedExtent( int d, QDockWindow *dw ) { QPtrList<QDockWindow> lst; QDockWindow *w; for ( w = dockWindows->first(); w; w = dockWindows->next() ) { if ( w->isHidden() ) continue; if ( orientation() == Horizontal ) { if ( dw->y() != w->y() ) continue; } else { if ( dw->x() != w->x() ) continue; } if ( orientation() == Horizontal ) d = QMAX( d, w->minimumHeight() ); else d = QMAX( d, w->minimumWidth() ); if ( w->isResizeEnabled() ) lst.append( w ); } for ( w = lst.first(); w; w = lst.next() ) { if ( orientation() == Horizontal ) w->setFixedExtentHeight( d ); else w->setFixedExtentWidth( d ); } }
/*! \internal Writes \a len bytes to the socket from \a data and returns the number of bytes written. Returns -1 if an error occurred. */ Q_LONG cAsyncNetIOPrivate::writeBlock( const char* data, Q_ULONG len ) { // Invalid Socket -> Disconnected if ( !socket->isValid() ) { socket->close(); return 0; } if ( len == 0 ) return 0; QByteArray* a = wba.last(); if ( a && a->size() + len < 128 ) { // small buffer, resize int i = a->size(); a->resize( i + len ); memcpy( a->data() + i, data, len ); } else { // append new buffer a = new QByteArray( len ); memcpy( a->data(), data, len ); wba.append( a ); } wsize += len; return len; }
void Core::setupShourtcutTips(KXMLGUIClient * client) { QPtrList<KXMLGUIClient> clients; if (client != 0) clients.append(client); else clients = TopLevel::getInstance()->main()->guiFactory()->clients(); for( QPtrListIterator<KXMLGUIClient> it(clients); it.current(); ++it ) { KActionCollection *actionCollection = (*it)->actionCollection(); for (int i = 0; i < actionCollection->count(); i++) { KAction *action = actionCollection->action(i); QString tooltip = action->toolTip(); if (tooltip.isEmpty()) tooltip = action->text().remove('&'); else { int i = tooltip.findRev('('); if (i > 0) tooltip = tooltip.left(i).stripWhiteSpace(); } QString shortcut = action->shortcutText(); if (!shortcut.isEmpty()) tooltip += " (" + shortcut + ")"; action->setToolTip(tooltip); } } }
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; }
static void selectedItems( QPtrList<Kleo::KeyListViewItem> & result, QListViewItem * start ) { for ( QListViewItem * item = start ; item ; item = item->nextSibling() ) { if ( item->isSelected() ) if ( Kleo::KeyListViewItem * i = Kleo::lvi_cast<Kleo::KeyListViewItem>( item ) ) result.append( i ); selectedItems( result, item->firstChild() ); } }
const QPtrList<Connection> Driver::connectionsList() const { QPtrList<Connection> clist; QPtrDictIterator<Connection> it( d->connections ); for( ; it.current(); ++it ) clist.append( &(*it) ); return clist; }
void RenderFlow::paintOutlines(QPainter *p, int _tx, int _ty) { if (style()->outlineStyle() <= BHIDDEN) return; QPtrList <QRect> rects; rects.setAutoDelete(true); rects.append(new QRect(0,0,0,0)); for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { rects.append(new QRect(curr->xPos(), curr->yPos(), curr->width(), curr->height())); } rects.append(new QRect(0,0,0,0)); for (unsigned int i = 1; i < rects.count() - 1; i++) paintOutlineForLine(p, _tx, _ty, *rects.at(i-1), *rects.at(i), *rects.at(i+1)); }
void KMJobViewer::jobSelection(QPtrList<KMJob>& l) { l.setAutoDelete(false); QPtrListIterator<JobItem> it(m_items); for (; it.current(); ++it) if (it.current()->isSelected()) l.append(it.current()->job()); }
void MythUIType::AddFocusableChildrenToList(QPtrList<MythUIType> &focusList) { if (m_CanHaveFocus) focusList.append(this); QValueVector<MythUIType *>::Iterator it; for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) (*it)->AddFocusableChildrenToList(focusList); }
int loadLog(QString fname) { FILE *f; int warning=0; f = fopen(QFile::encodeName(fname), "r"); if(f == NULL) return 1; char buffer[2048+1]; int lineno = 0; while(fgets(buffer, sizeof(buffer), f) != NULL) { ++lineno; buffer[sizeof(buffer) - 1] = 0; int slen = strlen(buffer); // skip blank lines if(slen < 10) continue; dlg->setProgress(dlg->progress() + slen); kapp->processEvents(); LogInfo *li = new LogInfo(buffer); if(li->error()) { // check if the connection has been terminated abnormally if(li->error() != 3) { warning++; kdError() << "ERROR IN FILE " << fname << " LINE " << lineno << "\"" << buffer << "\" (" << li->error() << ")" << endl; delete li; } else logList.append(li); } else logList.append(li); } fclose(f); if(warning) return 2; else return 0; }
void KWDocStructRootItem::setupTextFrameSets() { // Delete Empty item from list. QListViewItem* lvItem = firstChild(); if (lvItem && (lvItem->text(0) == i18n("Empty"))) delete lvItem; // Build a list of framesets ordered by their screen position (top left corner). KWDocument* dok = doc(); QValueList<KWOrderedFrameSet> orderedFrameSets; for ( int i = dok->frameSetCount() - 1; i >= 0; i-- ) { KWFrameSet* frameset = dok->frameSet(i); if ( frameset->type() == FT_TEXT && frameset->frameSetInfo() == KWFrameSet::FI_BODY && !frameset->groupmanager() && frameset->frameCount()>0) orderedFrameSets.append(KWOrderedFrameSet(frameset)); } qHeapSort(orderedFrameSets); // Build a list of frameset pointers from the sorted list. QPtrList<KWTextFrameSet> frameSetPtrs; frameSetPtrs.setAutoDelete(false); for ( uint i = 0; i < orderedFrameSets.count(); i++ ) frameSetPtrs.append(dynamic_cast<KWTextFrameSet *>(orderedFrameSets[i].frameSet())); // Remove deleted framesets from the listview. KWDocStructTextFrameSetItem* item = dynamic_cast<KWDocStructTextFrameSetItem *>(firstChild()); KWDocStructTextFrameSetItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameSetItem *>(item->nextSibling()); if (frameSetPtrs.containsRef(delItem->frameSet()) == 0) delete delItem; } // Add new framesets to the list or update existing ones. KWDocStructTextFrameSetItem* after = 0L; for ( uint i = 0; i < orderedFrameSets.count(); i++ ) { KWTextFrameSet* textFrameset = dynamic_cast<KWTextFrameSet *>(orderedFrameSets[i].frameSet()); item = findTextFrameSetItem(textFrameset); if (item) item->setText(0, textFrameset->name()); else { if (after) item = new KWDocStructTextFrameSetItem( this, after, textFrameset->name(), textFrameset); else item = new KWDocStructTextFrameSetItem(this, textFrameset->name(), textFrameset); } after = item; item->setupTextFrames(); } if ( childCount() == 0 ) ( void )new KListViewItem( this, i18n( "Empty" ) ); }
QPtrList<Resource> ManagerImpl::resources() { QPtrList<Resource> result; Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { result.append( *it ); } return result; }
QPtrList<DesignerDatabase> DesignerProjectImpl::databaseConnections() const { QPtrList<DesignerDatabase> lst; #ifndef QT_NO_SQL QPtrList<DatabaseConnection> conns = project->databaseConnections(); for ( DatabaseConnection *d = conns.first(); d; d = conns.next() ) lst.append( d->iFace() ); #endif return lst; }
QPtrList<PlaylistItem> QueueManager::newQueue() { QPtrList<PlaylistItem> queue; for( QListViewItem *key = m_listview->firstChild(); key; key = key->nextSibling() ) { queue.append( m_map[ key ] ); } return queue; }
void managementWidget::installSingleClicked() { int result; QPtrList<packageInfo> plist; packageInfo *package = packageDisplay->package; if (package) { QString filename = package->getFilename(); kdDebug() << "File=" << filename <<"\n"; pkgInterface *interface = package->interface; if (interface->noFetch || !filename.isEmpty()) { plist.append(package); if (!interface->installation->setup(&plist, interface->head)) { return; } result = interface->installation->exec(); if (interface->installation->result() == QDialog::Accepted || interface->installation->modified) { // it was accepted, so the package has been installed packageInfo *inf; for (inf = plist.first(); inf != 0; inf = plist.next()) { updatePackage(inf,TRUE); } if (treeList->currentItem()) { KpTreeListItem *p = treeList->currentItem(); packageDisplay->changePackage(p->info); } else { packageDisplay->changePackage(0); // change package to no package } setupInstButton(); } // kdDebug() << "Result=" << result <<"\n"; } else { QString url = package->getUrl(); if (!url.isEmpty()) { QString s = kpackage->fetchNetFile(url); if (!s.isEmpty()) { packageDisplay->changePackage(package); setupInstButton(); } } else { KpMsgE(i18n("Filename not available\n"),TRUE); } } } kpackage->setPercent(100); searchLine->updateSearch(); checkMarked(); }
QPtrList<QListViewItem> QueueList::selectedItems() { QPtrList<QListViewItem> selected; QListViewItemIterator it( this, QListViewItemIterator::Selected ); for( ; it.current(); ++it ) selected.append( it.current() ); return selected; }
void KGet_plug_in::slotShowLinks() { if ( !parent() || !parent()->inherits( "KHTMLPart" ) ) return; KHTMLPart *htmlPart = static_cast<KHTMLPart*>( parent() ); KParts::Part *activePart = 0L; if ( htmlPart->partManager() ) { activePart = htmlPart->partManager()->activePart(); if ( activePart && activePart->inherits( "KHTMLPart" ) ) htmlPart = static_cast<KHTMLPart*>( activePart ); } DOM::HTMLDocument doc = htmlPart->htmlDocument(); if ( doc.isNull() ) return; DOM::HTMLCollection links = doc.links(); QPtrList<LinkItem> linkList; std::set<QString> dupeCheck; for ( uint i = 0; i < links.length(); i++ ) { DOM::Node link = links.item( i ); if ( link.isNull() || link.nodeType() != DOM::Node::ELEMENT_NODE ) continue; LinkItem *item = new LinkItem( (DOM::Element) link ); if ( item->isValid() && dupeCheck.find( item->url.url() ) == dupeCheck.end() ) { linkList.append( item ); dupeCheck.insert( item->url.url() ); } else delete item; } if ( linkList.isEmpty() ) { KMessageBox::sorry( htmlPart->widget(), i18n("There are no links in the active frame of the current HTML page."), i18n("No Links") ); return; } KGetLinkView *view = new KGetLinkView(); QString url = doc.URL().string(); view->setPageURL( url ); view->setLinks( linkList ); view->show(); }
QPtrList<Resource> ManagerImpl::resources( bool active ) { QPtrList<Resource> result; Resource::List::ConstIterator it; for ( it = mResources.begin(); it != mResources.end(); ++it ) { if ( (*it)->isActive() == active ) { result.append( *it ); } } return result; }
QPtrList<PinModel> MuxModel::connectionsForInputPin(PinModel *input) { QPtrList<PinModel> connectedPins; for (QPtrListIterator<MuxMapping> it(mappings_); it != 0; ++it) { MuxMapping *mapping = it.current(); if (mapping->input() == input) { connectedPins.append(mapping->output()); } } return connectedPins; }
void PopupMenuEditor::insertedActions( QPtrList<QAction> & list ) { QAction * a = 0; PopupMenuEditorItem * i = itemList.first(); while ( i ) { a = i->action(); if ( a ) list.append( a ); i = itemList.next(); } }
void GUIClient::updateActions() { if ( !factory() ) return; unplugActionList( actionListName ); QPtrList<KAction> addList; addList.append(m_toolMenu); plugActionList( actionListName, addList ); }