|
| 1 | +/*************************************************************************** |
| 2 | + qgstablewidgetitem.h - QgsTableWidgetItem |
| 3 | +
|
| 4 | + --------------------- |
| 5 | + begin : 27.3.2016 |
| 6 | + copyright : (C) 2016 by Matthias Kuhn, OPENGIS.ch |
| 7 | + email : matthias@opengis.ch |
| 8 | + *************************************************************************** |
| 9 | + * * |
| 10 | + * This program is free software; you can redistribute it and/or modify * |
| 11 | + * it under the terms of the GNU General Public License as published by * |
| 12 | + * the Free Software Foundation; either version 2 of the License, or * |
| 13 | + * (at your option) any later version. * |
| 14 | + * * |
| 15 | + ***************************************************************************/ |
| 16 | +#ifndef QGSTABLEWIDGETITEM_H |
| 17 | +#define QGSTABLEWIDGETITEM_H |
| 18 | + |
| 19 | +#include <QTableWidget> |
| 20 | + |
| 21 | +/** |
| 22 | + * This can be used like a regular QTableWidgetItem with the difference that a |
| 23 | + * specific role can be set to sort. |
| 24 | + */ |
| 25 | +class GUI_EXPORT QgsTableWidgetItem : public QTableWidgetItem |
| 26 | +{ |
| 27 | + public: |
| 28 | + QgsTableWidgetItem(); |
| 29 | + /** |
| 30 | + * Creates a new table widget item with the specified text. |
| 31 | + */ |
| 32 | + QgsTableWidgetItem( const QString& text ); |
| 33 | + |
| 34 | + |
| 35 | + /** |
| 36 | + * Set the role by which the items should be sorted. |
| 37 | + * By default this will be set to Qt::DisplayRole |
| 38 | + */ |
| 39 | + void setSortRole( int role ); |
| 40 | + /** |
| 41 | + * Get the role by which the items should be sorted. |
| 42 | + * By default this will be Qt::DisplayRole |
| 43 | + */ |
| 44 | + int sortRole() const; |
| 45 | + |
| 46 | + bool operator <( const QTableWidgetItem& other ) const override; |
| 47 | + |
| 48 | + private: |
| 49 | + int mSortRole; |
| 50 | +}; |
| 51 | + |
| 52 | +#endif // QGSTABLEWIDGETITEM_H |
0 commit comments