QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgstreewidgetitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstreewidgetitem.h
3  -------------------
4  begin : 06 Nov, 2005
5  copyright : (C) 2005 by Brendan Morley
6  email : morb at ozemail dot com dot au
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef QGSTREEWIDGETITEM_H
20 #define QGSTREEWIDGETITEM_H
21 
22 #include <QTreeWidgetItem>
23 #include "qgis_sip.h"
24 #include <QObject>
25 #include "qgis_gui.h"
26 
36 class GUI_EXPORT QgsTreeWidgetItem : public QTreeWidgetItem
37 {
38  public:
39 
45  explicit QgsTreeWidgetItem( QTreeWidget *view SIP_TRANSFERTHIS, int type = Type );
46 
51  explicit QgsTreeWidgetItem( int type = Type );
52 
58  QgsTreeWidgetItem( const QStringList &strings, int type = Type );
59 
66  QgsTreeWidgetItem( QTreeWidget *view SIP_TRANSFERTHIS, const QStringList &strings, int type = Type );
67 
74  QgsTreeWidgetItem( QTreeWidget *view SIP_TRANSFERTHIS, QTreeWidgetItem *after, int type = Type );
75 
81  explicit QgsTreeWidgetItem( QTreeWidgetItem *parent SIP_TRANSFERTHIS, int type = Type );
82 
89  QgsTreeWidgetItem( QTreeWidgetItem *parent SIP_TRANSFERTHIS, const QStringList &strings, int type = Type );
90 
97  QgsTreeWidgetItem( QTreeWidgetItem *parent SIP_TRANSFERTHIS, QTreeWidgetItem *after, int type = Type );
98 
107  void setSortData( int column, const QVariant &value );
108 
115  QVariant sortData( int column ) const;
116 
124  void setAlwaysOnTopPriority( int priority );
125 
132  int alwaysOnTopPriority() const;
133 
138  bool operator<( const QTreeWidgetItem &other ) const override;
139 
144  bool operator>=( const QTreeWidgetItem &other ) const { return !( *this < other ); }
145 
146  private:
147 
148  enum ItemDataRole
149  {
150  CustomSortRole = Qt::UserRole + 1001,
151  AlwaysOnTopPriorityRole = Qt::UserRole + 1002,
152  };
153 
154 };
155 
162 class GUI_EXPORT QgsTreeWidgetItemObject: public QObject, public QgsTreeWidgetItem
163 {
164  Q_OBJECT
165 
166  public:
167 
172  explicit QgsTreeWidgetItemObject( int type = Type );
173 
175  explicit QgsTreeWidgetItemObject( QTreeWidget *parent SIP_TRANSFERTHIS, int type = Type );
176 
178  void setData( int column, int role, const QVariant &value ) override;
179 
180  signals:
182  void itemEdited( QTreeWidgetItem *item, int column );
183 };
184 
185 #endif // QGSTREEWIDGETITEM_H
Custom QgsTreeWidgetItem with extra signals when item is edited.
void itemEdited(QTreeWidgetItem *item, int column)
Emitted when the contents of the column in the specified item has been edited by the user.
QTreeWidgetItem subclass with custom handling for item sorting.
bool operator>=(const QTreeWidgetItem &other) const
Returns true if this item should appear after another item when sorting a list of items.
bool operator<(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is less than the second.
Definition: qgis.h:895
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53