Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QTreeViewPrivate Class Reference

#include <qtreeview_p.h>

Inheritance diagram for QTreeViewPrivate:
QAbstractItemViewPrivate QAbstractScrollAreaPrivate QFramePrivate QWidgetPrivate QObjectPrivate QObjectData QTreeWidgetPrivate

Classes

struct  AnimatedOperation
 

Public Functions

void _q_columnsAboutToBeRemoved (const QModelIndex &, int, int)
 This slot is called when columns are about to be removed. More...
 
void _q_columnsRemoved (const QModelIndex &, int, int)
 This slot is called when columns have been removed. More...
 
void _q_endAnimatedOperation ()
 
void _q_modelAboutToBeReset ()
 
void _q_modelDestroyed ()
 
void _q_sortIndicatorChanged (int column, Qt::SortOrder order)
 
int above (int item) const
 
int accessibleTable2Index (const QModelIndex &index) const
 
void adjustViewOptionsForIndex (QStyleOptionViewItemV4 *option, const QModelIndex &current) const
 
void beginAnimatedOperation ()
 
int below (int item) const
 
void calcLogicalIndices (QVector< int > *logicalIndices, QVector< QStyleOptionViewItemV4::ViewItemPosition > *itemPositions, int left, int right) const
 
void collapse (int item, bool emitSignal)
 
int columnAt (int x) const
 
QList< QPair< int, int > > columnRanges (const QModelIndex &topIndex, const QModelIndex &bottomIndex) const
 
int coordinateForItem (int item) const
 Returns the viewport y coordinate for item. More...
 
QItemViewPaintPairs draggablePaintPairs (const QModelIndexList &indexes, QRect *r) const
 Reimplemented Function More...
 
void drawAnimatedOperation (QPainter *painter) const
 
void expand (int item, bool emitSignal)
 
bool expandOrCollapseItemAtPos (const QPoint &pos)
 
int firstVisibleItem (int *offset=0) const
 
bool hasVisibleChildren (const QModelIndex &parent) const
 
int indentationForItem (int item) const
 
void initialize ()
 
void insertViewItems (int pos, int count, const QTreeViewItem &viewItem)
 
void invalidateHeightCache (int item) const
 
bool isIndexExpanded (const QModelIndex &idx) const
 
bool isItemHiddenOrDisabled (int i) const
 
bool isRowHidden (const QModelIndex &idx) const
 
int itemAtCoordinate (int coordinate) const
 Returns the index of the view item at the given viewport coordinate. More...
 
int itemDecorationAt (const QPoint &pos) const
 
QRect itemDecorationRect (const QModelIndex &index) const
 
int itemHeight (int item) const
 
void layout (int item, bool recusiveExpanding=false, bool afterIsUninitialized=false)
 
QModelIndex modelIndex (int i, int column=0) const
 
int pageDown (int item) const
 
int pageUp (int item) const
 
