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

CTreeView.cpp

/***************************************************************************

  CTreeView.cpp

  The TreeView class

  (c) 2000-2003 Benoît Minisini <gambas@users.sourceforge.net>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 1, or (at your option)
  any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

***************************************************************************/


#define __CTREEVIEW_CPP



#include <qapplication.h>
#include <qheader.h>
#include <qpalette.h>
#include <qscrollview.h>
#include <qlistview.h>
#if QT_VERSION >= 0x030200
#include <qobjectlist.h>
#else
#include <qobjcoll.h>
#endif

#include "gambas.h"

#include "CWidget.h"
#include "CPicture.h"
#include "CTreeView.h"

DECLARE_EVENT(EVENT_Select);    /* selection change */
DECLARE_EVENT(EVENT_Click);     /* simple click */
DECLARE_EVENT(EVENT_Activate);  /* double click */
DECLARE_EVENT(EVENT_Rename);  /* double click */
DECLARE_EVENT(EVENT_Expand);
DECLARE_EVENT(EVENT_Collapse);
DECLARE_EVENT(EVENT_ColumnClick);     /* simple click */

// Ceci est un test !
static int _column = -1;


/***************************************************************************

  class MyListViewItem

***************************************************************************/

void MyListViewItem::initData(CTREEVIEW *cont)
{
  picture = 0;
  key = 0;
  last = 0;
  prev = 0;
  container = cont;
  //sortKey = NULL;
}


MyListViewItem::MyListViewItem(CTREEVIEW *cont, MyListView *parent)
: QListViewItem(parent, parent->last)
{
  initData(cont);
  prev = parent->last;
  parent->last = this;
}

MyListViewItem::MyListViewItem(CTREEVIEW *cont, MyListView *parent, MyListViewItem *after)
: QListViewItem(parent, after)
{
  initData(cont);
  prev = after;

  if (after == parent->last)
    parent->last = this;
  else
  {
    MyListViewItem *n = ((MyListViewItem *)nextSibling());
    n->prev = this;
  }
}

MyListViewItem::MyListViewItem(CTREEVIEW *cont, MyListViewItem *parent)
: QListViewItem(parent, parent->last)
{
  initData(cont);
  prev = parent->last;
  parent->last = this;
}

MyListViewItem::MyListViewItem(CTREEVIEW *cont, MyListViewItem *parent, MyListViewItem *after)
: QListViewItem(parent, after)
{
  initData(cont);

  if (after == parent->last)
    parent->last = this;
  else
  {
    MyListViewItem *n = ((MyListViewItem *)nextSibling());
    n->prev = this;
  }
}

MyListViewItem::~MyListViewItem()
{
  MyListView *lw = (MyListView *)container->widget.widget;
  MyListViewItem *par = (MyListViewItem *)parent();

  //qDebug("< delete item %s %p", key, this);

  if (par)
  {
    if (par->last == this)
      par->last = prev;
  }
  else
  {
    if (lw->last == this)
      lw->last = prev;
  }

  par = ((MyListViewItem *)nextSibling());
  if (par)
    par->prev = prev;

  //qDebug("container = %p ->item = %p", container, container->item);

  if (container->item == this)
    container->item = par;
  if (container->save == this)
    container->save = 0;

  //if (container->last == this)
  //  container->last = NULL;

  container->dict->remove(key);

  GB.Unref((void **)&picture);
  GB.FreeString(&key);

  //qDebug("container = %p ->item = %p", container, container->item);
  //qDebug(">");
}


void MyListViewItem::setPicture(GB_OBJECT *pict)
{
  SET_PIXMAP(setPixmap, &picture, pict);
}

int MyListViewItem::compare(QListViewItem *i, int col, bool ascending) const
{
  if ((listView()->columnAlignment(col) & AlignHorizontal_Mask) == AlignRight)
  {
    if (text(col).length() > i->text(col).length())
      return 1;
    if (text(col).length() < i->text(col).length())
      return -1;
  }
  
  return QListViewItem::compare(i, col, ascending);
}


/***************************************************************************

  class MyListView

***************************************************************************/

MyListView::MyListView(QWidget *parent)
: QListView(parent)
{
  last = 0;
}


/***************************************************************************

  TreeView

***************************************************************************/

static void return_item(void *_object, MyListViewItem *item)
{
  if (!item)
    THIS->save = THIS->item;
  THIS->item = item;

  GB.ReturnBoolean(item == 0);
}


static MyListView *listview_init(void *_object, void *parent)
{
  MyListView *wid;

  wid = new MyListView(CONTAINER(parent));

  QObject::connect(wid, SIGNAL(selectionChanged()), &CTreeView::manager, SLOT(selected()));
  QObject::connect(wid, SIGNAL(doubleClicked(QListViewItem *)), &CTreeView::manager, SLOT(activated(QListViewItem *)));
  QObject::connect(wid, SIGNAL(clicked(QListViewItem *)), &CTreeView::manager, SLOT(clicked(QListViewItem *)));
  QObject::connect(wid, SIGNAL(itemRenamed(QListViewItem *, int)), &CTreeView::manager, SLOT(renamed(QListViewItem *, int)));

  CWIDGET_new(wid, (void *)_object, "ListView");

  THIS->dict = new QAsciiDict<MyListViewItem>;
  THIS->sorted = -1;
  THIS->asc = false;
  THIS->item = 0;
  THIS->save = 0;
  THIS->rename = false;

  wid->setSorting(-1);

  return wid;
}


BEGIN_METHOD(CTREEVIEW_new, GB_OBJECT parent)

  MyListView *wid = listview_init(_object, VARG(parent));

  QObject::connect(wid, SIGNAL(expanded(QListViewItem *)), &CTreeView::manager, SLOT(expanded(QListViewItem *)));
  QObject::connect(wid, SIGNAL(collapsed(QListViewItem *)), &CTreeView::manager, SLOT(collapsed(QListViewItem *)));

  wid->addColumn("-");
  wid->header()->hide();
  wid->setRootIsDecorated(true);
  wid->show();

