UserItemModel class reference
[Model/View module]

Declaration  

#include <QtLua/UserItemModel>

namespace QtLua {
class UserItemModel;
};

This class is a member of the QtLua namespace.

This class is declared in QtLua/qtluauseritemmodel.hh source file, line 60.

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  

Private type  

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)
  • QVariant data(const QModelIndex &index, int role) const

Protected functions  

Private functions  

  • bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
  • QMimeData * mimeData(const QModelIndexList &indexes) const
  • Qt::DropActions supportedDropActions() const

Static functions  

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

Private field  

Members detail  

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

This constructor is declared in QtLua/qtluauseritemmodel.hh source file, line 68.

Create a new item model with pointer to root item

~UserItemModel()  

This destructor is declared in QtLua/qtluauseritemmodel.hh source file, line 70.

This variable is declared in QtLua/qtluauseritemmodel.hh source file, line 109.

This member access is private.

int columnCount(const QModelIndex &parent) const  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 94.

bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 100.

This member access is private.

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

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 89.

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

This virtual function is declared in QtLua/qtluauseritemmodel.hh source file, line 81.

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)  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 73.

Get pointer to UserItem from QT model index.

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

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 76.

Get a lua table value with selected items on given view

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

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 90.

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

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 91.

QMimeData * mimeData(const QModelIndexList &indexes) const  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 101.

This member access is private.

virtual QStringList mimeTypes() const  

This virtual function is declared in QtLua/qtluauseritemmodel.hh source file, line 84.

This member access is protected.

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

QModelIndex parent(const QModelIndex &index) const  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 92.

int rowCount(const QModelIndex &parent) const  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 93.

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

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 95.

Qt::DropActions supportedDropActions() const  

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 102.

This member access is private.

QVariant data(const QModelIndex &index, int role) const  

This function is for internal use only.

This function is declared in QtLua/qtluauseritemmodel.hh source file, line 88.

Valid XHTML 1.0 StrictGenerated by diaxen on Sat Mar 30 16:23:03 2013 using MkDoc