+ setData( Qt::UserRole, items );
+ setValue( id( 0 ) );
+}
+
+void SMESHGUI_FilterTable::ComboItem::clear()
+{
+ QMap<int, QString> empty;
+ setItems( empty );
+}
+
+int SMESHGUI_FilterTable::ComboItem::count() const
+{
+ return myIdToIdx.count();
+}
+
+int SMESHGUI_FilterTable::ComboItem::value() const
+{
+ return( id( data( Qt::UserRole ).toStringList().indexOf( text() ) ) );
+}
+
+void SMESHGUI_FilterTable::ComboItem::setValue( const int theId )
+{
+ int idx = index( theId );
+ QStringList items = data( Qt::UserRole ).toStringList();
+ setText( idx >= 0 && idx < items.count() ? items[idx] : "" );
+}
+
+int SMESHGUI_FilterTable::ComboItem::id( int idx ) const
+{
+ QMap<int,int>::const_iterator it;
+ for ( it = myIdToIdx.begin(); it != myIdToIdx.end(); ++it )
+ if ( it.value() == idx ) return it.key();
+ return -1;
+}
+
+int SMESHGUI_FilterTable::ComboItem::index( int i ) const
+{
+ return myIdToIdx.contains( i ) ? myIdToIdx[i] : -1;
+}
+/*
+ Class : SMESHGUI_FilterTable::CheckItem
+ Description : Check table item.
+*/
+
+class SMESHGUI_FilterTable::CheckItem : public QTableWidgetItem
+{
+public:
+ static int Type();
+
+ CheckItem( bool = false );
+ CheckItem( const QString&, bool = false );
+ ~CheckItem();
+
+ void setChecked( bool );
+ bool checked() const;
+};
+
+int SMESHGUI_FilterTable::CheckItem::Type()
+{
+ return QTableWidgetItem::UserType + 2;
+}
+
+SMESHGUI_FilterTable::CheckItem::CheckItem( bool value )
+ : QTableWidgetItem( Type() )
+{
+ Qt::ItemFlags f = flags();
+ f = f | Qt::ItemIsUserCheckable;
+ f = f & ~Qt::ItemIsTristate;
+ f = f & ~Qt::ItemIsEditable;
+ setFlags( f );
+ setChecked(value);
+}
+
+SMESHGUI_FilterTable::CheckItem::CheckItem( const QString& text, bool value )
+ : QTableWidgetItem( Type() )
+{
+ Qt::ItemFlags f = flags();
+ f = f | Qt::ItemIsUserCheckable;
+ f = f & ~Qt::ItemIsTristate;
+ f = f & ~Qt::ItemIsEditable;
+ setFlags( f );
+ setChecked( value );
+ setText( text );
+}
+
+SMESHGUI_FilterTable::CheckItem::~CheckItem()
+{
+}
+
+void SMESHGUI_FilterTable::CheckItem::setChecked( bool value )
+{
+ setCheckState( value ? Qt::Checked : Qt::Unchecked );
+}
+
+bool SMESHGUI_FilterTable::CheckItem::checked() const
+{
+ return checkState() == Qt::Checked;
+}
+
+/*
+ Class : SMESHGUI_FilterTable::ComboDelegate
+ Description : Table used by this widget
+*/
+
+class SMESHGUI_FilterTable::ComboDelegate : public QItemDelegate
+{
+public:
+ ComboDelegate( QObject* = 0 );
+ ~ComboDelegate();
+
+ QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
+ const QModelIndex& ) const;
+
+ void setEditorData( QWidget*, const QModelIndex& ) const;
+ void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
+
+ void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&,
+ const QModelIndex& ) const;
+private:
+ QTableWidget* myTable;
+};