END_METHOD


BEGIN_METHOD(CLISTVIEW_new, GB_OBJECT parent)

  MyListView *wid = listview_init(_object, VARG(parent));

  wid->addColumn("-");
  wid->setColumnWidthMode(0, QListView::Manual);
  wid->setAllColumnsShowFocus(true);
  wid->setHScrollBarMode(QScrollView::AlwaysOff);
  wid->header()->hide();
  wid->setResizeMode(QListView::LastColumn);
  wid->show();

END_METHOD


BEGIN_METHOD(CCOLUMNVIEW_new, GB_OBJECT parent)

  MyListView *wid = listview_init(_object, VARG(parent));

  QObject::connect(wid, SIGNAL(clicked(QListViewItem *, const QPoint &, int)), &CTreeView::manager, SLOT(columnClicked(QListViewItem *, const QPoint &, int)));
  QObject::connect(wid->header(), SIGNAL(clicked(int)), &CTreeView::manager, SLOT(headerClicked(int)));
  QObject::connect(wid->header(), SIGNAL(sizeChange(int, int, int)), &CTreeView::manager, SLOT(headerSizeChange(int, int, int)));
  QObject::connect(wid, SIGNAL(expanded(QListViewItem *)), &CTreeView::manager, SLOT(expanded(QListViewItem *)));
  QObject::connect(wid, SIGNAL(collapsed(QListViewItem *)), &CTreeView::manager, SLOT(collapsed(QListViewItem *)));

  wid->addColumn(" ");
  wid->setColumnAlignment(0, Qt::AlignLeft);
  //wid->setColumnWidthMode(0, QListView::Manual);
  wid->header()->setMovingEnabled(false);
  wid->setAllColumnsShowFocus(true);
  wid->show();

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_free)

  delete THIS->dict;
  //if (THIS->numeric)
  //  delete[] THIS->numeric;

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_clear)

  WIDGET->clear();
  THIS->dict->clear();

END_METHOD


BEGIN_METHOD(CTREEVIEW_add, GB_STRING key; GB_STRING text; GB_OBJECT picture; GB_STRING parent; GB_STRING after)

  MyListViewItem *item;
  MyListView *wid = WIDGET;
  char *key = GB.ToZeroString(ARG(key));
  MyListViewItem *parent = NULL;
  MyListViewItem *after = NULL;
  char *akey;

  /*
  if (GB.IsMissing(4))
    qDebug("CTREEVIEW_add: key = %s  parent = NULL", key);
  else
    qDebug("CTREEVIEW_add: key = %s  parent = %s", key, GB.ToZeroString(PARAM(parent)));
  */

  if (*key == 0)
  {
    GB.Error("Null key");
    return;
  }

  item = (*THIS->dict)[key];
  if (item != NULL)
  {
    GB.Error("Key already used: &1", key);
    return;
  }

  if (!MISSING(parent))
  {
    akey = GB.ToZeroString(ARG(parent));
    parent = NULL;
    if (*akey)
    {
      parent = (*THIS->dict)[akey];
      if (parent == NULL)
      {
        GB.Error("Parent item does not exist");
        return;
      }
    }
  }

  if (!MISSING(after))
  {
    akey = GB.ToZeroString(ARG(after));
    if (*akey)
    {
      after = (*THIS->dict)[akey];
      if (after == NULL)
      {
        GB.Error("After item does not exist");
        return;
      }
    }
  }
  else
    after = NULL;

  if (parent == NULL)
  {
    if (after == NULL)
      item = new MyListViewItem(THIS, wid);
    else
      item = new MyListViewItem(THIS, wid, after);
  }
  else
  {
    if (after == NULL)
      item = new MyListViewItem(THIS, parent);
    else
      item = new MyListViewItem(THIS, parent, after);
  }

  item->setText(0, QSTRING_ARG(text));

  GB.StoreString(ARG(key), &item->key);
  THIS->dict->insert(item->key, item);

  if (!MISSING(picture))
    item->setPicture(ARG(picture));

  item->setRenameEnabled(0, THIS->rename);

  THIS->item = item;
  
  RETURN_SELF();

END_METHOD


BEGIN_METHOD(CLISTVIEW_add, GB_STRING key; GB_STRING text; GB_OBJECT picture; GB_STRING after)

  MyListViewItem *item;
  MyListView *wid = QLISTVIEW(_object);
  char *key = GB.ToZeroString(ARG(key));
  MyListViewItem *after = NULL;
  char *akey;

  if (*key == 0)
  {
    GB.Error("Null key");
    return;
  }

  item = (*THIS->dict)[key];
  if (item != NULL)
  {
    GB.Error("Key already used: &1", key);
    return;
  }

  if (!MISSING(after))
  {
    akey = GB.ToZeroString(ARG(after));
    if (*akey)
    {
      after = (*THIS->dict)[akey];
      if (after == NULL)
      {
        GB.Error("After item does not exist");
        return;
      }
    }
  }
  else
    after = 0; //WIDGET->last;

  if (after == NULL)
    item = new MyListViewItem(THIS, wid);
  else
    item = new MyListViewItem(THIS, wid, after);

  item->setText(0, QSTRING_ARG(text));

  GB.StoreString(ARG(key), &item->key);
  THIS->dict->insert(item->key, item);

  if (!MISSING(picture))
    item->setPicture(ARG(picture));

  item->setRenameEnabled(0, THIS->rename);

  THIS->item = item;
  
  RETURN_SELF();

END_METHOD


BEGIN_METHOD(CTREEVIEW_remove, GB_STRING key)

  MyListViewItem *lvi;
  char *key = GB.ToZeroString(ARG(key));
  //QListView *wid = QLISTVIEW(_object);

  lvi = CTreeView::getItem(THIS, key);
  if (!lvi)
    return;

  //THIS->dict->remove(key);
  delete lvi;

END_METHOD


