void App::slotWindowMenuCallback(int item) { QPtrList <QWidget> wl = workspace()->windowList(); if (item == ID_WINDOW_CASCADE || item == ID_WINDOW_TILE) { return; } if (wl.count()) { QWidget* widget; widget = wl.at(item); if (widget != NULL) { widget->show(); widget->setFocus(); } else { QMessageBox::critical(this, "Unable to select window", "Handle not found"); } disconnect(m_windowMenu); } }
QDragObject *KfindWindow::dragObject() { KURL::List uris; QPtrList< QListViewItem > selected = selectedItems(); // create a list of URIs from selection for(uint i = 0; i < selected.count(); i++) { KfFileLVI *item = (KfFileLVI *)selected.at(i); if(item) { uris.append(item->fileitem.url()); } } if(uris.count() <= 0) return 0; QUriDrag *ud = new KURLDrag(uris, (QWidget *)this, "kfind uridrag"); const QPixmap *pix = currentItem()->pixmap(0); if(pix && !pix->isNull()) ud->setPixmap(*pix); return ud; }
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 CustomPalette::slotChangeColorName( const QString &new_name ) { if ( sel_row != -1 && sel_col != -1 ) { color_names[sel_row][sel_col] = new_name; QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); Color *s_color = cl.at( map2Dto1D( sel_row, sel_col ) ); s_color -> setNameColor( new_name ); } }
void QDockArea::dockWindow( QDockWindow *dockWindow, DockWindowData *data ) { if ( !data ) return; dockWindow->reparent( this, QPoint( 0, 0 ), FALSE ); dockWindow->installEventFilter( this ); dockWindow->dockArea = this; dockWindow->updateGui(); if ( dockWindows->isEmpty() ) { dockWindows->append( dockWindow ); } else { QPtrList<QDockWindow> lineStarts = layout->lineStarts(); int index = 0; if ( (int)lineStarts.count() > data->line ) index = dockWindows->find( lineStarts.at( data->line ) ); if ( index == -1 ) { index = 0; (void)dockWindows->at( index ); } bool firstTime = TRUE; int offset = data->offset; for ( QDockWindow *dw = dockWindows->current(); dw; dw = dockWindows->next() ) { if ( !firstTime && lineStarts.find( dw ) != -1 ) break; if ( offset < point_pos( fix_pos( dw ), orientation() ) + size_extent( dw->size(), orientation() ) / 2 ) break; index++; firstTime = FALSE; } if ( index >= 0 && index < (int)dockWindows->count() && dockWindows->at( index )->newLine() && lineOf( index ) == data->line ) { dockWindows->at( index )->setNewLine( FALSE ); dockWindow->setNewLine( TRUE ); } else { dockWindow->setNewLine( FALSE ); } dockWindows->insert( index, dockWindow ); } dockWindow->show(); dockWindow->setFixedExtentWidth( data->fixedExtent.width() ); dockWindow->setFixedExtentHeight( data->fixedExtent.height() ); updateLayout(); setSizePolicy( QSizePolicy( orientation() == Horizontal ? QSizePolicy::Expanding : QSizePolicy::Minimum, orientation() == Vertical ? QSizePolicy::Expanding : QSizePolicy::Minimum ) ); }
void DvbStream::stopBroadcast() { int i; DVBout *o=0; QPtrList<DVBout> p; for ( i=0; i<(int)out.count(); i++ ) { o = out.at(i); o->stopBroadcast(); if ( !o->hasLive() && !o->hasRec() ) p.append( o ); } for ( i=0; i<(int)p.count(); i++ ) { removePids( p.at(i) ); if ( cam ) cam->stopService( &(p.at(i)->channel) ); removeOut( p.at(i) ); } if ( out.count()==0 ) stop(); emit isBroadcasting( false ); }
/***************************************************************************** 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 ); }
void DockContainer::nextToolView() { QPtrList< KMultiTabBarTab > *tabs = m_tb->tabs(); int pos = tabs->findRef(m_tb->tab(oldtab)); if(pos == -1) return; pos++; if(pos >= (int)tabs->count()) pos = 0; KMultiTabBarTab *tab = tabs->at(pos); if(!tab) return; // can never happen here, but who knows m_tb->setTab(tab->id(), true); tabClicked(tab->id()); }
Indicator * THERM::calculate () { Indicator *output = new Indicator; output->setDateFlag(dateFlag); output->setLogScale(logScale); QPtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getTHERM(pll); int loop; for (loop = 0; loop < (int) pll.count(); loop++) output->addLine(pll.at(loop)); return output; }
void KWDocStructTextFrameSetItem::setupTextFrames() { // TODO: KWTextFrameSet::frame() method returns frames in screen order? // Build a list of frame pointers. QPtrList<KWFrame> framePtrs; framePtrs.setAutoDelete(false); for (uint j = 0; j < m_frameset->frameCount(); j++) framePtrs.append(m_frameset->frame(j)); // Remove deleted frames from the listview. KWDocStructTextFrameItem* item = dynamic_cast<KWDocStructTextFrameItem *>(firstChild()); KWDocStructTextFrameItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameItem *>(item->nextSibling()); if (framePtrs.containsRef(delItem->frame()) == 0) delete delItem; } // Add new frames to the list or update existing ones. KWDocument* dok = doc(); KWDocStructTextFrameItem* after = 0; for (uint j = 0; j < framePtrs.count(); j++) { KWFrame* frame = framePtrs.at(j); QString name; if ( KListViewItem::parent()->firstChild() == this && dok->processingType() == KWDocument::WP ) { if ( dok->numColumns() == 1 ) name=i18n( "Page %1" ).arg(QString::number(j + 1)); else name=i18n( "Column %1" ).arg(QString::number(j + 1)); } else name=i18n( "Text Frame %1" ).arg(QString::number(j + 1)); KWDocStructTextFrameItem* child = findTextFrameItem(frame); if (child) child->setText(0, name); else { if (after) child = new KWDocStructTextFrameItem(this, after, name, m_frameset, frame); else child = new KWDocStructTextFrameItem(this, name, m_frameset, frame); } child->setupTextParags(); after = child; } }
void KWDocStructTableItem::setupCells() { // TODO: KWTableFrameSet::cell() method returns cells in screen order? // Build a list of cell pointers. QPtrList<KWTextFrameSet> cellPtrs; cellPtrs.setAutoDelete(false); for (uint row = 0; row < m_table->getRows(); ++row) for (uint col = 0; col < m_table->getColumns(); ++ col) { KWTextFrameSet* cell = m_table->cell(row, col); if (cell) cellPtrs.append(cell); } // Remove deleted cells from the listview. KWDocStructTextFrameItem* item = dynamic_cast<KWDocStructTextFrameItem *>(firstChild()); KWDocStructTextFrameItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameItem *>(item->nextSibling()); if (cellPtrs.containsRef(delItem->frameSet()) == 0) delete delItem; } // Add new cells to the list or update existing ones. // Note we skip over the frameset and add the frame instead, // as every cell has exactly one frame in the frameset. KWDocStructTextFrameItem* child; KWDocStructTextFrameItem* after = 0; for (uint j = 0; j < cellPtrs.count(); j++) { KWTextFrameSet* cell = cellPtrs.at(j); KWFrame* frame = cell->frame(0); if (frame) { QString name = cell->name(); child = findCellItem(cell); if (child) child->setText(0, name); else { if (after) child = new KWDocStructTextFrameItem(this, after, name, cell, frame); else child = new KWDocStructTextFrameItem(this, name, cell, frame); } child->setupTextParags(); after = child; } } }
void KSSLInfoDlg::slotChain(int x) { if(x == 0) { displayCert(d->_cert); } else { QPtrList< KSSLCertificate > cl = d->_cert->chain().getChain(); cl.setAutoDelete(true); for(int i = 0; i < x - 1; i++) cl.remove((unsigned int)0); KSSLCertificate thisCert = *(cl.at(0)); cl.remove((unsigned int)0); thisCert.chain().setChain(cl); displayCert(&thisCert); } }
void KfindWindow::deleteFiles() { QString tmp = i18n("Do you really want to delete the selected file?", "Do you really want to delete the %n selected files?", selectedItems().count()); if(KMessageBox::warningContinueCancel(parentWidget(), tmp, "", KGuiItem(i18n("&Delete"), "editdelete")) == KMessageBox::Cancel) return; // Iterate on all selected elements QPtrList< QListViewItem > selected = selectedItems(); for(uint i = 0; i < selected.count(); i++) { KfFileLVI *item = (KfFileLVI *)selected.at(i); KFileItem file = item->fileitem; KIO::NetAccess::del(file.url(), this); } selected.setAutoDelete(true); }
void BrowserBar::showHideVisibleBrowser( int index ) { int realindex = -1; QPtrList<MultiTabBarTab> tabs = *m_tabBar->tabs(); for( int i = 0, n = tabs.count(); i < n; ++i ) { if( tabs.at( i )->visible() ) index--; if( index < 0 ) { realindex = i; break; } } if( realindex >= 0 ) showHideBrowser( realindex ); }
ResourceSelectDialog::ResourceSelectDialog(AddressBook *ab, QWidget *parent, const char *name) : KDialog(parent, name, true) { setCaption(i18n("Resource Selection")); resize(300, 200); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setMargin(marginHint()); QGroupBox *groupBox = new QGroupBox(2, Qt::Horizontal, this); groupBox->setTitle(i18n("Resources")); mResourceId = new KListBox(groupBox); mainLayout->addWidget(groupBox); mainLayout->addSpacing(10); KButtonBox *buttonBox = new KButtonBox(this); buttonBox->addStretch(); buttonBox->addButton(KStdGuiItem::ok(), this, SLOT(accept())); buttonBox->addButton(KStdGuiItem::cancel(), this, SLOT(reject())); buttonBox->layout(); mainLayout->addWidget(buttonBox); // setup listbox uint counter = 0; QPtrList< Resource > list = ab->resources(); for(uint i = 0; i < list.count(); ++i) { Resource *resource = list.at(i); if(resource && !resource->readOnly()) { mResourceMap.insert(counter, resource); mResourceId->insertItem(resource->resourceName()); counter++; } } mResourceId->setCurrentItem(0); }
void KMdiDockContainer::prevToolView() { kdDebug( 760 ) << k_funcinfo << endl; QPtrList<KMultiTabBarTab>* tabs = m_tb->tabs(); int pos = tabs->findRef( m_tb->tab( oldtab ) ); if ( pos == -1 ) return ; pos--; if ( pos < 0 ) pos = tabs->count() - 1; KMultiTabBarTab *tab = tabs->at( pos ); if ( !tab ) return ; //can never happen here, but who knows m_tb->setTab( tab->id(), true ); tabClicked( tab->id() ); }
void QTodoList::sort(QTodoItem* item) { QTodoSortDialog sort_dialog; deselectAll(); selectSubTodos(item,true); if(sort_dialog.exec() == QDialog::Accepted) { preserveContentsYPos(); const QTodoSortCriteriaMap* criterias = sort_dialog.getCriterias(); QPtrList<QWidget> list_widgets; std::vector<QTodoItem*> sub_items = getSubTodos(item); list_widgets.append(0); for(std::vector<QTodoItem*>::iterator it = sub_items.begin(); it != sub_items.end(); ++it) { list_widgets.append((*it)); } QTodoListItemsSorter sorter(&list_widgets,criterias); QPtrList<QWidget>* sorted = sorter.get(); QTUM::get()->startRecording(); takeTodos(&sub_items); int pos = findWidget(item) + 1; for(unsigned int i = 0; i < sorted->count(); ++i) { if(QTodoItem* item = dynamic_cast<QTodoItem*>(sorted->at(i))) { insertTodo(item,pos+i); item->setDepth(item->getDepth()); } } QTUM::get()->stopRecording(); restoreContentsYPos(); } }
PlotLine * PP::calculateCustom (QString &p, QPtrList<PlotLine> &d) { // format1: PP_TYPE if (checkFormat(p, d, 1, 1)) return 0; int t = ppList.findIndex(formatStringList[0]); if (t == -1) { qDebug("PP::calculateCustom: invalid PP_TYPE parm"); return 0; } QPtrList<PlotLine> pll; pll.setAutoDelete(TRUE); getPP(pll); PlotLine *line = new PlotLine; PlotLine *tline = pll.at(t); line->copy(tline); return line; }
QLayoutItem *SimpleFlowIterator::current() { return idx < int(count()) ? list->at(idx) : 0; }
bool DVBevents::tableEIT( unsigned char* buffer ) { unsigned char* buf = buffer; unsigned int length, loop, sid, tid, eid, tsid, sn, lsn, nid; int i, sec; EventDesc *desc=0, *itdesc=0; EventSid *slist; QPtrList<EventDesc> *currentEvents; bool nodesc, parse; QDateTime start, cur, dt; unsigned int cdt = QDateTime::currentDateTime().toTime_t(); tid = getBits(buf,0,8); length = getBits(buf,12,12); sid = getBits(buf,24,16); sn = getBits(buf,48,8); lsn = getBits(buf,56,8); tsid = getBits(buf,64,16); nid = getBits(buf,80,16); length -=11; buf +=14; slist = currentSrc->getEventSid( nid, tsid, sid ); if ( !slist ) return false; slist->lock(); currentEvents = slist->getEvents(); QPtrListIterator<EventDesc> it( *currentEvents ); while ( length>4 ) { nodesc=parse=false; if ( !safeLen( buf+2 ) ) goto stop; eid = getBits(buf,0,16); if ( !safeLen( buf+2+5 ) ) goto stop; start = getDateTime( buf+2 ); nodesc=parse=true; it.toFirst(); while ( (desc=it.current())!=0 ) { if ( desc->sid==sid ) { if ( desc->startDateTime==start || desc->eid==eid ) { if ( desc->tid==0x4e && tid!=0x4e ) { parse = false; nodesc = false; break; } else { nodesc = false; if ( (cdt-desc->loop)<300 ) { // only reparse events every 300 seconds parse = false; } else { desc->extEvents.clear(); desc->shortEvents.clear(); desc->title=desc->subtitle=""; } 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; }
void TesterReport::createSummary (QPtrList<TradeItem> &trades, double account) { int shortTrades = 0; int longTrades = 0; int winLongTrades = 0; int loseLongTrades = 0; int winShortTrades = 0; int loseShortTrades = 0; double totalWinLongTrades = 0; double totalLoseLongTrades = 0; double totalWinShortTrades = 0; double totalLoseShortTrades = 0; double largestWin = 0; double largestLose = 0; double accountDrawdown = account; double commission = 0; double balance = account; int loop; for (loop = 0; loop < (int) trades.count(); loop++) { TradeItem *trade = trades.at(loop); // get long/short trades if (trade->getTradePosition() == TradeItem::Long) { longTrades++; if (trade->getProfit() < 0) { loseLongTrades++; totalLoseLongTrades = totalLoseLongTrades + trade->getProfit(); if (trade->getProfit() < largestLose) largestLose = trade->getProfit(); } else { winLongTrades++; totalWinLongTrades = totalWinLongTrades + trade->getProfit(); if (trade->getProfit() > largestWin) largestWin = trade->getProfit(); } } else { shortTrades++; if (trade->getProfit() < 0) { loseShortTrades++; totalLoseShortTrades = totalLoseShortTrades + trade->getProfit(); if (trade->getProfit() < largestLose) largestLose = trade->getProfit(); } else { winShortTrades++; totalWinShortTrades = totalWinShortTrades + trade->getProfit(); if (trade->getProfit() > largestWin) largestWin = trade->getProfit(); } } commission = commission + trade->getEntryCom() + trade->getExitCom(); balance = trade->getBalance(); if (trade->getBalance() < accountDrawdown) accountDrawdown = trade->getBalance(); tradeList->setNumRows(tradeList->numRows() + 1); QString ts; trade->getTradePositionString(ts); tradeList->setText(tradeList->numRows() - 1, 0, ts); trade->getEnterDateString(ts); tradeList->setText(tradeList->numRows() - 1, 1, ts); tradeList->setText(tradeList->numRows() - 1, 2, QString::number(trade->getEnterPrice())); trade->getExitDateString(ts); tradeList->setText(tradeList->numRows() - 1, 3, ts); tradeList->setText(tradeList->numRows() - 1, 4, QString::number(trade->getExitPrice())); trade->getExitSignalString(ts); tradeList->setText(tradeList->numRows() - 1, 5, ts); tradeList->setText(tradeList->numRows() - 1, 6, QString::number(trade->getProfit())); tradeList->setText(tradeList->numRows() - 1, 7, QString::number(trade->getBalance())); tradeList->setText(tradeList->numRows() - 1, 8, QString::number(trade->getVolume())); } // main summary summaryBalance->setNum(balance); summaryNetProfit->setNum(balance - account); summaryNetPercentage->setNum(((balance - account) / account) * 100); summaryInvestment->setNum(account); summaryCommission->setNum(commission); summaryDrawdown->setNum(accountDrawdown - account); summaryTrades->setNum(longTrades + shortTrades); summaryLongTrades->setNum(longTrades); summaryShortTrades->setNum(shortTrades); // win summary summaryWinTrades->setNum(winLongTrades + winShortTrades); summaryTotalWinTrades->setNum(totalWinLongTrades + totalWinShortTrades); summaryAverageWin->setNum((totalWinLongTrades + totalWinShortTrades) / (winLongTrades + winShortTrades)); summaryLargestWin->setNum(largestWin); summaryWinLongTrades->setNum(winLongTrades); summaryWinShortTrades->setNum(winShortTrades); // lose summary summaryLoseTrades->setNum(loseLongTrades + loseShortTrades); summaryTotalLoseTrades->setNum(totalLoseLongTrades + totalLoseShortTrades); summaryAverageLose->setNum((totalLoseLongTrades + totalLoseShortTrades) / (loseLongTrades + loseShortTrades)); summaryLargestLose->setNum(largestLose); summaryLoseLongTrades->setNum(loseLongTrades); summaryLoseShortTrades->setNum(loseShortTrades); }
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 ); }
/***************************************************************************** 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); }
QLayoutItem *FlowLayoutIterator::current() { return _idx < int(count()) ? _list->at(_idx) : 0; }
void CustomOrderedListEdit::slotEditButtonClicked() { OListEditForm *d = new OListEditForm( this ); initPtrList(); /* * Adding Enabled Items */ for( struct uim_custom_choice *item = m_itemList.first(); item; item = m_itemList.next() ) { d->addCheckItem( true, _FU8(item->label) ); } /* * Adding Disabled Items */ for( struct uim_custom_choice *valid_item = m_validItemList.first(); valid_item; valid_item = m_validItemList.next() ) { /* Exclude Enabled Item */ bool isActive = false; for( struct uim_custom_choice *item = m_itemList.first(); item; item = m_itemList.next() ) { if( QString::compare( valid_item->symbol, item->symbol ) == 0 ) { isActive = true; break; } } if( isActive == false ) { d->addCheckItem( false, _FU8(valid_item->label) ); } } /* Exec Dialog */ if( d->exec() == OListEditForm::Accepted ) { /* search active item's ptr, realloc it, and store in activeItemList */ QPtrList<struct uim_custom_choice> activeItemList; activeItemList.setAutoDelete( false ); QStringList activeItemLabelList = d->activeItemLabels(); for( unsigned int i = 0; i < activeItemLabelList.count(); i++ ) { struct uim_custom_choice *item = NULL; int j = 0; for( item = m_custom->range->as_olist.valid_items[0], j = 0; item; item = m_custom->range->as_olist.valid_items[++j] ) { if( QString::compare( activeItemLabelList[i], _FU8(item->label) ) == 0 ) { /* allocate new struct because we will free the old struct */ struct uim_custom_choice *activeItem = (struct uim_custom_choice *)malloc(sizeof(struct uim_custom_choice)); activeItem->symbol = item->symbol ? strdup(item->symbol) : NULL; activeItem->label = item->label ? strdup(item->label) : NULL; activeItem->desc = item->desc ? strdup(item->desc) : NULL; activeItemList.append( activeItem ); break; } } } /* free old items */ for( unsigned int i = 0; i < m_itemList.count(); i++ ) { free( m_custom->value->as_olist[i]->symbol ); free( m_custom->value->as_olist[i]->label ); free( m_custom->value->as_olist[i]->desc ); free( m_custom->value->as_olist[i] ); } /* create null-terminated new olist */ m_custom->value->as_olist = (struct uim_custom_choice **)realloc( m_custom->value->as_olist, sizeof(struct uim_custom_choice *) * (activeItemList.count() + 1) ); for( unsigned int i = 0; i < activeItemList.count(); i++ ) { m_custom->value->as_olist[i] = activeItemList.at(i); } m_custom->value->as_olist[activeItemList.count()] = NULL; /* save */ setCustom( m_custom ); /* reload */ update(); } delete d; }
void QDockArea::moveDockWindow( QDockWindow *w, const QPoint &p, const QRect &r, bool swap ) { invalidateFixedSizes(); int mse = -10; bool hasResizable = FALSE; for ( QDockWindow *dw = dockWindows->first(); dw; dw = dockWindows->next() ) { if ( dw->isHidden() ) continue; if ( dw->isResizeEnabled() ) hasResizable = TRUE; if ( orientation() != Qt::Horizontal ) mse = QMAX( QMAX( dw->fixedExtent().width(), dw->width() ), mse ); else mse = QMAX( QMAX( dw->fixedExtent().height(), dw->height() ), mse ); } if ( !hasResizable && w->isResizeEnabled() ) { if ( orientation() != Qt::Horizontal ) mse = QMAX( w->fixedExtent().width(), mse ); else mse = QMAX( w->fixedExtent().height(), mse ); } QDockWindow *dockWindow = 0; int dockWindowIndex = findDockWindow( w ); QPtrList<QDockWindow> lineStarts = layout->lineStarts(); QValueList<QRect> lines = layout->lineList(); bool wasAloneInLine = FALSE; QPoint pos = mapFromGlobal( p ); QRect lr = *lines.at( lineOf( dockWindowIndex ) ); if ( dockWindowIndex != -1 ) { if ( lineStarts.find( w ) != -1 && ( dockWindowIndex < (int)dockWindows->count() - 1 && lineStarts.find( dockWindows->at( dockWindowIndex + 1 ) ) != -1 || dockWindowIndex == (int)dockWindows->count() - 1 ) ) wasAloneInLine = TRUE; dockWindow = dockWindows->take( dockWindowIndex ); if ( !wasAloneInLine ) { // only do the pre-layout if the widget isn't the only one in its line if ( lineStarts.findRef( dockWindow ) != -1 && dockWindowIndex < (int)dockWindows->count() ) dockWindows->at( dockWindowIndex )->setNewLine( TRUE ); layout->layoutItems( QRect( 0, 0, width(), height() ), TRUE ); } } else { dockWindow = w; dockWindow->reparent( this, QPoint( 0, 0 ), TRUE ); if ( swap ) dockWindow->resize( dockWindow->height(), dockWindow->width() ); w->installEventFilter( this ); } lineStarts = layout->lineStarts(); lines = layout->lineList(); QRect rect = QRect( mapFromGlobal( r.topLeft() ), r.size() ); if ( orientation() == Horizontal && QApplication::reverseLayout() ) { rect = QRect( width() - rect.x() - rect.width(), rect.y(), rect.width(), rect.height() ); pos.rx() = width() - pos.x(); } dockWindow->setOffset( point_pos( rect.topLeft(), orientation() ) ); if ( orientation() == Horizontal ) { int offs = dockWindow->offset(); if ( width() - offs < dockWindow->minimumWidth() ) dockWindow->setOffset( width() - dockWindow->minimumWidth() ); } else { int offs = dockWindow->offset(); if ( height() - offs < dockWindow->minimumHeight() ) dockWindow->setOffset( height() - dockWindow->minimumHeight() ); } if ( dockWindows->isEmpty() ) { dockWindows->append( dockWindow ); } else { int dockLine = -1; bool insertLine = FALSE; int i = 0; QRect lineRect; // find the line which we touched with the mouse for ( QValueList<QRect>::Iterator it = lines.begin(); it != lines.end(); ++it, ++i ) { if ( point_pos( pos, orientation(), TRUE ) >= point_pos( (*it).topLeft(), orientation(), TRUE ) && point_pos( pos, orientation(), TRUE ) <= point_pos( (*it).topLeft(), orientation(), TRUE ) + size_extent( (*it).size(), orientation(), TRUE ) ) { dockLine = i; lineRect = *it; break; } } if ( dockLine == -1 ) { // outside the dock... insertLine = TRUE; if ( point_pos( pos, orientation(), TRUE ) < 0 ) // insert as first line dockLine = 0; else dockLine = (int)lines.count(); // insert after the last line ### size_t/int cast } else { // inside the dock (we have found a dockLine) if ( point_pos( pos, orientation(), TRUE ) < point_pos( lineRect.topLeft(), orientation(), TRUE ) + 4 ) { // mouse was at the very beginning of the line insertLine = TRUE; // insert a new line before that with the docking widget } else if ( point_pos( pos, orientation(), TRUE ) > point_pos( lineRect.topLeft(), orientation(), TRUE ) + size_extent( lineRect.size(), orientation(), TRUE ) - 4 ) { // mouse was at the very and of the line insertLine = TRUE; // insert a line after that with the docking widget dockLine++; } } if ( !insertLine && wasAloneInLine && lr.contains( pos ) ) // if we are alone in a line and just moved in there, re-insert it insertLine = TRUE; #if defined(QDOCKAREA_DEBUG) qDebug( "insert in line %d, and insert that line: %d", dockLine, insertLine ); qDebug( " (btw, we have %d lines)", lines.count() ); #endif QDockWindow *dw = 0; if ( dockLine >= (int)lines.count() ) { // insert after last line dockWindows->append( dockWindow ); dockWindow->setNewLine( TRUE ); #if defined(QDOCKAREA_DEBUG) qDebug( "insert at the end" ); #endif } else if ( dockLine == 0 && insertLine ) { // insert before first line dockWindows->insert( 0, dockWindow ); dockWindows->at( 1 )->setNewLine( TRUE ); #if defined(QDOCKAREA_DEBUG) qDebug( "insert at the begin" ); #endif } else { // insert somewhere in between // make sure each line start has a new line for ( dw = lineStarts.first(); dw; dw = lineStarts.next() ) dw->setNewLine( TRUE ); // find the index of the first widget in the search line int searchLine = dockLine; #if defined(QDOCKAREA_DEBUG) qDebug( "search line start of %d", searchLine ); #endif QDockWindow *lsw = lineStarts.at( searchLine ); int index = dockWindows->find( lsw ); if ( index == -1 ) { // the linestart widget hasn't been found, try to find it harder if ( lsw == w && dockWindowIndex <= (int)dockWindows->count()) index = dockWindowIndex; else index = 0; if ( index < (int)dockWindows->count() ) (void)dockWindows->at( index ); // move current to index } #if defined(QDOCKAREA_DEBUG) qDebug( " which starts at %d", index ); #endif if ( !insertLine ) { // if we insert the docking widget in the existing line // find the index for the widget bool inc = TRUE; bool firstTime = TRUE; for ( dw = dockWindows->current(); dw; dw = dockWindows->next() ) { if ( orientation() == Horizontal ) dw->setFixedExtentWidth( -1 ); else dw->setFixedExtentHeight( -1 ); if ( !firstTime && lineStarts.find( dw ) != -1 ) // we are in the next line, so break break; if ( point_pos( pos, orientation() ) < point_pos( fix_pos( dw ), orientation() ) + size_extent( dw->size(), orientation() ) / 2 ) { inc = FALSE; } if ( inc ) index++; firstTime = FALSE; } #if defined(QDOCKAREA_DEBUG) qDebug( "insert at index: %d", index ); #endif // if we insert it just before a widget which has a new line, transfer the newline to the docking widget // but not if we didn't only mave a widget in its line which was alone in the line before if ( !( wasAloneInLine && lr.contains( pos ) ) && index >= 0 && index < (int)dockWindows->count() && dockWindows->at( index )->newLine() && lineOf( index ) == dockLine ) { #if defined(QDOCKAREA_DEBUG) qDebug( "get rid of the old newline and get me one" ); #endif dockWindows->at( index )->setNewLine( FALSE ); dockWindow->setNewLine( TRUE ); } else if ( wasAloneInLine && lr.contains( pos ) ) { dockWindow->setNewLine( TRUE ); } else { // if we are somewhere in a line, get rid of the newline dockWindow->setNewLine( FALSE ); } } else { // insert in a new line, so make sure the dock widget and the widget which will be after it have a newline #if defined(QDOCKAREA_DEBUG) qDebug( "insert a new line" ); #endif if ( index < (int)dockWindows->count() ) { #if defined(QDOCKAREA_DEBUG) qDebug( "give the widget at %d a newline", index ); #endif QDockWindow* nldw = dockWindows->at( index ); if ( nldw ) nldw->setNewLine( TRUE ); } #if defined(QDOCKAREA_DEBUG) qDebug( "give me a newline" ); #endif dockWindow->setNewLine( TRUE ); } // finally insert the widget dockWindows->insert( index, dockWindow ); } } if ( mse != -10 && w->isResizeEnabled() ) { if ( orientation() != Qt::Horizontal ) w->setFixedExtentWidth( QMIN( QMAX( w->minimumWidth(), mse ), w->sizeHint().width() ) ); else w->setFixedExtentHeight( QMIN( QMAX( w->minimumHeight(), mse ), w->sizeHint().height() ) ); } updateLayout(); setSizePolicy( QSizePolicy( orientation() == Horizontal ? QSizePolicy::Expanding : QSizePolicy::Minimum, orientation() == Vertical ? QSizePolicy::Expanding : QSizePolicy::Minimum ) ); }
BorderLayout::BorderLayoutStruct *BorderLayoutIterator::currentStruct() { return idx < (int)count() ? list->at( idx ) : 0; }
QLayoutItem *BorderLayoutIterator::current() { return idx < (int)count() ? list->at( idx )->item : 0; }
int main(int argc, char *argv[]) { atexit(exitHelper); KInstance inst("d2asc"); KstDataSourcePtr file; KConfig *kConfigObject = new KConfig("kstdatarc", false, false); KstDataSource::setupOnStartup(kConfigObject); fieldEntry field; QValueList<fieldEntry> fieldList; char *filename; bool do_ave = false, do_skip = false; int start_frame=0, n_frames=2000000; int n_skip = 0; int NS=0, i_S; int i; if (argc < 3 || argv[1][0] == '-') { Usage(); return -1; } filename = argv[1]; for (i = 2; i < argc; i++) { if (argv[i][0] == '-') { if (argv[i][1] == 'f') { i++; start_frame = atoi(argv[i]); } else if (argv[i][1] == 'n') { i++; n_frames = atoi(argv[i]); } else if (argv[i][1] == 's') { i++; n_skip = atoi(argv[i]); if (n_skip>0) do_skip = true; } else if (argv[i][1] == 'a') { do_ave = true; } else if (argv[i][1] == 'x') { i++; field.field = argv[i]; field.doHex = true; fieldList.append(field); } else { Usage(); } } else { field.field = argv[i]; field.doHex = false; fieldList.append(field); } } if (!do_skip) { do_ave = false; } file = KstDataSource::loadSource(filename); if (!file || !file->isValid() || file->isEmpty()) { fprintf(stderr, "d2asc error: file %s has no data\n", filename); return -2; } /** make vectors and fill the list **/ QPtrList<KstRVector> vlist; for (i=0; i<int(fieldList.size()); i++) { if (!file->isValidField(fieldList[i].field)) { fprintf(stderr, "d2asc error: field %s in file %s is not valid\n", fieldList[i].field.latin1(), filename); return -3; } KstRVectorPtr v = new KstRVector(file, fieldList[i].field, KstObjectTag("tag", KstObjectTag::globalTagContext), start_frame, n_frames, n_skip, n_skip>0, do_ave); vlist.append(v); } /* find NS */ for (i = 0; i < int(fieldList.size()); i++) { while (vlist.at(i)->update(-1) != KstObject::NO_CHANGE) ; // read vector if (vlist.at(i)->length() > NS) { NS = vlist.at(i)->length(); } } for (i_S = 0; i_S < NS; i_S++) { for (i = 0; i < int(fieldList.size()); i++) { if (fieldList[i].doHex) { printf("%4x ", (int)vlist.at(i)->interpolate(i_S, NS)); } else { printf("%.16g ", vlist.at(i)->interpolate(i_S, NS)); } } printf("\n"); } }
CosmeticLayer::CosmeticLayer( QObject* parent, const QString& scl ) : QObject( parent ) { shapes = new QPtrList<Shape>(); _name = _path = scl; if ( !scl.endsWith( ".scl" ) ) { _name += ".scl"; _path += ".scl"; } _lineColor = QColor( 255, 0, 0 ); _fillColor = QColor( 255, 0, 0 ); // read the scl file and populate the shape list QFile file( _path ); QDomDocument doc; if ( file.open( IO_ReadOnly ) ) { if ( doc.setContent( &file ) ) { QDomElement rootElement = doc.documentElement(); QDomNode nodeShapes = rootElement.firstChild(); // <Shapes> QDomNode nodeShape = nodeShapes.firstChild(); // <Shape> QDomNode nodePoint; QDomElement elem; while ( !nodeShape.isNull() ) { QDomAttr attID = nodeShape.toElement().attributeNode( "Id" ); QDomAttr attType = nodeShape.toElement().attributeNode( "Type" ); int shapeID = attID.value().toInt(); int shapeType = attType.value().toInt(); nodePoint = nodeShape.firstChild(); // <Point> QPtrList<Point> points; while( !nodePoint.isNull() ) { QDomAttr attX = nodePoint.toElement().attributeNode( "X" ); QDomAttr attY = nodePoint.toElement().attributeNode( "Y" ); double x = attX.value().toDouble(); double y = attY.value().toDouble(); points.append( new Point( x, y ) ); nodePoint = nodePoint.nextSibling(); } Shape *shape; switch( shapeType ) { case 1: shape = new ShapePoint( shapeID, points.first()->x(), points.first()->y() ); addShape( shape ); break; case 996: shape = new ShapeCLLine( shapeID, points ); addShape( shape ); break; case 997: shape = new ShapeCLCircle( shapeID, *points.at(0), Point( points.at(1)->x(), points.at(1)->y() )); addShape( shape ); break; case 998: shape = new ShapeCLPolygon( shapeID, points ); addShape( shape ); break; default: break;// not yet implemented... }; nodeShape = nodeShape.nextSibling(); } } } }