/*!
	\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;
}
Esempio n. 2
0
void
QueueList::moveSelectedDown() // SLOT
{
    QPtrList<QListViewItem> list = selectedItems();

    for( QListViewItem *item  = list.last(); item; item = list.prev() )
    {
        QListViewItem *after = item->nextSibling();

        if( !after )
            continue;

        moveItem( item, 0, after );
    }

    ensureItemVisible( list.last() );
}
Esempio n. 3
0
MainWindow::~MainWindow()
{
  saveSettings();

  QPtrList<KParts::Part> parts = *mPartManager->parts();

  for ( KParts::Part *p = parts.last(); p; p = parts.prev() ) {
    delete p;
    p = 0;
  }

  Prefs::self()->writeConfig();
}
void VariablesListView::replaceVariable(DebuggerVariable* oldvar, DebuggerVariable* newvar)
{ 
  KListViewItem * item;
  
  // Remove children that doesen't exist anymore
  QPtrList<DebuggerVariable> oldlist = oldvar->values();
  for(DebuggerVariable* oldchild = oldlist.last(); oldchild; oldchild = oldlist.prev())
  {
    bool found = false;
    QPtrList<DebuggerVariable> newlist = newvar->values();
    for(DebuggerVariable* newchild = newlist.last(); newchild; newchild = newlist.prev())
    {
      if(newchild->name() == oldchild->name())
      {
        found = true;
        break;
      }
    }
    if(!found)
      oldvar->deleteChild(oldchild);
  }

  // Update and add children
  QPtrList<DebuggerVariable> newlist = newvar->values();
  for(DebuggerVariable* newchild = newlist.last(); newchild; newchild = newlist.prev())
  {
    bool found = false;
    QPtrList<DebuggerVariable> oldlist = oldvar->values();
    for(DebuggerVariable* oldchild = oldlist.last(); oldchild; oldchild = oldlist.prev())  
    {
      if(newchild->name() == oldchild->name())
      {
        found = true;
        replaceVariable( oldchild, newchild);
        break;
      }
    }
    if(!found)
    {
      DebuggerVariable* child = new DebuggerVariable();
      item = new KListViewItem(oldvar->item());
      child->setItem(item);
      replaceVariable( child, newchild);
      oldvar->append(child);
    }
  }
  
  item = oldvar->item();
  
  if(oldvar->value() != newvar->value())
    item->setPixmap(VariablesListViewColumns::Status, SmallIcon("ok"));
  else
    item->setPixmap(VariablesListViewColumns::Status, KPixmap());
  
  oldvar->copy(newvar, false);
  
  item->setText(VariablesListViewColumns::Name, oldvar->name());
  item->setText(VariablesListViewColumns::Type, oldvar->typeName());
  item->setText(VariablesListViewColumns::Size, oldvar->sizeName());
  item->setText(VariablesListViewColumns::Value, (newvar->isScalar() ? oldvar->value() : QString()));
  
}