53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#ifndef CTREEITEMDELEGATE_H
|
|
#define CTREEITEMDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
class CTreeItemDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum DelegateWidget{
|
|
ReadOnly = 0,
|
|
LineEdit = 1,
|
|
ComboBox = 2,
|
|
PicFile = 3,
|
|
IconFile = 4
|
|
};
|
|
|
|
CTreeItemDelegate(QObject *parent = 0, DelegateWidget type = LineEdit);
|
|
~CTreeItemDelegate();
|
|
|
|
/**
|
|
* @brief setComboMap DelegateWidget::ComboBox/PicFile/IconFile 有效
|
|
* @param map
|
|
*/
|
|
void setComboMap(const QMap<int, QString> &map);
|
|
|
|
/**
|
|
* @brief setFilePath DelegateWidget::IconFile 有效
|
|
* @param path
|
|
*/
|
|
void setFilePath(const QString &path);
|
|
|
|
QWidget *createEditor(QWidget *parent,
|
|
const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
void setModelData(QWidget *editor,
|
|
QAbstractItemModel *model,
|
|
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
|
|
void updateEditorGeometry(QWidget *editor,
|
|
const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
|
|
private:
|
|
DelegateWidget m_type;
|
|
QMap<int, QString> m_mapComboBox;
|
|
QString m_strFilePath;
|
|
};
|
|
|
|
#endif // CTREEITEMDELEGATE_H
|