From: vsr Date: Tue, 31 Jul 2007 09:58:30 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~66 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aef331fbc51f9ad6ca3217ae0db5586ab9818241;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 6d285ad5d..2089441d5 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -485,6 +485,22 @@ QString CAM_Application::moduleTitle( const QString& name ) const return res; } +/*! + \brief Get module icon name. + \param name module name + \return module icon or null QString if module is not found +*/ +QString CAM_Application::moduleIcon( const QString& name ) const +{ + QString res; + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it ) + { + if ( (*it).name == name ) + res = (*it).icon; + } + return res; +} + /*! \brief Get module library name by its title (user name). \param title module title (user name) @@ -566,6 +582,8 @@ void CAM_Application::readModuleList() continue; } + QString modIcon = resMgr->stringValue( *it, "icon", QString::null ); + QString modLibrary = resMgr->stringValue( *it, "library", QString::null ).trimmed(); if ( !modLibrary.isEmpty() ) { @@ -590,6 +608,7 @@ void CAM_Application::readModuleList() inf.name = modName; inf.title = modTitle; inf.internal = modLibrary; + inf.icon = modIcon; myInfoList.append( inf ); } diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index c7b545877..b79be8c38 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -62,6 +62,7 @@ public: QString moduleName( const QString& ) const; QString moduleTitle( const QString& ) const; + QString moduleIcon( const QString& ) const; virtual void createEmptyStudy(); @@ -81,8 +82,8 @@ private: void readModuleList(); private: - typedef struct { QString name, title, internal; } ModuleInfo; - typedef QList ModuleInfoList; + typedef struct { QString name, title, internal, icon; } ModuleInfo; + typedef QList ModuleInfoList; private: CAM_Module* myModule; //!< active module diff --git a/src/CAM/CAM_DataObject.cxx b/src/CAM/CAM_DataObject.cxx index ebb433eae..26ce74555 100755 --- a/src/CAM/CAM_DataObject.cxx +++ b/src/CAM/CAM_DataObject.cxx @@ -21,6 +21,8 @@ #include "CAM_Module.h" #include "CAM_DataModel.h" +#include + /*! \class CAM_DataObject \brief CAM-based implementation of the data object. @@ -123,6 +125,44 @@ QString CAM_ModuleObject::name() const return myDataModel ? myDataModel->module()->moduleName() : QString(); } +/*! + \brief Get data object icon for the specified column. + + The parameter \a index specifies the column number + (to display, for example, in the tree view widget). + + \param index column index + \return object icon for the specified column +*/ +QPixmap CAM_ModuleObject::icon( const int index ) const +{ + QPixmap p; + // show icon only for the "Name" column + if ( index == NameIdx && dataModel() && dataModel()->module() ) + p = dataModel()->module()->moduleIcon(); + if ( !p.isNull() ) + p = Qtx::scaleIcon( p, 16 ); + return p; +} + +/*! + \brief Get data object tooltip for the specified column. + + The parameter \a index specifies the column number + (to display, for example, in the tree view widget). + + \param index column index + \return object tooltip for the specified column +*/ +QString CAM_ModuleObject::toolTip( const int /*index*/ ) const +{ + // show the same tooltip for all columns + QString tip; + if ( dataModel() && dataModel()->module() ) + tip = QObject::tr( "MODULE_ROOT_OBJECT_TOOLTIP" ).arg( dataModel()->module()->moduleName() ); + return tip; +} + /*! \brief Get data model. \return data model pointer or 0 if it is not set diff --git a/src/CAM/CAM_DataObject.h b/src/CAM/CAM_DataObject.h index e2e7febc7..11bac528e 100755 --- a/src/CAM/CAM_DataObject.h +++ b/src/CAM/CAM_DataObject.h @@ -44,6 +44,8 @@ public: virtual ~CAM_ModuleObject(); virtual QString name() const; + QPixmap icon( const int = NameIdx ) const; + QString toolTip( const int = NameIdx ) const; virtual CAM_DataModel* dataModel() const; virtual void setDataModel( CAM_DataModel* ); diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index a53c7e1cb..6d76b6097 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -28,35 +28,7 @@ #include #include - -/*! Default module icon data set */ -static const char* ModuleIcon[] = { -"20 20 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" .................. ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" .................. ", -" . . . ", -" . . . ", -" ... ... ... ", -" .. .. .. .. .. .. ", -" . . . . . . ", -" .. .. .. .. .. .. ", -" ... ... ... "}; - -/*! Default module icon pixmap */ -QPixmap MYPixmap( ModuleIcon ); +#include /*! \class CAM_Module @@ -73,7 +45,6 @@ QPixmap MYPixmap( ModuleIcon ); CAM_Module::CAM_Module() : QObject(), myApp( 0 ), - myIcon( MYPixmap ), myDataModel( 0 ) { } @@ -89,7 +60,6 @@ CAM_Module::CAM_Module( const QString& name ) : QObject(), myApp( 0 ), myName( name ), - myIcon( MYPixmap ), myDataModel( 0 ) { } @@ -132,10 +102,17 @@ void CAM_Module::initialize( CAM_Application* app ) /*! \brief Get module icon. \return module icon pixmap - \sa setModuleIcon(), iconName() + \sa iconName() */ QPixmap CAM_Module::moduleIcon() const { + if ( myIcon.isNull() ) { + QString iname = iconName(); + if ( !iname.isEmpty() ) { + CAM_Module* that = (CAM_Module*)this; + that->myIcon = application()->resourceMgr()->loadPixmap( name(), iname, false ); + } + } return myIcon; } @@ -146,11 +123,11 @@ QPixmap CAM_Module::moduleIcon() const Default implementation returns empty string. \return module icon's name. - \sa moduleIcon(), setModuleIcon() + \sa moduleIcon() */ QString CAM_Module::iconName() const { - return ""; + return application()->moduleIcon( name() ); } /*! @@ -350,16 +327,6 @@ void CAM_Module::setModuleName( const QString& name ) myName = name; } -/*! - \brief Set module icon. - \param icon new module icon - \sa moduleIcon(), iconName() -*/ -void CAM_Module::setModuleIcon( const QPixmap& icon ) -{ - myIcon = icon; -} - /*! \brief Get menu manager. \return menu manager pointer diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 2b62f768a..df358c9e6 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -55,13 +55,12 @@ public: QString name() const; QString moduleName() const; - QPixmap moduleIcon() const; + virtual QPixmap moduleIcon() const; + virtual QString iconName() const; CAM_DataModel* dataModel() const; CAM_Application* application() const; - virtual QString iconName() const; - virtual void contextMenuPopup( const QString&, QMenu*, QString& ) {}; virtual void updateCommandsStatus() {}; @@ -96,7 +95,6 @@ protected: void setName( const QString& ); virtual void setModuleName( const QString& ); - virtual void setModuleIcon( const QPixmap& ); QtxActionMenuMgr* menuMgr() const; QtxActionToolMgr* toolMgr() const; diff --git a/src/CAM/resources/CAM_msg_en.ts b/src/CAM/resources/CAM_msg_en.ts index cb18f6673..e3ffa2608 100644 --- a/src/CAM/resources/CAM_msg_en.ts +++ b/src/CAM/resources/CAM_msg_en.ts @@ -9,5 +9,9 @@ ERROR_ACTIVATE_MODULE_MSG Failed to activate module %1 + + MODULE_ROOT_OBJECT_TOOLTIP + %1 module root object + diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 08fd32ca8..b8b50f211 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -59,6 +59,7 @@ #include #include +#include #include #include #include @@ -555,7 +556,7 @@ void LightApp_Application::createActions() printf( "****************************************************************\n" ); } - icon.fromImage( icon.toImage().scaled( iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); + icon = Qtx::scaleIcon( icon, iconSize ); moduleAction->insertModule( *it, icon ); } diff --git a/src/LightApp/LightApp_DataObject.cxx b/src/LightApp/LightApp_DataObject.cxx index 692dca449..75b250e74 100644 --- a/src/LightApp/LightApp_DataObject.cxx +++ b/src/LightApp/LightApp_DataObject.cxx @@ -270,6 +270,26 @@ QString LightApp_ModuleObject::name() const return CAM_ModuleObject::name(); } +/*! + \brief Get data object icon for the specified column. + \param index column index + \return object icon for the specified column +*/ +QPixmap LightApp_ModuleObject::icon( const int index ) const +{ + return CAM_ModuleObject::icon( index ); +} + +/*! + \brief Get data object tooltip for the specified column. + \param index column index + \return object tooltip for the specified column +*/ +QString LightApp_ModuleObject::toolTip( const int index ) const +{ + return CAM_ModuleObject::toolTip( index ); +} + /*! \brief Insert new child object to the children list at specified position. diff --git a/src/LightApp/LightApp_DataObject.h b/src/LightApp/LightApp_DataObject.h index da41a7d07..0d6ade400 100644 --- a/src/LightApp/LightApp_DataObject.h +++ b/src/LightApp/LightApp_DataObject.h @@ -70,6 +70,9 @@ public: virtual ~LightApp_ModuleObject(); virtual QString name() const; + QPixmap icon( const int = NameIdx ) const; + QString toolTip( const int = NameIdx ) const; + virtual void insertChild( SUIT_DataObject*, int ); }; diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 9fd27dc91..8bdc3502f 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -574,6 +574,26 @@ QString SalomeApp_ModuleObject::name() const return SalomeApp_DataObject::name(); } +/*! + \brief Get data object icon for the specified column. + \param index column index + \return object icon for the specified column +*/ +QPixmap SalomeApp_ModuleObject::icon( const int index ) const +{ + return CAM_ModuleObject::icon( index ); +} + +/*! + \brief Get data object tooltip for the specified column. + \param index column index + \return object tooltip for the specified column +*/ +QString SalomeApp_ModuleObject::toolTip( const int index ) const +{ + return CAM_ModuleObject::toolTip( index ); +} + /*! \class SalomeApp_RootObject \brief Root data object for the CORBA-based SALOME application. diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 5d9cb3217..dbf8267e7 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// 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/ or email : webmaster.salome@opencascade.com @@ -34,7 +34,7 @@ class SALOMEAPP_EXPORT SalomeApp_DataObject : public virtual LightApp_DataObject public: //! Column index - enum { + enum { ValueIdx = EntryIdx + 1, //!< value column IORIdx, //!< IOR column RefEntryIdx //!< reference entry column @@ -44,36 +44,36 @@ public: SalomeApp_DataObject( SUIT_DataObject* = 0 ); SalomeApp_DataObject( const _PTR(SObject)&, SUIT_DataObject* = 0 ); virtual ~SalomeApp_DataObject(); - - virtual int columnCount() const; - virtual QString columnTitle( const int = NameIdx ) const; - virtual bool appropriate( const int = NameIdx ) const; - virtual QString name() const; - virtual QString entry() const; + virtual int columnCount() const; + virtual QString columnTitle( const int = NameIdx ) const; + virtual bool appropriate( const int = NameIdx ) const; + + virtual QString name() const; + virtual QString entry() const; - virtual QString text( const int = NameIdx ) const; - virtual QPixmap icon( const int = NameIdx ) const; - virtual QColor color( const ColorRole, const int = NameIdx ) const; - virtual QString toolTip( const int = NameIdx ) const; + virtual QString text( const int = NameIdx ) const; + virtual QPixmap icon( const int = NameIdx ) const; + virtual QColor color( const ColorRole, const int = NameIdx ) const; + virtual QString toolTip( const int = NameIdx ) const; - virtual _PTR(SObject) object() const; + virtual _PTR(SObject) object() const; - bool isReference() const; - _PTR(SObject) referencedObject() const; + bool isReference() const; + _PTR(SObject) referencedObject() const; - virtual QString componentDataType() const; + virtual QString componentDataType() const; - virtual bool customSorting( const int = NameIdx ) const; - virtual bool compare( const QVariant&, const QVariant&, - const int = NameIdx ) const; + virtual bool customSorting( const int = NameIdx ) const; + virtual bool compare( const QVariant&, const QVariant&, + const int = NameIdx ) const; private: - QString ior( const _PTR(SObject)& ) const; - QString entry( const _PTR(SObject)& ) const; - QString value( const _PTR(SObject)& ) const; + QString ior( const _PTR(SObject)& ) const; + QString entry( const _PTR(SObject)& ) const; + QString value( const _PTR(SObject)& ) const; private: - _PTR(SObject) myObject; + _PTR(SObject) myObject; }; class SALOMEAPP_EXPORT SalomeApp_ModuleObject : public SalomeApp_DataObject, @@ -85,7 +85,9 @@ public: SalomeApp_ModuleObject( CAM_DataModel*, const _PTR(SObject)&, SUIT_DataObject* = 0 ); virtual ~SalomeApp_ModuleObject(); - virtual QString name() const; + virtual QString name() const; + QPixmap icon( const int = NameIdx ) const; + QString toolTip( const int = NameIdx ) const; }; class SALOMEAPP_EXPORT SalomeApp_RootObject : public SalomeApp_DataObject, @@ -95,12 +97,12 @@ public: SalomeApp_RootObject( LightApp_Study* ); virtual ~SalomeApp_RootObject(); - QString name() const; - QString entry() const; - QString text( const int = NameIdx ) const; - QPixmap icon( const int = NameIdx ) const; - QColor color( const ColorRole, const int = NameIdx ) const; - QString toolTip( const int = NameIdx ) const; + QString name() const; + QString entry() const; + QString text( const int = NameIdx ) const; + QPixmap icon( const int = NameIdx ) const; + QColor color( const ColorRole, const int = NameIdx ) const; + QString toolTip( const int = NameIdx ) const; }; class SALOMEAPP_EXPORT SalomeApp_SavePointObject : public virtual LightApp_DataObject @@ -108,27 +110,27 @@ class SALOMEAPP_EXPORT SalomeApp_SavePointObject : public virtual LightApp_DataO public: SalomeApp_SavePointObject( SUIT_DataObject*, const int, SalomeApp_Study* ); virtual ~SalomeApp_SavePointObject(); - - virtual QString name() const; - virtual QString entry() const; - virtual QPixmap icon( const int = NameIdx ) const; - virtual QString toolTip( const int = NameIdx ) const; + virtual QString name() const; + virtual QString entry() const; - int getId() const; + virtual QPixmap icon( const int = NameIdx ) const; + virtual QString toolTip( const int = NameIdx ) const; + + int getId() const; private: - int myId; - SalomeApp_Study* myStudy; + int myId; + SalomeApp_Study* myStudy; }; class SALOMEAPP_EXPORT SalomeApp_SavePointRootObject : public SUIT_DataObject { public: SalomeApp_SavePointRootObject( SUIT_DataObject* ); - - virtual QString name() const; - virtual QString toolTip( const int = NameIdx ) const; + + virtual QString name() const; + virtual QString toolTip( const int = NameIdx ) const; }; #endif