DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dsimplelistitem.h
1// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSIMPLELISTITEM_H
6#define DSIMPLELISTITEM_H
7
8#include <dtkwidget_global.h>
9#include <QObject>
10#include <QPainter>
11
12DWIDGET_BEGIN_NAMESPACE
13
14class LIBDTKWIDGETSHARED_EXPORT DSimpleListItem : public QObject
15{
16 Q_OBJECT
17
18public:
20
21 /*
22 * The interface function that used to compare the two DSimpleListItem
23 * The DSimpleListView requires this interface to keep the selected items unchanged when refreshed
24 *
25 * \item any subclass of DSimpleListItem, you can use static_cast in implementation to access any attribute to compare two items
26 * \return return true if two items have same attribute, the compare method implement by subclass of DSimpleListItem
27 */
28
29 virtual bool sameAs(DSimpleListItem *item)=0;
30
31 /*
32 * The interface function that used to draw background of DSimpleListItem.
33 * Such as background and selected effect.
34 *
35 * \rect row corresponding to the drawing of the rectangular area
36 * \painter the painter used to draw anything you want
37 * \index the index of DSimpleListItem, you can draw different rows effect based on the index, such as the zebra crossing
38 * \isSelect current item is selected, you can draw selected effect under content when isSelect is true
39 * \isHover current item is hovered, you can draw hover effect under content when isHover is true
40 */
41
42 virtual void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover)=0;
43
44 /*
45 * The interface function that used to draw foreground of DSimpleListItem.
46 *
47 * \rect column corresponding to the drawing of the rectangular area
48 * \painter the painter used to draw anything you want
49 * \column the column of DSimpleListItem, you can draw different column content based on the column index
50 * \index the index of DSimpleListItem, you can draw different rows effect based on the index, such as the zebra crossing
51 * \isSelect current item is selected, you can draw selected effect under content when isSelect is true
52 * \isHover current item is hovered, you can draw hover effect under content when isHover is true
53 */
54
55 virtual void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover)=0;
56};
57
58DWIDGET_END_NAMESPACE
59
60#endif
DSimpleListItem 是 DSimpleListView 的接口,得到 DSimpleListView 传递过来的 QPainter、列信息、表格矩形数据后,由开发者完全控制行内容的绘制.
Definition dsimplelistitem.h:15
virtual bool sameAs(DSimpleListItem *item)=0
此接口是用来比较两个 item 的函数.
virtual void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover)=0
drawForeground 用于绘制内容的接口函数.
virtual void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover)=0
drawBackground 用于绘制背景的接口函数.