Exemple #1
0
PlotLine * THERM::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format1: MA_TYPE, MA_PERIOD, THRESHOLD, SMOOTHING_TYPE, SMOOTHING_PERIOD

  if (checkFormat(p, d, 5, 5))
    return 0;

  QStringList mal;
  getMATypes(mal);
  maType = mal.findIndex(formatStringList[0]);
  maPeriod = formatStringList[1].toInt();
  threshold = formatStringList[2].toDouble();
  smoothType = mal.findIndex(formatStringList[3]);
  smoothing = formatStringList[4].toInt();

  QPtrList<PlotLine> pll;
  pll.setAutoDelete(FALSE);
  getTHERM(pll);

  int loop;
  for (loop = pll.count() - 1; loop > 0; loop--)
    pll.remove(loop);

  return pll.at(0);
}
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;
}
Exemple #3
0
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;
}
Exemple #4
0
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;
}
Exemple #5
0
void KMMimePartTree::slotEdit()
{
  QPtrList<QListViewItem> selected = selectedItems();
  if ( selected.count() != 1 )
    return;
  mReaderWin->slotEditAttachment( static_cast<KMMimePartTreeItem*>( selected.first() )->node() );
}
Exemple #6
0
STDMETHODIMP QOleDataObject::QueryGetData( FORMATETC *pformatetc )
{
#ifdef DEBUG_QDND_SRC
    qDebug( "QOleDataObject::QueryGetData( %p )", pformatetc );
#endif

    if ( !pformatetc ) {
        return E_INVALIDARG;
    }
    if ( pformatetc->lindex != -1 ) {
        return DV_E_LINDEX;
    }
    if ( pformatetc->dwAspect != DVASPECT_CONTENT ) {
        return DV_E_DVASPECT;
    }
    int tymed = pformatetc->tymed;
    /* Currently we only support HGLOBAL */
    if ( !( tymed & TYMED_HGLOBAL ) ) {
        return DV_E_TYMED;
    }

    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 ) ) {
            return S_OK;
        }
    }
    return DV_E_FORMATETC;
}
/***********************************************************************************
 KMixToolbox contains several GUI relevant methods that are shared between the 
 KMix Main Program, and the KMix Applet.
 kmixctrl - as not non-GUI application - does NOT link to KMixToolBox.

 This means: Shared GUI stuff goes into the KMixToolBox class , non-GUI stuff goes
 into the MixerToolBox class.
 ***********************************************************************************/