void paintAlternatingRowColors (QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const
 
void prepareAnimatedOperation (int item, QVariantAnimation::Direction d)
 
 QTreeViewPrivate ()
 
void removeViewItems (int pos, int count)
 
QPixmap renderTreeToPixmapForAnimation (const QRect &rect) const
 
void select (const QModelIndex &start, const QModelIndex &stop, QItemSelectionModel::SelectionFlags command)
 
QPair< int, int > startAndEndColumns (const QRect &rect) const
 
bool storeExpanded (const QPersistentModelIndex &idx)
 
void updateChildCount (const int parentItem, const int delta)
 
void updateScrollBars ()
 
int viewIndex (const QModelIndex &index) const
 
 ~QTreeViewPrivate ()
 
- Public Functions inherited from QAbstractItemViewPrivate
virtual void _q_columnsInserted (const QModelIndex &parent, int start, int end)
 This slot is called when columns have been inserted. More...
 
void _q_headerDataChanged ()
 
virtual void _q_layoutChanged ()
 This slot is called when the layout is changed. More...
 
virtual void _q_rowsInserted (const QModelIndex &parent, int start, int end)
 This slot is called when rows have been inserted. More...
 
virtual void _q_rowsRemoved (const QModelIndex &parent, int start, int end)
 This slot is called when rows have been removed. More...
 
void addEditor (const QModelIndex &index, QWidget *editor, bool isStatic)
 
bool canDecode (QDropEvent *e) const
 
void checkMouseMove (const QPersistentModelIndex &index)
 
void checkMouseMove (const QPoint &pos)
 
void checkPersistentEditorFocus ()
 When persistent aeditor gets/loses focus, we need to check and setcorrectly the current index. More...
 
void clearOrRemove ()
 In DND if something has been moved then this is called. More...
 
virtual QPoint contentsOffset () const
 
QItemSelectionModel::SelectionFlags contiguousSelectionCommand (const QModelIndex &index, const QEvent *event) const
 
QAbstractItemDelegatedelegateForIndex (const QModelIndex &index) const
 
int delegateRefCount (const QAbstractItemDelegate *delegate) const
 
void doDelayedItemsLayout (int delay=0)
 
void doDelayedReset ()
 
virtual bool dropOn (QDropEvent *event, int *row, int *col, QModelIndex *index)
 If the event hasn't already been accepted, determines the index to drop on. More...
 
bool droppingOnItself (QDropEvent *event, const QModelIndex &index)
 Return true if this is a move from ourself and index is a child of the selection that is being moved. More...
 
QWidgeteditor (const QModelIndex &index, const QStyleOptionViewItem &options)
 
const QEditorInfoeditorForIndex (const QModelIndex &index) const
 
void executePostedLayout () const
 
QItemSelectionModel::SelectionFlags extendedSelectionCommand (const QModelIndex &index, const QEvent *event) const
 
void fetchMore ()
 
bool hasEditor (const QModelIndex &index) const
 
QModelIndex indexForEditor (QWidget *editor) const
 
void init ()
 
void interruptDelayedItemsLayout () const
 
bool isAnimating () const
 
bool isIndexDragEnabled (const QModelIndex &index) const
 
bool isIndexDropEnabled (const QModelIndex &index) const
 
bool isIndexEnabled (const QModelIndex &index) const
 
bool isIndexSelectable (const QModelIndex &index) const
 
bool isIndexValid (const QModelIndex &index) const
 
bool isPersistent (const QModelIndex &index) const
 
QItemSelectionModel::SelectionFlags multiSelectionCommand (const QModelIndex &index, const QEvent *event) const
 
QPoint offset () const
 
bool openEditor (const QModelIndex &index, QEvent *event)
 
void paintDropIndicator (QPainter *painter)
 
virtual QAbstractItemView::DropIndicatorPosition position (const QPoint &pos, const QRect &rect, const QModelIndex &idx) const
 
 QAbstractItemViewPrivate ()
 
void releaseEditor (QWidget *editor) const
 
void removeEditor (QWidget *editor)
 
QPixmap renderToPixmap (const QModelIndexList &indexes, QRect *r) const
 
void scrollContentsBy (int dx, int dy)
 
void scrollDirtyRegion (int dx, int dy)
 
virtual void selectAll (QItemSelectionModel::SelectionFlags command)
 
QModelIndexList selectedDraggableIndexes () const
 
virtual bool selectionAllowed (const QModelIndex &index) const
 
QItemSelectionModel::SelectionFlags selectionBehaviorFlags () const
 
bool sendDelegateEvent (const QModelIndex &index, QEvent *event) const
 
void setDirtyRegion (const QRegion &visualRegion)
 
void setHoverIndex (const QPersistentModelIndex &index)
 
bool shouldAutoScroll (const QPoint &pos) const
 
bool shouldEdit (QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const
 
bool shouldForwardEvent (QAbstractItemView::EditTrigger trigger, const QEvent *event) const
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void updateDirtyRegion ()
 
void updateEditorData (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
QStyleOptionViewItemV4 viewOptionsV4 () const
 
virtual ~QAbstractItemViewPrivate ()
 
- Public Functions inherited from QAbstractScrollAreaPrivate
void _q_hslide (int)
 
void _q_showOrHideScrollBars ()
 
void _q_vslide (int)
 
void init ()
 
void layoutChildren ()
 
 QAbstractScrollAreaPrivate ()
 
void replaceScrollBar (QScrollBar *scrollBar, Qt::Orientation orientation)
 
virtual void scrollBarPolicyChanged (Qt::Orientation, Qt::ScrollBarPolicy)
 
void setSingleFingerPanEnabled (bool on=true)
 
bool viewportEvent (QEvent *event)
 
- Public Functions inherited from QFramePrivate
void init ()
 
 QFramePrivate ()
 
void updateFrameWidth ()
 Updated the frameWidth parameter. More...
 
void updateStyledFrameWidths ()
 Updates the frame widths from the style. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

bool allColumnsShowFocus
 
QTreeViewPrivate::AnimatedOperation animatedOperation
 
bool animationsEnabled
 
int autoExpandDelay
 
int columnResizeTimerID
 
QList< int > columnsToUpdate
 
int current
 
int defaultItemHeight
 
QSet< QPersistentModelIndexexpandedIndexes
 
bool expandsOnDoubleClick
 
bool geometryRecursionBlock
 
bool hasRemovedItems
 
QHeaderViewheader
 
QSet< QPersistentModelIndexhiddenIndexes
 
int hoverBranch
 
int indent
 
bool itemsExpandable
 
int lastViewedItem
 
QPair< int, int > leftAndRight
 
QBasicTimer openTimer
 
bool rootDecoration
 
bool sortingEnabled
 
bool spanning
 
QVector< QPersistentModelIndexspanningIndexes
 
bool uniformRowHeights
 
QVector< QTreeViewItemviewItems
 
- Public Variables inherited from QAbstractItemViewPrivate
bool alternatingColors
 
bool autoScroll
 
int autoScrollCount
 
int autoScrollMargin
 
QBasicTimer autoScrollTimer
 
QMap< int, QPointer< QAbstractItemDelegate > > columnDelegates
 
QItemSelectionModel::SelectionFlag ctrlDragSelectionFlag
 
bool currentIndexSet
 
QWidgetcurrentlyCommittingEditor
 
Qt::DropAction defaultDropAction
 
QBasicTimer delayedAutoScroll
 
QBasicTimer delayedEditing
 
bool delayedPendingLayout
 
QBasicTimer delayedReset
 
QAbstractItemView::DragDropMode dragDropMode
 
bool dragEnabled
 
QAbstractItemView::DropIndicatorPosition dropIndicatorPosition
 
QRect dropIndicatorRect
 
QEditorIndexHash editorIndexHash
 
QAbstractItemView::EditTriggers editTriggers
 
QPersistentModelIndex enteredIndex
 
QAbstractItemView::ScrollMode horizontalScrollMode
 
QPersistentModelIndex hover
 
QSize iconSize
 
QIndexEditorHash indexEditorHash
 
QPointer< QAbstractItemDelegateitemDelegate
 
QString keyboardInput
 
QElapsedTimer keyboardInputTime
 
QAbstractItemView::EditTrigger lastTrigger
 
QAbstractItemModelmodel
 
bool moveCursorUpdatedView
 
bool noSelectionOnMousePress
 
bool overwrite
 
QSet< QWidget * > persistent
 
bool pressedAlreadySelected
 
QPersistentModelIndex pressedIndex
 
Qt::KeyboardModifiers pressedModifiers
 
QPoint pressedPosition
 
QPersistentModelIndex root
 
QMap< int, QPointer< QAbstractItemDelegate > > rowDelegates
 
QPoint scrollDelayOffset
 
QAbstractItemView::SelectionBehavior selectionBehavior
 
QAbstractItemView::SelectionMode selectionMode
 
QPointer< QItemSelectionModelselectionModel
 
bool shouldClearStatusTip
 
bool shouldScrollToCurrentOnShow
 
bool showDropIndicator
 
QAbstractItemView::State state
 
QAbstractItemView::State stateBeforeAnimation
 
bool tabKeyNavigation
 
Qt::TextElideMode textElideMode
 
QRegion updateRegion
 
QBasicTimer updateTimer
 
QAbstractItemView::ScrollMode verticalScrollMode
 
bool viewportEnteredNeeded
 
bool wrapItemText
 
- Public Variables inherited from QAbstractScrollAreaPrivate
int bottom
 
QRect cornerPaintingRect
 
QWidgetcornerWidget
 
QScrollBarhbar
 
Qt::ScrollBarPolicy hbarpolicy
 
int left
 
QRect reverseCornerPaintingRect
 
int right
 
QAbstractScrollAreaScrollBarContainerscrollBarContainers [Qt::Vertical+1]
 
bool singleFingerPanEnabled
 
int top
 
QScrollBarvbar
 
Qt::ScrollBarPolicy vbarpolicy
 
QWidgetviewport
 
QScopedPointer< QObjectviewportFilter
 
int xoffset
 
int yoffset
 
- Public Variables inherited from QFramePrivate
short bottomFrameWidth
 
int frameStyle
 
short frameWidth
 
QRect frect
 
short leftFrameWidth
 
short lineWidth
 
short midLineWidth
 
short rightFrameWidth
 
short topFrameWidth
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 81 of file qtreeview_p.h.

Constructors and Destructors

◆ QTreeViewPrivate()

QTreeViewPrivate::QTreeViewPrivate ( )
inline

Definition at line 86 of file qtreeview_p.h.

89  uniformRowHeights(false), rootDecoration(true),
90  itemsExpandable(true), sortingEnabled(false),
92  allColumnsShowFocus(false), current(0), spanning(false),
bool expandsOnDoubleClick
Definition: qtreeview_p.h:185
bool allColumnsShowFocus
Definition: qtreeview_p.h:186
QHeaderView * header
Definition: qtreeview_p.h:175
bool geometryRecursionBlock
Definition: qtreeview_p.h:250

◆ ~QTreeViewPrivate()

QTreeViewPrivate::~QTreeViewPrivate ( )
inline

Definition at line 96 of file qtreeview_p.h.

96 {}

Functions

◆ _q_columnsAboutToBeRemoved()

void QTreeViewPrivate::_q_columnsAboutToBeRemoved ( const QModelIndex parent,
int  start,
int  end 
)
virtual

This slot is called when columns are about to be removed.

Warning
This function is not part of the public interface.

The deleted columns are those under the given parent from start to end inclusive.

Reimplemented from QAbstractItemViewPrivate.

Definition at line 3199 of file qtreeview.cpp.

3200 {
3201  if (start <= 0 && 0 <= end)
3202  viewItems.clear();
3204 }
virtual void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
This slot is called when columns are about to be removed.
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
static const KeyPair *const end

◆ _q_columnsRemoved()

void QTreeViewPrivate::_q_columnsRemoved ( const QModelIndex index,
int  start,
int  end 
)
virtual

This slot is called when columns have been removed.

Warning
This function is not part of the public interface.

The deleted rows are those under the given parent from start to end inclusive.

Reimplemented from QAbstractItemViewPrivate.

Definition at line 3206 of file qtreeview.cpp.

3207 {
3208  if (start <= 0 && 0 <= end)
3211 }
void doDelayedItemsLayout(int delay=0)
virtual void _q_columnsRemoved(const QModelIndex &parent, int start, int end)
This slot is called when columns have been removed.
QObject * parent
Definition: qobject.h:92
static const KeyPair *const end

◆ _q_endAnimatedOperation()

void QTreeViewPrivate::_q_endAnimatedOperation ( )

Definition at line 3185 of file qtreeview.cpp.

3186 {
3187  Q_Q(QTreeView);
3188  q->setState(stateBeforeAnimation);
3189  q->updateGeometries();
3190  viewport->update();
3191 }
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QAbstractItemView::State stateBeforeAnimation
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58

◆ _q_modelAboutToBeReset()

void QTreeViewPrivate::_q_modelAboutToBeReset ( )

Definition at line 3194 of file qtreeview.cpp.

3195 {
3196  viewItems.clear();
3197 }
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ _q_modelDestroyed()

void QTreeViewPrivate::_q_modelDestroyed ( )
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractItemViewPrivate.

Definition at line 1385 of file qtreeview.cpp.

1386 {
1387  //we need to clear that list because it contais QModelIndex to
1388  //the model currently being destroyed
1389  viewItems.clear();
1391 }
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ _q_sortIndicatorChanged()

void QTreeViewPrivate::_q_sortIndicatorChanged ( int  column,
Qt::SortOrder  order 
)

Definition at line 3813 of file qtreeview.cpp.

3814 {
3815  model->sort(column, order);
3816 }
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
Sorts the model by column in the given order.
QAbstractItemModel * model

◆ above()

int QTreeViewPrivate::above ( int  item) const
inline

Definition at line 224 of file qtreeview_p.h.

225  { int i = item; while (isItemHiddenOrDisabled(--item)){} return item < 0 ? i : item; }
bool isItemHiddenOrDisabled(int i) const
Definition: qtreeview_p.h:217

◆ accessibleTable2Index()

int QTreeViewPrivate::accessibleTable2Index ( const QModelIndex index) const
inline

Definition at line 231 of file qtreeview_p.h.

231  {
232  return (viewIndex(index) + (header ? 1 : 0)) * model->columnCount()+index.column() + 1;
233  }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
int viewIndex(const QModelIndex &index) const
Definition: qtreeview.cpp:3467
QHeaderView * header
Definition: qtreeview_p.h:175
QAbstractItemModel * model
int column() const
Returns the column this model index refers to.

◆ adjustViewOptionsForIndex()

void QTreeViewPrivate::adjustViewOptionsForIndex ( QStyleOptionViewItemV4 option,
const QModelIndex current 
) const
virtual

Reimplemented from QAbstractItemViewPrivate.

Definition at line 1413 of file qtreeview.cpp.

1414 {
1415  const int row = viewIndex(current); // get the index in viewItems[]
1416  option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None)
1419 
1421  || option->showDecorationSelected;
1422 
1423  QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index.
1424  QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only.
1425  const bool spanning = viewItems.at(row).spanning;
1426  const int left = (spanning ? header->visualIndex(0) : 0);
1427  const int right = (spanning ? header->visualIndex(0) : header->count() - 1 );
1428  calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
1429 
1430  int columnIndex = 0;
1431  for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) {
1432  int logicalIndex = header->logicalIndex(visualIndex);
1433  if (!header->isSectionHidden(logicalIndex)) {
1434  ++columnIndex;
1435  }
1436  }
1437 
1438  option->viewItemPosition = viewItemPosList.at(columnIndex);
1439 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
int visualIndex(int logicalIndex) const
Returns the visual index position of the section specified by the given logicalIndex, or -1 otherwise.
QAbstractItemView::SelectionBehavior selectionBehavior
bool isSectionHidden(int logicalIndex) const
Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise r...
void calcLogicalIndices(QVector< int > *logicalIndices, QVector< QStyleOptionViewItemV4::ViewItemPosition > *itemPositions, int left, int right) const
Definition: qtreeview.cpp:1532
int viewIndex(const QModelIndex &index) const
Definition: qtreeview.cpp:3467
bool showDecorationSelected
whether the decoration should be highlighted on selected items
Definition: qstyleoption.h:553
uint hasMoreSiblings
Definition: qtreeview_p.h:73
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
ViewItemPosition viewItemPosition
Gives the position of this view item relative to other items.
Definition: qstyleoption.h:619
int logicalIndex(int visualIndex) const
Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 ...
int count() const
Returns the number of sections in the header.
uint hasChildren
Definition: qtreeview_p.h:72
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
QHeaderView * header
Definition: qtreeview_p.h:175
int column() const
Returns the column this model index refers to.

◆ beginAnimatedOperation()

void QTreeViewPrivate::beginAnimatedOperation ( )

Definition at line 3111 of file qtreeview.cpp.

3112 {
3113  Q_Q(QTreeView);
3114 
3115  QRect rect = viewport->rect();
3116  rect.setTop(animatedOperation.top());
3118  const int limit = rect.height() * 2;
3119  int h = 0;
3121  for (int i = animatedOperation.item + 1; i < c && h < limit; ++i)
3122  h += itemHeight(i);
3123  rect.setHeight(h);
3125  }
3126 
3127  if (!rect.isEmpty()) {
3129 
3130  q->setState(QAbstractItemView::AnimatingState);
3131  animatedOperation.start(); //let's start the animation
3132  }
3133 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
unsigned char c[8]
Definition: qnumeric_p.h:62
QTreeViewPrivate::AnimatedOperation animatedOperation
QPixmap renderTreeToPixmapForAnimation(const QRect &rect) const
Definition: qtreeview.cpp:3147
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setEndValue(const QVariant &value)
#define Q_Q(Class)
Definition: qglobal.h:2483
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
Direction direction() const

◆ below()

int QTreeViewPrivate::below ( int  item) const
inline

Definition at line 226 of file qtreeview_p.h.

227  { int i = item; while (isItemHiddenOrDisabled(++item)){} return item >= viewItems.count() ? i : item; }
bool isItemHiddenOrDisabled(int i) const
Definition: qtreeview_p.h:217
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ calcLogicalIndices()

void QTreeViewPrivate::calcLogicalIndices ( QVector< int > *  logicalIndices,
QVector< QStyleOptionViewItemV4::ViewItemPosition > *  itemPositions,
int  left,
int  right 
) const

Definition at line 1532 of file qtreeview.cpp.

1533 {
1534  const int columnCount = header->count();
1535  /* 'left' and 'right' are the left-most and right-most visible visual indices.
1536  Compute the first visible logical indices before and after the left and right.
1537  We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */
1538  int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
1539  for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {
1540  int logicalIndex = header->logicalIndex(visualIndex);
1541  if (!header->isSectionHidden(logicalIndex)) {
1542  logicalIndexBeforeLeft = logicalIndex;
1543  break;
1544  }
1545  }
1546 
1547  for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) {
1548  int logicalIndex = header->logicalIndex(visualIndex);
1549  if (!header->isSectionHidden(logicalIndex)) {
1550  if (visualIndex > right) {
1551  logicalIndexAfterRight = logicalIndex;
1552  break;
1553  }
1554  logicalIndices->append(logicalIndex);
1555  }
1556  }
1557 
1558  itemPositions->resize(logicalIndices->count());
1559  for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) {
1560  const int headerSection = logicalIndices->at(currentLogicalSection);
1561  // determine the viewItemPosition depending on the position of column 0
1562  int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count()
1563  ? logicalIndexAfterRight
1564  : logicalIndices->at(currentLogicalSection + 1);
1565  int prevLogicalSection = currentLogicalSection - 1 < 0
1566  ? logicalIndexBeforeLeft
1567  : logicalIndices->at(currentLogicalSection - 1);
1569  if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)
1570  || (headerSection == 0 && nextLogicalSection == -1) || spanning)
1572  else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1))
1574  else if (nextLogicalSection == 0 || nextLogicalSection == -1)
1576  else
1578  (*itemPositions)[currentLogicalSection] = pos;
1579  }
1580 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
ViewItemPosition
This enum is used to represent the placement of the item on a row.
Definition: qstyleoption.h:613
bool isSectionHidden(int logicalIndex) const
Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise r...
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int logicalIndex(int visualIndex) const
Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 ...
int count() const
Returns the number of sections in the header.
QHeaderView * header
Definition: qtreeview_p.h:175

