From 9d50ae1c0c7e914814dda39bf80f8e50e67e1b68 Mon Sep 17 00:00:00 2001 From: env Date: Fri, 9 Sep 2005 05:25:28 +0000 Subject: [PATCH] ENV: Windows porting. --- src/ObjBrowser/OB_ListItem.cxx | 181 ++++++++++++++++----------------- src/ObjBrowser/OB_ListItem.h | 36 ++++--- 2 files changed, 114 insertions(+), 103 deletions(-) diff --git a/src/ObjBrowser/OB_ListItem.cxx b/src/ObjBrowser/OB_ListItem.cxx index 570d3a9e1..b3e4badab 100755 --- a/src/ObjBrowser/OB_ListItem.cxx +++ b/src/ObjBrowser/OB_ListItem.cxx @@ -7,84 +7,23 @@ #include #include +#include +using namespace std; + /*! Class: ListItem Descr: base template class */ -template -ListItem::ListItem( SUIT_DataObject* obj, QListView* parent ) -: T( parent ), -myObject( obj ) -{ - update(); -} - -template -ListItem::ListItem( SUIT_DataObject* obj, QListViewItem* parent ) -: T( parent ), -myObject( obj ) -{ - update(); -} - -template -ListItem::ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after ) -: T( parent, after ), -myObject( obj ) -{ - update(); -} template -ListItem::ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after ) -: T( parent, after ), +ListItemF::ListItemF(T& theT, SUIT_DataObject* obj) : +myT(theT), myObject( obj ) { - update(); } template -ListItem::ListItem( SUIT_DataObject* obj, QListView* parent, int type ) -: T( parent, "", (typename T::Type)type ), -myObject( obj ) -{ - update(); -} - -template -ListItem::ListItem( SUIT_DataObject* obj, QListViewItem* parent, int type ) -: T( parent, "", (typename T::Type)type ), -myObject( obj ) -{ - update(); -} - -template -ListItem::ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, int type ) -#if defined(QT_VERSION) && QT_VERSION >= 0x030101 -: T( parent, after, "", (typename T::Type)type ), -#else -: T( parent, "", (typename T::Type)type ), -#endif -myObject( obj ) -{ - update(); -} - -template -ListItem::ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, int type ) -#if defined(QT_VERSION) && QT_VERSION >= 0x030101 -: T( parent, after, "", (typename T::Type)type ), -#else -: T( parent, "", (typename T::Type)type ), -#endif -myObject( obj ) -{ - update(); -} - -template -void ListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ) +void ListItemF::paintC( QPainter* p, const QColorGroup& cg, int c, int w, int align ) { QColorGroup colorGrp( cg ); if ( myObject ) @@ -104,41 +43,41 @@ void ListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, i } - p->fillRect( 0, 0, w, this->height(), colorGrp.brush( QColorGroup::Base ) ); - int itemW = width( p->fontMetrics(), this->listView(), c ); + p->fillRect( 0, 0, w, myT.height(), colorGrp.brush( QColorGroup::Base ) ); + int itemW = myT.width( p->fontMetrics(), myT.listView(), c ); - T::paintCell( p, colorGrp, c, itemW, align ); + //myT.paintCell( p, colorGrp, c, itemW, align ); } template -void ListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ) +void ListItemF::paintFoc( QPainter* p, const QColorGroup& cg, const QRect& r ) { QRect rect = r; - rect.setWidth( width( p->fontMetrics(), this->listView(), 0 ) ); - T::paintFocus( p, cg, rect ); + rect.setWidth( myT.width( p->fontMetrics(), myT.listView(), 0 ) ); + //myT.paintFocus( p, cg, rect ); } template -void ListItem::setSelected( bool s ) +void ListItemF::setSel( bool s ) { - QListView* lv = T::listView(); + QListView* lv = myT.listView(); if ( s && lv && lv->inherits( "OB_ListView" ) ) { OB_ListView* objlv = (OB_ListView*)lv; - s = s && objlv->isOk( this ); + s = s && objlv->isOk( &myT ); } - QListViewItem::setSelected( s ); + //myT.setSelected( s ); } template -void ListItem::update() +void ListItemF::update() { SUIT_DataObject* obj = dataObject(); if ( !obj ) return; - setText( 0, obj->name() ); + myT.setText( 0, obj->name() ); int aIconW = obj->icon().width(); if ( aIconW > 0 ) @@ -148,14 +87,14 @@ void ListItem::update() QWMatrix aM; double aScale = 20.0 / aIconW; aM.scale( aScale, aScale ); - setPixmap( 0, obj->icon().xForm( aM ) ); + myT.setPixmap( 0, obj->icon().xForm( aM ) ); } else - setPixmap( 0, obj->icon() ); + myT.setPixmap( 0, obj->icon() ); } - this->setDragEnabled( obj->isDragable() ); - this->setDropEnabled( true ); + myT.setDragEnabled( obj->isDragable() ); + myT.setDropEnabled( true ); } /*! @@ -164,29 +103,55 @@ void ListItem::update() */ OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent ) -: ListItem( obj, parent ) +: ListItemF( *this, obj ), + QListViewItem(parent) { + update(); } OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent ) -: ListItem( obj, parent ) +: ListItemF( *this, obj), + QListViewItem(parent) { + update(); } OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after ) -: ListItem( obj, parent, after ) +: ListItemF( *this, obj), +QListViewItem(parent, after ) { + update(); } OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after ) -: ListItem( obj, parent, after ) +: ListItemF( *this,obj), +QListViewItem(parent, after ) { + update(); } OB_ListItem::~OB_ListItem() { } +void OB_ListItem::setSelected( bool s ) { + cout << "OB_ListItem::setSelected" << endl; + setSel(s); + QListViewItem::setSelected(s); +} + +void OB_ListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ){ + cout << "OB_ListItem::paintFocus" << endl; + paintFoc(p, cg, r); + QListViewItem::paintFocus(p, cg, r); +} + +void OB_ListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ) { + cout << "OB_ListItem::paintCell" << endl; + paintC(p, cg, c ,w, align); + QListViewItem::paintCell(p, cg, c, w, align); +} + int OB_ListItem::RTTI() { return 1000; @@ -203,29 +168,63 @@ int OB_ListItem::rtti() const */ OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type ) -: ListItem( obj, parent, type ) +: ListItemF( *this, obj), +QCheckListItem( parent, "", type ) { + update(); } OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type ) -: ListItem( obj, parent, type ) +: ListItemF( *this, obj), +QCheckListItem( parent, "", type ) { + update(); } OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type ) -: ListItem( obj, parent, after, type ) +: ListItemF( *this, obj), +#if defined(QT_VERSION) && QT_VERSION >= 0x030101 + QCheckListItem( parent, after, "", type ) +#else + QCheckListItem( parent, "", type ) +#endif { + update(); } OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type ) -: ListItem( obj, parent, after, type ) +: ListItemF( *this, obj), +#if defined(QT_VERSION) && QT_VERSION >= 0x030101 + QCheckListItem( parent, after, "", type ) +#else + QCheckListItem( parent, "", type ) +#endif { + update(); } OB_CheckListItem::~OB_CheckListItem() { } +void OB_CheckListItem::setSelected( bool s ) { + cout << "OB_CheckListItem::setSelected" << endl; + setSel(s); + QCheckListItem::setSelected(s); +} + +void OB_CheckListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ){ + cout << "OB_CheckListItem::paintFocus" << endl; + paintFoc(p, cg, r); + QCheckListItem::paintFocus(p, cg, r); +} + +void OB_CheckListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ) { + cout << "OB_CheckListItem::paintCell" << endl; + paintC(p, cg, c ,w, align); + QCheckListItem::paintCell(p, cg, c, w, align); +} + int OB_CheckListItem::RTTI() { return OB_ListItem::RTTI() + 1; diff --git a/src/ObjBrowser/OB_ListItem.h b/src/ObjBrowser/OB_ListItem.h index cc789d297..efb5b8f20 100755 --- a/src/ObjBrowser/OB_ListItem.h +++ b/src/ObjBrowser/OB_ListItem.h @@ -12,10 +12,11 @@ class SUIT_DataObject; base template class for ListViewItems and CheckListItems */ -template class ListItem : public T +template class ListItemF { public: - ListItem( SUIT_DataObject*, QListView* ); + ListItemF(T&, SUIT_DataObject* ); + /*ListItem( SUIT_DataObject*, QListView* ); ListItem( SUIT_DataObject*, QListViewItem* ); ListItem( SUIT_DataObject*, QListView*, QListViewItem* ); ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem* ); @@ -23,25 +24,26 @@ public: ListItem( SUIT_DataObject*, QListView*, int ); ListItem( SUIT_DataObject*, QListViewItem*, int ); ListItem( SUIT_DataObject*, QListView*, QListViewItem*, int ); - ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, int ); + ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, int );*/ - virtual void setSelected( bool s ); + void setSel( 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 ); + void paintFoc( QPainter* p, const QColorGroup& cg, const QRect& r ); + void paintC( QPainter* p, const QColorGroup& cg, int c, int w, int align ); -private: +protected: void update(); -private: +protected: SUIT_DataObject* myObject; + T& myT; }; /* ListViewItem class */ -class OB_EXPORT OB_ListItem : public ListItem +class OB_EXPORT OB_ListItem : public ListItemF, public QListViewItem { public: OB_ListItem( SUIT_DataObject*, QListView* ); @@ -51,6 +53,11 @@ public: virtual ~OB_ListItem(); + virtual void setSelected( bool s ); + 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 ); + + virtual int rtti() const; static int RTTI(); @@ -60,7 +67,7 @@ public: CheckListItem class */ -class OB_EXPORT OB_CheckListItem : public ListItem +class OB_EXPORT OB_CheckListItem : public ListItemF, public QCheckListItem { public: OB_CheckListItem( SUIT_DataObject*, QListView*, Type = CheckBox ); @@ -70,6 +77,11 @@ public: virtual ~OB_CheckListItem(); + virtual void setSelected( bool s ); + 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 ); + + virtual int rtti() const; static int RTTI(); @@ -77,8 +89,8 @@ public: protected: void stateChange( bool ); -private: - void update(); +//private: +// void update(); }; #endif -- 2.39.2