Logo Search packages:      
Sourcecode: kbfx version File versions  Download package

kbfxspinxlistbox.h

#ifndef KBFXSPINXLISTBOX_H
#define KBFXSPINXLISTBOX_H

#include <qlistbox.h>
#include <qwidget.h>
#include <qevent.h>
#include <qapplication.h>
#include <qcursor.h>
#include "vistalistbox.h"



class KbfxSpinxListBox:public QListBox
{

Q_OBJECT public:


KbfxSpinxListBox (QWidget * parent = 0, const char *name = 0, WFlags flags = 0):QListBox (parent, name,
          flags)
  {

    scrollIndex = 5;
    blocked = 1;
    this->setVScrollBarMode (QScrollView::AlwaysOff);
    parentRef = parent;
    scrolllen = 0;
    _type = 0;
    _selected = new QPoint (0, 0);
    _clickCount = 0;
    _lastIndex = 0;
  }

  void setMouseMode (int b)
  {

    blocked = b;

  }

  void setType (int type)
  {
    _type = type;

  }
void scrollNeeded()
{
      if (this->count() > 5)
            emit showScrollBar();
      else
            emit hideScrollBar();
}

signals:
  void test (QListBoxItem *);
//  void scrollNeeded (bool);
  void raiseNow (int);
  void showScrollBar(void);
  void hideScrollBar(void);
  public slots:
  void scrollRest (int);
  void scroll (int);

protected:
//virtual void paintEvent(QPaintEvent *event);
//virtual void timerEvent(QTimerEvent *event);
//virtual void hideEvent(QHideEvent *event);
  virtual void leaveEvent (QEvent *);

  virtual void dragLeaveEvent (QDragLeaveEvent *);

  virtual void dragMoveEvent (QDragMoveEvent *);

  virtual void mouseMoveEvent (QMouseEvent * e);

  virtual void showEvent(QShowEvent * e)
      {
            scrollNeeded();
      }

  virtual void wheelEvent (QWheelEvent * e);

  virtual void mouseReleaseEvent (QMouseEvent * e)
  {

    VistaListBoxItem *_item = (VistaListBoxItem *) this->itemAt (e->pos ());
    if (_item == NULL)
      return;
    *_selected = e->pos ();

    this->clearSelection ();
    _item->block (1);
    this->setCurrentItem (_item);
    this->clearAllButOne (_item);
    emit raiseNow (this->index (_item));
    emit clicked (_item);
    return;
  }


  virtual void enterEvent (QEvent * e)
  {
      this->scrollNeeded();

    VistaListBoxItem *_item = (VistaListBoxItem *) this->itemAt (*_selected);
    if (_item == NULL)
      return;

    this->clearSelection ();
//this->clearAllButOne(_item);
  }

  void clearBlock ()
  {

    if (!_type)
      return;
    int _m_count = this->count ();

    for (; _m_count >= 0; _m_count--)
      {

      VistaListBoxItem *__item__ =
        (VistaListBoxItem *) this->item (_m_count);
      if (__item__ == NULL)
        continue;
      __item__->block (0);
      }

  }

  void clearAllButOne (VistaListBoxItem * item)
  {
    if (!_type)
      return;
    int _m_count = this->count ();

    for (; _m_count >= 0; _m_count--)
      {

      VistaListBoxItem *__item__ =
        (VistaListBoxItem *) this->item (_m_count);
      if (__item__ == NULL || __item__ == item)
        continue;
      __item__->block (0);
      this->updateItem (__item__);
      }



  }

private:
  int m_x;
  int m_y;
  int scrollIndex;
  int blocked;
  VistaListBoxItem *_lastItem;
  QWidget *parentRef;
  int scrolllen;
  int _type;
  QPoint *_selected;
  int _lastIndex;
  int _clickCount;

};


#endif

Generated by  Doxygen 1.6.0   Back to index