◆ collapse()

void QTreeViewPrivate::collapse ( int  item,
bool  emitSignal 
)

Definition at line 3042 of file qtreeview.cpp.

3043 {
3044  Q_Q(QTreeView);
3045 
3046  if (item == -1 || expandedIndexes.isEmpty())
3047  return;
3048 
3049  //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll
3051 
3052  int total = viewItems.at(item).total;
3053  const QModelIndex &modelIndex = viewItems.at(item).index;
3054  if (!isPersistent(modelIndex))
3055  return; // if the index is not persistent, no chances it is expanded
3057  if (it == expandedIndexes.end() || viewItems.at(item).expanded == false)
3058  return; // nothing to do
3059 
3060 #ifndef QT_NO_ANIMATION
3061  if (emitSignal && animationsEnabled)
3063 #endif //QT_NO_ANIMATION
3064 
3065  //if already animating, stateBeforeAnimation is set to the correct value
3069  expandedIndexes.erase(it);
3070  viewItems[item].expanded = false;
3071  int index = item;
3072  while (index > -1) {
3073  viewItems[index].total -= total;
3074  index = viewItems[index].parentItem;
3075  }
3076  removeViewItems(item + 1, total); // collapse
3077  q->setState(stateBeforeAnimation);
3078 
3079  if (emitSignal) {
3080  emit q->collapsed(modelIndex);
3081 #ifndef QT_NO_ANIMATION
3082  if (animationsEnabled)
3084 #endif //QT_NO_ANIMATION
3085  }
3086 }
void prepareAnimatedOperation(int item, QVariantAnimation::Direction d)
Definition: qtreeview.cpp:3089
#define it(className, varName)
QSet< QPersistentModelIndex > expandedIndexes
Definition: qtreeview_p.h:194
QAbstractItemView::State state
bool isEmpty() const
Definition: qset.h:77
QModelIndex modelIndex(int i, int column=0) const
Definition: qtreeview.cpp:3511
#define Q_Q(Class)
Definition: qglobal.h:2483
QAbstractItemView::State stateBeforeAnimation
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
#define emit
Definition: qobjectdefs.h:76
iterator end()
Definition: qset.h:169
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void stop()
Stops the timer.
The QModelIndex class is used to locate data in a data model.
bool isPersistent(const QModelIndex &index) const
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index
void removeViewItems(int pos, int count)
Definition: qtreeview.cpp:3010
iterator erase(iterator i)
Definition: qset.h:172
iterator find(const T &value)
Definition: qset.h:182
void beginAnimatedOperation()
Definition: qtreeview.cpp:3111

◆ columnAt()

int QTreeViewPrivate::columnAt ( int  x) const

Definition at line 3551 of file qtreeview.cpp.

3552 {
3553  return header->logicalIndexAt(x);
3554 }
int logicalIndexAt(int position) const
Returns the section that covers the given position in the viewport.
QHeaderView * header
Definition: qtreeview_p.h:175

◆ columnRanges()

QList< QPair< int, int > > QTreeViewPrivate::columnRanges ( const QModelIndex topIndex,
const QModelIndex bottomIndex 
) const

Definition at line 3672 of file qtreeview.cpp.

