⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qabstractitemview.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    keyboard modifiers specified by \a modifiers.    In the base class this is a pure virtual function.*//*!    \fn int QAbstractItemView::horizontalOffset() const = 0    Returns the horizontal offset of the view.    In the base class this is a pure virtual function.    \sa verticalOffset()*//*!    \fn int QAbstractItemView::verticalOffset() const = 0    Returns the vertical offset of the view.    In the base class this is a pure virtual function.    \sa horizontalOffset()*//*!  \fn bool QAbstractItemView::isIndexHidden(const QModelIndex &index) const  Returns true if the item referred to by the given \a index is hidden in the view,  otherwise returns false.  Hiding is a view specific feature.  For example in TableView a column can be marked  as hidden or a row in the TreeView.  In the base class this is a pure virtual function.*//*!    \fn void QAbstractItemView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)    Applies the selection \a flags to the items in or touched by the    rectangle, \a rect.    When implementing your own itemview setSelection should call    selectionModel()->select(selection, flags) where selection    is either an empty QModelIndex or a QItemSelection that contains    all items that are contained in \a rect.    \sa selectionCommand(), selectedIndexes()*//*!    \fn QRegion QAbstractItemView::visualRegionForSelection(const QItemSelection &selection) const = 0    Returns the region from the viewport of the items in the given    \a selection.    In the base class this is a pure virtual function.    \sa visualRect(), selectedIndexes()*//*!    \fn void QAbstractItemView::update()    \internal*//*!    Constructs an abstract item view with the given \a parent.*/QAbstractItemView::QAbstractItemView(QWidget *parent)    : QAbstractScrollArea(*(new QAbstractItemViewPrivate), parent){    d_func()->init();}/*!    \internal*/QAbstractItemView::QAbstractItemView(QAbstractItemViewPrivate &dd, QWidget *parent)    : QAbstractScrollArea(dd, parent){    d_func()->init();}/*!    Destroys the view.*/QAbstractItemView::~QAbstractItemView(){}/*!  Sets the \a model for the view to present.  \bold{Note:} This function will also create and set a new selection model,  replacing any previously set with setSelectionModel(), but the old selection  model will not be deleted.  \sa selectionModel(), setSelectionModel()*/void QAbstractItemView::setModel(QAbstractItemModel *model){    Q_D(QAbstractItemView);    if (model == d->model)        return;    if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {        disconnect(d->model, SIGNAL(destroyed()),                   this, SLOT(_q_modelDestroyed()));        disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),                   this, SLOT(dataChanged(QModelIndex,QModelIndex)));        disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),                   this, SLOT(rowsInserted(QModelIndex,int,int)));        disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),                   this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));        disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),                   this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));        disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),                   this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));        disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),                   this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));        disconnect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));        disconnect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));    }    d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel());    // These asserts do basic sanity checking of the model    Q_ASSERT_X(d->model->index(0,0) == d->model->index(0,0),               "QAbstractItemView::setModel",               "A model should return the exact same index "               "(including its internal id/pointer) when asked for it twice in a row.");    Q_ASSERT_X(d->model->index(0,0).parent() == QModelIndex(),               "QAbstractItemView::setModel",               "The parent of a top level index should be invalid");    if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {        connect(d->model, SIGNAL(destroyed()),                this, SLOT(_q_modelDestroyed()));        connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),                this, SLOT(dataChanged(QModelIndex,QModelIndex)));        connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),                this, SLOT(rowsInserted(QModelIndex,int,int)));        connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),                this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));        connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),                this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));        connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),                this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));        connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),                this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));        connect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));        connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));    }    setSelectionModel(new QItemSelectionModel(d->model, this));    reset(); // kill editors, set new root and do layout}/*!    Returns the model that this view is presenting.*/QAbstractItemModel *QAbstractItemView::model() const{    Q_D(const QAbstractItemView);    return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model);}/*!    Sets the current selection model to the given \a selectionModel.    Note that, if you call setModel() after this function, the given \a selectionModel    will be replaced by a one created by the view.    \sa selectionModel(), setModel(), clearSelection()*/void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel){    // ### if the given model is null, we should use the original selection model    Q_ASSERT(selectionModel);    Q_D(QAbstractItemView);    if (selectionModel->model() != d->model) {        qWarning("QAbstractItemView::setSelectionModel() failed: "                 "Trying to set a selection model, which works on "                 "a different model than the view.");        return;    }    if (d->selectionModel) {        disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),                   this, SLOT(selectionChanged(QItemSelection,QItemSelection)));        disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),                   this, SLOT(currentChanged(QModelIndex,QModelIndex)));    }    d->selectionModel = selectionModel;    if (d->selectionModel) {        connect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),                this, SLOT(selectionChanged(QItemSelection,QItemSelection)));        connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),                this, SLOT(currentChanged(QModelIndex,QModelIndex)));    }}/*!    Returns the current selection model.    \sa setSelectionModel(), selectedIndexes()*/QItemSelectionModel* QAbstractItemView::selectionModel() const{    Q_D(const QAbstractItemView);    return d->selectionModel;}/*!    Sets the item delegate for this view and its model to \a delegate.    This is useful if you want complete control over the editing and    display of items.    Any existing delegate will be removed, but not deleted. QAbstractItemView    does not take ownership of \a delegate.    \warning You should not share the same instance of a delegate between views.    Doing so can cause incorrect or unintuitive editing behavior since each    view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}    signal, and attempt to access, modify or close an editor that has already been closed.    \sa itemDelegate()*/void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate){    Q_D(QAbstractItemView);    if (delegate == d->itemDelegate)        return;    if (d->itemDelegate) {        if (d->delegateRefCount(d->itemDelegate) == 1) {            disconnect(d->itemDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                       this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            disconnect(d->itemDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }    }    if (delegate) {        if (d->delegateRefCount(delegate) == 0) {            connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                    this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }    }    d->itemDelegate = delegate;}/*!    Returns the item delegate used by this view and model. This is    either one set with setItemDelegate(), or the default one.    \sa setItemDelegate()*/QAbstractItemDelegate *QAbstractItemView::itemDelegate() const{    return d_func()->itemDelegate;}/*!    \reimp*/QVariant QAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const{    const QModelIndex current = currentIndex();    if (!current.isValid() || query != Qt::ImMicroFocus)        return QAbstractScrollArea::inputMethodQuery(query);    return visualRect(current);}/*!    \since 4.2    Sets the given item \a delegate used by this view and model for the given    \a row. All items on \a row will be drawn and managed by \a delegate    instead of using the default delegate (i.e., itemDelegate()).    Any existing row delegate for \a row will be removed, but not    deleted. QAbstractItemView does not take ownership of \a delegate.    \note If a delegate has been assigned to both a row and a column, the row    delegate (i.e., this delegate) will take presedence and manage the    intersecting cell index.    \warning You should not share the same instance of a delegate between views.    Doing so can cause incorrect or unintuitive editing behavior since each    view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}    signal, and attempt to access, modify or close an editor that has already been closed.    \sa itemDelegateForRow(), setItemDelegateForColumn(), itemDelegate()*/void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *delegate){    Q_D(QAbstractItemView);    if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) {        if (d->delegateRefCount(rowDelegate) == 1) {            disconnect(rowDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                       this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            disconnect(rowDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }    }    if (delegate) {        if (d->delegateRefCount(delegate) == 0) {            connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                    this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }        d->rowDelegates.insert(row, delegate);    } else {        d->rowDelegates.remove(row);    }}/*!   \since 4.2   Returns the item delegate used by this view and model for the given \a row,   or 0 if no delegate has been assigned. You can call itemDelegate() to get a   pointer to the current delegate for a given index.   \sa setItemDelegateForRow(), itemDelegateForColumn(), setItemDelegate()*/QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const{    Q_D(const QAbstractItemView);    return d->rowDelegates.value(row, 0);}/*!    \since 4.2    Sets the given item \a delegate used by this view and model for the given    \a column. All items on \a column will be drawn and managed by \a delegate    instead of using the default delegate (i.e., itemDelegate()).    Any existing column delegate for \a column will be removed, but not    deleted. QAbstractItemView does not take ownership of \a delegate.    \note If a delegate has been assigned to both a row and a column, the row    delegate will take presedence and manage the intersecting cell index.    \warning You should not share the same instance of a delegate between views.    Doing so can cause incorrect or unintuitive editing behavior since each    view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}    signal, and attempt to access, modify or close an editor that has already been closed.    \sa itemDelegateForColumn(), setItemDelegateForRow(), itemDelegate()*/void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate){    Q_D(QAbstractItemView);    if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) {        if (d->delegateRefCount(columnDelegate) == 1) {            disconnect(columnDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                       this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            disconnect(columnDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }    }    if (delegate) {        if (d->delegateRefCount(delegate) == 0) {            connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),                    this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));            connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));        }        d->columnDelegates.insert(column, delegate);    } else {        d->columnDelegates.remove(column);    }}/*!    \since 4.2    Returns the item delegate used by this view and model for the given \a    column.  You can call itemDelegate() to get a pointer to the current delegate    for a given index.    \sa setItemDelegateForColumn(), itemDelegateForRow(), itemDelegate()*/QAbstractItemDelegate *QAbstractItemView::itemDelegateForColumn(int column) const{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -