Source Code (Use browser search to find items of interest.)

Class Index

khexedit'CColorListBox (./kdeutils/khexedit/optiondialog.h:43)

class CColorListBox : public KListBox
{
  Q_OBJECT

  public:
    CColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 );
    void setColor( uint index, const QColor &color );
    const QColor color( uint index );

  public slots:
    virtual void setEnabled( bool state );

  protected:
    void dragEnterEvent( QDragEnterEvent *e );
    void dragLeaveEvent( QDragLeaveEvent *e );
    void dragMoveEvent( QDragMoveEvent *e );
    void dropEvent( QDropEvent *e );

  private slots:
    void newColor( int index );

  private:
    int mCurrentOnDragEnter;

};



khexedit'CColorListBox::CColorListBox() (./kdeutils/khexedit/optiondialog.cc:937)

CColorListBox::CColorListBox( QWidget *parent, const char *name, WFlags f )
  :KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
{
  connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
  setAcceptDrops( true);
}



khexedit'CColorListBox::setEnabled() (./kdeutils/khexedit/optiondialog.cc:945)

void CColorListBox::setEnabled( bool state )
{
  if( state == isEnabled() )
  {
    return;
  }

  QListBox::setEnabled( state );
  for( uint i=0; i<count(); i++ )
  {
    updateItem( i );
  }
}



khexedit'CColorListBox::setColor() (./kdeutils/khexedit/optiondialog.cc:960)

void CColorListBox::setColor( uint index, const QColor &color )
{
  if( index < count() )
  { 
    CColorListItem *colorItem = (CColorListItem*)item(index);
    colorItem->setColor(color);
    updateItem( colorItem );
  }
} 



khexedit'CColorListBox::color() (./kdeutils/khexedit/optiondialog.cc:971)

const QColor CColorListBox::color( uint index )
{
  if( index < count() )
  {
    CColorListItem *colorItem = (CColorListItem*)item(index);
    return( colorItem->color() );
  }
  else
  {
    return( black );
  }
}



khexedit'CColorListBox::newColor() (./kdeutils/khexedit/optiondialog.cc:985)

void CColorListBox::newColor( int index ) 
{
  if( isEnabled() == false )
  {
    return;
  }

  if( (uint)index < count() )
  {
    QColor c = color( index );
    if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
    {
      setColor( index, c );
    }
  }
}



khexedit'CColorListBox::dragEnterEvent() (./kdeutils/khexedit/optiondialog.cc:1003)

void CColorListBox::dragEnterEvent( QDragEnterEvent *e )
{
  if( KColorDrag::canDecode(e) && isEnabled() )
  {
    mCurrentOnDragEnter = currentItem();
    e->accept( true );
  }
  else
  {
    mCurrentOnDragEnter = -1;
    e->accept( false );
  }
}



khexedit'CColorListBox::dragLeaveEvent() (./kdeutils/khexedit/optiondialog.cc:1018)

void CColorListBox::dragLeaveEvent( QDragLeaveEvent * ) 
{
  if( mCurrentOnDragEnter != -1 )
  {
    setCurrentItem( mCurrentOnDragEnter );
    mCurrentOnDragEnter = -1;
  }
}



khexedit'CColorListBox::dragMoveEvent() (./kdeutils/khexedit/optiondialog.cc:1028)

void CColorListBox::dragMoveEvent( QDragMoveEvent *e )
{
  if( KColorDrag::canDecode(e) && isEnabled() ) 
  {
    CColorListItem *item = (CColorListItem*)itemAt( e->pos() );
    if( item != 0 )
    {
      setCurrentItem ( item );
    }
  }
}



khexedit'CColorListBox::dropEvent() (./kdeutils/khexedit/optiondialog.cc:1041)

void CColorListBox::dropEvent( QDropEvent *e )
{
  QColor color;
  if( KColorDrag::decode( e, color ) ) 
  {
    int index = currentItem();
    if( index != -1 )
    {
      CColorListItem *colorItem = (CColorListItem*)item(index);
      colorItem->setColor(color);
      triggerUpdate( false ); // Redraw item
    }
    mCurrentOnDragEnter = -1;
  }
}