3674 {
3675  const int topVisual = header->visualIndex(topIndex.column()),
3676  bottomVisual = header->visualIndex(bottomIndex.column());
3677 
3678  const int start = qMin(topVisual, bottomVisual);
3679  const int end = qMax(topVisual, bottomVisual);
3680 
3681  QList<int> logicalIndexes;
3682 
3683  //we iterate over the visual indexes to get the logical indexes
3684  for (int c = start; c <= end; c++) {
3685  const int logical = header->logicalIndex(c);
3686  if (!header->isSectionHidden(logical)) {
3687  logicalIndexes << logical;
3688  }
3689  }
3690  //let's sort the list
3691  qSort(logicalIndexes.begin(), logicalIndexes.end());
3692 
3693  QList<QPair<int, int> > ret;
3695  current.first = -2; // -1 is not enough because -1+1 = 0
3696  current.second = -2;
3697  for(int i = 0; i < logicalIndexes.count(); ++i) {
3698  const int logicalColumn = logicalIndexes.at(i);
3699  if (current.second + 1 != logicalColumn) {
3700  if (current.first != -2) {
3701  //let's save the current one
3702  ret += current;
3703  }
3704  //let's start a new one
3705  current.first = current.second = logicalColumn;
3706  } else {
3707  current.second++;
3708  }
3709  }
3710 
3711  //let's get the last range
3712  if (current.first != -2) {
3713  ret += current;
3714  }
3715 
3716  return ret;
3717 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int visualIndex(int logicalIndex) const
Returns the visual index position of the section specified by the given logicalIndex, or -1 otherwise.
T1 first
Definition: qpair.h:65
T2 second
Definition: qpair.h:66
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isSectionHidden(int logicalIndex) const
Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise r...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
int logicalIndex(int visualIndex) const
Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 ...
static const KeyPair *const end
QHeaderView * header
Definition: qtreeview_p.h:175
int column() const
Returns the column this model index refers to.

◆ coordinateForItem()

int QTreeViewPrivate::coordinateForItem ( int  item) const

Returns the viewport y coordinate for item.

Warning
This function is not part of the public interface.

Definition at line 3364 of file qtreeview.cpp.

3365 {
3367  if (uniformRowHeights)
3368  return (item * defaultItemHeight) - vbar->value();
3369  // ### optimize (spans or caching)
3370  int y = 0;
3371  for (int i = 0; i < viewItems.count(); ++i) {
3372  if (i == item)
3373  return y - vbar->value();
3374  y += itemHeight(i);
3375  }
3376  } else { // ScrollPerItem
3377  int topViewItemIndex = vbar->value();
3378  if (uniformRowHeights)
3379  return defaultItemHeight * (item - topViewItemIndex);
3380  if (item >= topViewItemIndex) {
3381  // search in the visible area first and continue down
3382  // ### slow if the item is not visible
3383  int viewItemCoordinate = 0;
3384  int viewItemIndex = topViewItemIndex;
3385  while (viewItemIndex < viewItems.count()) {
3386  if (viewItemIndex == item)
3387  return viewItemCoordinate;
3388  viewItemCoordinate += itemHeight(viewItemIndex);
3389  ++viewItemIndex;
3390  }
3391  // below the last item in the view
3392  Q_ASSERT(false);
3393  return viewItemCoordinate;
3394  } else {
3395  // search the area above the viewport (used for editor widgets)
3396  int viewItemCoordinate = 0;
3397  for (int viewItemIndex = topViewItemIndex; viewItemIndex > 0; --viewItemIndex) {
3398  if (viewItemIndex == item)
3399  return viewItemCoordinate;
3400  viewItemCoordinate -= itemHeight(viewItemIndex - 1);
3401  }
3402  return viewItemCoordinate;
3403  }
3404  }
3405  return 0;
3406 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int value() const
QAbstractItemView::ScrollMode verticalScrollMode
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ draggablePaintPairs()

QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs ( const QModelIndexList indexes,
QRect r 
) const
virtual

Reimplemented Function

We have a QTreeView way of knowing what elements are on the viewport

Reimplemented from QAbstractItemViewPrivate.

Definition at line 1398 of file qtreeview.cpp.

1399 {
1400  Q_ASSERT(r);
1401  Q_Q(const QTreeView);
1402  if (spanningIndexes.isEmpty())
1404  QModelIndexList list;
1405  foreach (const QModelIndex &idx, indexes) {
1406  if (idx.column() > 0 && q->isFirstColumnSpanned(idx.row(), idx.parent()))
1407  continue;
1408  list << idx;
1409  }
1411 }
virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
QVector< QPersistentModelIndex > spanningIndexes
Definition: qtreeview_p.h:236
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
int row() const
Returns the row this model index refers to.
The QModelIndex class is used to locate data in a data model.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
int column() const
Returns the column this model index refers to.

◆ drawAnimatedOperation()

void QTreeViewPrivate::drawAnimatedOperation ( QPainter painter) const

Definition at line 3135 of file qtreeview.cpp.

3136 {
3137  const int start = animatedOperation.startValue().toInt(),
3141  const QPixmap top = collapsing ? animatedOperation.before : animatedOperation.after;
3142  painter->drawPixmap(0, start, top, 0, end - current - 1, top.width(), top.height());
3144  painter->drawPixmap(0, current, bottom);
3145 }
QTreeViewPrivate::AnimatedOperation animatedOperation
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QVariant endValue() const
QVariant currentValue() const
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QVariant startValue() const
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
Direction direction() const
static const KeyPair *const end

◆ expand()

void QTreeViewPrivate::expand ( int  item,
bool  emitSignal 
)

Definition at line 2961 of file qtreeview.cpp.

2962 {
2963  Q_Q(QTreeView);
2964 
2965  if (item == -1 || viewItems.at(item).expanded)
2966  return;
2967 
2968 #ifndef QT_NO_ANIMATION
2969  if (emitSignal && animationsEnabled)
2971 #endif //QT_NO_ANIMATION
2972  //if already animating, stateBeforeAnimation is set to the correct value
2975  q->setState(QAbstractItemView::ExpandingState);
2976  const QModelIndex index = viewItems.at(item).index;
2977  storeExpanded(index);
2978  viewItems[item].expanded = true;
2979  layout(item);
2980  q->setState(stateBeforeAnimation);
2981 
2982  if (model->canFetchMore(index))
2983  model->fetchMore(index);
2984  if (emitSignal) {
2985  emit q->expanded(index);
2986 #ifndef QT_NO_ANIMATION
2987  if (animationsEnabled)
2989 #endif //QT_NO_ANIMATION
2990  }
2991 }
void prepareAnimatedOperation(int item, QVariantAnimation::Direction d)
Definition: qtreeview.cpp:3089
QAbstractItemView::State state
void layout(int item, bool recusiveExpanding=false, bool afterIsUninitialized=false)
Definition: qtreeview.cpp:3220
#define Q_Q(Class)
Definition: qglobal.h:2483
QAbstractItemView::State stateBeforeAnimation
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
#define emit
Definition: qobjectdefs.h:76
virtual bool canFetchMore(const QModelIndex &parent) const
Returns true if there is more data available for parent; otherwise returns false. ...
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
virtual void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
The QModelIndex class is used to locate data in a data model.
bool storeExpanded(const QPersistentModelIndex &idx)
Definition: qtreeview_p.h:197
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index
QAbstractItemModel * model
void beginAnimatedOperation()
Definition: qtreeview.cpp:3111

◆ expandOrCollapseItemAtPos()

bool QTreeViewPrivate::expandOrCollapseItemAtPos ( const QPoint pos)

Definition at line 1361 of file qtreeview.cpp.

1362 {
1363  Q_Q(QTreeView);
1364  // we want to handle mousePress in EditingState (persistent editors)
1367  || !viewport->rect().contains(pos))
1368  return true;
1369 
1370  int i = itemDecorationAt(pos);
1371  if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {
1372  if (viewItems.at(i).expanded)
1373  collapse(i, true);
1374  else
1375  expand(i, true);
1376  if (!isAnimating()) {
1377  q->updateGeometries();
1378  viewport->update();
1379  }
1380  return true;
1381  }
1382  return false;
1383 }
QAbstractItemView::State state
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
void expand(int item, bool emitSignal)
Definition: qtreeview.cpp:2961
bool hasVisibleChildren(const QModelIndex &parent) const
Definition: qtreeview.cpp:3794
void collapse(int item, bool emitSignal)
Definition: qtreeview.cpp:3042
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
int itemDecorationAt(const QPoint &pos) const
Definition: qtreeview.cpp:3629

◆ firstVisibleItem()

int QTreeViewPrivate::firstVisibleItem ( int *  offset = 0) const

Definition at line 3522 of file qtreeview.cpp.

3523 {
3524  const int value = vbar->value();
3526  if (offset)
3527  *offset = 0;
3528  return (value < 0 || value >= viewItems.count()) ? -1 : value;
3529  }
3530  // ScrollMode == ScrollPerPixel
3531  if (uniformRowHeights) {
3532  if (!defaultItemHeight)
3533  return -1;
3534 
3535  if (offset)
3536  *offset = -(value % defaultItemHeight);
3537  return value / defaultItemHeight;
3538  }
3539  int y = 0; // ### optimize (use spans ?)
3540  for (int i = 0; i < viewItems.count(); ++i) {
3541  y += itemHeight(i); // the height value is cached
3542  if (y > value) {
3543  if (offset)
3544  *offset = y - value - itemHeight(i);
3545  return i;
3546  }
3547  }
3548  return -1;
3549 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int value() const
QAbstractItemView::ScrollMode verticalScrollMode
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ hasVisibleChildren()

bool QTreeViewPrivate::hasVisibleChildren ( const QModelIndex parent) const

Definition at line 3794 of file qtreeview.cpp.

