#ifndef MODEL_H
#define MODEL_H
#include "toolkit.h"
#include "../ui/tree.h"
#include "../common/context.h"
#include <QListView>
#include <QTreeView>
#include <QAbstractListModel>
#include <QAbstractTableModel>
#include <QAbstractItemModel>
#include <QItemSelectionModel>
class ListModel : public QAbstractListModel {
Q_OBJECT
UiObject *obj;
UiListPtr *list;
ui_model_getvalue_f getvalue;
ui_callback callback;
void *userdata;
QListView *view;
public:
ListModel(UiObject *obj, QListView *view, UiListPtr *list, ui_model_getvalue_f getvalue, ui_callback f,
void *userdata);
int rowCount(
const QModelIndex &parent = QModelIndex())
const;
QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
public slots:
void selectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
};
class TableModel : public QAbstractTableModel {
Q_OBJECT
UiObject *obj;
UiListPtr *list;
UiModelInfo *info;
QTreeView *view;
public:
TableModel(UiObject *obj, QTreeView *view, UiListPtr *list, UiModelInfo *info);
int rowCount(
const QModelIndex &parent = QModelIndex())
const;
int columnCount(
const QModelIndex &parent = QModelIndex())
const;
QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const;
void update();
public slots:
void selectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
void activate(
const QModelIndex &);
};
UiListSelection* listSelection(QItemSelectionModel *s);
#endif