mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
1a0a4b7e08
This patch fixes the combobox behavior on the inline edit to what it was ( well, similar to ) the GTK version, up and arrow keys will walk you to the list of choices, and it will update the other data as soon as you walks over it one drawback is that you cant ( for now, since I do have a very big headache at the moment ) cancel, since the cancel will just forgets the item and do not call 'setData' on the model, but we already called it while walking on the list. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#ifndef MODELDELEGATES_H
|
|
#define MODELDELEGATES_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
class QComboBox;
|
|
|
|
class StarWidgetsDelegate : public QStyledItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
explicit StarWidgetsDelegate(QWidget* parent = 0);
|
|
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
private:
|
|
QWidget *parentWidget;
|
|
};
|
|
|
|
class ComboBoxDelegate : public QStyledItemDelegate{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
|
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
|
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
virtual bool eventFilter(QObject* object, QEvent* event);
|
|
public slots:
|
|
void testActivation(const QString& s);
|
|
protected:
|
|
QAbstractItemModel *model;
|
|
};
|
|
|
|
class TankInfoDelegate : public ComboBoxDelegate{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TankInfoDelegate(QObject* parent = 0);
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
|
};
|
|
|
|
class WSInfoDelegate : public ComboBoxDelegate{
|
|
Q_OBJECT
|
|
public:
|
|
explicit WSInfoDelegate(QObject* parent = 0);
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
|
};
|
|
|
|
#endif
|