BEGIN_METHOD(CTREEVIEW_exist, GB_STRING key)

  GB.ReturnBoolean((*THIS->dict)[GB.ToZeroString(ARG(key))] != 0);

END_METHOD


BEGIN_METHOD(CTREEVIEW_find, GB_INTEGER x; GB_INTEGER y)

  QPoint p(VARG(x), VARG(y));
  MyListViewItem *lvi;

  //qDebug("before: %d %d", p.x(), p.y());
  WIDGET->viewport()->mapFrom(WIDGET, p);
  //qDebug("after: %d %d", p.x(), p.y());
  lvi = (MyListViewItem *)WIDGET->itemAt(p);

  return_item(THIS, lvi);
  
END_METHOD


BEGIN_METHOD(CTREEVIEW_get, GB_STRING key)

  MyListViewItem *item;
  char *key = GB.ToZeroString(ARG(key));

  item = CTreeView::getItem(THIS, key);
  if (!item)
    return;

  THIS->item = item;
  RETURN_SELF();

END_METHOD


BEGIN_PROPERTY(CTREEVIEW_mode)

  if (READ_PROPERTY)
    GB.ReturnInteger(WIDGET->selectionMode());
  else
    WIDGET->setSelectionMode((QListView::SelectionMode)VPROP(GB_INTEGER));

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_current)

  MyListViewItem *item = (MyListViewItem *)(WIDGET->currentItem());

  //if (item && (WIDGET->selectionMode() == QListView::Single) && !item->isSelected())
  //  item = 0;

  THIS->item = item;

  if (item == 0)
    GB.ReturnNull();
  else
    RETURN_SELF();

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_key)

  MyListViewItem *item = (MyListViewItem *)(WIDGET->currentItem());

  THIS->item = item;

  if (item == 0)
    GB.ReturnNull();
  else
    GB.ReturnString(item->key);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_item)

  if (THIS->item == 0)
    GB.ReturnNull();
  else
    RETURN_SELF();

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_available)

  GB.ReturnBoolean(THIS->item != 0);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_show_root)

  if (READ_PROPERTY)
    GB.ReturnBoolean(WIDGET->rootIsDecorated());
  else
    WIDGET->setRootIsDecorated(VPROP(GB_BOOLEAN));

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_sorted)

  if (READ_PROPERTY)
    GB.ReturnBoolean(OBJECT(CTREEVIEW)->sorted != -1);
  else
  {
    OBJECT(CTREEVIEW)->sorted = VPROP(GB_BOOLEAN) ? 0 : -1;
    WIDGET->setSorting(OBJECT(CTREEVIEW)->sorted);
    WIDGET->setShowSortIndicator(VPROP(GB_BOOLEAN));
  }

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_editable)

  if (READ_PROPERTY)
    GB.ReturnBoolean(THIS->rename);
  else
    THIS->rename = VPROP(GB_BOOLEAN);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_count)

  GB.ReturnInteger(WIDGET->childCount());

END_PROPERTY


BEGIN_METHOD_VOID(CTREEVIEW_back)

  MyListViewItem *item = THIS->save;
  THIS->save = 0;
  return_item(THIS, item);

END_METHOD

BEGIN_METHOD(CTREEVIEW_move_to, GB_STRING key)

  char *key = GB.ToZeroString(ARG(key));
  MyListViewItem *item = (*THIS->dict)[key];

  return_item(THIS, item);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_move_current)

  return_item(THIS, (MyListViewItem *)(WIDGET->currentItem()));

END_PROPERTY


BEGIN_METHOD_VOID(CTREEVIEW_first)

  return_item(THIS, (MyListViewItem *)(WIDGET->firstChild()));

END_METHOD

BEGIN_METHOD_VOID(CTREEVIEW_last)

  return_item(THIS, (MyListViewItem *)(WIDGET->last));

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_previous)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->prev) : 0);

END_METHOD

BEGIN_METHOD_VOID(CTREEVIEW_next)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->nextSibling()) : 0);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_parent)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->parent()) : 0);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_child)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->firstChild()) : 0);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_above)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->itemAbove()) : 0);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEW_below)

  return_item(THIS, THIS->item ? (MyListViewItem *)(THIS->item->itemBelow()) : 0);

END_METHOD



BEGIN_PROPERTY(CTREEVIEWITEM_key)

  GB.ReturnString(THIS->item->key);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEWITEM_picture)

  if (READ_PROPERTY)
    GB.ReturnObject(THIS->item->picture);
  else
    THIS->item->setPicture(PROP(GB_OBJECT));

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEWITEM_selected)

  MyListViewItem *it = THIS->item;

  if (READ_PROPERTY)
    GB.ReturnBoolean(it->isSelected());
  else
    it->listView()->setSelected(it, VPROP(GB_BOOLEAN));

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEWITEM_expanded)

  MyListViewItem *it = THIS->item;

  if (READ_PROPERTY)
    GB.ReturnBoolean(it->isOpen());
  else
    it->setOpen(VPROP(GB_BOOLEAN));

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEWITEM_text)

  MyListViewItem *it = THIS->item;

  if (READ_PROPERTY)
    GB.ReturnNewZeroString(TO_UTF8(it->text(0)));
  else
    it->setText(0, QSTRING_PROP());

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEWITEM_count)

  GB.ReturnInteger(THIS->item->childCount());

END_PROPERTY


BEGIN_METHOD_VOID(CTREEVIEWITEM_ensure_visible)

  //qDebug("ensure visible: %p", THIS->item);

  WIDGET->ensureItemVisible(THIS->item);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEWITEM_delete)

  //THIS->dict->remove(THIS->item->key);

  //qDebug("CTREEVIEWITEM_delete < %p %p", THIS, THIS->item);
  delete THIS->item;
  //qDebug("CTREEVIEWITEM_delete > %p", THIS->item);

END_METHOD


