From c27df5bb311a30afc85d6ab8e96dfb876342d141 Mon Sep 17 00:00:00 2001 From: ptv Date: Wed, 15 Nov 2006 06:36:15 +0000 Subject: [PATCH] remove fix from syspipe as regression on popup menu !!! --- src/Qtx/QtxAction.cxx | 305 ++++++++++++++++++----------------- src/Qtx/QtxActionMenuMgr.cxx | 118 +++++++------- src/Qtx/QtxActionMgr.cxx | 23 +-- src/Qtx/QtxActionToolMgr.cxx | 10 +- src/Qtx/QtxLogoMgr.cxx | 17 +- src/Qtx/QtxTable.cxx | 15 ++ 6 files changed, 265 insertions(+), 223 deletions(-) diff --git a/src/Qtx/QtxAction.cxx b/src/Qtx/QtxAction.cxx index 0dfba4cda..28173344b 100755 --- a/src/Qtx/QtxAction.cxx +++ b/src/Qtx/QtxAction.cxx @@ -21,8 +21,9 @@ #include "QtxAction.h" -#include + #include +#include /*! Name: QtxAction [public] @@ -31,7 +32,7 @@ */ QtxAction::QtxAction( QObject* parent, const char* name, bool toggle ) -: QAction( parent, name, toggle ) + : QAction( parent, name, toggle ) { } @@ -47,7 +48,7 @@ QtxAction::QtxAction( QObject* parent, const char* name, bool toggle ) QtxAction::QtxAction( const QString& text, const QIconSet& icon, const QString& menuText, int accel, QObject* parent, const char* name, bool toggle ) -: QAction( text, icon, menuText, accel, parent, name, toggle ) + : QAction( text, icon, menuText, accel, parent, name, toggle ) { } @@ -61,7 +62,7 @@ QtxAction::QtxAction( const QString& text, const QIconSet& icon, QtxAction::QtxAction( const QString& text, const QString& menuText, int accel, QObject* parent, const char* name, bool toggle ) -: QAction( text, menuText, accel, parent, name, toggle ) + : QAction( text, menuText, accel, parent, name, toggle ) { } @@ -82,41 +83,43 @@ QtxAction::~QtxAction() bool QtxAction::addTo( QWidget* w ) { - if ( !w->inherits( "QMenuBar" ) ) - return QAction::addTo( w ); - - // --- Add action to the QMenuBar --- - // n.b. currently for the actions inserted to the menu bar - // the following properties are not supported: - // * tooltips - // * what's this info - // * toggle mode - QMenuBar* mb = (QMenuBar*)w; - if ( myMenuIds.contains( w ) ) + if ( w->inherits( "QMenuBar" ) ) { + + + // --- Add action to the QMenuBar --- + // n.b. currently for the actions inserted to the menu bar + // the following properties are not supported: + // * tooltips + // * what's this info + // * toggle mode + QMenuBar* mb = (QMenuBar*)w; + if ( myMenuIds.find( w ) != myMenuIds.end() ) return false; // already added - QMenuData* mData = mb; - int idx = mData->count(); - while ( idx > 0 ) - { - QMenuData* md = 0; - QMenuItem* mItem = mb->findItem( mb->idAt( idx - 1 ), &md ); - if ( md == mData && mItem && mItem->isSeparator() && mItem->widget() && qstrcmp( mItem->widget()->name(), "qt_maxtools" ) ) - idx--; - else - break; - } - if ( name() == "qt_separator_action" ) // separator - myMenuIds.insert( w, mb->insertSeparator( idx ) ); - else if ( iconSet().isNull() ) // has no icon - myMenuIds.insert( w, mb->insertItem( menuText(), this, SIGNAL( activated() ), accel(), -1, idx ) ); - else // has icon - myMenuIds.insert( w, mb->insertItem( iconSet(), menuText(), this, SIGNAL( activated() ), accel(), -1, idx ) ); - - mb->setItemEnabled( myMenuIds[w], isEnabled() ); - mb->setItemVisible( myMenuIds[w], isVisible() ); - return true; + + + + + + + + + + + + if ( name() == "qt_separator_action" ) // separator + myMenuIds[ w ] = mb->insertSeparator(); + else if ( iconSet().isNull() ) // has no icon + myMenuIds[ w ] = mb->insertItem( menuText(), this, SIGNAL( activated() ), accel() ); + else // has icon + myMenuIds[ w ] = mb->insertItem( iconSet(), menuText(), this, SIGNAL( activated() ), accel() ); + mb->setItemEnabled( myMenuIds[ w ], isEnabled() ); + mb->setItemVisible( myMenuIds[ w ], isVisible() ); + + return true; + } + return QAction::addTo( w ); } /*! @@ -131,109 +134,109 @@ bool QtxAction::addTo( QWidget* w, const int index ) if ( !addTo( w ) ) return false; - if ( w->inherits( "QPopupMenu" ) ) - { + if ( w->inherits( "QPopupMenu" ) ) { + // --- Add action to the QPopupMenu --- QPopupMenu* popup = (QPopupMenu*)w; - if ( index >= 0 && index < (int)popup->count() - 1 ) - { + if ( index >= 0 && index < (int)popup->count() - 1 ) { + int id = popup->idAt( popup->count() - 1 ); - if ( id != -1 ) - { - QMenuItem* item = popup->findItem( id ); - if ( item && item->isSeparator() ) - { - popup->removeItem( id ); - popup->insertSeparator( index ); - } - else - { - QPopupMenu* p = item ? item->popup() : 0; - int accel = popup->accel( id ); - bool isOn = popup->isItemEnabled( id ); - bool isVisible = popup->isItemVisible( id ); - bool isChecked = popup->isItemChecked( id ); - QString text = popup->text( id ); - QIconSet icon; - if ( popup->iconSet( id ) ) - icon = *popup->iconSet( id ); - popup->removeItem( id ); - int pos; - if ( icon.isNull() ) - { - if ( p ) - pos = popup->indexOf( popup->insertItem( text, p, id, index ) ); - else - pos = popup->indexOf( popup->insertItem( text, id, index ) ); - } - else - { - if ( p ) - pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) ); - else - pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) ); - } - popup->setId( pos, id ); - popup->setAccel( accel, id ); - popup->setItemEnabled( id, isOn ); - popup->setItemVisible( id, isVisible ); - popup->setItemChecked( id, isChecked ); - if ( !whatsThis().isEmpty() ) - popup->setWhatsThis( id, whatsThis() ); - if ( !p ) - popup->connectItem( id, this, SLOT( internalActivation() ) ); - } + if ( id != -1 ) { + + QMenuItem* item = popup->findItem( id ); + if ( item && item->isSeparator() ) { + + popup->removeItem( id ); + popup->insertSeparator( index ); + } + else { + + QPopupMenu* p = item ? item->popup() : 0; + int accel = popup->accel( id ); + bool isOn = popup->isItemEnabled( id ); + bool isVisible = popup->isItemVisible( id ); + bool isChecked = popup->isItemChecked( id ); + QString text = popup->text( id ); + QIconSet icon; + if ( popup->iconSet( id ) ) + icon = *popup->iconSet( id ); + popup->removeItem( id ); + int pos; + if ( icon.isNull() ) + + if ( p ) + pos = popup->indexOf( popup->insertItem( text, p, id, index ) ); + else + pos = popup->indexOf( popup->insertItem( text, id, index ) ); + + else + + if ( p ) + pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) ); + else + pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) ); + + popup->setId( pos, id ); + popup->setAccel( accel, id ); + popup->setItemEnabled( id, isOn ); + popup->setItemVisible( id, isVisible ); + popup->setItemChecked( id, isChecked ); + if ( !whatsThis().isEmpty() ) + popup->setWhatsThis( id, whatsThis() ); + if ( !p ) + popup->connectItem( id, this, SLOT( internalActivation() ) ); + } } } } - else if ( w->inherits( "QMenuBar" ) ) - { + else if ( w->inherits( "QMenuBar" ) ) { + // --- Add action to the QMenuBar --- QMenuBar* mb = (QMenuBar*)w; - if ( index >= 0 && index < (int)mb->count() - 1 ) - { + if ( index >= 0 && index < (int)mb->count() - 1 ) { + int id = mb->idAt( mb->count() - 1 ); - if ( id != -1 ) - { - QMenuItem* item = mb->findItem( id ); - if ( item && item->isSeparator() ) - { - mb->removeItem( id ); - mb->insertSeparator( index ); - } - else - { - QPopupMenu* p = item ? item->popup() : 0; - int accel = mb->accel( id ); - bool isOn = mb->isItemEnabled( id ); - bool isVisible = mb->isItemVisible( id ); - QString text = mb->text( id ); - QIconSet icon; - if ( mb->iconSet( id ) ) - icon = *mb->iconSet( id ); - mb->removeItem( id ); - int pos; - if ( icon.isNull() ) - { - if ( p ) - pos = mb->indexOf( mb->insertItem( text, p, id, index ) ); - else - pos = mb->indexOf( mb->insertItem( text, id, index ) ); - } - else - { - if ( p ) - pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) ); - else - pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) ); - } - mb->setId( pos, id ); - mb->setAccel( accel, id ); - mb->setItemEnabled( id, isOn ); - mb->setItemVisible( id, isVisible ); - if ( !p ) - mb->connectItem( id, this, SIGNAL( activated() ) ); - } + if ( id != -1 ) { + + QMenuItem* item = mb->findItem( id ); + if ( item && item->isSeparator() ) { + + mb->removeItem( id ); + mb->insertSeparator( index ); + } + else { + + QPopupMenu* p = item ? item->popup() : 0; + int accel = mb->accel( id ); + bool isOn = mb->isItemEnabled( id ); + bool isVisible = mb->isItemVisible( id ); + QString text = mb->text( id ); + QIconSet icon; + if ( mb->iconSet( id ) ) + icon = *mb->iconSet( id ); + mb->removeItem( id ); + int pos; + if ( icon.isNull() ) + + if ( p ) + pos = mb->indexOf( mb->insertItem( text, p, id, index ) ); + else + pos = mb->indexOf( mb->insertItem( text, id, index ) ); + + else + + if ( p ) + pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) ); + else + pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) ); + + mb->setId( pos, id ); + mb->setAccel( accel, id ); + mb->setItemEnabled( id, isOn ); + mb->setItemVisible( id, isVisible ); + if ( !p ) + mb->connectItem( id, this, SIGNAL( activated() ) ); + } } } } @@ -248,21 +251,21 @@ bool QtxAction::addTo( QWidget* w, const int index ) bool QtxAction::removeFrom( QWidget* w ) { - bool res = false; + // check if widget is QMenuBar - if ( w->inherits( "QMenuBar" ) ) - { + if ( w->inherits( "QMenuBar" ) ) { + QMenuBar* mb = (QMenuBar*)w; - if ( myMenuIds.find( w ) != myMenuIds.end() ) - { - mb->removeItem( myMenuIds[ w ] ); - myMenuIds.remove( w ); - res = true; - } + if ( myMenuIds.find( w ) == myMenuIds.end() ) + return false; // not yet added + mb->removeItem( myMenuIds[ w ] ); + myMenuIds.remove( w ); + return true; + } - else - res = QAction::removeFrom( w ); - return res; + return QAction::removeFrom( w ); + + } /*! @@ -308,27 +311,27 @@ void QtxAction::setPopup( QWidget* w, const int id, QPopupMenu* subPopup ) const pmd->removeItem( id ); // add new item - if ( w->inherits( "QPopupMenu" ) ) - { + if ( w->inherits( "QPopupMenu" ) ) { + // --- QPopupMenu --- QPopupMenu* popup = (QPopupMenu*)w; if ( icon.isNull() ) pos = popup->indexOf( subPopup ? popup->insertItem( text, subPopup, id, pos ) : - popup->insertItem( text, id, pos ) ); + popup->insertItem( text, id, pos ) ); else pos = popup->indexOf( subPopup ? popup->insertItem( icon, text, subPopup, id, pos ) : - popup->insertItem( icon, text, id, pos ) ); + popup->insertItem( icon, text, id, pos ) ); } - else - { + else { + // --- QMenuBar --- QMenuBar* mb = (QMenuBar*)w; if ( icon.isNull() ) pos = mb->indexOf( subPopup ? mb->insertItem( text, subPopup, id, pos ) : - mb->insertItem( text, id, pos ) ); + mb->insertItem( text, id, pos ) ); else pos = mb->indexOf( subPopup ? mb->insertItem( icon, text, subPopup, id, pos ) : - mb->insertItem( icon, text, id, pos ) ); + mb->insertItem( icon, text, id, pos ) ); } // restore properties @@ -340,3 +343,5 @@ void QtxAction::setPopup( QWidget* w, const int id, QPopupMenu* subPopup ) const // delete old popup delete oldPopup; } + + diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index aa49bd8bd..3b5cef89a 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -115,12 +115,13 @@ public: QPopupMenu* popup() const; private: - int myId; - QPopupMenu* myPopup; - bool myEmptyEnabled; - QMap myIds; + int myId; + QPopupMenu* myPopup; + bool myEmptyEnabled; + QMap myIds; }; + /*! Constructor for menu action \param text - description text @@ -130,12 +131,15 @@ private: \param allowEmpty - if it is true, it makes possible to add this action with empty popup to menu */ -QtxActionMenuMgr::MenuAction::MenuAction( const QString& text, const QString& menuText, - QObject* parent, const int id, const bool allowEmpty ) +QtxActionMenuMgr::MenuAction::MenuAction( const QString& text, + const QString& menuText, + QObject* parent, + const int id, + const bool allowEmpty ) : QtxAction( text, menuText, 0, parent ), -myId( id ), -myPopup( 0 ), -myEmptyEnabled( allowEmpty ) + myId( id ), + myPopup( 0 ), + myEmptyEnabled( allowEmpty ) { myPopup = new QPopupMenu(); } @@ -168,29 +172,29 @@ bool QtxActionMenuMgr::MenuAction::addTo( QWidget* w ) if ( !myEmptyEnabled && !myPopup->count() ) return false; // not allowed empty menu - if ( w->inherits( "QPopupMenu" ) ) - { + if ( w->inherits( "QPopupMenu" ) ) { + QValueList l = prepareIds( w ); int idx; - if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) - { + if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) { + QPopupMenu* pm = (QPopupMenu*)w; myIds[ w ] = pm->idAt( idx ); if ( myId != -1 ) - pm->setId( idx, myId ); + pm->setId( idx, myId ); setPopup( pm, myId != -1 ? myId : myIds[ w ], myPopup ); } } - else if ( w->inherits( "QMenuBar" ) ) - { + else if ( w->inherits( "QMenuBar" ) ) { + QValueList l = prepareIds( w ); int idx; - if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) - { + if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) { + QMenuBar* mb = (QMenuBar*)w; myIds[ w ] = mb->idAt( idx ); if ( myId != -1 ) - mb->setId( idx, myId ); + mb->setId( idx, myId ); setPopup( mb, myId != -1 ? myId : myIds[ w ], myPopup ); } } @@ -214,26 +218,26 @@ bool QtxActionMenuMgr::MenuAction::removeFrom( QWidget* w ) if ( myIds.find( w ) == myIds.end() ) return false; // not yet added - if ( w->inherits( "QPopupMenu" ) ) - { - if ( myId != -1 ) - { + if ( w->inherits( "QPopupMenu" ) ) { + if ( myId != -1 ) { + + QPopupMenu* pm = (QPopupMenu*)w; int idx = pm->indexOf( myId ); - if ( idx != -1 ) - pm->setId( idx, myIds[ w ] ); + if ( idx != -1 ) pm->setId( idx, myIds[ w ] ); + } myIds.remove( w ); return QtxAction::removeFrom( w );; } else if ( w->inherits( "QMenuBar" ) ) { - if ( myId != -1 ) - { + if ( myId != -1 ) { + QMenuBar* mb = (QMenuBar*)w; int idx = mb->indexOf( myId ); - if ( idx != -1 ) - mb->setId( idx, myIds[ w ] ); + if ( idx != -1 ) mb->setId( idx, myIds[ w ] ); + } myIds.remove( w ); return QtxAction::removeFrom( w ); @@ -255,7 +259,7 @@ QPopupMenu* QtxActionMenuMgr::MenuAction::popup() const */ QtxActionMenuMgr::QtxActionMenuMgr( QMainWindow* p ) : QtxActionMgr( p ), -myMenu( p ? p->menuBar() : 0 ) + myMenu( p ? p->menuBar() : 0 ) { myRoot.id = -1; myRoot.group = -1; @@ -274,7 +278,7 @@ myMenu( p ? p->menuBar() : 0 ) */ QtxActionMenuMgr::QtxActionMenuMgr( QWidget* mw, QObject* p ) : QtxActionMgr( p ), -myMenu( mw ) + myMenu( mw ) { myRoot.id = -1; myRoot.group = -1; @@ -407,7 +411,7 @@ int QtxActionMenuMgr::insert( const int id, const int pId, const int group, cons node->idx = idx; node->group = group; - pNode->children.append( node ); + pNode->children.append( node ); triggerUpdate( pNode->id, false ); @@ -468,7 +472,7 @@ int QtxActionMenuMgr::insert( const QString& title, const int pId, const int gro node->idx = idx; node->id = myMenus.insert( gid, ma ).key(); - pNode->children.append( node ); + pNode->children.append( node ); triggerUpdate( pNode->id, false ); @@ -919,15 +923,15 @@ void QtxActionMenuMgr::updateMenu( MenuNode* startNode, const bool rec, const bo a->removeFrom( mw ); } /* VSR: commented to allow direct creating of menus by calling insertItem() methods - if ( mw->inherits( "QMenuBar" ) ) - ((QMenuBar*)mw)->clear(); - else if ( mw->inherits( "QPopupMenu" ) ) - ((QPopupMenu*)mw)->clear(); + if ( mw->inherits( "QMenuBar" ) ) + ((QMenuBar*)mw)->clear(); + else if ( mw->inherits( "QPopupMenu" ) ) + ((QPopupMenu*)mw)->clear(); */ QMap idMap; for ( NodeListIterator it2( node->children ); it2.current(); ++it2 ) { - NodeList& lst = idMap[it2.current()->group]; + NodeList& lst = idMap[it2.current()->group]; int idx = it2.current()->idx; if ( idx < 0 || idx >= (int)lst.count() ) lst.append( it2.current() ); @@ -949,18 +953,21 @@ void QtxActionMenuMgr::updateMenu( MenuNode* startNode, const bool rec, const bo const NodeList& lst = idMap[*gIt]; for ( NodeListIterator iter( lst ); iter.current(); ++iter ) { - if ( rec ) - updateMenu( iter.current(), rec, false ); + + MenuNode* par = iter.current()->parent; if ( !isVisible( iter.current()->id, par ? par->id : -1 ) ) continue; + if ( rec ) + updateMenu( iter.current(), rec, false ); + QAction* a = itemAction( iter.current()->id ); if ( !a ) a = menuAction( iter.current()->id ); if ( a ) - a->addTo( mw ); + a->addTo( mw ); } } @@ -975,11 +982,11 @@ void QtxActionMenuMgr::updateMenu( MenuNode* startNode, const bool rec, const bo */ void QtxActionMenuMgr::internalUpdate() { - if ( !isUpdatesEnabled() ) - return; + if ( isUpdatesEnabled() ) + + + updateMenu(); - updateMenu(); - myUpdateIds.clear(); } /*! @@ -1113,16 +1120,16 @@ void QtxActionMenuMgr::triggerUpdate( const int id, const bool rec ) */ void QtxActionMenuMgr::updateContent() { - // Warning: For correct updating it is necessary to update the most enclosed submenu firstly - // because not updated empty submenu will be skipped. Now the submenu are iterated in - // ascending order their identifiers. For a submenu with automatically generated identifiers - // will work correctly as the uppermost submenu have the biggest number (identifiers generated - // reduction from -1). Generally when any submenu will have positive identifiers are obviously - // appropriated can to work not truly. In this case it is required to improve the given method - // and to add preliminary sorting a submenu on depth of an enclosure. + + + + + + + for ( QMap::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it ) { - MenuNode* node = it.key() == -1 ? &myRoot : find( it.key() ); + MenuNode* node = find( it.key(), 0 ); if ( node ) updateMenu( node, it.data() ); } @@ -1134,9 +1141,10 @@ void QtxActionMenuMgr::updateContent() \param r - menu reader \param mgr - menu manager */ -QtxActionMenuMgr::MenuCreator::MenuCreator( QtxActionMgr::Reader* r, QtxActionMenuMgr* mgr ) +QtxActionMenuMgr::MenuCreator::MenuCreator( QtxActionMgr::Reader* r, + QtxActionMenuMgr* mgr ) : QtxActionMgr::Creator( r ), -myMgr( mgr ) + myMgr( mgr ) { } diff --git a/src/Qtx/QtxActionMgr.cxx b/src/Qtx/QtxActionMgr.cxx index b4acf9880..11bd7c4bf 100644 --- a/src/Qtx/QtxActionMgr.cxx +++ b/src/Qtx/QtxActionMgr.cxx @@ -314,12 +314,12 @@ void QtxActionMgr::setVisible( const int, const int, const bool ) */ void QtxActionMgr::update() { - if ( !isUpdatesEnabled() ) - return; + if ( isUpdatesEnabled() ) + + + internalUpdate(); + - internalUpdate(); - if ( myUpdTimer ) - myUpdTimer->stop(); } /*! @@ -467,8 +467,8 @@ void QtxActionMgr::Reader::setOption( const QString& name, const QString& value /*! - Class: QtxActionMgr::XMLReader - Level: Public + Constructor + */ QtxActionMgr::XMLReader::XMLReader( const QString& root, const QString& item, @@ -609,11 +609,11 @@ bool QtxActionMgr::XMLReader::isNodeSimilar( const QDomNode& node, /*! - Class: QtxActionMgr::Creator - Level: Public -*/ -/*! + + + + \return integer value by attributes \param attrs - attributes \param name - name of attribute @@ -697,3 +697,4 @@ bool QtxActionMgr::Creator::loadPixmap( const QString& fname, QPixmap& pix ) con return res; } + diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index 4202b438f..e1727f189 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -447,13 +447,13 @@ void QtxActionToolMgr::updateToolBar( const int tId ) */ void QtxActionToolMgr::internalUpdate() { - if ( !isUpdatesEnabled() ) - return; + + for ( ToolBarMap::ConstIterator it1 = myToolBars.begin(); it1 != myToolBars.end(); ++it1 ) updateToolBar( it1.key() ); - myUpdateIds.clear(); + } /*! @@ -604,8 +604,8 @@ void QtxActionToolMgr::triggerUpdate( const int id ) } /*! - Class: QtxActionToolMgr::ToolCreator - Level: Public + Constructor + */ QtxActionToolMgr::ToolCreator::ToolCreator( QtxActionMgr::Reader* r, QtxActionToolMgr* mgr ) diff --git a/src/Qtx/QtxLogoMgr.cxx b/src/Qtx/QtxLogoMgr.cxx index aa1189152..2103eccae 100644 --- a/src/Qtx/QtxLogoMgr.cxx +++ b/src/Qtx/QtxLogoMgr.cxx @@ -14,7 +14,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "QtxLogoMgr.h" @@ -27,6 +27,9 @@ #include #include +/*! + Constructor +*/ QtxLogoMgr::QtxLogoMgr( QMenuBar* mb ) : QObject( mb ), myMenus( mb ), @@ -34,6 +37,9 @@ myId( 0 ) { } +/*! + Destructor +*/ QtxLogoMgr::~QtxLogoMgr() { } @@ -106,6 +112,9 @@ void QtxLogoMgr::clear() generate(); } +/*! + Inserts logo to menu bar +*/ void QtxLogoMgr::generate() { if ( !menuBar() ) @@ -169,12 +178,16 @@ void QtxLogoMgr::generate() QApplication::sendPostedEvents( cnt, QEvent::ChildInserted ); cnt->addSpacing( 2 ); - myId = menuBar()->insertItem( cnt, INT_MAX ); + myId = menuBar()->insertItem( cnt ); QApplication::sendPostedEvents( menuBar()->parentWidget(), QEvent::LayoutHint ); QApplication::postEvent( menuBar()->parentWidget(), new QEvent( QEvent::LayoutHint ) ); } +/*! + \return index of found logo + \param id - logo id +*/ int QtxLogoMgr::find( const QString& id ) const { int idx = -1; diff --git a/src/Qtx/QtxTable.cxx b/src/Qtx/QtxTable.cxx index 63553cf80..a390bfde9 100644 --- a/src/Qtx/QtxTable.cxx +++ b/src/Qtx/QtxTable.cxx @@ -74,6 +74,7 @@ protected: virtual void mousePressEvent( QMouseEvent* ); virtual void mouseReleaseEvent( QMouseEvent* ); virtual void paintSection( QPainter*, int, const QRect& ); + virtual void paintEvent( QPaintEvent * ); private: typedef QMap SpanMap; @@ -108,6 +109,7 @@ myTable( table ), myPressed( -1 ), mySection( -1 ) { + setWFlags( WRepaintNoErase ); } QtxTable::Header::~Header() @@ -383,6 +385,19 @@ void QtxTable::Header::paintSection( QPainter* p, int index, const QRect& fr ) mySection = -1; } +void QtxTable::Header::paintEvent( QPaintEvent *pe ) +{ + //const QRect& r = pe->rect(); + QRect r = rect(); + QPixmap pix( r.width(), r.height() ); + QPainter::redirect( this, &pix ); + QHeader::paintEvent( pe ); + QPainter::redirect( this, 0 ); + QPainter painter( this ); + painter.drawPixmap( r, pix ); + //QHeader::paintEvent( pe ); +} + bool QtxTable::Header::filterEvent( QMouseEvent* e ) const { int c = orientation() == Horizontal ? e->pos().x() : e->pos().y(); -- 2.39.2