pqTreeWidgetItem.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqTreeWidgetItem_h
5 #define pqTreeWidgetItem_h
6 
7 #include "pqWidgetsModule.h"
8 #include <QTreeWidgetItem>
9 
16 class PQWIDGETS_EXPORT pqTreeWidgetItem : public QTreeWidgetItem
17 {
18  typedef QTreeWidgetItem Superclass;
19 
20 public:
21  pqTreeWidgetItem(int atype = UserType)
22  : Superclass(atype)
23  , CallbackHandler(nullptr)
24  {
25  }
26  pqTreeWidgetItem(const QStringList& strings, int atype = UserType)
27  : Superclass(strings, atype)
28  , CallbackHandler(nullptr)
29  {
30  }
31  pqTreeWidgetItem(QTreeWidget* aparent, int atype = UserType)
32  : Superclass(aparent, atype)
33  , CallbackHandler(nullptr)
34  {
35  }
36  pqTreeWidgetItem(QTreeWidget* aparent, const QStringList& strings, int atype = UserType)
37  : Superclass(aparent, strings, atype)
38  , CallbackHandler(nullptr)
39  {
40  }
41  pqTreeWidgetItem(QTreeWidget* aparent, QTreeWidgetItem* preceding, int atype = UserType)
42  : Superclass(aparent, preceding, atype)
43  , CallbackHandler(nullptr)
44  {
45  }
46  pqTreeWidgetItem(QTreeWidgetItem* aparent, int atype = UserType)
47  : Superclass(aparent, atype)
48  , CallbackHandler(nullptr)
49  {
50  }
51  pqTreeWidgetItem(QTreeWidgetItem* aparent, const QStringList& strings, int atype = UserType)
52  : Superclass(aparent, strings, atype)
53  , CallbackHandler(nullptr)
54  {
55  }
56  pqTreeWidgetItem(QTreeWidgetItem* aparent, QTreeWidgetItem* preceding, int atype = UserType)
57  : Superclass(aparent, preceding, atype)
58  , CallbackHandler(nullptr)
59  {
60  }
61 
65  void setData(int column, int role, const QVariant& v) override;
66 
68  {
69  public:
70  virtual ~pqCallbackHandler() = default;
71 
75  virtual void dataAboutToChange(pqTreeWidgetItem* /*item*/, int /*column*/, int /*role*/){};
76 
80  virtual void checkStateAboutToChange(pqTreeWidgetItem* /*item*/, int /*column*/){};
81 
85  virtual void checkStateChanged(pqTreeWidgetItem* /*item*/, int /*column*/){};
86 
90  virtual void dataChanged(pqTreeWidgetItem* /*item*/, int /*column*/, int /*role*/){};
91 
95  virtual bool acceptChange(pqTreeWidgetItem* /*item*/, const QVariant& /*curValue*/,
96  const QVariant& /*newValue*/, int /*column*/, int /*role*/)
97  {
98  return true;
99  }
100  };
101 
105  void setCallbackHandler(pqCallbackHandler* hdlr) { this->CallbackHandler = hdlr; }
106 
107 protected:
109 };
110 
111 #endif
pqTreeWidgetItem(QTreeWidgetItem *aparent, int atype=UserType)
pqTreeWidgetItem(const QStringList &strings, int atype=UserType)
pqTreeWidgetItem(QTreeWidget *aparent, QTreeWidgetItem *preceding, int atype=UserType)
void setCallbackHandler(pqCallbackHandler *hdlr)
Set the name of the callback slot to call.
pqTreeWidgetItem(QTreeWidget *aparent, const QStringList &strings, int atype=UserType)
virtual void checkStateAboutToChange(pqTreeWidgetItem *, int)
Called to indicate that the data is about to be changed.
pqTreeWidgetItem(QTreeWidgetItem *aparent, QTreeWidgetItem *preceding, int atype=UserType)
virtual void dataChanged(pqTreeWidgetItem *, int, int)
Called to indicate that the data has been changed.
virtual bool acceptChange(pqTreeWidgetItem *, const QVariant &, const QVariant &, int, int)
Called to check if the change has to be accepted or rejected.
pqTreeWidgetItem is a QTreeWidgetItem with callbacks for whenever the data for the pqTreeWidgetItem c...
#define PQWIDGETS_EXPORT
pqTreeWidgetItem(QTreeWidgetItem *aparent, const QStringList &strings, int atype=UserType)
pqCallbackHandler * CallbackHandler
pqTreeWidgetItem(int atype=UserType)
virtual void dataAboutToChange(pqTreeWidgetItem *, int, int)
Called to indicate that the data is about to be changed.
pqTreeWidgetItem(QTreeWidget *aparent, int atype=UserType)
virtual void checkStateChanged(pqTreeWidgetItem *, int)
Called to indicate that the check state for the item has been changed.