BEGIN_METHOD_VOID(CTREEVIEWITEM_clear)

  const MyListViewItem *item = (const MyListViewItem *)THIS->item->firstChild();
  const MyListViewItem *next;

  //qDebug("< CTREEVIEWITEM_clear");

  while (item)
  {
    next = (const MyListViewItem *)item->nextSibling();
    //THIS->dict->remove(((MyListViewItem *)item)->key);
    delete item;
    item = next;
  }

  //qDebug("CTREEVIEWITEM_clear >");

END_METHOD


/*
BEGIN_METHOD_VOID(CTREEVIEWITEM_init)

  CLASS_Item = GB.FindClass("Item");

END_METHOD
*/


BEGIN_PROPERTY(CTREEVIEWITEM_editable)

  if (READ_PROPERTY)
    GB.ReturnBoolean(THIS->item->renameEnabled(0));
  else
    THIS->item->setRenameEnabled(0, VPROP(GB_BOOLEAN));

END_PROPERTY


BEGIN_METHOD_VOID(CTREEVIEWITEM_rename)

  THIS->item->startRename(0);

END_METHOD

/*
BEGIN_PROPERTY(CTREEVIEWITEM_sort_key)

  MyListViewItem *it = THIS->item;

  if (READ_PROPERTY)
    GB.ReturnInteger(it->sortKey);
  else
    it->sortKey = VPROP(GB_INTEGER);

END_PROPERTY
*/




/***************************************************************************

  Columns

***************************************************************************/

BEGIN_PROPERTY(CLISTVIEW_columns)

  RETURN_SELF();

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_resizable)

  if (READ_PROPERTY)
    GB.ReturnBoolean(WIDGET->header()->isResizeEnabled());
  else
  {
    WIDGET->header()->setResizeEnabled(VPROP(GB_BOOLEAN));
    //WIDGET->setResizeMode(PROPERTY(GB_BOOLEAN) ? QListView::NoColumn : QListView::LastColumn);
  }

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_auto_resize)

  if (READ_PROPERTY)
    GB.ReturnBoolean(WIDGET->resizeMode() == QListView::LastColumn);
  else
    WIDGET->setResizeMode(VPROP(GB_BOOLEAN) ? QListView::LastColumn : QListView::NoColumn);

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_moveable)

  if (READ_PROPERTY)
    GB.ReturnBoolean(WIDGET->header()->isMovingEnabled());
  else
    WIDGET->header()->setMovingEnabled(VPROP(GB_BOOLEAN));

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_columns_count)

  long col;
  QListView::ResizeMode mode;
  //bool *numeric;
  //int i, n;

  if (READ_PROPERTY)
  {
    GB.ReturnInteger(WIDGET->columns());
    return;
  }

  col = VPROP(GB_INTEGER);

  if (col < 1 || col > 64)
  {
    GB.Error("Bad number of columns");
    return;
  }

  //mode = WIDGET->resizeMode();
  //WIDGET->setResizeMode(

  /*
  numeric = new bool[col];
  memset(numeric, 0, col * sizeof(*numeric));
  
  if (THIS->numeric)
  {
    n = QMIN(WIDGET->columns(), col);
    for (i = 0; i < n; i++)
      numeric[i] = THIS->numeric[i];
    delete[] THIS->numeric;
  }
  
  THIS->numeric = numeric;
  */
  
  mode = WIDGET->resizeMode();
  WIDGET->setResizeMode(QListView::NoColumn);
  
  if (col < WIDGET->columns())
  {
    while (col < WIDGET->columns())
      WIDGET->removeColumn(WIDGET->columns() - 1);
  }
  else if (col > WIDGET->columns())
  {
    while (col > WIDGET->columns())
    {
      WIDGET->addColumn("");
      //WIDGET->setColumnWidthMode(WIDGET->columns() - 1, QListView::Manual);
    }
  }

  WIDGET->setResizeMode(mode);
  
END_PROPERTY


BEGIN_METHOD(CLISTVIEW_columns_get, GB_INTEGER col)

  long col = VARG(col);

  if (col < 0 || col >= WIDGET->columns())
  {
    GB.Error("Bad column index");
    return;
  }

  _column = col;

  RETURN_SELF();

END_PROPERTY


BEGIN_METHOD_VOID(CLISTVIEW_columns_adjust)

  QHeader *header = WIDGET->header();
  int col = WIDGET->columns() - 1;
  int w;

  w = WIDGET->width() - WIDGET->frameWidth() * 2 - header->sectionPos(col);

  WIDGET->setColumnWidth(col, w);
  //updateScrollBars();
  //qDebug("setColumnWidth %d = %d", col, w);
  //header->resize(w, header->height());

  /*header->resizeSection(header->count() - 1,
    WIDGET->frameSize().width() - WIDGET );*/

END_METHOD


BEGIN_PROPERTY(CLISTVIEW_column_text)

  if (READ_PROPERTY)
    GB.ReturnNewZeroString(TO_UTF8(WIDGET->columnText(_column)));
  else
    WIDGET->setColumnText(_column, QSTRING_PROP());

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_column_width)

  int w;

  if (READ_PROPERTY)
    GB.ReturnInteger(WIDGET->columnWidth(_column));
  else
  {
    w = VPROP(GB_INTEGER);
    //if ((_column == (WIDGET->columns() - 1)) && w < 0)
    //  updateLastColumn(WIDGET);
    //else
    WIDGET->setColumnWidthMode(_column, QListView::Manual);
    WIDGET->setColumnWidth(_column, w);
  }

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_column_alignment)

  if (READ_PROPERTY)
    GB.ReturnInteger(WIDGET->columnAlignment(_column));
  else
    WIDGET->setColumnAlignment(_column, VPROP(GB_INTEGER));

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_columns_sort)

  int sort;

  if (READ_PROPERTY)
    GB.ReturnInteger(THIS->sorted);
  else
  {
    sort = VPROP(GB_INTEGER);
    if (sort < -1 || sort >= WIDGET->columns())
      return;
    THIS->sorted = sort;
    THIS->asc = true;
    WIDGET->setSorting(THIS->sorted);
  }