3795 {
3796  Q_Q(const QTreeView);
3797  if (model->hasChildren(parent)) {
3798  if (hiddenIndexes.isEmpty())
3799  return true;
3800  if (q->isIndexHidden(parent))
3801  return false;
3802  int rowCount = model->rowCount(parent);
3803  for (int i = 0; i < rowCount; ++i) {
3804  if (!q->isRowHidden(i, parent))
3805  return true;
3806  }
3807  if (rowCount == 0)
3808  return true;
3809  }
3810  return false;
3811 }
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
bool isEmpty() const
Definition: qset.h:77
#define Q_Q(Class)
Definition: qglobal.h:2483
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns true if parent has any children; otherwise returns false.
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
QSet< QPersistentModelIndex > hiddenIndexes
Definition: qtreeview_p.h:210
QAbstractItemModel * model

◆ indentationForItem()

int QTreeViewPrivate::indentationForItem ( int  item) const

Definition at line 3329 of file qtreeview.cpp.

3330 {
3331  if (item < 0 || item >= viewItems.count())
3332  return 0;
3333  int level = viewItems.at(item).level;
3334  if (rootDecoration)
3335  ++level;
3336  return level * indent;
3337 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ initialize()

void QTreeViewPrivate::initialize ( )

Definition at line 2942 of file qtreeview.cpp.

2943 {
2944  Q_Q(QTreeView);
2946  q->setSelectionBehavior(QAbstractItemView::SelectRows);
2947  q->setSelectionMode(QAbstractItemView::SingleSelection);
2948  q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
2949  q->setAttribute(Qt::WA_MacShowFocusRect);
2950 
2952  header->setMovable(true);
2953  header->setStretchLastSection(true);
2955  q->setHeader(header);
2956 #ifndef QT_NO_ANIMATION
2958 #endif //QT_NO_ANIMATION
2959 }
QTreeViewPrivate::AnimatedOperation animatedOperation
void setStretchLastSection(bool stretch)
void setDefaultAlignment(Qt::Alignment alignment)
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
void _q_endAnimatedOperation()
Definition: qtreeview.cpp:3185
void setMovable(bool movable)
If movable is true, the header may be moved by the user; otherwise it is fixed in place...
QHeaderView * header
Definition: qtreeview_p.h:175
void updateStyledFrameWidths()
Updates the frame widths from the style.
Definition: qframe.cpp:417
The QHeaderView class provides a header row or header column for item views.
Definition: qheaderview.h:58

◆ insertViewItems()

void QTreeViewPrivate::insertViewItems ( int  pos,
int  count,
const QTreeViewItem viewItem 
)

Definition at line 2993 of file qtreeview.cpp.

2994 {
2995  viewItems.insert(pos, count, viewItem);
2996  QTreeViewItem *items = viewItems.data();
2997  for (int i = pos + count; i < viewItems.count(); i++)
2998  if (items[i].parentItem >= pos)
2999  items[i].parentItem += count;
3000 #ifndef QT_NO_ACCESSIBILITY
3001 #ifdef Q_WS_X11
3002  Q_Q(QTreeView);
3003  if (QAccessible::isActive()) {
3005  }
3006 #endif
3007 #endif
3008 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_Q(Class)
Definition: qglobal.h:2483
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152

◆ invalidateHeightCache()

void QTreeViewPrivate::invalidateHeightCache ( int  item) const
inline

Definition at line 228 of file qtreeview_p.h.

229  { viewItems[item].height = 0; }
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ isIndexExpanded()

bool QTreeViewPrivate::isIndexExpanded ( const QModelIndex idx) const
inline

Definition at line 204 of file qtreeview_p.h.

204  {
205  //We first check if the idx is a QPersistentModelIndex, because creating QPersistentModelIndex is slow
206  return isPersistent(idx) && expandedIndexes.contains(idx);
207  }
QSet< QPersistentModelIndex > expandedIndexes
Definition: qtreeview_p.h:194
bool contains(const T &value) const
Definition: qset.h:91
bool isPersistent(const QModelIndex &index) const

◆ isItemHiddenOrDisabled()

bool QTreeViewPrivate::isItemHiddenOrDisabled ( int  i) const
inline

Definition at line 217 of file qtreeview_p.h.

217  {
218  if (i < 0 || i >= viewItems.count())
219  return false;
220  const QModelIndex index = viewItems.at(i).index;
221  return isRowHidden(index) || !isIndexEnabled(index);
222  }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool isIndexEnabled(const QModelIndex &index) const
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
bool isRowHidden(const QModelIndex &idx) const
Definition: qtreeview_p.h:212
The QModelIndex class is used to locate data in a data model.
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index

◆ isRowHidden()

bool QTreeViewPrivate::isRowHidden ( const QModelIndex idx) const
inline

Definition at line 212 of file qtreeview_p.h.

212  {
213  //We first check if the idx is a QPersistentModelIndex, because creating QPersistentModelIndex is slow
214  return isPersistent(idx) && hiddenIndexes.contains(idx);
215  }
bool contains(const T &value) const
Definition: qset.h:91
QSet< QPersistentModelIndex > hiddenIndexes
Definition: qtreeview_p.h:210
bool isPersistent(const QModelIndex &index) const

◆ itemAtCoordinate()

int QTreeViewPrivate::itemAtCoordinate ( int  coordinate) const

Returns the index of the view item at the given viewport coordinate.

Warning
This function is not part of the public interface.
See also
modelIndex()

Definition at line 3418 of file qtreeview.cpp.

3419 {
3420  const int itemCount = viewItems.count();
3421  if (itemCount == 0)
3422  return -1;
3424  return -1;
3426  if (uniformRowHeights) {
3427  const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight;
3428  return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
3429  }
3430  // ### optimize
3431  int viewItemCoordinate = 0;
3432  const int contentsCoordinate = coordinate + vbar->value();
3433  for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) {
3434  viewItemCoordinate += itemHeight(viewItemIndex);
3435  if (viewItemCoordinate >= contentsCoordinate)
3436  return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
3437  }
3438  } else { // ScrollPerItem
3439  int topViewItemIndex = vbar->value();
3440  if (uniformRowHeights) {
3441  if (coordinate < 0)
3442  coordinate -= defaultItemHeight - 1;
3443  const int viewItemIndex = topViewItemIndex + (coordinate / defaultItemHeight);
3444  return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
3445  }
3446  if (coordinate >= 0) {
3447  // the coordinate is in or below the viewport
3448  int viewItemCoordinate = 0;
3449  for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.count(); ++viewItemIndex) {
3450  viewItemCoordinate += itemHeight(viewItemIndex);
3451  if (viewItemCoordinate > coordinate)
3452  return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
3453  }
3454  } else {
3455  // the coordinate is above the viewport
3456  int viewItemCoordinate = 0;
3457  for (int viewItemIndex = topViewItemIndex; viewItemIndex >= 0; --viewItemIndex) {
3458  if (viewItemCoordinate <= coordinate)
3459  return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
3460  viewItemCoordinate -= itemHeight(viewItemIndex);
3461  }
3462  }
3463  }
3464  return -1;
3465 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int value() const
QAbstractItemView::ScrollMode verticalScrollMode
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ itemDecorationAt()

int QTreeViewPrivate::itemDecorationAt ( const QPoint pos) const

Definition at line 3629 of file qtreeview.cpp.

3630 {
3632  int x = pos.x();
3633  int column = header->logicalIndexAt(x);
3634  if (column != 0)
3635  return -1; // no logical index at x
3636 
3637  int viewItemIndex = itemAtCoordinate(pos.y());
3638  QRect returning = itemDecorationRect(modelIndex(viewItemIndex));
3639  if (!returning.contains(pos))
3640  return -1;
3641 
3642  return viewItemIndex;
3643 }
int itemAtCoordinate(int coordinate) const
Returns the index of the view item at the given viewport coordinate.
Definition: qtreeview.cpp:3418
QModelIndex modelIndex(int i, int column=0) const
Definition: qtreeview.cpp:3511
QRect itemDecorationRect(const QModelIndex &index) const
Definition: qtreeview.cpp:3645
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
int logicalIndexAt(int position) const
Returns the section that covers the given position in the viewport.
QHeaderView * header
Definition: qtreeview_p.h:175

◆ itemDecorationRect()

QRect QTreeViewPrivate::itemDecorationRect ( const QModelIndex index) const

Definition at line 3645 of file qtreeview.cpp.

3646 {
3647  Q_Q(const QTreeView);
3648  if (!rootDecoration && index.parent() == root)
3649  return QRect(); // no decoration at root
3650 
3651  int viewItemIndex = viewIndex(index);
3652  if (viewItemIndex < 0 || !hasVisibleChildren(viewItems.at(viewItemIndex).index))
3653  return QRect();
3654 
3655  int itemIndentation = indentationForItem(viewItemIndex);
3657  int size = header->sectionSize(0);
3658 
3659  QRect rect;
3660  if (q->isRightToLeft())
3661  rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex),
3662  indent, itemHeight(viewItemIndex));
3663  else
3664  rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex),
3665  indent, itemHeight(viewItemIndex));
3666  QStyleOption opt;
3667  opt.initFrom(q);
3668  opt.rect = rect;
3669  return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
3670 }
virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int coordinateForItem(int item) const
Returns the viewport y coordinate for item.
Definition: qtreeview.cpp:3364
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
int viewIndex(const QModelIndex &index) const
Definition: qtreeview.cpp:3467
int sectionViewportPosition(int logicalIndex) const
Returns the section viewport position of the given logicalIndex.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QPersistentModelIndex root
int sectionSize(int logicalIndex) const
Returns the width (or height for vertical headers) of the given logicalIndex.
bool hasVisibleChildren(const QModelIndex &parent) const
Definition: qtreeview.cpp:3794
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
int indentationForItem(int item) const
Definition: qtreeview.cpp:3329
QHeaderView * header
Definition: qtreeview_p.h:175
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ itemHeight()

