UserItemModel class reference
[Model/View module]

Declaration  

#include <QtLua/UserItemModel>

namespace QtLua {
class UserItemModel;
};

This class is a member of the QtLua namespace.

Description  

This class together with the UserListItem and UserItem classes enable easy use of list or hierarchical data structures that can be viewed and modified from lua script, Qt view widgets and C++ code.

The hierarchical data structure is accessible from lua as nested tables. Data are not duplicated and any change to the data from lua immediately update to the Qt view widget.

Usage example:

// code from examples/cpp/mvc/itemtreeview.cc:30

state = new QtLua::State();

// Create tree root node
QtLua::UserListItem::ptr root = QTLUA_REFNEW(QtLua::UserListItem, );

// Set as lua global
(*state)["root"] = root;

// Insert 2 new nodes
QTLUA_REFNEW(QtLua::UserItem, "foo")->insert(root);
QTLUA_REFNEW(QtLua::UserItem, "foo2")->insert(root);

// Create Qt view widget and set model
model = new QtLua::UserItemModel(root);

treeview = new QTreeView(0);
treeview->setModel(model);
setCentralWidget(treeview);

// Rename node from lua script
state->exec_statements("root.bar = root.foo2");

Members  

Functions  

  • UserItemModel(Ref<UserListItem> root, QObject *parent = [...])
  • ~UserItemModel()
  • int columnCount(const QModelIndex &parent) const
  • Qt::ItemFlags flags(const QModelIndex &index) const
  • QVariant headerData(int section, Qt::Orientation orientation, int role = [...]) const
  • QModelIndex index(int row, int column, const QModelIndex &parent) const
  • QModelIndex parent(const QModelIndex &index) const
  • int rowCount(const QModelIndex &parent) const
  • bool setData(const QModelIndex &index, const QVariant &value, int role)

Protected functions  

Static functions  

  • static Ref<UserItem> get_item(const QModelIndex &index)
  • static Value get_selection(State *ls, const QAbstractItemView &view)

Members detail  

UserItemModel(Ref<UserListItem> root, QObject *parent = 0)  

Create a new item model with pointer to root item

~UserItemModel()  

No documentation available

int columnCount(const QModelIndex &parent) const  

No documentation available

Qt::ItemFlags flags(const QModelIndex &index) const  

No documentation available

virtual Ref<UserItem> from_mimedata(const QMimeData *data)  

This member access is protected.

May be reimplemented to return a new item created from mime data. Used when dropping external objects.

static Ref<UserItem> get_item(const QModelIndex &index)  

Get pointer to UserItem from QT model index.

static Value get_selection(State *ls, const QAbstractItemView &view)  

Get a lua table value with selected items on given view

QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const  

No documentation available

QModelIndex index(int row, int column, const QModelIndex &parent) const  

No documentation available

virtual QStringList mimeTypes() const  

This member access is protected.

Return supported mime type. May be reimplemented to add more types.

QModelIndex parent(const QModelIndex &index) const  

No documentation available

int rowCount(const QModelIndex &parent) const  

No documentation available

bool setData(const QModelIndex &index, const QVariant &value, int role)  

No documentation available

Valid XHTML 1.0 StrictGenerated by diaxen on Sat Mar 30 15:29:55 2013 using MkDoc