#include "OB_ListItem.h"
+#include "OB_ListView.h"
+
#include <SUIT_DataObject.h>
#include <qpainter.h>
T::paintFocus( p, cg, rect );
}
+template<class T>
+void ListItem<T>::setSelected( bool s )
+{
+ if ( s && listView() && listView()->inherits( "OB_ListView" ) )
+ {
+ OB_ListView* oblv = (OB_ListView*)listView();
+ s = s && oblv->isOk( this );
+ }
+
+ QListViewItem::setSelected( s );
+}
+
template<class T>
void ListItem<T>::update()
{
base template class for ListViewItems and CheckListItems
*/
-template<class T> class ListItem : public T {
+template<class T> class ListItem : public T
+{
public:
ListItem( SUIT_DataObject*, QListView* );
ListItem( SUIT_DataObject*, QListViewItem* );
ListItem( SUIT_DataObject*, QListView*, QListViewItem*, int );
ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, int );
- virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
-
- virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
-
- inline SUIT_DataObject* dataObject() const
- { return myObject; }
+ virtual void setSelected( bool s );
+ inline SUIT_DataObject* dataObject() const { return myObject; }
+ virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
+ virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
private:
- void update();
+ void update();
private:
SUIT_DataObject* myObject;
myFilter = f;
}
-void OB_ListView::setSelected( QListViewItem* item, bool sel )
+bool OB_ListView::isOk( QListViewItem* item ) const
{
- bool on = sel;
- if ( filter() )
- {
- SUIT_DataObject* obj = dataObject( item );
- if ( obj )
- on = on && filter()->isOk( obj );
- }
-
- QListView::setSelected( item, on );
+ bool ok = true;
+ SUIT_DataObject* obj = dataObject( item );
+ if ( obj && filter() )
+ ok = filter()->isOk( obj );
+ return ok;
}
int OB_ListView::addColumn( const QString& label, int width )
OB_Filter* filter() const;
void setFilter( OB_Filter* );
- virtual void setSelected( QListViewItem*, bool );
-
virtual int addColumn( const QString& label, int width = -1 );
virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
+ bool isOk( QListViewItem* ) const;
+
signals:
void dropped( QPtrList<QListViewItem>, QListViewItem*, int );