END_PROPERTY


BEGIN_PROPERTY(CLISTVIEW_columns_ascending)

  if (READ_PROPERTY)
    GB.ReturnBoolean(THIS->asc);
  else
  {
    THIS->asc = VPROP(GB_BOOLEAN);
    WIDGET->setSorting(THIS->sorted, THIS->asc);
  }

END_PROPERTY

/*
BEGIN_PROPERTY(CLISTVIEW_column_numeric)

  if (READ_PROPERTY)
    GB.ReturnNewZeroString(TO_UTF8(WIDGET->columnText(_column)));
  else
    WIDGET->setColumnText(_column, QSTRING_PROP());

END_PROPERTY
*/


BEGIN_PROPERTY(CLISTVIEW_column_auto_resize)

  if (READ_PROPERTY)
    GB.ReturnBoolean(WIDGET->columnWidthMode(_column) != QListView::Manual);
  else
    WIDGET->setColumnWidthMode(_column, VPROP(GB_BOOLEAN) ? QListView::Maximum : QListView::Manual);

END_PROPERTY


BEGIN_METHOD(CTREEVIEWITEM_get, GB_INTEGER col)

  const MyListViewItem* item = THIS->item;

  GB.ReturnNewZeroString(TO_UTF8(item->text(VARG(col))));

END_METHOD


BEGIN_METHOD(CTREEVIEWITEM_put, GB_STRING text; GB_INTEGER col)

  MyListViewItem* item = THIS->item;

  item->setText(VARG(col), QSTRING_ARG(text));

END_METHOD


BEGIN_PROPERTY(CTREEVIEW_client_width)

  //long w = WIDGET->width() - WIDGET->frameWidth() * 2;
  //long sw = WIDGET->verticalScrollBar()->width();
  //long width = w;

  //if (WIDGET->verticalScrollBar()->isHidden())
  //  width -= sw;

  //qDebug("client_width = %ld (%ld) -> %ld", w, sw, width);


  GB.ReturnInteger(WIDGET->width() - WIDGET->frameWidth() * 2);
  //GB.ReturnInteger(width);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_client_height)

  GB.ReturnInteger(WIDGET->height() - WIDGET->frameWidth() * 2);

END_PROPERTY


BEGIN_PROPERTY(CTREEVIEW_header)

  if (READ_PROPERTY)
    GB.ReturnBoolean(!WIDGET->header()->isHidden());
  else
  {
    if (VPROP(GB_BOOLEAN))
      WIDGET->header()->show();
    else
      WIDGET->header()->hide();

    WIDGET->triggerUpdate();
  }


END_PROPERTY

#if 0
BEGIN_PROPERTY(CTREEVIEW_scrollbar)

  long scroll;

  if (READ_PROPERTY)
  {
    scroll = 0;
    if (WIDGET->hScrollBarMode() == QScrollView::Auto)
      scroll += 1;
    if (WIDGET->vScrollBarMode() == QScrollView::Auto)
      scroll += 2;

    GB.ReturnInteger(scroll);
  }
  else
  {
    scroll = VPROP(GB_INTEGER) & 3;
    WIDGET->setHScrollBarMode( (scroll & 1) ? QScrollView::Auto : QScrollView::AlwaysOff);
    WIDGET->setVScrollBarMode( (scroll & 2) ? QScrollView::Auto : QScrollView::AlwaysOff);
  }

END_PROPERTY
#endif


/***************************************************************************

  ListViewItem

***************************************************************************/

GB_DESC CListViewItemDesc[] =
{
  GB_DECLARE(".ListViewItem", 0), GB_VIRTUAL_CLASS(),

  GB_PROPERTY_READ("Key", "s", CTREEVIEWITEM_key),
  GB_PROPERTY("Picture", "Picture", CTREEVIEWITEM_picture),
  GB_PROPERTY("Selected", "b", CTREEVIEWITEM_selected),
  GB_PROPERTY("Text", "s", CTREEVIEWITEM_text),
  GB_METHOD("EnsureVisible", NULL, CTREEVIEWITEM_ensure_visible, NULL),
  GB_METHOD("Delete", NULL, CTREEVIEWITEM_delete, NULL),
  GB_PROPERTY("Editable", "b", CTREEVIEWITEM_editable),

  //GB_METHOD("Next", ".ListViewItem", CTREEVIEWITEM_next, NULL),
  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),

  GB_END_DECLARE
};


/***************************************************************************

  TreeViewItem

***************************************************************************/

GB_DESC CTreeViewItemDesc[] =
{
  GB_DECLARE(".TreeViewItem", 0), GB_VIRTUAL_CLASS(),

  GB_PROPERTY_READ("Key", "s", CTREEVIEWITEM_key),
  GB_PROPERTY("Picture", "Picture", CTREEVIEWITEM_picture),
  GB_PROPERTY("Selected", "b", CTREEVIEWITEM_selected),
  GB_PROPERTY("Text", "s", CTREEVIEWITEM_text),
  GB_METHOD("EnsureVisible", NULL, CTREEVIEWITEM_ensure_visible, NULL),
  GB_METHOD("Delete", NULL, CTREEVIEWITEM_delete, NULL),
  GB_METHOD("Clear", NULL, CTREEVIEWITEM_clear, NULL),

  GB_PROPERTY("Expanded", "b", CTREEVIEWITEM_expanded),
  GB_PROPERTY_READ("Children", "i", CTREEVIEWITEM_count),
  GB_PROPERTY_READ("Count", "i", CTREEVIEWITEM_count),

  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveChild", "b", CTREEVIEW_child, NULL),
  GB_METHOD("MoveParent", "b", CTREEVIEW_parent, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),

  GB_PROPERTY("Editable", "b", CTREEVIEWITEM_editable),
  GB_METHOD("Rename", NULL, CTREEVIEWITEM_rename, NULL),

  GB_END_DECLARE
};


