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 <[email protected]>
7 
8  SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 
11 #pragma once
12 
13 #include <QStyledItemDelegate>
14 #include <QItemDelegate>
15 
16 class QCheckBox;
17 class QSpinBox;
18 class QDoubleSpinBox;
19 class QComboBox;
20 
21 class NotEditableDelegate : public QStyledItemDelegate
22 {
23  Q_OBJECT
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 
40 class UseAutoFocusDelegate : public QItemDelegate
41 {
42  Q_OBJECT
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 
57 class ExposureDelegate : public QStyledItemDelegate
58 {
59  Q_OBJECT
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 
72 class OffsetDelegate : public QStyledItemDelegate
73 {
74  Q_OBJECT
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 
87 class LockDelegate : public QStyledItemDelegate
88 {
89  Q_OBJECT
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 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const const override
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const const override
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const const override
QObject * parent() const const
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const const override
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.