/*!
\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).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap CAM_ModuleObject::icon( const int index ) const
+QPixmap CAM_ModuleObject::icon( const int id ) const
{
QPixmap p;
// show icon only for the "Name" column
- if ( index == NameIdx && dataModel() && dataModel()->module() )
+ if ( id == NameId && dataModel() && dataModel()->module() )
p = dataModel()->module()->moduleIcon();
if ( !p.isNull() )
p = Qtx::scaleIcon( p, 16 );
/*!
\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).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString CAM_ModuleObject::toolTip( const int /*index*/ ) const
+QString CAM_ModuleObject::toolTip( const int /*id*/ ) const
{
// show the same tooltip for all columns
QString tip;
virtual ~CAM_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
virtual CAM_DataModel* dataModel() const;
virtual void setDataModel( CAM_DataModel* );
#include <UnitsAPI.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
-
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
if ( !myUnitSystem.IsBound( aName ) )
myUnitSystem.Bind( aName, aLabel );
+
+
}
}
aDicItem->myComponent = this;
aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems );
myDataMap.Add( anID, aDicItem );
+
+ bool exist = false;
+ for( int i=1, n=myKeys.Length(); i<=n && !exist; i++ )
+ if( myKeys.Value( i )==anID )
+ {
+ cout << "Doubled key:" << anID << endl;
+ exist = true;
+ }
+ if( !exist )
+ myKeys.Append( anID );
}
}
return aDicItem;
}
+
+/*!
+ \brief Return all keys of the group
+ \param seq - string container to be filled with keys
+*/
+void DDS_DicGroup::GetKeys( TColStd_SequenceOfAsciiString& seq ) const
+{
+ seq = myKeys;
+}
#include "DDS_DicItem.h"
#include <MMgt_TShared.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
+#include <TColStd_SequenceOfAsciiString.hxx>
#include <NCollection_List.hxx>
class LDOM_Element;
-class TColStd_SequenceOfAsciiString;
DEFINE_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
DDS_DicGroup( const TCollection_AsciiString& );
TCollection_AsciiString GetName() const;
+ Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const;
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
DDS_IndexedDataMapOfDicItems myDataMap;
UnitSystemMap myUnitSystem;
TCollection_AsciiString myActiveSystem;
+ TColStd_SequenceOfAsciiString myKeys;
friend class DDS_Dictionary;
LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
if ( !anOpt.isNull() )
{
- LDOM_NodeList anOptions = anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
+ LDOM_NodeList anOptions = anOpt.GetAttributesList();//anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
{
LDOM_Node node = anOptions.item( oi );
- if ( node.getNodeType() != LDOM_Node::ELEMENT_NODE )
- continue;
-
- LDOM_Element& elem = (LDOM_Element&)node;
- TCollection_AsciiString name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+ LDOM_Node::NodeType t = node.getNodeType();
+ TCollection_AsciiString name;
TCollection_ExtendedString value;
- const LDOM_Node aNode = elem.getFirstChild();
- LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) );
- if ( !anOptTxt.isNull() )
- value = anOptTxt.getData();
+
+ if( t==LDOM_Node::ELEMENT_NODE )
+ {
+ const LDOM_Element& elem = ( const LDOM_Element& )node;
+ name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+
+ const LDOM_Node aNode = elem.getFirstChild();
+ LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) );
+ if ( !anOptTxt.isNull() )
+ value = anOptTxt.getData();
+ }
+ else if( t==LDOM_Node::ATTRIBUTE_NODE )
+ {
+ const LDOM_Attr& attr = ( const LDOM_Attr& )node;
+ name = ( Standard_CString )attr.getName().GetString();
+ LDOMString v = attr.getValue();
+ if( v.Type()==LDOMBasicString::LDOM_Integer )
+ {
+ Standard_Integer ival;
+ v.GetInteger( ival );
+ value = TCollection_ExtendedString( ival );
+ }
+ else
+ value = ( Standard_CString )v.GetString();
+ }
+ else
+ continue;
if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
myOptions.Bind( name, value );
return aRetValue;
}
+
+/*!
+ \brief Fill given string container \a seq with keys belonging to group with name \a theComponent
+ \param theComponent name of group whose keys should be stored in the container
+ \param seq returned string container with keys belonging to group; it is not cleared before filling
+*/
+void DDS_Dictionary::GetKeys( const TCollection_AsciiString& theComponent, TColStd_SequenceOfAsciiString& seq ) const
+{
+ Handle( DDS_DicGroup ) aDicGroup;
+ if( myGroupMap.Contains( theComponent ) )
+ aDicGroup = myGroupMap.FindFromKey( theComponent );
+
+ if( !aDicGroup.IsNull() )
+ aDicGroup->GetKeys( seq );
+}
// Return instance of data dictionary. Create instance if it is NULL.
+ Standard_EXPORT void GetKeys( const TCollection_AsciiString&, TColStd_SequenceOfAsciiString& ) const;
+
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString&,
const TCollection_AsciiString& ) const;
{
viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
OCCViewer_Viewer* vm;
+ bool staticTrihedron = resMgr->booleanValue( "OCCViewer", "static_trihedron", true );
#ifndef DISABLE_SALOMEOBJECT
vm = new SOCC_Viewer();
#else
- vm = new OCCViewer_Viewer();
+ vm = new OCCViewer_Viewer( true, staticTrihedron );
#endif
vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
virtual bool checkDataObject( LightApp_DataObject* theObj );
+ virtual void updateDesktopTitle();
+
signals:
void studyOpened();
void studySaved();
virtual void loadPreferences();
virtual void savePreferences();
- virtual void updateDesktopTitle();
-
virtual QMap<int, QString> activateModuleActions() const;
virtual void moduleActionSelected( const int );
#include "LightApp_Module.h"
#include "LightApp_Application.h"
+#include <SUIT_TreeModel.h>
#include <SUIT_DataBrowser.h>
#include <SUIT_DataObject.h>
LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
: CAM_DataModel( theModule )
{
+ myGroupId = 0;
+ if( module() )
+ myGroupId = qHash( module()->name() );
}
/*!
{
return true;
}
+
+/*!
+ \return data model group id used for custom columns creation
+*/
+int LightApp_DataModel::groupId() const
+{
+ return myGroupId;
+}
+
+/*!
+ Register custom column in the object browser
+ \param browser - object browser where new column should be created
+ \param name - translated column name
+ \param custom_id - custom column identificator passed into data object's methods text(), icon() etc
+*/
+void LightApp_DataModel::registerColumn( SUIT_DataBrowser* browser, const QString& name, const int custom_id )
+{
+ SUIT_AbstractModel* m = dynamic_cast<SUIT_AbstractModel*>( browser ? browser->model() : 0 );
+ if( m )
+ m->registerColumn( groupId(), name, custom_id );
+}
+
+/*!
+ Remove registered custom column from the object browser
+ \param browser - object browser where new column should be created
+ \param name - translated column name
+*/
+void LightApp_DataModel::unregisterColumn( SUIT_DataBrowser* browser, const QString& name )
+{
+ SUIT_AbstractModel* m = dynamic_cast<SUIT_AbstractModel*>( browser ? browser->model() : 0 );
+ if( m )
+ m->unregisterColumn( groupId(), name );
+}
class LightApp_Module;
class LightApp_Study;
class LightApp_DataObject;
+class SUIT_DataBrowser;
/*!
Description : Base class of data model
LightApp_Module* getModule() const;
+ int groupId() const;
+ void registerColumn( SUIT_DataBrowser*, const QString&, const int );
+ void unregisterColumn( SUIT_DataBrowser*, const QString& );
+
signals:
void opened();
void saved();
LightApp_Study* getStudy() const;
virtual void build();
virtual void updateWidgets();
+
+private:
+ int myGroupId;
};
#endif
#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
+#include "LightApp_DataModel.h"
-#include <CAM_DataModel.h>
#include <CAM_Module.h>
#include <SUIT_DataObjectKey.h>
{
}
-/*!
- \brief Get the number of the columns provided by the data tree.
- \return number of the columns
-*/
-int LightApp_DataObject::columnCount() const
-{
- // add "Entry" column
- return CAM_DataObject::columnCount() + 1;
-}
-
-/*!
- \brief Get column title.
- \param index column index
- \return title of the specified column
-*/
-QString LightApp_DataObject::columnTitle( const int index ) const
-{
- // add "Entry" column
- return index == EntryIdx ? QObject::tr( "ENTRY_COLUMN" )
- : CAM_DataObject::columnTitle( index );
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool LightApp_DataObject::appropriate( const int index ) const
+int LightApp_DataObject::groupId() const
{
- // add "Entry" column
- return index == EntryIdx ? true : CAM_DataObject::appropriate( index );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ return m ? m->groupId() : CAM_DataObject::groupId();
}
/*!
/*!
\brief Get object text data for the specified column.
- Column with \a index = 0 (NameIdx) is supposed to be used
+ Column with \a id = 0 (NameId) is supposed to be used
to get the object name.
- Column with \a index = 1 (EntryIdx) is supposed to be used
+ Column with \a id = 1 (EntryId) is supposed to be used
to get the object entry.
- \param index column index
+ \param id column id
\return object text data
*/
-QString LightApp_DataObject::text( const int index ) const
+QString LightApp_DataObject::text( const int id ) const
{
- // add "Entry" column
- return index == EntryIdx ? entry() : CAM_DataObject::text( index );
+ return id == EntryId ? entry() : CAM_DataObject::text( id );
}
/*!
/*!
\brief Check if the specified column supports custom sorting.
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool LightApp_DataObject::customSorting( const int index ) const
+bool LightApp_DataObject::customSorting( const int id ) const
{
// perform custom sorting for the "Entry" column
- return index == EntryIdx ? true
- : CAM_DataObject::customSorting( index );
+ return id == EntryId ? true : CAM_DataObject::customSorting( id );
}
/*!
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
-bool LightApp_DataObject::compare( const QVariant& left, const QVariant& right,
- const int index ) const
+bool LightApp_DataObject::compare( const QVariant& left, const QVariant& right, const int id ) const
{
- if ( index == EntryIdx ) {
+ if ( id == EntryId )
+ {
// perform custom sorting for the "Entry" column
QString leftStr = left.toString();
QString rightStr = right.toString();
}
return QString::localeAwareCompare( leftStr, rightStr ) < 0;
}
- return CAM_DataObject::compare( left, right, index );
+ return CAM_DataObject::compare( left, right, id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap LightApp_ModuleObject::icon( const int index ) const
+QPixmap LightApp_ModuleObject::icon( const int id ) const
{
- return CAM_ModuleObject::icon( index );
+ return CAM_ModuleObject::icon( id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString LightApp_ModuleObject::toolTip( const int index ) const
+QString LightApp_ModuleObject::toolTip( const int id ) const
{
- return CAM_ModuleObject::toolTip( index );
+ return CAM_ModuleObject::toolTip( id );
}
/*!
class Key;
public:
- //! Column index
+ //! Column id
enum {
- EntryIdx = NameIdx + 1 //!< entry column
+ EntryId = NameId + 1 //!< entry column
};
public:
LightApp_DataObject( SUIT_DataObject* = 0 );
virtual ~LightApp_DataObject();
- virtual int columnCount() const;
- virtual QString columnTitle( const int = NameIdx ) const;
- virtual bool appropriate( const int = NameIdx ) const;
-
virtual SUIT_DataObjectKey* key() const;
virtual QString entry() const;
- virtual QString text( const int = NameIdx ) const;
+ virtual QString text( const int = NameId ) const;
virtual SUIT_DataObject* componentObject() 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 = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
+ virtual int groupId() const;
protected:
QString myCompDataType;
virtual ~LightApp_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
virtual void insertChild( SUIT_DataObject*, int );
};
#include "LightApp_ShowHideOp.h"
#include "LightApp_SelectionMgr.h"
-#include <SUIT_DataBrowser.h>
#include <SUIT_Study.h>
#include <SUIT_DataObject.h>
+#include <SUIT_DataBrowser.h>
#include <SUIT_Operation.h>
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Desktop.h>
+#include <SUIT_TreeModel.h>
+#ifndef DISABLE_SALOMEOBJECT
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
+#endif
#ifndef DISABLE_VTKVIEWER
#ifndef DISABLE_SALOMEOBJECT
#include <QString>
#include <QStringList>
+
/*!Constructor.*/
LightApp_Module::LightApp_Module( const QString& name )
: CAM_Module( name ),
{
// return true if selected objects belong to this module
bool isCompatible = true;
+#ifndef DISABLE_SALOMEOBJECT
SALOME_ListIO selected;
if ( LightApp_SelectionMgr *Sel = getApp()->selectionMgr() )
Sel->selectedObjects( selected );
isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType );
}
}
+#endif
return isCompatible;
}
if ( mySwitchOp == 0 )
mySwitchOp = new LightApp_SwitchOp( this );
+ QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ if( m )
+ {
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+ m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
+ treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ }
return res;
}
anIt.value()->abort();
}
- return CAM_Module::activateModule( study );
+ QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ if( m )
+ {
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+
+ treeModel->setAppropriate( EntryCol, Qtx::Shown );
+ m->unregisterColumn( getApp()->objectBrowser(), EntryCol );
+ }
+ return CAM_Module::deactivateModule( study );
}
/*!NOT IMPLEMENTED*/
/*!Create new instance of data model and return it.*/
CAM_DataModel* LightApp_Module::createDataModel()
{
- return new LightApp_DataModel(this);
+ return new LightApp_DataModel( this );
}
/*!Create and return instance of LightApp_Selection.*/
void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
{
}
+
+/*!
+ \brief Returns instance of operation by its id; if there is no operation
+ corresponding to this id, null pointer is returned
+ \param id - operation id
+ \return operation instance
+*/
+LightApp_Operation* LightApp_Module::operation( const int id ) const
+{
+ return myOperations.contains( id ) ? myOperations[id] : 0;
+}
virtual bool isSelectionCompatible();
+ LightApp_Operation* operation( const int ) const;
+
private:
typedef QMap<int,LightApp_Operation*> MapOfOperation;
OCCViewer_SetRotationPointDlg.cxx \
OCCViewer_ClippingDlg.cxx \
OCCViewer_AxialScaleDlg.cxx \
- OCCViewer_Trihedron.cxx
+ OCCViewer_Trihedron.cxx \
+ OCCViewer_ToolTip.cxx
MOC_FILES = \
OCCViewer_AISSelector_moc.cxx \
OCCViewer_CreateRestoreViewDlg_moc.cxx \
OCCViewer_SetRotationPointDlg_moc.cxx \
OCCViewer_ClippingDlg_moc.cxx \
- OCCViewer_AxialScaleDlg_moc.cxx
+ OCCViewer_AxialScaleDlg_moc.cxx \
+ OCCViewer_ToolTip_moc.cxx
+
nodist_libOCCViewer_la_SOURCES = $(MOC_FILES)
dist_salomeres_DATA = \
--- /dev/null
+// 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
+// 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
+// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: OCCViewer_ToolTip.cxx
+// Author: Alexandre SOLOVYOV
+
+#include <OCCViewer_ToolTip.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <SUIT_ViewManager.h>
+
+#include <SelectMgr_EntityOwner.hxx>
+
+/*!
+ Constructor
+
+ \param wnd - window where the tooltip should be assigned
+*/
+OCCViewer_ToolTip::OCCViewer_ToolTip( OCCViewer_ViewWindow* wnd )
+: QtxToolTip( wnd->getViewPort() ),
+ myWnd( wnd )
+{
+ connect( this, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
+ this, SLOT( onToolTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );
+}
+
+/*!
+ Destructor
+ */
+OCCViewer_ToolTip::~OCCViewer_ToolTip()
+{
+}
+
+/*!
+ \return font of the tooltip
+ */
+QFont OCCViewer_ToolTip::font() const
+{
+ return myFont;
+}
+
+/*!
+ Change font of the tooltip
+
+ \param f - new font
+ */
+void OCCViewer_ToolTip::setFont( const QFont& f )
+{
+ myFont = f;
+}
+
+/*!
+ Tooltip handler
+
+ \param p - current point
+ \param str - returned tooltip text
+ \param f - returned tooltip font
+ \param txtRect - returned tooltip text rectangle
+ \param rect - returned tooltip rectangle
+ */
+void OCCViewer_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect )
+{
+ OCCViewer_Viewer* v = dynamic_cast<OCCViewer_Viewer*>( myWnd->getViewManager()->getViewModel() );
+ Handle( AIS_InteractiveContext ) aCont = v->getAISContext();
+ if( aCont.IsNull() )
+ return;
+
+ QString txt;
+ Handle( SelectMgr_EntityOwner ) owner = aCont->DetectedOwner();
+ if( !owner.IsNull() )
+ emit toolTipFor( owner, txt );
+
+ Handle_AIS_InteractiveObject obj = aCont->DetectedInteractive();
+ if( txt.isEmpty() && !obj.IsNull() )
+ emit toolTipFor( obj, txt );
+
+ if( txt.isEmpty() )
+ return;
+
+ str = txt;
+ QFontMetrics m( myFont );
+ int w = m.width( str ), h = m.height();
+
+ txtRect = QRect( p.x()+4, p.y()-h, w, h );
+ rect = txtRect;
+}
--- /dev/null
+// 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
+// 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
+// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_TOOLTIP_H
+#define OCCVIEWER_TOOLTIP_H
+
+#include <OCCViewer.h>
+#include <QtxToolTip.h>
+#include <QFont>
+
+class OCCViewer_ViewWindow;
+class Handle_SelectMgr_EntityOwner;
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class OCCViewer_ToolTip
+ \brief Custom tooltip for AIS_InteractiveObjects and SelectMgr_EntityOwners in the OCC Viewer
+*/
+class OCCVIEWER_EXPORT OCCViewer_ToolTip : public QtxToolTip
+{
+ Q_OBJECT
+
+public:
+ OCCViewer_ToolTip( OCCViewer_ViewWindow* );
+ virtual ~OCCViewer_ToolTip();
+
+ QFont font() const;
+ void setFont( const QFont& );
+
+signals:
+ /*!
+ Called when owner is detected; allows to redefine tooltip text for owner
+ */
+ void toolTipFor( const Handle_SelectMgr_EntityOwner&, QString& );
+ /*!
+ Called when object is detected; allows to redefine tooltip text for object
+ */
+ void toolTipFor( const Handle_AIS_InteractiveObject&, QString& );
+
+public slots:
+ void onToolTip( QPoint, QString&, QFont&, QRect&, QRect& );
+
+private:
+ OCCViewer_ViewWindow* myWnd;
+ QFont myFont;
+};
+
+#endif
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron, false ) )
{
setTitle( tr( "OCC_VIEW_TITLE" ) );
}
int id = -1;
QString aDefValue = defaultValue();
if ( !aDefValue.isEmpty() )
- id = aDefValue.toInt();
-
- if ( id == -1 )
- id = getId( 0 );
-
- setIntegerValue( id );
+ setString( aDefValue );
+ else
+ setIntegerValue( getId( 0 ) );
}
/*!
if ( cb )
{
if ( myIcons.contains( id ) )
- cb->insertItem( -1, QIcon(myIcons[id]), myValue[id] );
+ cb->addItem( QIcon(myIcons[id]), myValue[id] );
else
- cb->insertItem( -1, myValue[id] );
+ cb->addItem( myValue[id] );
}
}
//
#include "QDS_Datum.h"
-#include "QDS_Validator.h"
-
-#include <DDS_Dictionary.h>
-
+#include <QLayout>
+#include <QVariant>
#include <QTimer>
-#include <QLabel>
-#include <QWidget>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QGridLayout>
-#include <QMessageBox>
#include <QEvent>
+#include <QMessageBox>
+#include <QApplication>
-#include <TColStd_SequenceOfAsciiString.hxx>
+#include <QDS_Validator.h>
+#include <DDS_Dictionary.h>
/*!
\class QDS_Datum::Wrapper
Wrapper( QWidget* = 0 );
virtual ~Wrapper();
- QWidget* widget() const;
- void setWidget( QWidget* );
+ QWidget* widget() const;
+ void setWidget( QWidget* );
virtual void setGeometry( int x, int y, int w, int h );
virtual void setSizePolicy( QSizePolicy );
private:
- QWidget* myWid;
- QHBoxLayout* myBase;
+ QWidget* myWid;
};
/*!
: QWidget( parent ),
myWid( 0 )
{
- //QHBoxLayout* base = new QHBoxLayout( this );
- //base->setAutoAdd( true );
- myBase = new QHBoxLayout( this );
+ setLayout( new QHBoxLayout() );
+ layout()->setSpacing( 0 );
+ layout()->setMargin( 0 );
setFocusPolicy( Qt::StrongFocus );
}
*/
void QDS_Datum::Wrapper::setWidget( QWidget* wid )
{
- if ( myWid == wid )
+ if ( myWid == wid || !wid )
return;
+ wid->setParent( this );
+ QHBoxLayout* hl = qobject_cast<QHBoxLayout*>( layout() );
+ if( myWid )
+ hl->removeWidget( myWid );
+ hl->addWidget( wid );
myWid = wid;
- if ( !myWid )
- return;
-
- if ( myWid->parent() != this ) {
- myWid->setParent( this );
- myWid->move( QPoint( 0, 0 ) );
- myWid->hide();
- myBase->addWidget( myWid );
- }
-
setTabOrder( this, myWid );
setFocusProxy( myWid );
myUnits( 0 ),
myControl( 0 ),
myFlags( flags ),
- myInitialised( false )
+ myInitialised( false ),
+ myTr( false )
{
if ( myFlags & Label )
myWrapper.insert( Label, new Wrapper( parent ) );
return res;
}
+/*!
+ \brief Return state of custom translation.
+ \return true if custom translation is enabled
+*/
+bool QDS_Datum::isCustomTr() const
+{
+ return myTr;
+}
+
+/*!
+ \brief Change state of custom translation.
+
+ Custom translation means that text labels of datums are translated
+ with help of standard Qt mechanism of internationalization. In this
+ case special records should be placed into *.ts files under context "QDS".
+ For example, if label has name "myLabel", the corresponding translation
+ should be written:
+ <context>
+ <name>QDS</name>
+ <message>
+ <source>myLabel</source>
+ <translation>myLabel translation</translation>
+ </message>
+ ...
+
+ If custom translation mechanism is deactivated, then labels will be shown
+ with text got from xml data dictionary file
+
+ By default, the custom translation is deactivated
+
+ \param on - if it is true, custom translation is activated, otherwise, deactivated
+*/
+void QDS_Datum::enableCustomTr( const bool on )
+{
+ myTr = on;
+ labelWidget()->setText( label() );
+}
+
/*!
\brief Get the datum label text.
\return label text
QString labStr;
if ( !myDicItem.IsNull() )
+ {
labStr = toQString( myDicItem->GetLabel() );
-
+ if( labStr.isNull() )
+ labStr = toQString( myDicItem->GetId() );
+ }
+ if( myTr )
+ {
+ QString dest = QApplication::translate( "QDS", labStr.toLatin1().constData() );
+ if( labStr != dest )
+ labStr = dest;
+ }
if ( flags() & NotAccel )
labStr = removeAccel( labStr );
-
return labStr;
}
info += QString( "\n" ) + extMsg;
QString msg;
- for ( uint i = 0; i < info.length(); i++ )
+ for ( int i = 0; i < info.length(); i++ )
if ( info.at( i ) == '\n' )
msg += QString( "<br>" );
else
#define QDS_DATUM_H
#include "QDS.h"
-
-#include <QString>
-#include <QVariant>
#include <QPointer>
+#include <QMap>
+#include <QLabel>
+
+class QHBoxLayout;
+class QVBoxLayout;
+class QGridLayout;
+class QValidator;
#include <DDS_DicItem.h>
-class QLabel;
class QWidget;
-class QValidator;
-class QVBoxLayout;
-class QHBoxLayout;
-class QGridLayout;
class QDS_EXPORT QDS_Datum : public QObject, public QDS
{
operator QWidget*() const;
+ bool isCustomTr() const;
+ void enableCustomTr( const bool );
+
signals:
void paramChanged();
void paramChanged( QString& );
QString mySourceValue;
QString myTargetValue;
- bool myInitialised;
+ bool myInitialised, myTr;
friend class QDS;
};
sb->setSuffix( suffix() );
sb->setPrefix( prefix() );
- sb->setMinimum( minValue().toInt() );
- sb->setMaximum( maxValue().toInt() );
+ sb->setMinimum( minValue().isEmpty() ? -INT_MAX : minValue().toInt() );
+ sb->setMaximum( maxValue().isEmpty() ? INT_MAX : maxValue().toInt() );
+
}
}
QtxPathEdit_moc.cxx \
QtxPathListEdit_moc.cxx \
QtxPopupMgr_moc.cxx \
+ QtxRubberBand_moc.cxx \
QtxSearchTool_moc.cxx \
QtxSplash_moc.cxx \
QtxToolBar_moc.cxx \
AppropriateRole = Qt::UserRole + 100 //!< can be used to return \c true if data is appropriate
};
+ typedef enum {
+ Shown, //!< column should be always visible
+ Hidden, //!< column should be always hidden
+ Toggled //!< it should be possible to show/hide the column with help of popup menu
+ } Appropriate; //!< appropriate status
+
static QString toQString( const char*, const int = -1 );
static QString toQString( const short*, const int = -1 );
static QString toQString( const unsigned char*, const int = -1 );
#include <QWidget>
-class QTX_EXPORT QtxAbstractRubberBand: public QWidget
+class QTX_EXPORT QtxAbstractRubberBand : public QWidget
{
+ Q_OBJECT
+
protected:
QtxAbstractRubberBand( QWidget* );
class QTX_EXPORT QtxRectRubberBand: public QtxAbstractRubberBand
{
-public:
+ Q_OBJECT
+public:
QtxRectRubberBand( QWidget* );
virtual ~QtxRectRubberBand();
class QTX_EXPORT QtxPolyRubberBand: public QtxAbstractRubberBand
{
-public:
+ Q_OBJECT
+public:
QtxPolyRubberBand( QWidget* );
virtual ~QtxPolyRubberBand();
else if ( qVariantCanConvert<QPixmap>( iconData ) )
icon = qVariantValue<QPixmap>( iconData );
}
- if ( ( !lab.isEmpty() || !icon.isNull() ) &&
- appropriate.isValid() ? appropriate.toBool() : true ) {
+ if( ( !lab.isEmpty() || !icon.isNull() ) &&
+ appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true )
+ {
QAction* a = menu.addAction( icon, lab );
a->setCheckable( true );
a->setChecked( !isSectionHidden( i ) );
e->accept();
}
+
/*!
\class QtxTreeView
\brief Tree view class with possibility to display columns popup menu.
{
emit( sortingEnabled( enabled ) );
}
+
+void QtxTreeView::setModel( QAbstractItemModel* m )
+{
+ if( model() )
+ disconnect( model(), SIGNAL( headerDataChanged( Qt::Orientation, int, int ) ),
+ this, SLOT( onAppropriate( Qt::Orientation, int, int ) ) );
+ QTreeView::setModel( m );
+ connect( model(), SIGNAL( headerDataChanged( Qt::Orientation, int, int ) ),
+ this, SLOT( onAppropriate( Qt::Orientation, int, int ) ) );
+}
+
+void QtxTreeView::onAppropriate( Qt::Orientation orient, int first, int last )
+{
+ if( orient==Qt::Horizontal )
+ for( int i=first; i<=last; i++ )
+ {
+ int appr = model()->headerData( i, orient, Qtx::AppropriateRole ).toInt();
+ header()->setSectionHidden( i, appr==Qtx::Hidden );
+ }
+}
void resizeColumnToEncloseContents( int );
+ virtual void setModel( QAbstractItemModel* );
+
protected slots:
void onHeaderClicked( int );
void rowsAboutToBeRemoved( const QModelIndex&, int, int );
void selectionChanged( const QItemSelection&, const QItemSelection& );
+ void onAppropriate( Qt::Orientation, int, int );
protected:
void setOpened( const QModelIndex&, const int, bool );
Q_OBJECT
public:
- enum { FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
- ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
- EditCutId, EditCopyId, EditPasteId, HelpAboutId, UserID };
+ enum { MenuFileId, FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
+ MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
+ MenuEditId, EditCutId, EditCopyId, EditPasteId,
+ MenuHelpId, HelpAboutId,
+ UserID
+ };
public:
STD_Application();
bool exitConfirmation() const;
void setExitConfirmation( const bool );
+ virtual void updateDesktopTitle();
+
signals:
/*!emit that view manager added*/
void viewManagerAdded( SUIT_ViewManager* );
virtual void onViewManagerActivated( SUIT_ViewManager* );
protected:
- enum { MenuFileId = 1,
- MenuViewId = 2,
- MenuEditId = 3,
- MenuHelpId = 7
- };
-
enum { OpenCancel, OpenNew, OpenExist };
enum { CloseCancel, CloseSave, CloseDiscard };
protected:
virtual void createActions();
- virtual void updateDesktopTitle();
virtual void updateCommandsStatus();
virtual void setDesktop( SUIT_Desktop* );
myActionMap.insert( ident, a );
if ( desktop() && desktop()->menuMgr() )
- desktop()->menuMgr()->registerAction( a );
+ desktop()->menuMgr()->registerAction( a, id );
if ( desktop() && desktop()->toolMgr() )
- desktop()->toolMgr()->registerAction( a );
+ desktop()->toolMgr()->registerAction( a, id );
return ident;
}
setItemDelegate( qobject_cast<SUIT_ProxyModel*>( model() )->delegate() );
connect( treeView(), SIGNAL( sortingEnabled( bool ) ),
model(), SLOT( setSortingEnabled( bool ) ) );
+ connect( treeView(), SIGNAL( clicked( const QModelIndex& ) ),
+ this, SLOT( onClicked( const QModelIndex& ) ) );
connect( treeView(), SIGNAL( doubleClicked( const QModelIndex& ) ),
this, SLOT( onDblClicked( const QModelIndex& ) ) );
connect( treeView(), SIGNAL( expanded( const QModelIndex& ) ),
\sa updateKey(), setUpdateKey()
*/
+/*!
+ \fn void SUIT_DataBrowser::clicked( SUIT_DataObject* o );
+ \brief This signal is emitted when a mouse button is clicked.
+
+ The data object the mouse was clicked on is specified by \a o.
+ The signal is only emitted when the object is valid.
+
+ \param o data object which is clicked
+*/
+
/*!
\fn void SUIT_DataBrowser::doubleClicked( SUIT_DataObject* o );
\brief This signal is emitted when a mouse button is double-clicked.
setModified();
}
+/*!
+ \brief Called when item is clicked in the tree view
+ \internal
+
+ Emits signal clicked( SUIT_DataObject* );
+*/
+void SUIT_DataBrowser::onClicked( const QModelIndex& index )
+{
+ SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
+
+ if ( m ) {
+ SUIT_DataObject* obj = m->object( index );
+ if ( obj ) emit( clicked( obj ) );
+ }
+}
+
/*!
\brief Called when item is double-clicked in the tree view
\internal
signals:
void requestUpdate();
+ void clicked( SUIT_DataObject* );
void doubleClicked( SUIT_DataObject* );
private slots:
void onModelUpdated();
+ void onClicked( const QModelIndex& );
void onDblClicked( const QModelIndex& );
void onExpanded( const QModelIndex& );
return child;
}
-/*!
- \brief Get the number of the columns provided by the data tree.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns 1 ("Name" column) only.
-
- \return number of the columns
-*/
-int SUIT_DataObject::columnCount() const
-{
- return 1; // one column ("Name") is provided by default
-}
-
-/*!
- \brief Get column title.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns the title for the first column ("Name") only.
-
- \param index column index
- \return title of the specified column
-*/
-QString SUIT_DataObject::columnTitle( const int index ) const
-{
- if ( index == NameIdx )
- return QObject::tr( "NAME_COLUMN" ); // one column ("Name") is provided by default
- return QString();
-}
-
-/*!
- \brief Get column icon.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns null pixmap.
-
- \param index column index
- \return icon of the specified column
-*/
-QPixmap SUIT_DataObject::columnIcon( const int /*index*/ ) const
-{
- return QPixmap();
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
-
- Default implementation returns \c false because 'Name' column should be
- always visible.
-
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool SUIT_DataObject::appropriate( const int /*index*/ ) const
-{
- return false;
-}
-
/*!
\brief Get the number of the child objects.
\return number of the children
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- Column with \a index = 0 (NameIdx) is supposed to be used
+ Column with \a id = 0 (NameId) is supposed to be used
to get the object name (as it does the default implementation).
- \param index column index
+ \param id column id
\return object text data
*/
-QString SUIT_DataObject::text( const int index ) const
+QString SUIT_DataObject::text( const int id ) const
{
- return index == NameIdx ? name() : QString();
+ return id == NameId ? name() : QString();
}
/*!
This method can be re-implemented in the subclasses.
Default implementation returns null pixmap.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SUIT_DataObject::icon( const int /*index*/ ) const
+QPixmap SUIT_DataObject::icon( const int /*id*/ ) const
{
return QPixmap();
}
This method can be re-implemented in the subclasses.
Default implementation returns null color.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
\param role color role
- \param index column index
+ \param id column id
\return object color for the specified column
*/
-QColor SUIT_DataObject::color( const ColorRole /*role*/, const int /*index*/ ) const
+QColor SUIT_DataObject::color( const ColorRole /*role*/, const int /*id*/ ) const
{
return QColor();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
+ The parameter \a id specifies the column identificator
(to display, for example, in the tree view widget).
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString SUIT_DataObject::toolTip( const int /*index*/ ) const
+QString SUIT_DataObject::toolTip( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object status tip for the specified column
*/
-QString SUIT_DataObject::statusTip( const int /*index*/ ) const
+QString SUIT_DataObject::statusTip( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object "what's this" information for the specified column
*/
-QString SUIT_DataObject::whatsThis( const int /*index*/ ) const
+QString SUIT_DataObject::whatsThis( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns application default font.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object font for the specified column
*/
-QFont SUIT_DataObject::font( const int /*index*/ ) const
+QFont SUIT_DataObject::font( const int /*id*/ ) const
{
return QFont();
}
Default implementation returns default alignment which
is Qt:AlignLeft.
- The parameter \a index specifies the column number
+ The parameter \a id specifies the column identificator
(to display, for example, in the tree view widget).
- \param index column index
+ \param id column id
\return object text alignment flags for the specified column
*/
-int SUIT_DataObject::alignment( const int /*index*/ ) const
+int SUIT_DataObject::alignment( const int /*id*/ ) const
{
return Qt::AlignLeft;
}
This method can be re-implemented in the subclasses.
Default implementation returns \c false (all objects are not checkable).
- \param index column index
+ \param id column id
\return \c true if the item can be checked or unchecked by the user
\sa isOn(), setOn()
*/
-bool SUIT_DataObject::isCheckable( const int /*index*/ ) const
+bool SUIT_DataObject::isCheckable( const int /*id*/ ) const
{
return false;
}
Default implementation supports the checked state for the first
("Name") column only.
- \param index column index
+ \param id column id
\return checked state of the object for the specified column
\sa setOn(), isCheckable()
*/
-bool SUIT_DataObject::isOn( const int index ) const
+bool SUIT_DataObject::isOn( const int id ) const
{
- return index == NameIdx && myCheck;
+ return id == NameId && myCheck;
}
/*!
("Name") column only.
\param on new checked state of the object for the specified column
- \param index column index
+ \param id column id
\sa isOn(), isCheckable()
*/
-void SUIT_DataObject::setOn( const bool on, const int index )
+void SUIT_DataObject::setOn( const bool on, const int id )
{
- if ( index == NameIdx )
+ if( id == NameId )
myCheck = on;
}
Default implementation returns false ("Name" column does not require
custom sorting).
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool SUIT_DataObject::customSorting( const int /*index*/ ) const
+bool SUIT_DataObject::customSorting( const int /*id*/ ) const
{
return false;
}
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
bool SUIT_DataObject::compare( const QVariant& /*left*/, const QVariant& /*right*/,
- const int /*index*/ ) const
+ const int /*id*/ ) const
{
return false;
}
{
}
+/*!
+ \brief return unique group identificator
+
+ Groups of data objects are used for column information search.
+ Each column of data model has one or several registered group id
+ If object has the same group id as one of registered, the information
+ will be shown; the custom id of column will be passed into data() method
+ in order to identify column from point of view of data object
+
+ */
+int SUIT_DataObject::groupId() const
+{
+ return 0;
+}
+
/*!
\fn void SUIT_DataObject::Signal::created( SUIT_DataObject* object );
\brief Emitted when data object is created.
HighlightedText //!< highlighted foreground (text) color
} ColorRole;
- //! Column index
- enum {
- NameIdx //!< name column
+ //! Column id
+ enum
+ {
+ NameId //!< name column
};
SUIT_DataObject( SUIT_DataObject* = 0 );
SUIT_DataObject* lastChild() const;
SUIT_DataObject* firstChild() const;
- virtual int columnCount() const;
- virtual QString columnTitle( const int = NameIdx ) const;
- virtual QPixmap columnIcon( const int = NameIdx ) const;
- virtual bool appropriate( const int = NameIdx ) const;
-
int childCount() const;
int childPos( const SUIT_DataObject* ) const;
SUIT_DataObject* childObject( const int ) const;
virtual void setParent( SUIT_DataObject* );
virtual QString name() 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 statusTip( const int = NameIdx ) const;
- virtual QString whatsThis( const int = NameIdx ) const;
- virtual QFont font( const int = NameIdx ) const;
- virtual int alignment( const int = NameIdx ) const;
+ virtual QString text( const int = NameId ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QColor color( const ColorRole, const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
+ virtual QString statusTip( const int = NameId ) const;
+ virtual QString whatsThis( const int = NameId ) const;
+ virtual QFont font( const int = NameId ) const;
+ virtual int alignment( const int = NameId ) const;
virtual bool isDragable() const;
virtual bool isDropAccepted( SUIT_DataObject* obj );
virtual bool isEnabled() const;
virtual bool isSelectable() const;
- virtual bool isCheckable( const int = NameIdx ) const;
+ virtual bool isCheckable( const int = NameId ) const;
- virtual bool isOn( const int = NameIdx ) const;
- virtual void setOn( const bool, const int = NameIdx );
+ virtual bool isOn( const int = NameId ) const;
+ virtual void setOn( const bool, const int = NameId );
virtual bool isOpen() const;
virtual void setOpen( const bool );
virtual void update();
- virtual bool customSorting( const int = NameIdx ) const;
- virtual bool compare( const QVariant&, const QVariant&,
- const int = NameIdx ) const;
+ virtual bool customSorting( const int = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
virtual SUIT_DataObjectKey* key() const;
+ virtual int groupId() const;
static Signal* signal();
static bool connect( const char*, QObject*, const char* );
#include "SUIT_DataObject.h"
#include <QApplication>
+#include <QHash>
+
+SUIT_AbstractModel::SUIT_AbstractModel()
+{
+}
+
+SUIT_AbstractModel::operator const QAbstractItemModel*() const
+{
+ return dynamic_cast<const QAbstractItemModel*>( this );
+}
+
+SUIT_AbstractModel::operator QAbstractItemModel*()
+{
+ return dynamic_cast<QAbstractItemModel*>( this );
+}
+
+SUIT_AbstractModel::operator const QObject*() const
+{
+ return dynamic_cast<const QObject*>( this );
+}
+
+
+
+
+
/*!
\class SUIT_TreeModel::TreeItem
delete myRootItem;
}
+/*!
+ \brief Register new column in the model
+ \param group_id - unique data object group identificator
+ \param name - translated column name
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ */
+void SUIT_TreeModel::registerColumn( const int group_id, const QString& name, const int custom_id )
+{
+ bool found = false;
+ for( int i=0, n=myColumns.size(); i<n && !found; i++ )
+ if( name==myColumns[i].myName )
+ {
+ myColumns[i].myIds.insert( group_id, custom_id );
+ found = true;
+ }
+ if( !found )
+ {
+ ColumnInfo inf;
+ inf.myName = name;
+ inf.myIds.insert( group_id, custom_id );
+ inf.myAppropriate = Qtx::Shown;
+ int n = myColumns.size();
+ myColumns.resize( n+1 );
+ myColumns[n] = inf;
+ reset();
+ }
+}
+
+/*!
+ \brief Remove column from the model
+
+ Please take into account that column is removed only for given group_id, it means
+ that information of data objects with such group_id won't be shown.
+ If there is not any registered group_id for this column after removing, the column will be hidden
+ otherwise it continue to be shown
+
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ */
+void SUIT_TreeModel::unregisterColumn( const int group_id, const QString& name )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myIds.remove( group_id );
+ if( myColumns[i].myIds.isEmpty() )
+ {
+ myColumns.remove( i );
+ reset();
+ }
+ break;
+ }
+}
+
+/*!
+ \brief Change column icon.
+
+ \param name - column name
+ \param icon - new icon of the specified column
+*/
+void SUIT_TreeModel::setColumnIcon( const QString& name, const QPixmap& icon )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myIcon = icon;
+ break;
+ }
+}
+
+/*!
+ \brief Get column icon.
+
+ \param name - column name
+ \return icon of the specified column
+*/
+QPixmap SUIT_TreeModel::columnIcon( const QString& name ) const
+{
+ QPixmap res;
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ res = myColumns[i].myIcon;
+ break;
+ }
+ return res;
+}
+
+/*!
+ \brief Change appropriate status
+
+ Appropriate status determines if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ If appropriate status is not specified yet, the \c Shown value is taken,
+ it means that column should be always visible.
+
+ \param name - column name
+ \param appr - new appropriate status
+*/
+void SUIT_TreeModel::setAppropriate( const QString& name, const Qtx::Appropriate appr )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myAppropriate = appr;
+ emit headerDataChanged( Qt::Horizontal, i, i );
+ break;
+ }
+}
+
+/*!
+ \brief Check if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ Default implementation (if appropriate status is not specified yet)
+ returns \c Shown, it means that column should be always visible.
+
+ \param name - column name
+ \return appropriate status
+*/
+Qtx::Appropriate SUIT_TreeModel::appropriate( const QString& name ) const
+{
+ Qtx::Appropriate appr = Qtx::Shown;
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ appr = myColumns[i].myAppropriate;
+ break;
+ }
+ return appr;
+}
+
+
/*!
\brief Get data tree root object.
\return data tree root
QColor c;
QVariant val;
- if ( obj ) {
- switch ( role ) {
+ int obj_group_id = obj->groupId();
+ const ColumnInfo& inf = myColumns[index.column()];
+
+ int id = -1;
+ if( inf.myIds.contains( 0 ) )
+ id = inf.myIds[0];
+ if( inf.myIds.contains( obj_group_id ) )
+ id = inf.myIds[obj_group_id];
+
+ if( id<0 )
+ return QVariant();
+
+ if ( obj )
+ {
+ switch ( role )
+ {
case DisplayRole:
// data object text for the specified column
- val = obj->text( index.column() );
+ val = obj->text( id );
break;
case DecorationRole:
// data object icon for the specified column
- val = obj->icon( index.column() );
+ val = obj->icon( id );
break;
case ToolTipRole:
// data object tooltip for the specified column
- val = obj->toolTip( index.column() );
+ val = obj->toolTip( id );
break;
case StatusTipRole:
// data object status tip for the specified column
- val = obj->statusTip( index.column() );
+ val = obj->statusTip( id );
break;
case WhatsThisRole:
// data object what's this info for the specified column
- val = obj->whatsThis( index.column() );
+ val = obj->whatsThis( id );
break;
case FontRole:
// data object font for the specified column
- val = obj->font( index.column() );
+ val = obj->font( id );
break;
case TextAlignmentRole:
// data object text alignment for the specified column
- val = obj->alignment( index.column() );
+ val = obj->alignment( id );
break;
case BackgroundRole:
// data background color for the specified column
- c = obj->color( SUIT_DataObject::Background, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Base );
+ c = obj->color( SUIT_DataObject::Background, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Base );
c.setAlpha( 0 );
val = c;
break;
case ForegroundRole:
// data foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::Foreground, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Foreground );
+ c = obj->color( SUIT_DataObject::Foreground, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Foreground );
val = c;
break;
case BaseColorRole:
// editor background color for the specified column
- c = obj->color( SUIT_DataObject::Base, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Base );
+ c = obj->color( SUIT_DataObject::Base, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Base );
val = c;
break;
case TextColorRole:
// editor foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::Text, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Text );
+ c = obj->color( SUIT_DataObject::Text, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Text );
val = c;
break;
case HighlightRole:
// adta object highlighted background color for the specified column
- c = obj->color( SUIT_DataObject::Highlight, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Highlight );
+ c = obj->color( SUIT_DataObject::Highlight, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Highlight );
val = c;
break;
case HighlightedTextRole:
// data object highlighted foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::HighlightedText, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::HighlightedText );
+ c = obj->color( SUIT_DataObject::HighlightedText, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::HighlightedText );
val = c;
break;
case CheckStateRole:
// data object checked state for the specified column
// NOTE! three-state check is not supported currently
- if ( obj->isCheckable( index.column() ) )
- val = obj->isOn( index.column() ) ? Qt::Checked : Qt::Unchecked;
+ if( obj->isCheckable( id ) )
+ val = obj->isOn( id ) ? Qt::Checked : Qt::Unchecked;
break;
case SizeHintRole:
// data size hint
\param role data role
\return header data
*/
-QVariant SUIT_TreeModel::headerData( int column, Qt::Orientation orientation,
- int role ) const
+QVariant SUIT_TreeModel::headerData( int column, Qt::Orientation orientation, int role ) const
{
QVariant d;
// NOTE! only horizontal header is supported
- if ( root() && orientation == Qt::Horizontal ) {
- switch ( role ) {
+ if ( root() && orientation == Qt::Horizontal )
+ {
+ switch ( role )
+ {
case DisplayRole:
// column title
- d = root()->columnTitle( column );
+ d = myColumns[column].myName;
break;
case DecorationRole:
// column icon
- d = root()->columnIcon( column );
+ d = myColumns[column].myIcon;
break;
case AppropriateRole:
// appropriate flag (can column be hidden via context popup menu)
- d = root()->appropriate( column );
+ d = myColumns[column].myAppropriate;
break;
default:
break;
QModelIndex SUIT_TreeModel::index( int row, int column,
const QModelIndex& parent ) const
{
- if ( hasIndex( row, column, parent ) ) {
+ if( hasIndex( row, column, parent ) )
+ {
TreeItem* parentItem = treeItem( parent );
- if ( parentItem ) {
+ QString pname;
+ if( parentItem && parentItem->dataObject() )
+ pname = parentItem->dataObject()->name();
+ if( parentItem )
+ {
TreeItem* childItem = parentItem->child( row );
- if ( childItem )
+ if( childItem )
+ {
+ QString cname = childItem->dataObject()->name();
return createIndex( row, column, childItem );
}
}
+ }
return QModelIndex();
}
*/
int SUIT_TreeModel::columnCount( const QModelIndex& /*parent*/ ) const
{
- return root() ? root()->columnCount() : 0;
+ return myColumns.size();
}
/*!
if ( !myRootItem )
myRootItem = new TreeItem( 0 );
+ registerColumn( 0, QObject::tr( "NAME_COLUMN" ), SUIT_DataObject::NameId );
updateTree();
}
// update all columns corresponding to the given data object
QModelIndex firstIdx = index( obj, 0 );
- QModelIndex lastIdx = index( obj, obj->columnCount() - 1 );
+ QModelIndex lastIdx = index( obj, columnCount() - 1 );
emit dataChanged( firstIdx, lastIdx );
}
\param model tree model
\param parent parent object
*/
-SUIT_ProxyModel::SUIT_ProxyModel( SUIT_TreeModel* model, QObject* parent )
+SUIT_ProxyModel::SUIT_ProxyModel( SUIT_AbstractModel* model, QObject* parent )
: QSortFilterProxyModel( parent ),
mySortingEnabled( true )
{
- connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
- setSourceModel( model );
+ connect( *model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
+ setSourceModel( *model );
}
/*!
return QSortFilterProxyModel::lessThan( left, right );
}
+/*!
+ \brief Check if the specified column supports custom sorting.
+ \param column column index on which data is being sorted
+ \return \c true if column requires custom sorting
+ \sa lessThan()
+*/
+bool SUIT_ProxyModel::customSorting( const int column ) const
+{
+ return treeModel() ? treeModel()->customSorting( column ) : false;
+}
+
/*!
\brief Enable/disable sorting.
\param enabled new flag state
\brief Get tree model.
\return tree model
*/
-SUIT_TreeModel* SUIT_ProxyModel::treeModel() const
+SUIT_AbstractModel* SUIT_ProxyModel::treeModel() const
+{
+ return dynamic_cast<SUIT_AbstractModel*>( sourceModel() );
+}
+
+/*!
+ \brief Register new column in the model
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ */
+void SUIT_ProxyModel::registerColumn( const int group_id, const QString& name, const int custom_id )
{
- return dynamic_cast<SUIT_TreeModel*>( sourceModel() );
+ if( treeModel() )
+ treeModel()->registerColumn( group_id, name, custom_id );
}
+/*!
+ \brief Remove column from the model
+
+ Please take into account that column is removed only for given group_id, it means
+ that information of data objects with such group_id won't be shown.
+ If there is not any registered group_id for this column after removing, the column will be hidden
+ otherwise it continue to be shown
+
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ */
+void SUIT_ProxyModel::unregisterColumn( const int group_id, const QString& name )
+{
+ if( treeModel() )
+ treeModel()->unregisterColumn( group_id, name );
+}
+
+/*!
+ \brief Change column icon.
+
+ \param name - column name
+ \param icon - new icon of the specified column
+*/
+void SUIT_ProxyModel::setColumnIcon( const QString& name, const QPixmap& icon )
+{
+ if( treeModel() )
+ treeModel()->setColumnIcon( name, icon );
+}
+
+/*!
+ \brief Get column icon.
+
+ \param name - column name
+ \return icon of the specified column
+*/
+QPixmap SUIT_ProxyModel::columnIcon( const QString& name ) const
+{
+ return treeModel() ? treeModel()->columnIcon( name ) : QPixmap();
+}
+
+/*!
+ \brief Change appropriate status
+
+ Appropriate status determines if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ If appropriate status is not specified yet, the \c Shown value is taken,
+ it means that column should be always visible.
+
+ \param name - column name
+ \param appr - new appropriate status
+*/
+void SUIT_ProxyModel::setAppropriate( const QString& name, const Qtx::Appropriate appr )
+{
+ if( treeModel() )
+ treeModel()->setAppropriate( name, appr );
+}
+
+/*!
+ \brief Check if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ Default implementation (if appropriate status is not specified yet)
+ returns \c Shown, it means that column should be always visible.
+
+ \param name - column name
+ \return appropriate status
+*/
+Qtx::Appropriate SUIT_ProxyModel::appropriate( const QString& name ) const
+{
+ return treeModel() ? treeModel()->appropriate( name ) : Qtx::Shown;
+}
+
+
+
+
+
+
/*!
\class SUIT_ItemDelegate
\brief An SUIT_DataObject-based item delegate class.
class SUIT_DataObject;
class SUIT_TreeModel;
-class SUIT_EXPORT SUIT_TreeModel : public QAbstractItemModel
+class SUIT_EXPORT SUIT_AbstractModel
+{
+public:
+ SUIT_AbstractModel();
+
+ operator const QAbstractItemModel*() const;
+ operator QAbstractItemModel*();
+ operator const QObject*() const;
+
+ virtual SUIT_DataObject* root() const = 0;
+ virtual void setRoot( SUIT_DataObject* ) = 0;
+ virtual SUIT_DataObject* object( const QModelIndex& = QModelIndex() ) const = 0;
+ virtual QModelIndex index( const SUIT_DataObject*, int = 0 ) const = 0;
+ virtual bool autoDeleteTree() const = 0;
+ virtual void setAutoDeleteTree( const bool ) = 0;
+ virtual bool autoUpdate() const = 0;
+ virtual void setAutoUpdate( const bool ) = 0;
+ virtual QAbstractItemDelegate* delegate() const = 0;
+ virtual bool customSorting( const int ) const = 0;
+ virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const = 0;
+
+ virtual void updateTree( const QModelIndex& ) = 0;
+ virtual void updateTree( SUIT_DataObject* = 0 ) = 0;
+
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id ) = 0;
+ virtual void unregisterColumn( const int group_id, const QString& name ) = 0;
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon ) = 0;
+ virtual QPixmap columnIcon( const QString& name ) const = 0;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr ) = 0;
+ virtual Qtx::Appropriate appropriate( const QString& name ) const = 0;
+};
+
+
+class SUIT_EXPORT SUIT_TreeModel : public QAbstractItemModel, public SUIT_AbstractModel
{
Q_OBJECT
virtual QModelIndex index( int, int, const QModelIndex& = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex& ) const;
- virtual int columnCount( const QModelIndex& = QModelIndex() ) const;
- virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
+ virtual int columnCount( const QModelIndex& = QModelIndex() ) const;
+ virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
+ virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon );
+ virtual QPixmap columnIcon( const QString& name ) const;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
+ virtual Qtx::Appropriate appropriate( const QString& name ) const;
SUIT_DataObject* object( const QModelIndex& = QModelIndex() ) const;
QModelIndex index( const SUIT_DataObject*, int = 0 ) const;
TreeItem* treeItem( const SUIT_DataObject* ) const;
SUIT_DataObject* object( const TreeItem* ) const;
- TreeItem* createItem( SUIT_DataObject*,
- TreeItem* = 0,
- TreeItem* = 0 );
+ TreeItem* createItem( SUIT_DataObject*, TreeItem* = 0, TreeItem* = 0 );
void updateItem( TreeItem* );
void removeItem( TreeItem* );
private:
typedef QMap<SUIT_DataObject*, TreeItem*> ItemMap;
+ typedef struct
+ {
+ QString myName;
+ QMap<int,int> myIds;
+ QPixmap myIcon;
+ Qtx::Appropriate myAppropriate;
+
+ } ColumnInfo;
- SUIT_DataObject* myRoot;
- TreeItem* myRootItem;
- ItemMap myItems;
- bool myAutoDeleteTree;
- bool myAutoUpdate;
+ SUIT_DataObject* myRoot;
+ TreeItem* myRootItem;
+ ItemMap myItems;
+ bool myAutoDeleteTree;
+ bool myAutoUpdate;
+ QVector<ColumnInfo> myColumns;
friend class SUIT_TreeModel::TreeSync;
};
-class SUIT_EXPORT SUIT_ProxyModel : public QSortFilterProxyModel
+class SUIT_EXPORT SUIT_ProxyModel : public QSortFilterProxyModel, public SUIT_AbstractModel
{
Q_OBJECT
public:
SUIT_ProxyModel( QObject* = 0 );
SUIT_ProxyModel( SUIT_DataObject*, QObject* = 0 );
- SUIT_ProxyModel( SUIT_TreeModel*, QObject* = 0 );
+ SUIT_ProxyModel( SUIT_AbstractModel*, QObject* = 0 );
~SUIT_ProxyModel();
SUIT_DataObject* root() const;
void setAutoUpdate( const bool );
bool isSortingEnabled() const;
+ bool customSorting( const int ) const;
+
+ virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
+ virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon );
+ virtual QPixmap columnIcon( const QString& name ) const;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
+ virtual Qtx::Appropriate appropriate( const QString& name ) const;
QAbstractItemDelegate* delegate() const;
void modelUpdated();
protected:
- virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
-
-private:
- SUIT_TreeModel* treeModel() const;
+ SUIT_AbstractModel* treeModel() const;
private:
bool mySortingEnabled;
connect( ob, SIGNAL( doubleClicked( SUIT_DataObject* ) ), this, SLOT( onDblClick( SUIT_DataObject* ) ) );
+ QString
+ ValueCol = QObject::tr( "VALUE_COLUMN" ),
+ IORCol = QObject::tr( "IOR_COLUMN" ),
+ RefCol = QObject::tr( "REFENTRY_COLUMN" ),
+ EntryCol = QObject::tr( "ENTRY_COLUMN" );
+
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
+ treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
+ treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
+ treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
+ treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
+ treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ treeModel->setAppropriate( ValueCol, Qtx::Toggled );
+ treeModel->setAppropriate( IORCol, Qtx::Toggled );
+ treeModel->setAppropriate( RefCol, Qtx::Toggled );
+
bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true );
int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
- for ( int i = SalomeApp_DataObject::EntryIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
+ for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
{
pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i-1 ).toLatin1() ), defCols,
- LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i-1 ) );
+ LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_id_%d", i ) );
}
pref->setItemProperty( "orientation", Qt::Vertical, defCols );
void SalomeApp_Application::objectBrowserColumnsVisibility()
{
if ( objectBrowser() )
- for ( int i = SalomeApp_DataObject::EntryIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
- objectBrowser()->treeView()->setColumnHidden( i,
- !(resourceMgr()->booleanValue( "ObjectBrowser",
- QString().sprintf( "visibility_column_%d", i-1 ),
- true )) );
+ for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
+ {
+ bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i ), true );
+ objectBrowser()->treeView()->setColumnHidden( i, !shown );
+ }
}
virtual bool isPossibleToClose( bool& );
virtual bool useStudy( const QString& );
+ virtual void updateDesktopTitle();
public slots:
virtual void onLoadDoc();
virtual void onSelectionChanged();
virtual void createPreferences( LightApp_Preferences* );
- virtual void updateDesktopTitle();
virtual bool closeAction( const int, bool& );
virtual int closeChoice( const QString& );
{
}
-/*!
- \brief Get the number of the columns provided by the data tree.
- \return number of the columns
-*/
-int SalomeApp_DataObject::columnCount() const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- return LightApp_DataObject::columnCount() + 3;
-}
-
-/*!
- \brief Get column title.
- \param index column index
- \return title of the specified column
-*/
-QString SalomeApp_DataObject::columnTitle( const int index ) const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- switch ( index ) {
- case ValueIdx:
- return QObject::tr( "VALUE_COLUMN" ) ;
- case IORIdx:
- return QObject::tr( "IOR_COLUMN" ) ;
- case RefEntryIdx:
- return QObject::tr( "REFENTRY_COLUMN" ) ;
- default:
- break;
- }
- return LightApp_DataObject::columnTitle( index );
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool SalomeApp_DataObject::appropriate( const int index ) const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- return index > EntryIdx && index <= RefEntryIdx ? true :
- LightApp_DataObject::appropriate( index );
-}
-
/*!
\brief Get data object name.
\return object name
/*!
\brief Get object text data for the specified column.
- This method returns the data according to the specufied column \a index:
- - NameIdx : object name (by calling name() method)
- - EntryIdx : object entry (by calling entry() method)
- - ValueIdx : object value
- - IORIdx : object IOR
- - RefEntryIdx : object reference entry
+ This method returns the data according to the specufied column \a id:
+ - NameId : object name (by calling name() method)
+ - EntryId : object entry (by calling entry() method)
+ - ValueId : object value
+ - IORId : object IOR
+ - RefEntryId : object reference entry
- \param index column index
+ \param id column id
\return object text data
*/
-QString SalomeApp_DataObject::text( const int index ) const
+QString SalomeApp_DataObject::text( const int id ) const
{
QString txt;
// add "Value", "IOR", and "Reference Entry" columns
- switch ( index )
+ switch ( id )
{
- case ValueIdx:
+ case ValueId:
#ifndef WIN32
if ( componentObject() != this )
#else
if ( txt.isEmpty() )
txt = value( referencedObject() );
break;
- case IORIdx:
+ case IORId:
txt = ior( referencedObject() );
break;
- case RefEntryIdx:
+ case RefEntryId :
if ( isReference() )
txt = entry( referencedObject() );
break;
default:
- txt = LightApp_DataObject::text( index );
+ txt = LightApp_DataObject::text( id );
break;
}
return txt;
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_DataObject::icon( const int index ) const
+QPixmap SalomeApp_DataObject::icon( const int id ) const
{
- // we display icon only for the first (NameIdx) column
- if ( index == NameIdx ) {
+ // we display icon only for the first (NameId ) column
+ if ( id == NameId ) {
_PTR(GenericAttribute) anAttr;
if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){
_PTR(AttributePixMap) aPixAttr ( anAttr );
}
}
}
- return LightApp_DataObject::icon( index );
+ return LightApp_DataObject::icon( id );
}
/*!
\brief Get data object color for the specified column.
\param role color role
- \param index column index (not used)
+ \param id column id (not used)
\return object color for the specified column
*/
-QColor SalomeApp_DataObject::color( const ColorRole role, const int index ) const
+QColor SalomeApp_DataObject::color( const ColorRole role, const int id ) const
{
- // we ignore parameter <index> in order to use the same colors for
+ // we ignore parameter <id> in order to use the same colors for
// all columns
QColor c;
switch ( role )
break;
}
if ( !c.isValid() )
- c = LightApp_DataObject::color( role, index );
+ c = LightApp_DataObject::color( role, id );
return c;
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_DataObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const
{
- // we ignore parameter <index> in order to use the same tooltip for
+ // we ignore parameter <id> in order to use the same tooltip for
// all columns
return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() );
}
/*!
\brief Check if the specified column supports custom sorting.
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool SalomeApp_DataObject::customSorting( const int index ) const
+bool SalomeApp_DataObject::customSorting( const int id ) const
{
// perform custom sorting for the "Entry" and "Reference Entry" columns
- return index == EntryIdx || index == RefEntryIdx ? true
- : LightApp_DataObject::customSorting( index );
+ return id == EntryId || id == RefEntryId ? true
+ : LightApp_DataObject::customSorting( id );
}
/*!
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
-bool SalomeApp_DataObject::compare( const QVariant& left, const QVariant& right,
- const int index ) const
+bool SalomeApp_DataObject::compare( const QVariant& left, const QVariant& right, const int id ) const
{
// use the same custom sorting for the "Reference Entry" column as for the
// "Entry" column (call base implementation)
- return LightApp_DataObject::compare( left, right, index == RefEntryIdx ? EntryIdx : index );
+ return LightApp_DataObject::compare( left, right, id == RefEntryId ? EntryId : id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_ModuleObject::icon( const int index ) const
+QPixmap SalomeApp_ModuleObject::icon( const int id ) const
{
- return SalomeApp_DataObject::icon( index );
+ return SalomeApp_DataObject::icon( id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString SalomeApp_ModuleObject::toolTip( const int index ) const
+QString SalomeApp_ModuleObject::toolTip( const int id ) const
{
- return SalomeApp_DataObject::toolTip( index );
+ return SalomeApp_DataObject::toolTip( id );
}
/*!
/*!
\brief Get object text data for the specified column.
- \param index column index
+ \param id column id
\return object text data
*/
-QString SalomeApp_RootObject::text( const int index ) const
+QString SalomeApp_RootObject::text( const int id ) const
{
- return LightApp_RootObject::text( index );
+ return LightApp_RootObject::text( id );
}
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_RootObject::icon( const int index ) const
+QPixmap SalomeApp_RootObject::icon( const int id ) const
{
- return LightApp_RootObject::icon( index );
+ return LightApp_RootObject::icon( id );
}
/*!
\brief Get data object color for the specified column.
\param role color role
- \param index column index (not used)
+ \param id column id (not used)
\return object color for the specified column
*/
-QColor SalomeApp_RootObject::color( const ColorRole role, const int index ) const
+QColor SalomeApp_RootObject::color( const ColorRole role, const int id ) const
{
- return LightApp_RootObject::color( role, index );
+ return LightApp_RootObject::color( role, id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_RootObject::toolTip( const int index ) const
+QString SalomeApp_RootObject::toolTip( const int id ) const
{
- return LightApp_RootObject::toolTip( index );
+ return LightApp_RootObject::toolTip( id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_SavePointObject::icon( const int /*index*/ ) const
+QPixmap SalomeApp_SavePointObject::icon( const int /*id*/ ) const
{
return QPixmap();
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_SavePointObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_SavePointObject::toolTip( const int /*id*/ ) const
{
return QObject::tr( "SAVE_POINT_OBJECT_TOOLTIP" ).arg( name() );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_SavePointRootObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_SavePointRootObject::toolTip( const int /*id*/ ) const
{
return QObject::tr( "SAVE_POINT_ROOT_TOOLTIP" );
}
{
public:
- //! Column index
+ //! Column id
enum {
- ValueIdx = EntryIdx + 1, //!< value column
- IORIdx, //!< IOR column
- RefEntryIdx //!< reference entry column
+ ValueId = EntryId + 1, //!< value column
+ IORId, //!< IOR column
+ RefEntryId //!< reference entry column
};
public:
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 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 = NameId ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QColor color( const ColorRole, const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
virtual _PTR(SObject) object() 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 = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
+
private:
QString ior( const _PTR(SObject)& ) const;
QString entry( const _PTR(SObject)& ) const;
virtual ~SalomeApp_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
};
class SALOMEAPP_EXPORT SalomeApp_RootObject : public SalomeApp_DataObject,
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 text( const int = NameId ) const;
+ QPixmap icon( const int = NameId ) const;
+ QColor color( const ColorRole, const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
};
class SALOMEAPP_EXPORT SalomeApp_SavePointObject : public virtual LightApp_DataObject
virtual QString name() const;
virtual QString entry() const;
- virtual QPixmap icon( const int = NameIdx ) const;
- virtual QString toolTip( const int = NameIdx ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
int getId() const;
SalomeApp_SavePointRootObject( SUIT_DataObject* );
virtual QString name() const;
- virtual QString toolTip( const int = NameIdx ) const;
+ virtual QString toolTip( const int = NameId ) const;
};
#endif
<parameter name="auto_size" value="false" />
<parameter name="auto_size_first" value="true" />
<parameter name="resize_on_expand_item" value="false" />
- <parameter name="visibility_column_0" value="false" />
- <parameter name="visibility_column_1" value="true" />
- <parameter name="visibility_column_2" value="false" />
- <parameter name="visibility_column_3" value="false" />
+ <parameter name="visibility_column_id_1" value="true" />
+ <parameter name="visibility_column_id_2" value="true" />
+ <parameter name="visibility_column_id_3" value="true" />
+ <parameter name="visibility_column_id_4" value="true" />
</section>
<section name="PyConsole">
<!-- Python console preferences -->