mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-28 02:43:49 -06:00
interface/qt: add assignable editor delegate
This commit is contained in:
parent
9ed25c03ac
commit
b835e7ca97
34
src/modules/interface/qt/data/AssignableEditorDelegate.cpp
Normal file
34
src/modules/interface/qt/data/AssignableEditorDelegate.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "AssignableEditorDelegate.h"
|
||||
#include "AssignableData.h"
|
||||
#include <EnumEditor.h>
|
||||
#include <IntRangeEditor.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
AssignableEditorDelegate::AssignableEditorDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
||||
}
|
||||
|
||||
QWidget *AssignableEditorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
// Check which type the editor should be
|
||||
AssignableData data = qvariant_cast<AssignableData>(index.data());
|
||||
|
||||
qDebug() << data.m_rangeInfo.int_range.max;
|
||||
|
||||
switch (data.m_valueCategory) {
|
||||
case TC_ASSIGNABLE_RANGE:
|
||||
return new IntRangeEditor(parent);
|
||||
case TC_ASSIGNABLE_ENUM:
|
||||
return new EnumEditor(parent);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AssignableEditorDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
void AssignableEditorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
||||
|
||||
}
|
13
src/modules/interface/qt/data/AssignableEditorDelegate.h
Normal file
13
src/modules/interface/qt/data/AssignableEditorDelegate.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class AssignableEditorDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssignableEditorDelegate(QObject *parent = nullptr);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
};
|
Loading…
Reference in New Issue
Block a user