int QTreeViewPrivate::itemHeight ( int  item) const

Definition at line 3339 of file qtreeview.cpp.

3340 {
3341  if (uniformRowHeights)
3342  return defaultItemHeight;
3343  if (viewItems.isEmpty())
3344  return 0;
3345  const QModelIndex &index = viewItems.at(item).index;
3346  if (!index.isValid())
3347  return 0;
3348  int height = viewItems.at(item).height;
3349  if (height <= 0) {
3350  height = q_func()->indexRowSizeHint(index);
3351  viewItems[item].height = height;
3352  }
3353  return qMax(height, 0);
3354 }
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QModelIndex class is used to locate data in a data model.
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ layout()

void QTreeViewPrivate::layout ( int  i,
bool  recursiveExpanding = false,
bool  afterIsUninitialized = false 
)
Warning
This function is not part of the public interface. creates and initialize the viewItem structure of the children of the element

set recursiveExpanding if the function has to expand all the children (called from expandAll) afterIsUninitialized is when we recurse from layout(-1), it means all the items after 'i' are not yet initialized and need not to be moved

Definition at line 3220 of file qtreeview.cpp.

3221 {
3222  Q_Q(QTreeView);
3224  QModelIndex parent = (i < 0) ? (QModelIndex)root : modelIndex(i);
3225 
3226  if (i>=0 && !parent.isValid()) {
3227  //modelIndex() should never return something invalid for the real items.
3228  //This can happen if columncount has been set to 0.
3229  //To avoid infinite loop we stop here.
3230  return;
3231  }
3232 
3233  int count = 0;
3234  if (model->hasChildren(parent)) {
3235  if (model->canFetchMore(parent))
3236  model->fetchMore(parent);
3237  count = model->rowCount(parent);
3238  }
3239 
3240  bool expanding = true;
3241  if (i == -1) {
3242  if (uniformRowHeights) {
3243  QModelIndex index = model->index(0, 0, parent);
3244  defaultItemHeight = q->indexRowSizeHint(index);
3245  }
3246  viewItems.resize(count);
3247  afterIsUninitialized = true;
3248  } else if (viewItems[i].total != (uint)count) {
3249  if (!afterIsUninitialized)
3250  insertViewItems(i + 1, count, QTreeViewItem()); // expand
3251  else if (count > 0)
3252  viewItems.resize(viewItems.count() + count);
3253  } else {
3254  expanding = false;
3255  }
3256 
3257  int first = i + 1;
3258  int level = (i >= 0 ? viewItems.at(i).level + 1 : 0);
3259  int hidden = 0;
3260  int last = 0;
3261  int children = 0;
3262  QTreeViewItem *item = 0;
3263  for (int j = first; j < first + count; ++j) {
3264  current = model->index(j - first, 0, parent);
3265  if (isRowHidden(current)) {
3266  ++hidden;
3267  last = j - hidden + children;
3268  } else {
3269  last = j - hidden + children;
3270  if (item)
3271  item->hasMoreSiblings = true;
3272  item = &viewItems[last];
3273  item->index = current;
3274  item->parentItem = i;
3275  item->level = level;
3276  item->height = 0;
3277  item->spanning = q->isFirstColumnSpanned(current.row(), parent);
3278  item->expanded = false;
3279  item->total = 0;
3280  item->hasMoreSiblings = false;
3281  if (recursiveExpanding || isIndexExpanded(current)) {
3282  if (recursiveExpanding)
3283  expandedIndexes.insert(current);
3284  item->expanded = true;
3285  layout(last, recursiveExpanding, afterIsUninitialized);
3286  item = &viewItems[last];
3287  children += item->total;
3288  item->hasChildren = item->total > 0;
3289  last = j - hidden + children;
3290  } else {
3291  item->hasChildren = hasVisibleChildren(current);
3292  }
3293  }
3294  }
3295 
3296  // remove hidden items
3297  if (hidden > 0) {
3298  if (!afterIsUninitialized)
3299  removeViewItems(last + 1, hidden);
3300  else
3301  viewItems.resize(viewItems.size() - hidden);
3302  }
3303 
3304  if (!expanding)
3305  return; // nothing changed
3306 
3307  while (i > -1) {
3308  viewItems[i].total += count - hidden;
3309  i = viewItems[i].parentItem;
3310  }
3311 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QSet< QPersistentModelIndex > expandedIndexes
Definition: qtreeview_p.h:194
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
QModelIndex modelIndex(int i, int column=0) const
Definition: qtreeview.cpp:3511
void layout(int item, bool recusiveExpanding=false, bool afterIsUninitialized=false)
Definition: qtreeview.cpp:3220
QObjectList children
Definition: qobject.h:93
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isIndexExpanded(const QModelIndex &idx) const
Definition: qtreeview_p.h:204
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns true if parent has any children; otherwise returns false.
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
int row() const
Returns the row this model index refers to.
const_iterator insert(const T &value)
Definition: qset.h:179
unsigned int uint
Definition: qglobal.h:996
virtual bool canFetchMore(const QModelIndex &parent) const
Returns true if there is more data available for parent; otherwise returns false. ...
uint hasMoreSiblings
Definition: qtreeview_p.h:73
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QPersistentModelIndex root
bool isRowHidden(const QModelIndex &idx) const
Definition: qtreeview_p.h:212
virtual void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
The QModelIndex class is used to locate data in a data model.
bool hasVisibleChildren(const QModelIndex &parent) const
Definition: qtreeview.cpp:3794
uint hasChildren
Definition: qtreeview_p.h:72
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index
QObject * parent
Definition: qobject.h:92
void removeViewItems(int pos, int count)
Definition: qtreeview.cpp:3010
void insertViewItems(int pos, int count, const QTreeViewItem &viewItem)
Definition: qtreeview.cpp:2993
QAbstractItemModel * model
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ modelIndex()

QModelIndex QTreeViewPrivate::modelIndex ( int  i,
int  column = 0 
) const

Definition at line 3511 of file qtreeview.cpp.

3512 {
3513  if (i < 0 || i >= viewItems.count())
3514  return QModelIndex();
3515 
3516  QModelIndex ret = viewItems.at(i).index;
3517  if (column)
3518  ret = ret.sibling(ret.row(), column);
3519  return ret;
3520 }
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int row() const
Returns the row this model index refers to.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QModelIndex class is used to locate data in a data model.
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178

◆ pageDown()

int QTreeViewPrivate::pageDown ( int  item) const

Definition at line 3321 of file qtreeview.cpp.

3322 {
3324  while (isItemHiddenOrDisabled(index))
3325  index++;
3326  return index == -1 ? viewItems.count() - 1 : index;
3327 }
int itemAtCoordinate(int coordinate) const
Returns the index of the view item at the given viewport coordinate.
Definition: qtreeview.cpp:3418
bool isItemHiddenOrDisabled(int i) const
Definition: qtreeview_p.h:217
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int coordinateForItem(int item) const
Returns the viewport y coordinate for item.
Definition: qtreeview.cpp:3364
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
quint16 index

◆ pageUp()

int QTreeViewPrivate::pageUp ( int  item) const

Definition at line 3313 of file qtreeview.cpp.

3314 {
3316  while (isItemHiddenOrDisabled(index))
3317  index--;
3318  return index == -1 ? 0 : index;
3319 }
int itemAtCoordinate(int coordinate) const
Returns the index of the view item at the given viewport coordinate.
Definition: qtreeview.cpp:3418
bool isItemHiddenOrDisabled(int i) const
Definition: qtreeview_p.h:217
int coordinateForItem(int item) const
Returns the viewport y coordinate for item.
Definition: qtreeview.cpp:3364
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
quint16 index

◆ paintAlternatingRowColors()

void QTreeViewPrivate::paintAlternatingRowColors ( QPainter painter,
QStyleOptionViewItemV4 option,
int  y,
int  bottom 
) const

Definition at line 1337 of file qtreeview.cpp.

1338 {
1339  Q_Q(const QTreeView);
1340  if (!alternatingColors || !q->style()->styleHint(QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, option, q))
1341  return;
1342  int rowHeight = defaultItemHeight;
1343  if (rowHeight <= 0) {
1344  rowHeight = itemDelegate->sizeHint(*option, QModelIndex()).height();
1345  if (rowHeight <= 0)
1346  return;
1347  }
1348  while (y <= bottom) {
1349  option->rect.setRect(0, y, viewport->width(), rowHeight);
1350  if (current & 1) {
1352  } else {
1353  option->features &= ~QStyleOptionViewItemV2::Alternate;
1354  }
1355  ++current;
1356  q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q);
1357  y += rowHeight;
1358  }
1359 }
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const =0
This pure abstract function must be reimplemented if you want to provide custom rendering.
#define Q_Q(Class)
Definition: qglobal.h:2483
The QStyleOptionViewItemV2 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:562
ViewItemFeatures features
a bitwise OR of the features that describe this view item
Definition: qstyleoption.h:577
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
QPointer< QAbstractItemDelegate > itemDelegate
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The QModelIndex class is used to locate data in a data model.
int height() const
Returns the height.
Definition: qsize.h:129
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ prepareAnimatedOperation()

