TTreeView Class

Header: #include <TTreeView>
Inherits: QTreeView and TUiInterface
Inherited By:

TCategoryTreeView

Properties

Public Functions

TTreeView(QWidget *parent = 0)
~TTreeView()

Reimplemented Public Functions

virtual void setModel(QAbstractItemModel *iItemModel)

Public Slots

QVariantList allDataMap(const QString &iChildKeyStr = QString( "CHILDREN" ), const QString &iIndexKeyStr = QString( "" ), bool iIncludeHiddenInt = true, const QModelIndex &iParentModelIndex = QModelIndex())
int allExpendedCount()
void clearData()
int colummNumber(const QString &iColName)
QString columnName(int iColumnInt) const
QMenu *contextMenu()
QVariant currentPrimaryKey()
QVariant currentRowDataList()
QVariant currentRowDataMap()
int dragMode() const
QModelIndex findRow(const QVariant &iValueVar, const QString &iColNameStr = QString( "" ), const QModelIndex &iParentModelIndex = QModelIndex())
QModelIndexList findRows(const QVariant &iValueVar, const QString &iColNameStr = QString( "" ), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())
QModelIndexList findRows(const QVariantList &iValueVarLst, const QString &iColNameStr = QString( "" ), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())
QModelIndexList findRows(const QRegExp &iRegExp, const QStringList &iColNameStr = QStringList(), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())
virtual QVariant getData(const QString &key = "", const QVariant &options = QVariant())
int gridLineMode() const
QVariantList headerItem()
THeaderViewPopup *headerPopup()
QVariantList initialHeaderItem()
bool isColumnVisible(const QString iColNameStr)
bool isColumnVisible(int iColumnInt)
QMap<QString, bool> isColumnVisible(const QStringList &iColumnStrLst = QStringList())
void loadFlattenData(const QVariantList &iDataVarLst, const QString &iIndexKeyStr)
void loadTreeData(const QVariantList &iDataVarLst, const QString &iChildKeyStr = QString( "CHILDREN" ))
void moveRowsBottom(const QModelIndexList &iModelIndexLst)
void moveRowsDown(const QModelIndexList &iModelIndexLst)
void moveRowsTop(const QModelIndexList &iModelIndexLst)
void moveRowsUp(const QModelIndexList &iModelIndexLst)
void moveSelectedRowsBottom()
void moveSelectedRowsDown()
void moveSelectedRowsTop()
void moveSelectedRowsUp()
void refreshRowExpanded(TTreeItem *iRootTreeItemPtr = 0)
void refreshRowVisible(TTreeItem *iRootTreeItemPtr = 0)
void restorSaveState(const QString &iData)
void restoreRowsExpanded(const QVariantMap &iDataVarMap, const QModelIndex &iParentModelIndex = QModelIndex())
void restoreRowsVisible(const QVariantMap &iDataVarMap, const QModelIndex &iParentModelIndex = QModelIndex())
QString saveState()
void selectRow(const QVariant &iKeyVar, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)
void selectRow(const QModelIndex &iModelIndex, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)
void selectRows(const QVariantList &iKeyVarLst, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)
void selectRows(const QModelIndexList &iKeyVarLst, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)
QModelIndexList selectedIndexes()
QVariantList selectedPrimaryKeys(bool iIncludeHiddenBol = false)
QVariantList selectedRowDataMaps(bool iIncludeHiddenBol = false)
void setColumnState(int iColumnInt, const QVariantMap &iStateVarMap, bool iResetBol = false)
void setColumnVisible(const QString iColNameStr, bool iVisibleBol)
void setColumnVisible(int iColumnInt, bool iVisibleBol)
void setColumnVisible(QMap<QString, bool> iVisiblesMap)
void setContextMenu(QMenu *iMenuPtr)
virtual void setData(const QString &key, const QVariant &data)
void setDataKeyList(const QStringList &iKeyStrLst)
void setDragMode(int iDragModeInt)
void setExpandedKey(const QString &iKeyStr)
void setGridLineMode(int iModeInt)
void setHeaderItem(const QVariantList &iHeaderItemVarLst)
void setHeaderPopupEnabled(bool iBol)
void setPrimaryKey(const QString &iKeyStr)
void setRowAllParentExpanded(const QModelIndex &iModelIndex)
void setRowAllParentVisible(const QModelIndex &iModelIndex)
void setRowData(const QModelIndex &iModelIndex, const QVariant &iRowDataVar, bool iResetBol = false)
void setRowDataByPrimaryKey(const QVariant &iPrimaryKey, const QVariant &iRowDataVar, bool iResetBol = false)
void setRowExpanded(const QModelIndex &iModelIndex, bool iExpandBol)
void setRowKeyValue(const QModelIndex &iModelIndex, const QString &iKeyStr, const QVariant &iValueVar, bool iEmitChangeBol = true)
void setRowKeyValueByPrimaryKey(const QVariant &iPrimaryKey, const QString &iKeyStr, const QVariant &iValueVar, bool iEmitChangeBol = true)
void setRowVisible(const QModelIndex &iModelIndex, bool iVisibleBol)
void setVisibleKey(const QString &iKeyStr)
void showContextMenu(const QPoint &iPoint)
void showHeaderPopup(const QPoint &iPoint)
void syncParentItemVisible(int iFilterModeInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())
void unselectAll()

