Filer
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
CustomItemDelegate Class Reference

A custom delegate for rendering items in views. More...

#include <CustomItemDelegate.h>

Inheritance diagram for CustomItemDelegate:
Inheritance graph
[legend]
Collaboration diagram for CustomItemDelegate:
Collaboration graph
[legend]

Public Slots

void animationValueChanged (double value)
 Animates the value change for the animation. More...
 
void animationFinished ()
 Slot called when the animation has finished.
 
void stopAnimation ()
 Stops the currently running animation.
 
void startAnimation (const QModelIndex &index)
 Starts an animation for the specified index. More...
 
bool isAnimationRunning () const
 Checks if an animation is currently running. More...
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Creates and returns a custom editor widget. More...
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Sets the model data based on the edited data in the editor. More...
 

Signals

void fileDropped (const QString &filePath, const QPoint &iconPosition)
 Signal emitted when a file is dropped onto the delegate item. More...
 

Public Member Functions

 CustomItemDelegate (QObject *parent=nullptr, QAbstractProxyModel *fileSystemModel=nullptr)
 Constructs a CustomItemDelegate object. More...
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Renders the item's appearance using a QPainter. More...
 
void setSelectionModel (QItemSelectionModel *selectionModel)
 Installs event filters on the specified view to intercept events. More...
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Overrides the sizeHint method to set the size of the delegate items. More...
 

Protected Member Functions

bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 

Detailed Description

A custom delegate for rendering items in views.

The CustomItemDelegate class provides a custom delegate for rendering items in views, such as QTreeView or QListView. It extends QStyledItemDelegate and adds custom behavior like animations, context menus, and drag-and-drop handling.

Constructor & Destructor Documentation

◆ CustomItemDelegate()

CustomItemDelegate::CustomItemDelegate ( QObject *  parent = nullptr,
QAbstractProxyModel *  fileSystemModel = nullptr 
)
explicit

Constructs a CustomItemDelegate object.

Parameters
parentThe parent QObject.
fileSystemModelA pointer to the CustomFileSystemModel.

Member Function Documentation

◆ animationValueChanged

void CustomItemDelegate::animationValueChanged ( double  value)
slot

Animates the value change for the animation.

Parameters
valueThe new animation value.

◆ createEditor

QWidget * CustomItemDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
overrideslot

Creates and returns a custom editor widget.

Parameters
parentThe parent widget of the editor.
optionStyle options for the item.
indexModel index of the item being edited.
Returns
A pointer to the custom editor widget.

◆ fileDropped

void CustomItemDelegate::fileDropped ( const QString &  filePath,
const QPoint &  iconPosition 
)
signal

Signal emitted when a file is dropped onto the delegate item.

Parameters
filePathThe path of the dropped file.
iconPositionThe position of the icon.

◆ isAnimationRunning

bool CustomItemDelegate::isAnimationRunning ( ) const
slot

Checks if an animation is currently running.

Returns
True if an animation is running, otherwise false.

◆ paint()

void CustomItemDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Renders the item's appearance using a QPainter.

Parameters
painterThe QPainter object to paint with.
optionThe style options for rendering.
indexThe model index to be rendered.

◆ setModelData

void CustomItemDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const
overrideslot

Sets the model data based on the edited data in the editor.

Parameters
editorThe editor widget.
modelThe model that holds the item data.
indexModel index of the item being edited.

◆ setSelectionModel()

void CustomItemDelegate::setSelectionModel ( QItemSelectionModel *  selectionModel)

Installs event filters on the specified view to intercept events.

Parameters
viewThe view on which to install the event filters.

Overrides the event filter to handle events for the delegate.

Parameters
objectThe QObject that sent the event.
eventThe event to be filtered.
Returns
True if the event was handled, otherwise false.

Sets the selection model for the delegate.

Parameters
selectionModelThe QItemSelectionModel to use for selection.

◆ sizeHint()

QSize CustomItemDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
inlineoverride

Overrides the sizeHint method to set the size of the delegate items.

Parameters
optionThe style options for the item.
indexThe index of the item.
Returns
The preferred size of the item.

◆ startAnimation

void CustomItemDelegate::startAnimation ( const QModelIndex &  index)
slot

Starts an animation for the specified index.

Parameters
indexThe index of the item to animate.

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