-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace QgsNumericSortTreeWidgetItem with upgraded QgsTreeWidgetItem
QgsNumericSortTreeWidgetItem had a giant TODO saying "make it work". This makes it work, and adds some other useful features like being able to specify custom sort value and force items to always sort on top.
- Loading branch information
1 parent
631b5e8
commit 39b3e72
Showing
20 changed files
with
634 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/** \ingroup gui | ||
* \class QgsTreeWidgetItem | ||
* \note added in QGIS 3.0 | ||
* QTreeWidgetItem subclass with custom handling for item sorting. | ||
* | ||
* QgsTreeWidgetItem allows for items to be sorted using a specified user role, and | ||
* also correctly handles sorting numeric or mixed text and numeric values. | ||
*/ | ||
class QgsTreeWidgetItem : QTreeWidgetItem | ||
{ | ||
%TypeHeaderCode | ||
#include <qgstreewidgetitem.h> | ||
%End | ||
public: | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param view parent QTreeWidget view | ||
* @param type item type | ||
*/ | ||
explicit QgsTreeWidgetItem( QTreeWidget * view /TransferThis/, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param type item type | ||
*/ | ||
explicit QgsTreeWidgetItem( int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param strings list of strings containing text for each column in the item | ||
* @param type item type | ||
*/ | ||
QgsTreeWidgetItem( const QStringList &strings, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param view parent QTreeWidget view | ||
* @param strings list of strings containing text for each column in the item | ||
* @param type item type | ||
*/ | ||
QgsTreeWidgetItem( QTreeWidget *view /TransferThis/, const QStringList &strings, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param view parent QTreeWidget view | ||
* @param after QTreeWidgetItem to place insert item after in the view | ||
* @param type item type | ||
*/ | ||
QgsTreeWidgetItem( QTreeWidget *view /TransferThis/, QTreeWidgetItem *after, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param parent QTreeWidgetItem item | ||
* @param type item type | ||
*/ | ||
explicit QgsTreeWidgetItem( QTreeWidgetItem *parent /TransferThis/, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param parent QTreeWidgetItem item | ||
* @param strings list of strings containing text for each column in the item | ||
* @param type item type | ||
*/ | ||
QgsTreeWidgetItem( QTreeWidgetItem *parent /TransferThis/, const QStringList &strings, int type = Type ); | ||
|
||
/** Constructor for QgsTreeWidgetItem | ||
* @param parent QTreeWidgetItem item | ||
* @param after QTreeWidgetItem to place insert item after in the view | ||
* @param type item type | ||
*/ | ||
QgsTreeWidgetItem( QTreeWidgetItem *parent /TransferThis/, QTreeWidgetItem *after, int type = Type ); | ||
|
||
/** Sets the custom sort data for a specified column. If set, this value will be used when | ||
* sorting the item instead of the item's display text. If not set, the item's display | ||
* text will be used when sorting. | ||
* @param column column index | ||
* @param value sort value | ||
* @see sortData() | ||
*/ | ||
void setSortData( int column, const QVariant& value ); | ||
|
||
/** Returns the custom sort data for a specified column. If set, this value will be used when | ||
* sorting the item instead of the item's display text. If not set, the item's display | ||
* text will be used when sorting. | ||
* @see setSortData() | ||
*/ | ||
QVariant sortData( int column ) const; | ||
|
||
/** Sets a the item to display always on top of other items in the widget, regardless of the | ||
* sort column and sort or display value for the item. | ||
* @param priority priority for sorting always on top items. Items with a lower priority will | ||
* be placed above items with a higher priority. | ||
* @see alwaysOnTopPriority() | ||
*/ | ||
void setAlwaysOnTopPriority( int priority ); | ||
|
||
/** Returns the item's priority when it is set to show always on top. Items with a lower priority will | ||
* be placed above items with a higher priority. | ||
* @returns priority, or -1 if item is not set to show always on top | ||
* @see setAlwaysOnTopPriority() | ||
*/ | ||
int alwaysOnTopPriority() const; | ||
|
||
virtual bool operator<( const QTreeWidgetItem &other ) const; | ||
|
||
}; | ||
|
||
/** \ingroup gui | ||
* \class QgsTreeWidgetItemObject | ||
* \note added in QGIS 3.0 | ||
* Custom QgsTreeWidgetItem with extra signals when item is edited. | ||
*/ | ||
class QgsTreeWidgetItemObject: QObject, QgsTreeWidgetItem | ||
{ | ||
%TypeHeaderCode | ||
#include <qgstreewidgetitem.h> | ||
%End | ||
public: | ||
|
||
/** Constructor for QgsTreeWidgetItemObject | ||
* @param type item type | ||
*/ | ||
explicit QgsTreeWidgetItemObject( int type = Type ); | ||
|
||
/** Constructs a tree widget item of the specified type and appends it to the items in the given parent. */ | ||
explicit QgsTreeWidgetItemObject( QTreeWidget * parent /TransferThis/, int type = Type ); | ||
|
||
/** Sets the value for the item's column and role to the given value. */ | ||
virtual void setData( int column, int role, const QVariant & value ); | ||
|
||
signals: | ||
/** This signal is emitted when the contents of the column in the specified item has been edited by the user. */ | ||
void itemEdited( QTreeWidgetItem* item, int column ); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.