void QTreeViewPrivate::prepareAnimatedOperation ( int  item,
QVariantAnimation::Direction  d 
)

Definition at line 3089 of file qtreeview.cpp.

3090 {
3091  animatedOperation.item = item;
3094 
3095  int top = coordinateForItem(item) + itemHeight(item);
3096  QRect rect = viewport->rect();
3097  rect.setTop(top);
3099  const int limit = rect.height() * 2;
3100  int h = 0;
3101  int c = item + viewItems.at(item).total + 1;
3102  for (int i = item + 1; i < c && h < limit; ++i)
3103  h += itemHeight(i);
3104  rect.setHeight(h);
3105  animatedOperation.setEndValue(top + h);
3106  }
3109 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
unsigned char c[8]
Definition: qnumeric_p.h:62
QTreeViewPrivate::AnimatedOperation animatedOperation
QPixmap renderTreeToPixmapForAnimation(const QRect &rect) const
Definition: qtreeview.cpp:3147
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setEndValue(const QVariant &value)
void setStartValue(const QVariant &value)
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int coordinateForItem(int item) const
Returns the viewport y coordinate for item.
Definition: qtreeview.cpp:3364
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void setDirection(Direction direction)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
Qt::LayoutDirection direction

◆ removeViewItems()

void QTreeViewPrivate::removeViewItems ( int  pos,
int  count 
)

Definition at line 3010 of file qtreeview.cpp.

3011 {
3012  viewItems.remove(pos, count);
3013  QTreeViewItem *items = viewItems.data();
3014  for (int i = pos; i < viewItems.count(); i++)
3015  if (items[i].parentItem >= pos)
3016  items[i].parentItem -= count;
3017 #ifndef QT_NO_ACCESSIBILITY
3018 #ifdef Q_WS_X11
3019  Q_Q(QTreeView);
3020  if (QAccessible::isActive()) {
3022  }
3023 #endif
3024 #endif
3025 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_Q(Class)
Definition: qglobal.h:2483
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152

◆ renderTreeToPixmapForAnimation()

QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation ( const QRect rect) const

Definition at line 3147 of file qtreeview.cpp.

3148 {
3149  Q_Q(const QTreeView);
3150  QPixmap pixmap(rect.size());
3151  if (rect.size().isEmpty())
3152  return pixmap;
3153  pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels.
3154  QPainter painter(&pixmap);
3155  painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base());
3156  painter.translate(0, -rect.top());
3157  q->drawTree(&painter, QRegion(rect));
3158  painter.end();
3159 
3160  //and now let's render the editors the editors
3163  QWidget *editor = it.key();
3164  const QModelIndex &index = it.value();
3165  option.rect = q->visualRect(index);
3166  if (option.rect.isValid()) {
3167 
3168  if (QAbstractItemDelegate *delegate = delegateForIndex(index))
3169  delegate->updateEditorGeometry(editor, option, index);
3170 
3171  const QPoint pos = editor->pos();
3172  if (rect.contains(pos)) {
3173  editor->render(&pixmap, pos - rect.topLeft());
3174  //the animation uses pixmap to display the treeview's content
3175  //the editor is rendered on this pixmap and thus can (should) be hidden
3176  editor->hide();
3177  }
3178  }
3179  }
3180 
3181 
3182  return pixmap;
3183 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QAbstractItemDelegate class is used to display and edit data items from a model.
#define it(className, varName)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_Q(Class)
Definition: qglobal.h:2483
QEditorIndexHash editorIndexHash
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void hide()
Hides the widget.
Definition: qwidget.h:501
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
QAbstractItemDelegate * delegateForIndex(const QModelIndex &index) const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QWidget * editor(const QModelIndex &index, const QStyleOptionViewItem &options)
QStyleOptionViewItemV4 viewOptionsV4() const
quint16 index
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void render(QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render...
Definition: qwidget.cpp:5372
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ select()

void QTreeViewPrivate::select ( const QModelIndex start,
const QModelIndex stop,
QItemSelectionModel::SelectionFlags  command 
)

Definition at line 3719 of file qtreeview.cpp.

3721 {
3722  Q_Q(QTreeView);
3723  QItemSelection selection;
3724  const int top = viewIndex(topIndex),
3725  bottom = viewIndex(bottomIndex);
3726 
3727  const QList< QPair<int, int> > colRanges = columnRanges(topIndex, bottomIndex);
3728  QList< QPair<int, int> >::const_iterator it;
3729  for (it = colRanges.begin(); it != colRanges.end(); ++it) {
3730  const int left = (*it).first,
3731  right = (*it).second;
3732 
3733  QModelIndex previous;
3734  QItemSelectionRange currentRange;
3735  QStack<QItemSelectionRange> rangeStack;
3736  for (int i = top; i <= bottom; ++i) {
3738  QModelIndex parent = index.parent();
3739  QModelIndex previousParent = previous.parent();
3740  if (previous.isValid() && parent == previousParent) {
3741  // same parent
3742  if (qAbs(previous.row() - index.row()) > 1) {
3743  //a hole (hidden index inside a range) has been detected
3744  if (currentRange.isValid()) {
3745  selection.append(currentRange);
3746  }
3747  //let's start a new range
3748  currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
3749  } else {
3750  QModelIndex tl = model->index(currentRange.top(), currentRange.left(),
3751  currentRange.parent());
3752  currentRange = QItemSelectionRange(tl, index.sibling(index.row(), right));
3753  }
3754  } else if (previous.isValid() && parent == model->index(previous.row(), 0, previousParent)) {
3755  // item is child of previous
3756  rangeStack.push(currentRange);
3757  currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
3758  } else {
3759  if (currentRange.isValid())
3760  selection.append(currentRange);
3761  if (rangeStack.isEmpty()) {
3762  currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
3763  } else {
3764  currentRange = rangeStack.pop();
3765  index = currentRange.bottomRight(); //let's resume the range
3766  --i; //we process again the current item
3767  }
3768  }
3769  previous = index;
3770  }
3771  if (currentRange.isValid())
3772  selection.append(currentRange);
3773  for (int i = 0; i < rangeStack.count(); ++i)
3774  selection.append(rangeStack.at(i));
3775  }
3776  q->selectionModel()->select(selection, command);
3777 }
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
QModelIndex bottomRight() const
Returns the index for the item located at the bottom-right corner of the selection range...
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool isValid() const
Returns true if the selection range is valid; otherwise returns false.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QItemSelectionRange class manages information about a range of selected items in a model...
QModelIndex modelIndex(int i, int column=0) const
Definition: qtreeview.cpp:3511
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
int row() const
Returns the row this model index refers to.
int viewIndex(const QModelIndex &index) const
Definition: qtreeview.cpp:3467
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
quint16 index
QObject * parent
Definition: qobject.h:92
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
QAbstractItemModel * model
QList< QPair< int, int > > columnRanges(const QModelIndex &topIndex, const QModelIndex &bottomIndex) const
Definition: qtreeview.cpp:3672
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ startAndEndColumns()

QPair< int, int > QTreeViewPrivate::startAndEndColumns ( const QRect rect) const

Definition at line 3779 of file qtreeview.cpp.

3780 {
3781  Q_Q(const QTreeView);
3782  int start = header->visualIndexAt(rect.left());
3783  int end = header->visualIndexAt(rect.right());
3784  if (q->isRightToLeft()) {
3785  start = (start == -1 ? header->count() - 1 : start);
3786  end = (end == -1 ? 0 : end);
3787  } else {
3788  start = (start == -1 ? 0 : start);
3789  end = (end == -1 ? header->count() - 1 : end);
3790  }
3791  return qMakePair<int,int>(qMin(start, end), qMax(start, end));
3792 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
int visualIndexAt(int position) const
Returns the visual index of the section that covers the given position in the viewport.
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int count() const
Returns the number of sections in the header.
static const KeyPair *const end
QHeaderView * header
Definition: qtreeview_p.h:175

◆ storeExpanded()

bool QTreeViewPrivate::storeExpanded ( const QPersistentModelIndex idx)
inline

Definition at line 197 of file qtreeview_p.h.

197  {
198  if (expandedIndexes.contains(idx))
199  return false;
200  expandedIndexes.insert(idx);
201  return true;
202  }
QSet< QPersistentModelIndex > expandedIndexes
Definition: qtreeview_p.h:194
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179

◆ updateChildCount()

void QTreeViewPrivate::updateChildCount ( const int  parentItem,
const int  delta 
)

◆ updateScrollBars()

void QTreeViewPrivate::updateScrollBars ( )

Definition at line 3556 of file qtreeview.cpp.

3557 {
3558  Q_Q(QTreeView);
3559  QSize viewportSize = viewport->size();
3560  if (!viewportSize.isValid())
3561  viewportSize = QSize(0, 0);
3562 
3563  if (viewItems.isEmpty()) {
3564  q->doItemsLayout();
3565  }
3566 
3567  int itemsInViewport = 0;
3568  if (uniformRowHeights) {
3569  if (defaultItemHeight <= 0)
3570  itemsInViewport = viewItems.count();
3571  else
3572  itemsInViewport = viewportSize.height() / defaultItemHeight;
3573  } else {
3574  const int itemsCount = viewItems.count();
3575  const int viewportHeight = viewportSize.height();
3576  for (int height = 0, item = itemsCount - 1; item >= 0; --item) {
3577  height += itemHeight(item);
3578  if (height > viewportHeight)
3579  break;
3580  ++itemsInViewport;
3581  }
3582  }
3584  if (!viewItems.isEmpty())
3585  itemsInViewport = qMax(1, itemsInViewport);
3586  vbar->setRange(0, viewItems.count() - itemsInViewport);
3587  vbar->setPageStep(itemsInViewport);
3588  vbar->setSingleStep(1);
3589  } else { // scroll per pixel
3590  int contentsHeight = 0;
3591  if (uniformRowHeights) {
3592  contentsHeight = defaultItemHeight * viewItems.count();
3593  } else { // ### optimize (spans or caching)
3594  for (int i = 0; i < viewItems.count(); ++i)
3595  contentsHeight += itemHeight(i);
3596  }
3597  vbar->setRange(0, contentsHeight - viewportSize.height());
3598  vbar->setPageStep(viewportSize.height());
3599  vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2));
3600  }
3601 
3602  const int columnCount = header->count();
3603  const int viewportWidth = viewportSize.width();
3604  int columnsInViewport = 0;
3605  for (int width = 0, column = columnCount - 1; column >= 0; --column) {
3606  int logical = header->logicalIndex(column);
3607  width += header->sectionSize(logical);
3608  if (width > viewportWidth)
3609  break;
3610  ++columnsInViewport;
3611  }
3612  if (columnCount > 0)
3613  columnsInViewport = qMax(1, columnsInViewport);
3615  hbar->setRange(0, columnCount - columnsInViewport);
3616  hbar->setPageStep(columnsInViewport);
3617  hbar->setSingleStep(1);
3618  } else { // scroll per pixel
3619  const int horizontalLength = header->length();
3620  const QSize maxSize = q->maximumViewportSize();
3621  if (maxSize.width() >= horizontalLength && vbar->maximum() <= 0)
3622  viewportSize = maxSize;
3623  hbar->setPageStep(viewportSize.width());
3624  hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0));
3625  hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2));
3626  }
3627 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QAbstractItemView::ScrollMode horizontalScrollMode
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
#define Q_Q(Class)
Definition: qglobal.h:2483
int itemHeight(int item) const
Definition: qtreeview.cpp:3339
int width() const
Returns the width.
Definition: qsize.h:126
QAbstractItemView::ScrollMode verticalScrollMode
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
int length() const
Returns the length along the orientation of the header.
int logicalIndex(int visualIndex) const
Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 ...
int count() const
Returns the number of sections in the header.
int sectionSize(int logicalIndex) const
Returns the width (or height for vertical headers) of the given logicalIndex.
int height() const
Returns the height.
Definition: qsize.h:129
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
int maximum() const
QHeaderView * header
Definition: qtreeview_p.h:175