/***************************************************************************

  ColumnViewItem

***************************************************************************/

GB_DESC CColumnViewItemDesc[] =
{
  GB_DECLARE(".ColumnViewItem", 0), GB_VIRTUAL_CLASS(),

  GB_PROPERTY_READ("Key", "s", CTREEVIEWITEM_key),
  GB_PROPERTY("Picture", "Picture", CTREEVIEWITEM_picture),
  GB_PROPERTY("Selected", "b", CTREEVIEWITEM_selected),
  GB_PROPERTY("Text", "s", CTREEVIEWITEM_text),
  GB_METHOD("EnsureVisible", NULL, CTREEVIEWITEM_ensure_visible, NULL),
  GB_METHOD("Delete", NULL, CTREEVIEWITEM_delete, NULL),
  GB_METHOD("Clear", NULL, CTREEVIEWITEM_clear, NULL),

  GB_PROPERTY("Expanded", "b", CTREEVIEWITEM_expanded),
  GB_PROPERTY_READ("Children", "i", CTREEVIEWITEM_count),
  GB_PROPERTY_READ("Count", "i", CTREEVIEWITEM_count),

  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveChild", "b", CTREEVIEW_child, NULL),
  GB_METHOD("MoveParent", "b", CTREEVIEW_parent, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),

  GB_METHOD("_get", "s", CTREEVIEWITEM_get, "(Column)i"),
  GB_METHOD("_put", NULL, CTREEVIEWITEM_put, "(Text)s(Column)i"),

  GB_PROPERTY("Editable", "b", CTREEVIEWITEM_editable),
  GB_METHOD("Rename", NULL, CTREEVIEWITEM_rename, NULL),

  //GB_PROPERTY("SortKey", "f", CTREEVIEWITEM_sort_key),
  
  GB_END_DECLARE
};


/***************************************************************************

  ListView

***************************************************************************/

GB_DESC CListViewDesc[] =
{
  GB_DECLARE("ListView", sizeof(CTREEVIEW)), GB_INHERITS("Control"),

  GB_CONSTANT("None", "i", QListView::NoSelection),
  GB_CONSTANT("Single", "i", QListView::Single),
  GB_CONSTANT("Multi", "i", QListView::Multi),
  GB_CONSTANT("Extended", "i", QListView::Extended),

  GB_METHOD("_new", NULL, CLISTVIEW_new, "(Parent)Container;"),
  GB_METHOD("_free", NULL, CTREEVIEW_free, NULL),

  GB_PROPERTY("Mode", "i<ListView,None,Single,Multi,Extended>", CTREEVIEW_mode),
  GB_PROPERTY("Sorted", "b", CTREEVIEW_sorted),
  GB_PROPERTY("Editable", "b", CTREEVIEW_editable),
  GB_PROPERTY("ScrollBar", "i<Scroll>", CWIDGET_scrollbar),
  GB_PROPERTY("Border", "b", CWIDGET_border_simple),

  GB_PROPERTY_READ("Count", "i", CTREEVIEW_count),

  GB_PROPERTY_READ("Available", "b", CTREEVIEW_available),
  GB_METHOD("MoveTo", "b", CTREEVIEW_move_to, "(Key)s"),
  GB_METHOD("MoveCurrent", "b", CTREEVIEW_move_current, NULL),
  GB_METHOD("MoveFirst", "b", CTREEVIEW_first, NULL),
  GB_METHOD("MoveLast", "b", CTREEVIEW_last, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),
  //GB_METHOD("MoveBack", "b", CTREEVIEW_back, NULL),

  GB_METHOD("_get", ".ListViewItem", CTREEVIEW_get, "(Key)s"),

  GB_METHOD("Clear", NULL, CTREEVIEW_clear, NULL),
  GB_METHOD("Add", ".ListViewItem", CLISTVIEW_add, "(Key)s(Text)s[(Picture)Picture;(After)s]"),
  GB_METHOD("Remove", NULL, CTREEVIEW_remove, "(Key)s"),
  GB_METHOD("Exist", "b", CTREEVIEW_exist, "(Key)s"),
  GB_METHOD("Find", "b", CTREEVIEW_find, "(X)i(Y)i"),

  GB_PROPERTY_READ("Current", ".ListViewItem", CTREEVIEW_current),
  GB_PROPERTY_READ("Key", "s", CTREEVIEW_key),
  GB_PROPERTY_READ("Item", ".ListViewItem", CTREEVIEW_item),

  GB_CONSTANT("_Properties", "s", CLISTVIEW_PROPERTIES),
  GB_CONSTANT("_DefaultEvent", "s", "Click"),

  GB_PROPERTY_READ("ClientWidth", "i", CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientW", "i",  CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientHeight", "i", CTREEVIEW_client_height),
  GB_PROPERTY_READ("ClientH", "i", CTREEVIEW_client_height),

  GB_EVENT("Select", NULL, NULL, &EVENT_Select),
  GB_EVENT("Activate", NULL, NULL, &EVENT_Activate),
  GB_EVENT("Click", NULL, NULL, &EVENT_Click),
  GB_EVENT("Rename", NULL, NULL, &EVENT_Rename),

  GB_END_DECLARE
};



/***************************************************************************

  TreeView

***************************************************************************/

