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)
continue;
}
+ QString modIcon = resMgr->stringValue( *it, "icon", QString::null );
+
QString modLibrary = resMgr->stringValue( *it, "library", QString::null ).trimmed();
if ( !modLibrary.isEmpty() )
{
inf.name = modName;
inf.title = modTitle;
inf.internal = modLibrary;
+ inf.icon = modIcon;
myInfoList.append( inf );
}
QString moduleName( const QString& ) const;
QString moduleTitle( const QString& ) const;
+ QString moduleIcon( const QString& ) const;
virtual void createEmptyStudy();
void readModuleList();
private:
- typedef struct { QString name, title, internal; } ModuleInfo;
- typedef QList<ModuleInfo> ModuleInfoList;
+ typedef struct { QString name, title, internal, icon; } ModuleInfo;
+ typedef QList<ModuleInfo> ModuleInfoList;
private:
CAM_Module* myModule; //!< active module
#include "CAM_Module.h"
#include "CAM_DataModel.h"
+#include <Qtx.h>
+
/*!
\class CAM_DataObject
\brief CAM-based implementation of the data object.
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
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* );
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
-
-/*! 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 <SUIT_ResourceMgr.h>
/*!
\class CAM_Module
CAM_Module::CAM_Module()
: QObject(),
myApp( 0 ),
- myIcon( MYPixmap ),
myDataModel( 0 )
{
}
: QObject(),
myApp( 0 ),
myName( name ),
- myIcon( MYPixmap ),
myDataModel( 0 )
{
}
/*!
\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;
}
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() );
}
/*!
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
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() {};
void setName( const QString& );
virtual void setModuleName( const QString& );
- virtual void setModuleIcon( const QPixmap& );
QtxActionMenuMgr* menuMgr() const;
QtxActionToolMgr* toolMgr() const;
<source>ERROR_ACTIVATE_MODULE_MSG</source>
<translation>Failed to activate module %1</translation>
</message>
+ <message>
+ <source>MODULE_ROOT_OBJECT_TOOLTIP</source>
+ <translation>%1 module root object</translation>
+ </message>
</context>
</TS>
#include <SUIT_Accel.h>
#include <SUIT_MessageBox.h>
+#include <Qtx.h>
#include <QtxMRUAction.h>
#include <QtxDockAction.h>
#include <QtxToolBar.h>
printf( "****************************************************************\n" );
}
- icon.fromImage( icon.toImage().scaled( iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
+ icon = Qtx::scaleIcon( icon, iconSize );
moduleAction->insertModule( *it, icon );
}
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.
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 );
};
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.
// 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
public:
//! Column index
- enum {
+ enum {
ValueIdx = EntryIdx + 1, //!< value column
IORIdx, //!< IOR column
RefEntryIdx //!< reference entry column
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,
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,
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
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