-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageitemdelegate.h
59 lines (44 loc) · 1.76 KB
/
imageitemdelegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
//Need to fix the out of focus problem
#ifndef IMAGEITEMDELEGATE_H
#define IMAGEITEMDELEGATE_H
#include <QStyledItemDelegate>
#include <imagewidgetdelegate.h>
#include <QWidget>
#include <QObject>
#include <QSize>
#include <QString>
#include <QEvent>
#include <QPoint>
#include "metatypedeclaration.h"
#include "medialistwidget.h"
class ImageItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
enum EditMode {Editable, ReadOnly};
enum Status{New,Old,Modified};
ImageItemDelegate(MediaListWidget *parent = 0);
//QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
bool editorEvent(QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
int imageSize;
float imageScale;
private:
MediaListWidget *origParent;
int margin=5;
int prefWidth;
int prefHeight;
QPoint posDelete(const QStyleOptionViewItem & option) const;
private slots:
void updateObject(ImageWidgetDelegate* editor);
void buttonClicked();
void imageScaleChanged();
//bool editorEvent(QEvent *event, QAbstractItemModel *model,const QStyleOptionViewItem &option,const QModelIndex &index);
};
//Q_DECLARE_METATYPE(QSqlRecord);
#endif // IMAGEITEMDELEGATE_H