Kstars

filterdelegate.h
1/* Ekos Filter Delegates
2
3 Collection of delegates assigned to each individual column
4 in the table view.
5
6 SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include <QStyledItemDelegate>
14#include <QItemDelegate>
15
16class QCheckBox;
17class QSpinBox;
18class QDoubleSpinBox;
19class QComboBox;
20
21class NotEditableDelegate : public QStyledItemDelegate
22{
24 public:
25 explicit NotEditableDelegate(QObject *parent = nullptr)
27 {}
28
29 protected:
30 bool editorEvent(QEvent *, QAbstractItemModel *, const QStyleOptionViewItem &, const QModelIndex &) override
31 {
32 return false;
33 }
34 QWidget* createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override
35 {
36 return nullptr;
37 }
38};
39
40class UseAutoFocusDelegate : public QItemDelegate
41{
43 public:
44 explicit UseAutoFocusDelegate(QObject *parent = nullptr) : QItemDelegate(parent) {}
45
46 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
47 void setEditorData(QWidget *, const QModelIndex &index) const override;
48 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
49 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
50 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
51 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &, const QModelIndex &index) override;
52
53 private:
54 mutable QCheckBox *cb = { nullptr };
55};
56
57class ExposureDelegate : public QStyledItemDelegate
58{
60 public:
61 explicit ExposureDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
62
63 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
64 void setEditorData(QWidget *, const QModelIndex &index) const override;
65 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
66 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
67
68 private:
69 mutable QDoubleSpinBox *spinbox = { nullptr };
70};
71
72class OffsetDelegate : public QStyledItemDelegate
73{
75 public:
76 explicit OffsetDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
77
78 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
79 void setEditorData(QWidget *, const QModelIndex &index) const override;
80 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
81 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
82
83 private:
84 mutable QSpinBox *spinbox = { nullptr };
85};
86
87class LockDelegate : public QStyledItemDelegate
88{
90 public:
91 explicit LockDelegate(QStringList filterList, QObject *parent = nullptr);
92
93 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
94 void setEditorData(QWidget *, const QModelIndex &index) const override;
95 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
96 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
97 void setCurrentFilterList(const QStringList &list);
98
99 private:
100 mutable QComboBox *lockbox = { nullptr };
101 QStringList m_FilterList;
102};
103
Q_OBJECTQ_OBJECT
virtual bool event(QEvent *e)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.