TableTreeModel class reference
[Model/View module]

Declaration  

#include <QtLua/TableTreeModel>

namespace QtLua {
class TableTreeModel;
};

This class is a member of the QtLua namespace.

Description  

This class can be used to expose lua tables content to Qt view widgets in a flat or hierarchical manner.

Lua tables and UserData objects with valid table operations are handled.

Lua tables can be edited from Qt views using this model. The TableTreeModel::Attribute flags can be used to finely control which editing actions are allowed. User input may be evaluated as a lua expression when editing a table entry.

Lua tables change may not update the model on the fly and the TableTreeModel::update function must be called to refresh views on heavy modifications. This is partially due to lack of lua mechanism to implement efficient table change event.

Usage example:

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

state = new QtLua::State();
state->openlib(QtLua::AllLibs);

// Create a new model and expose lua global table
model = new QtLua::TableTreeModel((*state)["_G"], QtLua::TableTreeModel::Recursive);

// Create Qt view widget
treeview = new QTreeView(0);
treeview->setModel(model);

setCentralWidget(treeview);

See also TableDialog class.

Members  

Types  

Functions  

  • TableTreeModel(const Value &root, TableTreeModel::Attributes attr, QObject *parent = [...])
  • ~TableTreeModel()
  • QModelIndex buddy(const QModelIndex &index) const
  • int columnCount(const QModelIndex &parent) const
  • QVariant data(const QModelIndex &index, int role) const
  • Qt::ItemFlags flags(const QModelIndex &index) const
  • TableTreeModel::Attributes get_attr(const QModelIndex &index) const
  • Value get_value(const QModelIndex &index) const
  • bool hasChildren(const QModelIndex &parent) const
  • QVariant headerData(int section, Qt::Orientation orientation, int role) const
  • bool insertRows(int row, int count, const QModelIndex &parent)
  • QModelIndex parent(const QModelIndex &index) const
  • bool removeRows(int row, int count, const QModelIndex &parent)
  • int rowCount(const QModelIndex &parent) const
  • bool setData(const QModelIndex &index, const QVariant &value, int role)
  • void update()

Members detail  

TableTreeModel(const Value &root, TableTreeModel::Attributes attr, QObject *parent = 0)  

Create a new lua table model.

~TableTreeModel()  

No documentation available

enum Attribute  

Specifies TableTreeModel behavior for a given lua table

IdentifierValueDescription
Recursive0Expose nested tables too.
UserDataIter0Iterate over UserData objects too.
HideType0Do not show entry type in an additionnal column.
UnquoteKeys0Strip double quotes from string keys
UnquoteValues0Strip double quotes from string values
Editable0Allow editing exposed lua tables.
EditFixedType0Prevent value type change when editing.
EditLuaEval0Evaluate user input as a lua expression.
EditInsert0Allow insertion of new entries.
EditRemove0Allow deletion of existing entries.
EditKey0Allow entry key update.
EditAll0Editable, EditInsert, EditRemove and EditKey allowed

See also TableTreeModel::Attributes typedef.

typedef TableTreeModel::Attribute Attributes  

No documentation available

QModelIndex buddy(const QModelIndex &index) const  

No documentation available

int columnCount(const QModelIndex &parent) const  

No documentation available

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

No documentation available

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

No documentation available

TableTreeModel::Attributes get_attr(const QModelIndex &index) const  

Get supported operations for entry at given QModelIndex

Value get_value(const QModelIndex &index) const  

Get lua value at given model index

bool hasChildren(const QModelIndex &parent) const  

No documentation available

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

No documentation available

bool insertRows(int row, int count, const QModelIndex &parent)  

No documentation available

QModelIndex parent(const QModelIndex &index) const  

No documentation available

bool removeRows(int row, int count, const QModelIndex &parent)  

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

void update()  

Clear cached table content and reset model.

Valid XHTML 1.0 StrictGenerated by diaxen on Sun Jan 8 22:46:02 2012 using MkDoc