Krita Source Code Documentation
Loading...
Searching...
No Matches
FileItemDelegate Class Reference
+ Inheritance diagram for FileItemDelegate:

Public Member Functions

QList< QWidget * > createItemWidgets (const QModelIndex &index) const override
 
 FileItemDelegate (QAbstractItemView *itemView, KisAutoSaveRecoveryDialog *dlg)
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &) const override
 
QSize sizeHint (const QStyleOptionViewItem &, const QModelIndex &) const override
 
void updateItemWidgets (const QList< QWidget * > &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override
 

Public Attributes

KisAutoSaveRecoveryDialogm_parent
 

Detailed Description

Definition at line 42 of file KisAutoSaveRecoveryDialog.cpp.

Constructor & Destructor Documentation

◆ FileItemDelegate()

FileItemDelegate::FileItemDelegate ( QAbstractItemView * itemView,
KisAutoSaveRecoveryDialog * dlg )
inline

Definition at line 46 of file KisAutoSaveRecoveryDialog.cpp.

47 : KWidgetItemDelegate(itemView, dlg)
48 , m_parent(dlg)
49 {
50 }
KisAutoSaveRecoveryDialog * m_parent

Member Function Documentation

◆ createItemWidgets()

QList< QWidget * > FileItemDelegate::createItemWidgets ( const QModelIndex & index) const
inlineoverride

Definition at line 52 of file KisAutoSaveRecoveryDialog.cpp.

53 {
54 // a lump of coal and a piece of elastic will get you through the world
55 QWidget *page = new QWidget;
56 QHBoxLayout *layout = new QHBoxLayout(page);
57
58 QCheckBox *checkBox = new QCheckBox;
59 checkBox->setProperty("fileitem", index.data());
60
61 connect(checkBox, SIGNAL(toggled(bool)), m_parent, SLOT(toggleFileItem(bool)));
62 QLabel *thumbnail = new QLabel;
63 QLabel *filename = new QLabel;
64 QLabel *dateModified = new QLabel;
65
66 layout->addWidget(checkBox);
67 layout->addWidget(thumbnail);
68 layout->addWidget(filename);
69 layout->addWidget(dateModified);
70
71 page->setFixedSize(600, 200);
72
73 return QList<QWidget*>() << page;
74 }
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))

References connect(), and m_parent.

◆ paint()

void FileItemDelegate::paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex &  ) const
inlineoverride

Definition at line 106 of file KisAutoSaveRecoveryDialog.cpp.

107 {
108 //paint background for selected or hovered item
109 QStyleOptionViewItem opt = option;
110 itemView()->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, 0);
111 }

◆ sizeHint()

QSize FileItemDelegate::sizeHint ( const QStyleOptionViewItem & ,
const QModelIndex &  ) const
inlineoverride

Definition at line 113 of file KisAutoSaveRecoveryDialog.cpp.

114 {
115 return QSize(600, 200);
116 }

◆ updateItemWidgets()

void FileItemDelegate::updateItemWidgets ( const QList< QWidget * > & widgets,
const QStyleOptionViewItem & option,
const QPersistentModelIndex & index ) const
inlineoverride

Definition at line 81 of file KisAutoSaveRecoveryDialog.cpp.

87 {
88 FileItem *fileItem = (FileItem*)index.data().value<void*>();
89
90 QWidget* page= widgets[0];
91 QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(page->layout());
92 QCheckBox *checkBox = qobject_cast<QCheckBox*>(layout->itemAt(0)->widget());
93 QLabel *thumbnail = qobject_cast<QLabel*>(layout->itemAt(1)->widget());
94 QLabel *filename = qobject_cast<QLabel*>(layout->itemAt(2)->widget());
95 QLabel *modified = qobject_cast<QLabel*>(layout->itemAt(3)->widget());
96
97 checkBox->setChecked(fileItem->checked);
98 thumbnail->setPixmap(QPixmap::fromImage(fileItem->thumbnail));
99 filename->setText(fileItem->name);
100 modified->setText(fileItem->date);
101
102 // move the page _up_ otherwise it will draw relative to the actual position
103 page->setGeometry(option.rect.translated(0, -option.rect.y()));
104 }

References FileItem::checked, FileItem::date, FileItem::name, and FileItem::thumbnail.

Member Data Documentation

◆ m_parent

KisAutoSaveRecoveryDialog* FileItemDelegate::m_parent

Definition at line 119 of file KisAutoSaveRecoveryDialog.cpp.


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