◆ viewIndex()

int QTreeViewPrivate::viewIndex ( const QModelIndex index) const

Definition at line 3467 of file qtreeview.cpp.

3468 {
3469  if (!_index.isValid() || viewItems.isEmpty())
3470  return -1;
3471 
3472  const int totalCount = viewItems.count();
3473  const QModelIndex index = _index.sibling(_index.row(), 0);
3474  const int row = index.row();
3475  const qint64 internalId = index.internalId();
3476 
3477  // We start nearest to the lastViewedItem
3478  int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem);
3479  for (int i = 0; i < localCount; ++i) {
3480  const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index;
3481  if (idx1.row() == row && idx1.internalId() == internalId) {
3483  return lastViewedItem;
3484  }
3485  const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index;
3486  if (idx2.row() == row && idx2.internalId() == internalId) {
3487  lastViewedItem = lastViewedItem - i - 1;
3488  return lastViewedItem;
3489  }
3490  }
3491 
3492  for (int j = qMax(0, lastViewedItem + localCount); j < totalCount; ++j) {
3493  const QModelIndex &idx = viewItems.at(j).index;
3494  if (idx.row() == row && idx.internalId() == internalId) {
3495  lastViewedItem = j;
3496  return j;
3497  }
3498  }
3499  for (int j = qMin(totalCount, lastViewedItem - localCount) - 1; j >= 0; --j) {
3500  const QModelIndex &idx = viewItems.at(j).index;
3501  if (idx.row() == row && idx.internalId() == internalId) {
3502  lastViewedItem = j;
3503  return j;
3504  }
3505  }
3506 
3507  // nothing found
3508  return -1;
3509 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
int row() const
Returns the row this model index refers to.
__int64 qint64
Definition: qglobal.h:942
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QModelIndex class is used to locate data in a data model.
QModelIndex index
Definition: qtreeview_p.h:68
QVector< QTreeViewItem > viewItems
Definition: qtreeview_p.h:178
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

Properties

◆ allColumnsShowFocus

bool QTreeViewPrivate::allColumnsShowFocus

Definition at line 186 of file qtreeview_p.h.

◆ animatedOperation

QTreeViewPrivate::AnimatedOperation QTreeViewPrivate::animatedOperation

◆ animationsEnabled

bool QTreeViewPrivate::animationsEnabled

Definition at line 195 of file qtreeview_p.h.

◆ autoExpandDelay

int QTreeViewPrivate::autoExpandDelay

Definition at line 243 of file qtreeview_p.h.

◆ columnResizeTimerID

int QTreeViewPrivate::columnResizeTimerID

Definition at line 239 of file qtreeview_p.h.

◆ columnsToUpdate

QList<int> QTreeViewPrivate::columnsToUpdate

Definition at line 240 of file qtreeview_p.h.

◆ current

int QTreeViewPrivate::current
mutable

Definition at line 190 of file qtreeview_p.h.

◆ defaultItemHeight

int QTreeViewPrivate::defaultItemHeight

Definition at line 180 of file qtreeview_p.h.

◆ expandedIndexes

QSet<QPersistentModelIndex> QTreeViewPrivate::expandedIndexes

Definition at line 194 of file qtreeview_p.h.

◆ expandsOnDoubleClick

bool QTreeViewPrivate::expandsOnDoubleClick

Definition at line 185 of file qtreeview_p.h.

◆ geometryRecursionBlock

bool QTreeViewPrivate::geometryRecursionBlock

Definition at line 250 of file qtreeview_p.h.

◆ hasRemovedItems

bool QTreeViewPrivate::hasRemovedItems

Definition at line 253 of file qtreeview_p.h.

◆ header

QHeaderView* QTreeViewPrivate::header

Definition at line 175 of file qtreeview_p.h.

◆ hiddenIndexes

QSet<QPersistentModelIndex> QTreeViewPrivate::hiddenIndexes

Definition at line 210 of file qtreeview_p.h.

◆ hoverBranch

int QTreeViewPrivate::hoverBranch
mutable

Definition at line 247 of file qtreeview_p.h.

◆ indent

int QTreeViewPrivate::indent

Definition at line 176 of file qtreeview_p.h.

◆ itemsExpandable

bool QTreeViewPrivate::itemsExpandable

Definition at line 183 of file qtreeview_p.h.

◆ lastViewedItem

int QTreeViewPrivate::lastViewedItem
mutable

Definition at line 179 of file qtreeview_p.h.

◆ leftAndRight

QPair<int,int> QTreeViewPrivate::leftAndRight
mutable

Definition at line 189 of file qtreeview_p.h.

◆ openTimer

QBasicTimer QTreeViewPrivate::openTimer

Definition at line 244 of file qtreeview_p.h.

◆ rootDecoration

bool QTreeViewPrivate::rootDecoration

Definition at line 182 of file qtreeview_p.h.

◆ sortingEnabled

bool QTreeViewPrivate::sortingEnabled

Definition at line 184 of file qtreeview_p.h.

◆ spanning

bool QTreeViewPrivate::spanning
mutable

Definition at line 191 of file qtreeview_p.h.

◆ spanningIndexes

QVector<QPersistentModelIndex> QTreeViewPrivate::spanningIndexes

Definition at line 236 of file qtreeview_p.h.

◆ uniformRowHeights

bool QTreeViewPrivate::uniformRowHeights

Definition at line 181 of file qtreeview_p.h.

◆ viewItems

QVector<QTreeViewItem> QTreeViewPrivate::viewItems
mutable

Definition at line 178 of file qtreeview_p.h.


The documentation for this class was generated from the following files: