QAbstractItemView

Класс QAbstractItemView объявляет необходимый минимум методов для реализации своего визуального представления таблицы. Ниже необходимые функции для переопределения.

От QAbstractItemView наследуются к примеру классы QTableview и QHeaderView.

#include "qzabstractitemview.h"

QzAbstractItemView::QzAbstractItemView(QWidget *parent) :
    QAbstractItemView(parent)
{
}


QRect QzAbstractItemView::visualRect(const QModelIndex &index) const
{
    return QRect();
}

void QzAbstractItemView::scrollTo(const QModelIndex &index, ScrollHint hint )
{

}

QModelIndex QzAbstractItemView::indexAt(const QPoint &point) const
{
    return QModelIndex();
}

int QzAbstractItemView::horizontalOffset() const
{
    //QAbstractItemView::horizontalOffset();
    return -1;
}
int QzAbstractItemView::verticalOffset() const
{
    return -1;

}

bool QzAbstractItemView::isIndexHidden(const QModelIndex &index) const
{
    return true;
}

void QzAbstractItemView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
{


}

QRegion QzAbstractItemView::visualRegionForSelection(const QItemSelection &selection) const
{
    return QRegion();
}


QModelIndexList QzAbstractItemView::selectedIndexes() const
{
    return QModelIndexList();
}

bool QzAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEvent *event)
{
    return true;

}


QItemSelectionModel::SelectionFlags QzAbstractItemView::selectionCommand(const QModelIndex &index,
                                                                         const QEvent *event ) const
{
    return QItemSelectionModel::NoUpdate;
}


void QzAbstractItemView::setModel(QAbstractItemModel *model)
{

}

void QzAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel)
{

}

void QzAbstractItemView::keyboardSearch(const QString &search)
{

}


int QzAbstractItemView::sizeHintForRow(int row) const
{

    return -1;
}

int QzAbstractItemView::sizeHintForColumn(int column) const
{
    return -1;
}


QVariant QzAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const
{
    return 0;
}


void QzAbstractItemView::reset()
{

}

void QzAbstractItemView::setRootIndex(const QModelIndex &index)
{

}

void QzAbstractItemView::doItemsLayout()
{

}

void QzAbstractItemView::selectAll()
{

}



void QzAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{

}

void QzAbstractItemView::rowsInserted(const QModelIndex &parent, int start, int end)
{

}

void QzAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
{

}

void QzAbstractItemView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{

}

void QzAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{

}

void QzAbstractItemView::updateEditorData()
{

}

void QzAbstractItemView::updateEditorGeometries()
{

}

void QzAbstractItemView::updateGeometries()
{

}

void QzAbstractItemView::verticalScrollbarAction(int action)
{

}

void QzAbstractItemView::horizontalScrollbarAction(int action)
{

}

void QzAbstractItemView::verticalScrollbarValueChanged(int value)
{

}

void QzAbstractItemView::horizontalScrollbarValueChanged(int value)
{

}

void QzAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
{

}

void QzAbstractItemView::commitData(QWidget *editor)
{

}

void QzAbstractItemView::editorDestroyed(QObject *editor)
{

}


QModelIndex QzAbstractItemView::moveCursor(CursorAction cursorAction,
                                           Qt::KeyboardModifiers modifiers)
{

    return QModelIndex();
}


#ifndef QT_NO_DRAGANDDROP

void QzAbstractItemView::startDrag(Qt::DropActions supportedActions)
{

}
#endif


#ifndef QZABSTRACTIMTEMVIEW_H
#define QZABSTRACTIMTEMVIEW_H

#include 

class QzAbstractItemView : public QAbstractItemView
{
    Q_OBJECT
public:
    explicit QzAbstractItemView(QWidget *parent = 0);
    
    virtual void setModel(QAbstractItemModel *model);

    virtual void setSelectionModel(QItemSelectionModel *selectionModel);

    virtual void keyboardSearch(const QString &search);

    virtual int sizeHintForRow(int row) const;
    virtual int sizeHintForColumn(int column) const;

    virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;


    virtual QRect visualRect(const QModelIndex &index) const ;
    virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) ;
    virtual QModelIndex indexAt(const QPoint &point) const ;



public Q_SLOTS:
    virtual void reset();
    virtual void setRootIndex(const QModelIndex &index);
    virtual void doItemsLayout();
    virtual void selectAll();

protected Q_SLOTS:
    virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
    virtual void rowsInserted(const QModelIndex &parent, int start, int end);
    virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
    virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
    virtual void updateEditorData();
    virtual void updateEditorGeometries();
    virtual void updateGeometries();
    virtual void verticalScrollbarAction(int action);
    virtual void horizontalScrollbarAction(int action);
    virtual void verticalScrollbarValueChanged(int value);
    virtual void horizontalScrollbarValueChanged(int value);
    virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
    virtual void commitData(QWidget *editor);
    virtual void editorDestroyed(QObject *editor);

protected:

    virtual QModelIndex moveCursor(CursorAction cursorAction,
                                   Qt::KeyboardModifiers modifiers);

    virtual int horizontalOffset() const ;
    virtual int verticalOffset() const;

    virtual bool isIndexHidden(const QModelIndex &index) const;

    virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
    virtual QRegion visualRegionForSelection(const QItemSelection &selection) const ;

    virtual QModelIndexList selectedIndexes() const;

    virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);

    virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
                                                                 const QEvent *event = 0) const;


#ifndef QT_NO_DRAGANDDROP
    virtual void startDrag(Qt::DropActions supportedActions);
#endif


    
};

#endif // QZABSTRACTIMTEMVIEW_H



Файлы для скачивания