Signals

void anyDataChanged()
void dataChanged()
void indexWidgetCommit(QWidget *iWidget, const QModelIndex &iModelIndex)
virtual void notification(const QString &type, const QVariant &data = QVariant(), const QString &uuid = QStringLiteral( "" ))
void rowCheckStateChanged(const QModelIndex &iModelIndex)
void rowsInserted()
void rowsMoved()
void rowsRemoved()

Static Public Members

QHeaderView::ResizeMode str2resizeMode(const QString &iStr)
  • 5 static public members inherited from QWidget

Additional Inherited Members

Detailed Description

Property Documentation

dragMode : int

Access functions:

int dragMode() const
void setDragMode(int iDragModeInt)

Member Function Documentation

TTreeView::TTreeView(QWidget *parent = 0)

Default constructs an instance of TTreeView.

TTreeView::~TTreeView()

Destroys the instance of TTreeView.

[slot] QVariantList TTreeView::allDataMap(const QString &iChildKeyStr = QString( "CHILDREN" ), const QString &iIndexKeyStr = QString( "" ), bool iIncludeHiddenInt = true, const QModelIndex &iParentModelIndex = QModelIndex())

获取所有数据

[slot] int TTreeView::allExpendedCount()

[signal] void TTreeView::anyDataChanged()

[slot] void TTreeView::clearData()

[slot] int TTreeView::colummNumber(const QString &iColName)

[slot] QString TTreeView::columnName(int iColumnInt) const

[slot] QMenu *TTreeView::contextMenu()

See also setContextMenu().

[slot] QVariant TTreeView::currentPrimaryKey()

获取当前行的主键值

[slot] QVariant TTreeView::currentRowDataList()

获取当前行数据,返回的数据格式为List结构

[slot] QVariant TTreeView::currentRowDataMap()

获取当前行数据,返回的数据格式为Map结构

[signal] void TTreeView::dataChanged()

[slot] QModelIndex TTreeView::findRow(const QVariant &iValueVar, const QString &iColNameStr = QString( "" ), const QModelIndex &iParentModelIndex = QModelIndex())

[slot] QModelIndexList TTreeView::findRows(const QVariant &iValueVar, const QString &iColNameStr = QString( "" ), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())

[slot] QModelIndexList TTreeView::findRows(const QVariantList &iValueVarLst, const QString &iColNameStr = QString( "" ), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())

[slot] QModelIndexList TTreeView::findRows(const QRegExp &iRegExp, const QStringList &iColNameStr = QStringList(), int iFilterInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())

[virtual slot] QVariant TTreeView::getData(const QString &key = "", const QVariant &options = QVariant())

[slot] int TTreeView::gridLineMode() const

See also setGridLineMode().

[slot] QVariantList TTreeView::headerItem()

See also setHeaderItem().

[slot] THeaderViewPopup *TTreeView::headerPopup()

[signal] void TTreeView::indexWidgetCommit(QWidget *iWidget, const QModelIndex &iModelIndex)

[slot] QVariantList TTreeView::initialHeaderItem()

[slot] bool TTreeView::isColumnVisible(const QString iColNameStr)

列是否显示 colname :列名称

[slot] bool TTreeView::isColumnVisible(int iColumnInt)

列是否显示 column :列编号

[slot] QMap<QString, bool> TTreeView::isColumnVisible(const QStringList &iColumnStrLst = QStringList())

列是否显示 columns :列名称列表

返回格式{col1:true, col2:false}

[slot] void TTreeView::loadFlattenData(const QVariantList &iDataVarLst, const QString &iIndexKeyStr)

载入table结构的数据

indexkey :指定某一列数据为index,使其生成Tree结构数据

See also TTreeModel::loadFlattenData() and TTreeModel::indexString().

[slot] void TTreeView::loadTreeData(const QVariantList &iDataVarLst, const QString &iChildKeyStr = QString( "CHILDREN" ))

载入数型结构的数据

childkey :指定某一列数据为子条目数据

See also TTreeModel::loadTreeData().

[slot] void TTreeView::moveRowsBottom(const QModelIndexList &iModelIndexLst)

[slot] void TTreeView::moveRowsDown(const QModelIndexList &iModelIndexLst)

[slot] void TTreeView::moveRowsTop(const QModelIndexList &iModelIndexLst)

[slot] void TTreeView::moveRowsUp(const QModelIndexList &iModelIndexLst)

[slot] void TTreeView::moveSelectedRowsBottom()

[slot] void TTreeView::moveSelectedRowsDown()

[slot] void TTreeView::moveSelectedRowsTop()

[slot] void TTreeView::moveSelectedRowsUp()

[virtual signal] void TTreeView::notification(const QString &type, const QVariant &data = QVariant(), const QString &uuid = QStringLiteral( "" ))

[slot] void TTreeView::refreshRowExpanded(TTreeItem *iRootTreeItemPtr = 0)

[slot] void TTreeView::refreshRowVisible(TTreeItem *iRootTreeItemPtr = 0)

刷新行显示状态; 当TTreeModel中直接更改row的显示状态时 可调用此函数刷新行显示状态

See also TTreeModel::setRowVisible().

[slot] void TTreeView::restorSaveState(const QString &iData)

[slot] void TTreeView::restoreRowsExpanded(const QVariantMap &iDataVarMap, const QModelIndex &iParentModelIndex = QModelIndex())

[slot] void TTreeView::restoreRowsVisible(const QVariantMap &iDataVarMap, const QModelIndex &iParentModelIndex = QModelIndex())

[signal] void TTreeView::rowCheckStateChanged(const QModelIndex &iModelIndex)

[signal] void TTreeView::rowsInserted()

[signal] void TTreeView::rowsMoved()

[signal] void TTreeView::rowsRemoved()

[slot] QString TTreeView::saveState()

[slot] void TTreeView::selectRow(const QVariant &iKeyVar, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)

[slot] void TTreeView::selectRow(const QModelIndex &iModelIndex, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)

[slot] void TTreeView::selectRows(const QVariantList &iKeyVarLst, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)

[slot] void TTreeView::selectRows(const QModelIndexList &iKeyVarLst, QItemSelectionModel::SelectionFlags iSelectionFlag = QItemSelectionModel::Select | QItemSelectionModel::Rows)

[slot] QModelIndexList TTreeView::selectedIndexes()

获取选择的indexs

[slot] QVariantList TTreeView::selectedPrimaryKeys(bool iIncludeHiddenBol = false)

[slot] QVariantList TTreeView::selectedRowDataMaps(bool iIncludeHiddenBol = false)

[slot] void TTreeView::setColumnState(int iColumnInt, const QVariantMap &iStateVarMap, bool iResetBol = false)

设置列状态 column :列编号 state :列状态数据,如{visible:true, size:100, resizeMode:'Stretch'} reset :是否重置状态

[slot] void TTreeView::setColumnVisible(const QString iColNameStr, bool iVisibleBol)

设置列是否显示 colname :列名称,setHeaderItem()中name对应的值 visible :true=显示, false=隐藏

