2013-04-27 15:27:27 +00:00
|
|
|
#ifndef MODELDELEGATES_H
|
|
|
|
#define MODELDELEGATES_H
|
|
|
|
|
2013-05-02 22:27:36 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2013-07-16 18:31:44 +00:00
|
|
|
class QComboBox;
|
2013-10-03 14:50:40 +00:00
|
|
|
class QPainter;
|
2013-04-27 15:27:27 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveListDelegate : public QStyledItemDelegate {
|
2013-12-11 23:44:05 +00:00
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DiveListDelegate(QObject *parent = 0)
|
|
|
|
: QStyledItemDelegate(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2013-12-11 23:44:05 +00:00
|
|
|
};
|
|
|
|
|
2013-05-02 22:27:36 +00:00
|
|
|
class StarWidgetsDelegate : public QStyledItemDelegate {
|
2013-04-27 15:27:27 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
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;
|
|
|
|
|
2013-05-02 22:27:36 +00:00
|
|
|
private:
|
|
|
|
QWidget *parentWidget;
|
2013-04-27 15:27:27 +00:00
|
|
|
};
|
2013-05-22 17:11:49 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class ComboBoxDelegate : public QStyledItemDelegate {
|
2013-05-22 17:11:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
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 &currString = QString());
|
Make the Qt ComboBox behave in a Better Way
So, the ComboBox is a beast, and when used on a Delegate
it's very hard to get things right, wich is a pitty, because
I overly like qt. So:
1 - Combobox needs to show the popup when user press ↓ and ↑ keys
2 - Combobox needs to select when user press enter, not twice.
3 - Combobox neesds to select when user selects from the mouse, not
pressing enter after.
4 - Combobox needs to not mess with stuff when moving around.
Everything that I listed there works on a non-delegate combobox,
but for some reason, a delegate missed those, so I reimplemented
all. not nice, but now we have a code that will work, I hope.
*fingers crossed*
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-25 19:37:24 +00:00
|
|
|
//HACK: try to get rid of this in the future.
|
|
|
|
void fakeActivation();
|
2013-10-15 16:45:24 +00:00
|
|
|
void fixTabBehavior();
|
2014-02-28 04:09:57 +00:00
|
|
|
virtual void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
|
|
|
|
2013-06-16 13:15:19 +00:00
|
|
|
protected:
|
|
|
|
QAbstractItemModel *model;
|
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class TankInfoDelegate : public ComboBoxDelegate {
|
2013-06-16 13:15:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit TankInfoDelegate(QObject *parent = 0);
|
|
|
|
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
|
|
|
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
2013-05-22 17:11:49 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class WSInfoDelegate : public ComboBoxDelegate {
|
2013-05-24 01:40:16 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit WSInfoDelegate(QObject *parent = 0);
|
|
|
|
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
|
|
|
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
2013-05-24 01:40:16 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class AirTypesDelegate : public ComboBoxDelegate {
|
2013-08-30 10:14:30 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit AirTypesDelegate(QObject *parent = 0);
|
|
|
|
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
2013-08-30 10:14:30 +00:00
|
|
|
};
|
|
|
|
|
2013-10-03 14:50:40 +00:00
|
|
|
/* ProfilePrintDelagate:
|
|
|
|
* this delegate is used to modify the look of the table that is printed
|
|
|
|
* bellow profiles.
|
|
|
|
*/
|
2014-02-28 04:09:57 +00:00
|
|
|
class ProfilePrintDelegate : public QStyledItemDelegate {
|
2013-10-03 14:50:40 +00:00
|
|
|
public:
|
|
|
|
explicit ProfilePrintDelegate(QObject *parent = 0);
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // MODELDELEGATES_H
|