GB_DESC CTreeViewDesc[] =
{
  GB_DECLARE("TreeView", sizeof(CTREEVIEW)), GB_INHERITS("Control"),

  GB_CONSTANT("None", "i", QListView::NoSelection),
  GB_CONSTANT("Single", "i", QListView::Single),
  GB_CONSTANT("Multi", "i", QListView::Multi),
  GB_CONSTANT("Extended", "i", QListView::Extended),

  GB_METHOD("_new", NULL, CTREEVIEW_new, "(Parent)Container;"),
  GB_METHOD("_free", NULL, CTREEVIEW_free, NULL),

  GB_PROPERTY("Mode", "i<TreeView,None,Single,Multi,Extended>", CTREEVIEW_mode),
  GB_PROPERTY("Root", "b", CTREEVIEW_show_root),
  GB_PROPERTY("Sorted", "b", CTREEVIEW_sorted),
  GB_PROPERTY("Editable", "b", CTREEVIEW_editable),
  GB_PROPERTY("ScrollBar", "i<Scroll>", CWIDGET_scrollbar),
  GB_PROPERTY("Border", "b", CWIDGET_border_simple),
  //GB_PROPERTY("Rename", "b", CTREEVIEW_rename),

  GB_PROPERTY_READ("Count", "i", CTREEVIEW_count),

  GB_PROPERTY_READ("Available", "b", CTREEVIEW_available),
  GB_METHOD("MoveCurrent", "b", CTREEVIEW_move_current, NULL),
  GB_METHOD("MoveTo", "b", CTREEVIEW_move_to, "(Key)s"),
  GB_METHOD("MoveFirst", "b", CTREEVIEW_first, NULL),
  GB_METHOD("MoveLast", "b", CTREEVIEW_last, NULL),
  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveChild", "b", CTREEVIEW_child, NULL),
  GB_METHOD("MoveParent", "b", CTREEVIEW_parent, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),
  GB_METHOD("MoveBack", "b", CTREEVIEW_back, NULL),

  GB_METHOD("_get", ".TreeViewItem", CTREEVIEW_get, "(Key)s"),

  GB_METHOD("Clear", NULL, CTREEVIEW_clear, NULL),
  GB_METHOD("Add", ".TreeViewItem", CTREEVIEW_add, "(Key)s(Text)s[(Picture)Picture;(Parent)s(After)s]"),
  GB_METHOD("Remove", NULL, CTREEVIEW_remove, "(Key)s"),
  GB_METHOD("Exist", "b", CTREEVIEW_exist, "(Key)s"),
  GB_METHOD("Find", "b", CTREEVIEW_find, "(X)i(Y)i"),

  GB_PROPERTY_READ("Current", ".TreeViewItem", CTREEVIEW_current),
  GB_PROPERTY_READ("Key", "s", CTREEVIEW_key),
  GB_PROPERTY_READ("Item", ".TreeViewItem", CTREEVIEW_item),

  GB_CONSTANT("_Properties", "s", CTREEVIEW_PROPERTIES),
  GB_CONSTANT("_DefaultEvent", "s", "Click"),

  GB_PROPERTY_READ("ClientWidth", "i", CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientW", "i",  CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientHeight", "i", CTREEVIEW_client_height),
  GB_PROPERTY_READ("ClientH", "i", CTREEVIEW_client_height),

  GB_EVENT("Select", NULL, NULL, &EVENT_Select),
  GB_EVENT("Activate", NULL, NULL, &EVENT_Activate),
  GB_EVENT("Click", NULL, NULL, &EVENT_Click),
  GB_EVENT("Rename", NULL, NULL, &EVENT_Rename),
  GB_EVENT("Expand", NULL, NULL, &EVENT_Expand),
  GB_EVENT("Collapse", NULL, NULL, &EVENT_Collapse),

  GB_END_DECLARE
};


/***************************************************************************

  ColumnView

***************************************************************************/

GB_DESC CColumnViewColumnDesc[] =
{
  GB_DECLARE(".ColumnViewColumn", 0), GB_VIRTUAL_CLASS(),

  GB_PROPERTY("Text", "s", CLISTVIEW_column_text),
  GB_PROPERTY("Alignment", "i<Align,Left,Center,Right>", CLISTVIEW_column_alignment),
  GB_PROPERTY("Width", "i", CLISTVIEW_column_width),
  GB_PROPERTY("AutoResize", "b", CLISTVIEW_column_auto_resize),
  //GB_PROPERTY("Numeric", "b", CLISTVIEW_column_numeric),

  GB_END_DECLARE
};

GB_DESC CColumnViewColumnsDesc[] =
{
  GB_DECLARE(".ColumnViewColumns", 0), GB_VIRTUAL_CLASS(),

  GB_METHOD("_get", ".ColumnViewColumn", CLISTVIEW_columns_get, "(Column)i"),

  GB_PROPERTY("Count", "i", CLISTVIEW_columns_count),
  GB_PROPERTY("Sort", "i", CLISTVIEW_columns_sort),
  GB_PROPERTY("Ascending", "b", CLISTVIEW_columns_ascending),

  //GB_METHOD("Adjust", NULL, CLISTVIEW_columns_adjust, NULL),

  GB_END_DECLARE
};