See also isColumnVisible() and setHeaderItem().

[slot] void TTreeView::setColumnVisible(int iColumnInt, bool iVisibleBol)

设置列是否显示 column :列编号 visible :true=显示, false=隐藏

[slot] void TTreeView::setColumnVisible(QMap<QString, bool> iVisiblesMap)

设置列是否显示 visibles :如{col1:true,col2:false}

[slot] void TTreeView::setContextMenu(QMenu *iMenuPtr)

See also contextMenu().

[virtual slot] void TTreeView::setData(const QString &key, const QVariant &data)

[slot] void TTreeView::setDataKeyList(const QStringList &iKeyStrLst)

设置数据Key列表,格式如下


  ["colnm1","colnm2","colnm3","colnm4","colnm5","colnm6"]

[slot] void TTreeView::setExpandedKey(const QString &iKeyStr)

[slot] void TTreeView::setGridLineMode(int iModeInt)

网格线模式:1:水平方向,2:垂直方向,3:水平+垂直

See also gridLineMode().

[slot] void TTreeView::setHeaderItem(const QVariantList &iHeaderItemVarLst)

TTreeView设置列标题信息,格式如下


  [
        {
            "name": "col1","display":"第一列","resizeMode":"ResizeToContents",
            "displayRole":".colnm1"
        },
        {
            "name": "col2","display":"第二列","resizeMode":"Fixed",
            "displayRole":".colnm2"
        },
        {
            "name": "col3","display":"第三列","resizeMode":"Stretch",
            "textAlignment":"HCenter|VCenter",
            "displayRole":".colnm3","typeRole":"html"
        },
        {
            "name": "col4","display":"第四列","resizeMode":"Interactive",
            "displayRole":".colnm4","typeRole":"progress"
        },
        {
            "name": "col5","display":"第五列",
            "displayRole":".colnm5","typeRole":"button",
            "propertyRole": {"text":"设置"}
        }
    ]

See also headerItem() and TTreeModel::setHeaderItem().

[slot] void TTreeView::setHeaderPopupEnabled(bool iBol)

[virtual] void TTreeView::setModel(QAbstractItemModel *iItemModel)

Reimplemented from QAbstractItemView::setModel().

TTreeView设置Model, TTreeView在创建时会新建一个TTreeModel 作为默认Model

[slot] void TTreeView::setPrimaryKey(const QString &iKeyStr)

设置数据设置主键名称

[slot] void TTreeView::setRowAllParentExpanded(const QModelIndex &iModelIndex)

[slot] void TTreeView::setRowAllParentVisible(const QModelIndex &iModelIndex)

[slot] void TTreeView::setRowData(const QModelIndex &iModelIndex, const QVariant &iRowDataVar, bool iResetBol = false)

[slot] void TTreeView::setRowDataByPrimaryKey(const QVariant &iPrimaryKey, const QVariant &iRowDataVar, bool iResetBol = false)

[slot] void TTreeView::setRowExpanded(const QModelIndex &iModelIndex, bool iExpandBol)

设置行是否展开

[slot] void TTreeView::setRowKeyValue(const QModelIndex &iModelIndex, const QString &iKeyStr, const QVariant &iValueVar, bool iEmitChangeBol = true)

[slot] void TTreeView::setRowKeyValueByPrimaryKey(const QVariant &iPrimaryKey, const QString &iKeyStr, const QVariant &iValueVar, bool iEmitChangeBol = true)

[slot] void TTreeView::setRowVisible(const QModelIndex &iModelIndex, bool iVisibleBol)

设置行是否显示

See also TTreeModel::setRowVisible().

[slot] void TTreeView::setVisibleKey(const QString &iKeyStr)

[slot] void TTreeView::showContextMenu(const QPoint &iPoint)

[slot] void TTreeView::showHeaderPopup(const QPoint &iPoint)

[static] QHeaderView::ResizeMode TTreeView::str2resizeMode(const QString &iStr)

[slot] void TTreeView::syncParentItemVisible(int iFilterModeInt = 1, const QModelIndex &iParentModelIndex = QModelIndex())

[slot] void TTreeView::unselectAll()