void KMixToolBox::setIcons(QPtrList<QWidget> &mdws, bool on ) {
    for ( QWidget *qmdw=mdws.first(); qmdw!=0; qmdw=mdws.next() ) {
	if ( qmdw->inherits("MixDeviceWidget") ) { // -<- play safe here
	    static_cast<MixDeviceWidget*>(qmdw)->setIcons( on );
	}
    }
}
Exemple #8
0
void QtCalculator::temp_stack_next(){

  CALCAMNT *number;

  if( temp_stack.current() == temp_stack.getLast()){
        KNotifyClient::beep();
        return;
  }

  number = temp_stack.next();

  if(number == NULL){
       KNotifyClient::beep();
    return;
  }
  else{
    //    printf("Number: %Lg\n",*number);
    last_input = RECALL;
    DISPLAY_AMOUNT = *number;
    UpdateDisplay();

  }


}
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 );
    }
}
Exemple #10
0
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 );
    }
}
void KSSLD::cacheSaveToDisk() {
  KSSLCNode *node;

  for (node = certList.first(); node; node = certList.next()) {
    if (node->permanent || node->expires > QDateTime::currentDateTime()) {
      // First convert to a binary format and then write the kconfig entry
      // write the (CN, policy, cert) to KSimpleConfig
      cfg->setGroup(node->cert->getSubject());
      cfg->writeEntry("Certificate", node->cert->toString());
      cfg->writeEntry("Policy", node->policy);
      cfg->writeEntry("Expires", node->expires);
      cfg->writeEntry("Permanent", node->permanent);
      cfg->writeEntry("Hosts", node->hosts);
      // Also write the chain
      QStringList qsl;
      QPtrList<KSSLCertificate> cl = node->cert->chain().getChain();
      for (KSSLCertificate *c = cl.first(); c != 0; c = cl.next()) {
         //kdDebug() << "Certificate in chain: " <<  c->toString() << endl;
         qsl << c->toString();
      }
      cl.setAutoDelete(true);
      cfg->writeEntry("Chain", qsl);
    }
  }  

  cfg->sync();

  // insure proper permissions -- contains sensitive data
  QString cfgName(KGlobal::dirs()->findResource("config", "ksslpolicies"));
  if (!cfgName.isEmpty())
    ::chmod(QFile::encodeName(cfgName), 0600);
}
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;
}
Exemple #13
0
void QTodoList::sort()
{
	QTodoSortDialog sort_dialog;

	deselectAll();

	if(sort_dialog.exec() == QDialog::Accepted)
	{
		preserveContentsYPos();
		const QTodoSortCriteriaMap* criterias = sort_dialog.getCriterias();

		QPtrList<QWidget> list_widgets;
		list_widgets.append(0);
		QTodoListIterator it(this);
		for(;it.current();++it)
			list_widgets.append(it.current());

		QTodoListItemsSorter sorter(&list_widgets,criterias);
		QPtrList<QWidget>* sorted = sorter.get();

		QTUM::get()->startRecording();
		takeAll();
		for(unsigned int i = 0; i < sorted->count(); ++i)
		{
			if(QTodoItem* item = dynamic_cast<QTodoItem*>(sorted->at(i)))
			{
				insertTodo(item,i);
				item->setDepth(item->getDepth());
			}
		}
		QTUM::get()->stopRecording();
		restoreContentsYPos();
	}
}
Exemple #14
0
//
// A window title was selected from window menu, show that window
//
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
	{
	  assert(false);
	}
      
      disconnect(m_windowMenu);
    }
}
Exemple #15
0
STDMETHODIMP QOleDataObject::GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium )
{
    // is data is in our format?
    HRESULT hr = QueryGetData( pformatetcIn );
    if ( hr != S_OK )
        return hr;

    int cf = pformatetcIn->cfFormat;
    pmedium->tymed = TYMED_HGLOBAL;

    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 );

            ba = c->convertFromMime( ba, mime, cf );
            HGLOBAL hGlobal = GlobalAlloc ( GMEM_MOVEABLE | GMEM_SHARE, ba.size() );
            if ( !hGlobal )
                return E_OUTOFMEMORY;

            memcpy ( GlobalLock ( hGlobal ), ba.data(), ba.size() );
            GlobalUnlock ( hGlobal );
            pmedium->hGlobal = hGlobal;
            pmedium->pUnkForRelease = NULL;
            return S_OK;
        }
    }
    return E_UNEXPECTED;
}
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 );
    }
}
Exemple #17
0
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;
}
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();
}
Exemple #19
0
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 );
}
Exemple #20
0
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
    }

}
Exemple #21
0
void
Core::selectEditor(Komposer::Editor *editor)
{
    if(!editor)
        return;

    KParts::Part *part = editor->part();

    editor->select();

    QPtrList<KParts::Part> *partList = const_cast<QPtrList<KParts::Part>*>(
                                           m_partManager->parts());
    if(partList->find(part) == -1)
        addPart(part);

    m_partManager->setActivePart(part);
    QWidget *view = part->widget();
    Q_ASSERT(view);

    kdDebug() << "Raising view " << view << endl;
    if(view)
    {
        m_stack->raiseWidget(view);
        view->show();
        view->setFocus();
        m_currentEditor = editor;
    }
}
Exemple #22
0
void KPrintAction::slotAboutToShow()
{
	popupMenu()->clear();
	d->printers.clear();
	QPtrList<KMPrinter>	*prts = KMManager::self()->printerList();
	if (prts && !prts->isEmpty())
	{
		QPtrListIterator<KMPrinter>	it(*prts);
		bool	first(false);
		int	ID(0);
		for (; it.current(); ++it)
		{
			if (d->type == All || (d->type == Specials && it.current()->isSpecial()) || (d->type == Regular && !it.current()->isSpecial()))
			{
				if (d->type == All && !first && it.current()->isSpecial())
				{
					if (popupMenu()->count() > 0)
						popupMenu()->insertSeparator();
					first = true;
				}
				popupMenu()->insertItem(SmallIconSet(it.current()->pixmap()), it.current()->name(), ID++);
				d->printers.append(it.current()->name());
			}
		}
	}
}
Exemple #23
0
void DOMTreeView::slotMovedItems(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &/*afterFirst*/, QPtrList<QListViewItem> &afterNow)
{
  MultiCommand *cmd = new MultiCommand(i18n("Move Nodes"));
  _refreshed = false;

  QPtrList<QListViewItem>::Iterator it = items.begin();
  QPtrList<QListViewItem>::Iterator anit = afterNow.begin();
  for (; it != items.end(); ++it, ++anit) {
    DOMListViewItem *item = static_cast<DOMListViewItem *>(*it);
    DOMListViewItem *anitem = static_cast<DOMListViewItem *>(*anit);
    DOM::Node parent = static_cast<DOMListViewItem *>(item->parent())->node();
    Q_ASSERT(!parent.isNull());

// kdDebug(90180) << " afternow " << anitem << " node " << (anitem ? anitem->node().nodeName().string() : QString()) << "=" << (anitem ? anitem->node().nodeValue().string() : QString()) << endl;

    cmd->addCommand(new MoveNodeCommand(item->node(), parent,
      anitem ? anitem->node().nextSibling() : parent.firstChild())
    );
  }

  mainWindow()->executeAndAddCommand(cmd);

  // refresh *anyways*, otherwise consistency is disturbed
  if (!_refreshed) refresh();

  slotShowNode(current_node);
}
Exemple #24
0
// -----------------------------------------------------------
void QucsApp::slotCursorRight()
{
  if(!editText->isHidden()) return;  // for edit of component property ?

  QPtrList<Element> movingElements;
  Schematic *Doc = (Schematic*)DocumentTab->currentPage();
  int markerCount = Doc->copySelectedElements(&movingElements);

  if((movingElements.count() - markerCount) < 1) {
    if(markerCount > 0) {  // only move marker if nothing else selected
      Doc->markerLeftRight(false, &movingElements);
      movingElements.clear();
    }
    else {
      if(Doc->scrollRight(-Doc->horizontalScrollBar()->lineStep()))
        Doc->scrollBy(Doc->horizontalScrollBar()->lineStep(), 0);
    }

    Doc->viewport()->update();
    view->drawn = false;
    return;
  }

  view->moveElements(&movingElements, Doc->GridX, 0);  // move "GridX" to right
  view->MAx3 = 1;  // sign for moved elements
  view->endElementMoving(Doc, &movingElements);
}
Exemple #25
0
void Chaser::createContents(QPtrList <QString> &list)
{
  unsigned long functionId = 0;
  
  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Function"))
	{
	  functionId = list.next()->toULong();
	  
	  Function* function = _app->doc()->searchFunction(functionId);
	  if (function != NULL)
	    {
	      addStep(function);
	    }
	  else
	    {
	      qDebug("Unable to find member for chaser <" + name() + ">");
	    }

	  functionId = 0;
	}
      else
	{
	  // Unknown keyword
	  list.next();
	}
    }
}
/*!
	\internal
	Reads and removes from internal read buffer \a nbytes and place then into \a sink.
	Returns true if successfull or false if there were not enought bytes to fullfill
	the request.
*/
bool cAsyncNetIOPrivate::consumeReadBuf( Q_ULONG nbytes, char *sink )
{
    if ( nbytes <= 0 || nbytes > rsize )
		return false;
    rsize -= nbytes;
    for ( ;; ) 
	{
		QByteArray *a = rba.first();
		if ( rindex + nbytes >= a->size() ) 
		{
			// Here we skip the whole byte array and get the next later
			int len = a->size() - rindex;
			if ( sink ) 
			{
				memcpy( sink, a->data()+rindex, len );
				sink += len;
			}
			nbytes -= len;
			rba.remove();
			rindex = 0;
			if ( nbytes == 0 ) 
			{		// nothing more to skip
				break;
			}
		} else {
			// Here we skip only a part of the first byte array
			if ( sink )
				memcpy( sink, a->data()+rindex, nbytes );
			rindex += nbytes;
			break;
		}
    }
    return true;
}
/*!
	\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;
}
Exemple #28
0
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;
}
void RemoveTargetDialog::init()
{
	QPtrList <SubprojectItem> subprojectItems = m_widget->allSubprojectItems();

	TargetItem* titem = 0;

	for ( SubprojectItem* spitem = subprojectItems.first(); spitem; spitem = subprojectItems.next() )
	{
		if ( m_titem->name.isEmpty() )
			break;

		for ( titem = spitem->targets.first(); titem; titem = spitem->targets.next() )
		{
			if ( m_titem->name == titem->name )
				continue;

			if ( titem->primary == "LTLIBRARIES" || titem->primary == "PROGRAMS"
				|| titem->primary == "LIBRARIES"  || titem->primary == "JAVA" )
			{
				QString canonname = AutoProjectTool::canonicalize ( titem->name );

				if ( spitem->variables[canonname + "_LIBADD"].contains ( m_titem->name ) > 0 ||
					spitem->variables[canonname + "_LDADD"].contains ( m_titem->name ) > 0 )
				{
					dependencyListBox->insertItem ( SmallIcon ( "target_kdevelop" ), spitem->path + " (" + titem->name + ")" );

					dependentSubprojects.append ( spitem );
				}
			}
		}
	}

	if ( dependencyListBox->count() == 0 )
		dependencyListBox->insertItem ( i18n("no dependency", "<none>") );
}
Exemple #30
0
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;
}