GB_DESC CColumnViewDesc[] =
{
  GB_DECLARE("ColumnView", sizeof(CTREEVIEW)), GB_INHERITS("Control"),

  GB_CONSTANT("None", "i", QListView::NoSelection),
  GB_CONSTANT("Single", "i", QListView::Single),
  GB_CONSTANT("Multi", "i", QListView::Multi),
  GB_CONSTANT("Extended", "i", QListView::Extended),

  GB_METHOD("_new", NULL, CCOLUMNVIEW_new, "(Parent)Container;"),
  GB_METHOD("_free", NULL, CTREEVIEW_free, NULL),

  GB_PROPERTY("Mode", "i<TreeView,None,Single,Multi,Extended>", CTREEVIEW_mode),
  GB_PROPERTY("Root", "b", CTREEVIEW_show_root),
  GB_PROPERTY("Sorted", "b", CTREEVIEW_sorted),
  GB_PROPERTY("Editable", "b", CTREEVIEW_editable),
  GB_PROPERTY("ScrollBar", "i<Scroll>", CWIDGET_scrollbar),
  GB_PROPERTY("Border", "b", CWIDGET_border_simple),

  GB_PROPERTY_READ("Count", "i", CTREEVIEW_count),

  GB_PROPERTY_READ("Available", "b", CTREEVIEW_available),
  GB_METHOD("MoveCurrent", "b", CTREEVIEW_move_current, NULL),
  GB_METHOD("MoveTo", "b", CTREEVIEW_move_to, "(Key)s"),
  GB_METHOD("MoveFirst", "b", CTREEVIEW_first, NULL),
  GB_METHOD("MoveLast", "b", CTREEVIEW_last, NULL),
  GB_METHOD("MoveNext", "b", CTREEVIEW_next, NULL),
  GB_METHOD("MovePrevious", "b", CTREEVIEW_previous, NULL),
  GB_METHOD("MoveChild", "b", CTREEVIEW_child, NULL),
  GB_METHOD("MoveParent", "b", CTREEVIEW_parent, NULL),
  GB_METHOD("MoveAbove", "b", CTREEVIEW_above, NULL),
  GB_METHOD("MoveBelow", "b", CTREEVIEW_below, NULL),
  GB_METHOD("MoveBack", "b", CTREEVIEW_back, NULL),

  GB_METHOD("_get", ".ColumnViewItem", CTREEVIEW_get, "(Key)s"),

  GB_METHOD("Clear", NULL, CTREEVIEW_clear, NULL),
  GB_METHOD("Add", ".ColumnViewItem", CTREEVIEW_add, "(Key)s(Text)s[(Picture)Picture;(Parent)s(After)s]"),
  GB_METHOD("Remove", NULL, CTREEVIEW_remove, "(Key)s"),
  GB_METHOD("Exist", "b", CTREEVIEW_exist, "(Key)s"),
  GB_METHOD("Find", "b", CTREEVIEW_find, "(X)i(Y)i"),

  GB_PROPERTY_READ("Current", ".ColumnViewItem", CTREEVIEW_current),
  GB_PROPERTY_READ("Key", "s", CTREEVIEW_key),
  GB_PROPERTY_READ("Item", ".ColumnViewItem", CTREEVIEW_item),

  GB_EVENT("Select", NULL, NULL, &EVENT_Select),
  GB_EVENT("Activate", NULL, NULL, &EVENT_Activate),
  GB_EVENT("Click", NULL, NULL, &EVENT_Click),
  GB_EVENT("Rename", NULL, NULL, &EVENT_Rename),
  GB_EVENT("Expand", NULL, NULL, &EVENT_Expand),
  GB_EVENT("Collapse", NULL, NULL, &EVENT_Collapse),
  GB_EVENT("ColumnClick", NULL, "(Column)i", &EVENT_ColumnClick),

  GB_PROPERTY_READ("Columns", ".ColumnViewColumns", CLISTVIEW_columns),

  GB_PROPERTY("Resizable", "b", CLISTVIEW_resizable),
  GB_PROPERTY("AutoResize", "b", CLISTVIEW_auto_resize),
  GB_PROPERTY("Header", "b", CTREEVIEW_header),

  GB_PROPERTY_READ("ClientWidth", "i", CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientW", "i",  CTREEVIEW_client_width),
  GB_PROPERTY_READ("ClientHeight", "i", CTREEVIEW_client_height),
  GB_PROPERTY_READ("ClientH", "i", CTREEVIEW_client_height),

  GB_CONSTANT("_Properties", "s", CCOLUMNVIEW_PROPERTIES),
  GB_CONSTANT("_DefaultEvent", "s", "Click"),

  GB_END_DECLARE
};


/***************************************************************************

  class CTreeView

***************************************************************************/

CTreeView CTreeView::manager;


MyListViewItem *CTreeView::getItem(CTREEVIEW *treeview, char *key)
{
  MyListViewItem *item = (*treeview->dict)[key];

  if (item == 0)
  {
    GB.Error("Unknown item: '&1'", key);
    return NULL;
  }

  return item;
}

void CTreeView::raiseEvent(int ev, QListViewItem *it)
{
  GET_SENDER(_object);
  MyListViewItem *old = THIS->item;

  if (!it)
    it = WIDGET->currentItem();
  THIS->item = (MyListViewItem *)it;
  RAISE_EVENT(ev);

  THIS->item = old;
}

void CTreeView::selected(void)
{
  raiseEvent(EVENT_Select, 0);
}

void CTreeView::activated(QListViewItem *it)
{
  if (!it)
    return;
  raiseEvent(EVENT_Activate, it);
}

void CTreeView::clicked(QListViewItem *it)
{
  if (!it)
    return;
  raiseEvent(EVENT_Click, it);
}

static void post_rename_event(void *object)
{
  GB.Raise(object, EVENT_Rename, 0);
  GB.Unref(&object);
}

void CTreeView::renamed(QListViewItem *it, int col)
{
  GET_SENDER(_object);

  if (it == 0)
    return;

  THIS->item = (MyListViewItem *)it;
  GB.Ref(THIS);
  GB.Post((void (*)())post_rename_event, (long)THIS);
}

void CTreeView::columnClicked(QListViewItem *it, const QPoint &p, int c)
{
  GET_SENDER(_object);

  if (it == 0)
    return;

  THIS->item = (MyListViewItem *)it;

  GB.Raise(_object, EVENT_ColumnClick, 1, GB_T_INTEGER, c);
}

void CTreeView::expanded(QListViewItem *it)
{
  raiseEvent(EVENT_Expand, it);
}

void CTreeView::collapsed(QListViewItem *it)
{
  raiseEvent(EVENT_Collapse, it);
}

void CTreeView::headerClicked(int c)
{
  CTREEVIEW *_object = (CTREEVIEW *)CWidget::get((QObject *)sender());

  if (_object->sorted == c)
    _object->asc = !_object->asc;
  else
    _object->asc = true;

  _object->sorted = c;

  //WIDGET->setSorted(_object->sorted, _object->asc);
}


void CTreeView::headerSizeChange(int c, int os, int ns)
{
//  CTREEVIEW *_object = (CTREEVIEW *)CWidget::get((QObject *)sender());
//  updateLastColumn(WIDGET);
}


Generated by  Doxygen 1.6.0   Back to index