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

📄 qabstractitemview_p.h

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 H
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef QABSTRACTITEMVIEW_P_H#define QABSTRACTITEMVIEW_P_H////  W A R N I N G//  -------------//// This file is not part of the Qt API.  It exists purely as an// implementation detail.  This header file may change from version to// version without notice, or even be removed.//// We mean it.//#include "private/qabstractscrollarea_p.h"#include "QtGui/qapplication.h"#include "QtCore/qdatetime.h"#include "QtGui/qevent.h"#include "QtGui/qmime.h"#include "QtCore/qpair.h"#include "QtCore/qtimer.h"#include "QtGui/qregion.h"#include "QtCore/qdebug.h"#ifndef QT_NO_ITEMVIEWStypedef QList<QPair<QPersistentModelIndex, QPointer<QWidget> > > _q_abstractitemview_editor_container;typedef _q_abstractitemview_editor_container::const_iterator _q_abstractitemview_editor_const_iterator;typedef _q_abstractitemview_editor_container::iterator _q_abstractitemview_editor_iterator;class Q_GUI_EXPORT QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate{    Q_DECLARE_PUBLIC(QAbstractItemView)public:    QAbstractItemViewPrivate();    virtual ~QAbstractItemViewPrivate();    void init();    void _q_rowsRemoved(const QModelIndex &parent, int start, int end);    void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);    void _q_columnsRemoved(const QModelIndex &parent, int start, int end);    void fetchMore();    bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const;    bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const;    bool shouldAutoScroll(const QPoint &pos) const;    void doDelayedItemsLayout();    QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options);    bool sendDelegateEvent(const QModelIndex &index, QEvent *event) const;    bool openEditor(const QModelIndex &index, QEvent *event);    QItemSelectionModel::SelectionFlags multiSelectionCommand(const QModelIndex &index,                                                              const QEvent *event) const;    QItemSelectionModel::SelectionFlags extendedSelectionCommand(const QModelIndex &index,                                                                 const QEvent *event) const;    QItemSelectionModel::SelectionFlags contiguousSelectionCommand(const QModelIndex &index,                                                                   const QEvent *event) const;    inline QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const    {        switch (selectionBehavior) {        case QAbstractItemView::SelectRows: return QItemSelectionModel::Rows;        case QAbstractItemView::SelectColumns: return QItemSelectionModel::Columns;        case QAbstractItemView::SelectItems: default: return QItemSelectionModel::NoUpdate;        }    }#ifndef QT_NO_DRAGANDDROP    inline bool canDecode(QDropEvent *e) const {        if (!model)            return false;        QStringList modelTypes = model->mimeTypes();        const QMimeData *mime = e->mimeData();        for (int i = 0; i < modelTypes.count(); ++i)            if (mime->hasFormat(modelTypes.at(i))                && (e->proposedAction() & model->supportedDropActions()))                return true;        return false;    }    inline void paintDropIndicator(QPainter *painter)    {        if (showDropIndicator && state == QAbstractItemView::DraggingState)            if (dropIndicatorRect.height() == 0) // FIXME: should be painted by style                painter->drawLine(dropIndicatorRect.topLeft(), dropIndicatorRect.topRight());            else painter->drawRect(dropIndicatorRect);    }    inline QAbstractItemView::DropIndicatorPosition position(const QPoint &pos,                                                             const QRect &rect,                                                             int margin) const {        if (pos.y() - rect.top() < margin) return QAbstractItemView::AboveItem;        if (rect.bottom() - pos.y() < margin) return QAbstractItemView::BelowItem;        if (rect.contains(pos, true)) return QAbstractItemView::OnItem;        return QAbstractItemView::OnViewport;    }#endif    inline void releaseEditor(QWidget *editor) const {        if (editor) {            QObject::disconnect(editor, SIGNAL(destroyed(QObject*)),                                q_func(), SLOT(editorDestroyed(QObject*)));            editor->removeEventFilter(delegate);            editor->hide(); // change the focus to the next widget            QTimer::singleShot(0, editor, SLOT(deleteLater())); // delete even later        }    }    inline void executePostedLayout() const {        if (delayedLayout.isActive() && state != QAbstractItemView::CollapsingState) {            delayedLayout.stop();            const_cast<QAbstractItemView*>(q_func())->doItemsLayout();        }    }    inline void setDirtyRegion(const QRegion &visualRegion) {        updateRegion += visualRegion;        if (!updateTimer.isActive())            updateTimer.start(0, q_func());    }    inline void scrollDirtyRegion(int dx, int dy) {        scrollDelayOffset = QPoint(-dx, -dy);        updateDirtyRegion();        scrollDelayOffset = QPoint(0, 0);    }    inline void scrollContentsBy(int dx, int dy) {        scrollDirtyRegion(dx, dy);        viewport->scroll(dx, dy);    }    void updateDirtyRegion() {        updateTimer.stop();        viewport->update(updateRegion);        updateRegion = QRegion();    }    void removeSelectedRows();    virtual bool selectionAllowed(const QModelIndex &index) const {        // in some views we want to go ahead with selections, even if the index is invalid        return index.isValid();    }    inline QPoint offset() const {        const Q_Q(QAbstractItemView);        return QPoint(q->isRightToLeft() ? -q->horizontalOffset()                      : q->horizontalOffset(), q->verticalOffset());    }    QWidget *editorForIndex(const QModelIndex &index) const;    inline bool hasEditor(const QModelIndex &index) const {        return editorForIndex(index) != 0;    }    QModelIndex indexForEditor(QWidget *editor) const;    void addEditor(const QModelIndex &index, QWidget *editor);    void removeEditor(QWidget *editor);    inline QModelIndex indexForIterator(const _q_abstractitemview_editor_iterator &it) const {        return (*it).first;    }    inline QWidget *editorForIterator(const _q_abstractitemview_editor_iterator &it) const {        return (*it).second;    }    inline QModelIndex indexForIterator(const _q_abstractitemview_editor_const_iterator &it) const {        return (*it).first;    }    inline QWidget *editorForIterator(const _q_abstractitemview_editor_const_iterator &it) const {        return (*it).second;    }    QPointer<QAbstractItemModel> model;    QPointer<QAbstractItemDelegate> delegate;    QPointer<QItemSelectionModel> selectionModel;    QAbstractItemView::SelectionMode selectionMode;    QAbstractItemView::SelectionBehavior selectionBehavior;    _q_abstractitemview_editor_container editors;    QList<QWidget*> persistent;    QPersistentModelIndex enteredIndex;    QPersistentModelIndex pressedIndex;    Qt::KeyboardModifiers pressedModifiers;    QPoint pressedPosition;    QAbstractItemView::State state;    QAbstractItemView::EditTriggers editTriggers;    QPersistentModelIndex root;    QPersistentModelIndex hover;    int horizontalStepsPerItem;    int verticalStepsPerItem;    bool tabKeyNavigation;#ifndef QT_NO_DRAGANDDROP    bool showDropIndicator;    QRect dropIndicatorRect;    bool dragEnabled;    QAbstractItemView::DropIndicatorPosition dropIndicatorPosition;#endif    QString keyboardInput;    QTime keyboardInputTime;    bool autoScroll;    QBasicTimer autoScrollTimer;    int autoScrollMargin;    int autoScrollInterval;    int autoScrollCount;    bool alternatingColors;    QSize iconSize;    Qt::TextElideMode textElideMode;    QRegion updateRegion; // used for the internal update system    QPoint scrollDelayOffset;    QBasicTimer updateTimer;    QBasicTimer delayedEditing;    mutable QBasicTimer delayedLayout;};#include <qvector.h>template <typename T>inline int qBinarySearch(const QVector<T> &vec, const T &item, int start, int end){    int i = (start + end + 1) >> 1;    while (end - start > 0) {        if (vec.at(i) > item)            end = i - 1;        else            start = i;        i = (start + end + 1) >> 1;    }    return i;}#endif // QT_NO_ITEMVIEWS#endif // QABSTRACTITEMVIEW_P_H

⌨️ 快捷键说明

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