Back to index

salome-gui  6.5.0
SUIT_DataBrowser.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : SUIT_DataBrowser.h
00021 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00022 //
00023 #ifndef SUIT_DATABROWSER_H
00024 #define SUIT_DATABROWSER_H
00025 
00026 #include "SUIT.h"
00027 #include "SUIT_PopupClient.h"
00028 #include "SUIT_DataObject.h"
00029 #include <OB_Browser.h>
00030 
00031 class QShortcut;
00032 
00033 class SUIT_EXPORT SUIT_DataBrowser : public OB_Browser, public SUIT_PopupClient
00034 {
00035   Q_OBJECT
00036 
00037 public:
00038   SUIT_DataBrowser( QWidget* = 0 );
00039   SUIT_DataBrowser( SUIT_DataObject*, QWidget* = 0 );
00040   ~SUIT_DataBrowser();
00041   
00042   enum {UpdateShortcut = 0, RenameShortcut};
00043 
00044   virtual QString  popupClientType() const;
00045 
00046   SUIT_DataObject* root() const;
00047   void             setRoot( SUIT_DataObject* );
00048 
00049   bool             autoUpdate() const;
00050   void             setAutoUpdate( const bool );
00051 
00052   bool             updateModified() const;
00053   void             setUpdateModified( const bool );
00054 
00055   void             updateTree( SUIT_DataObject* = 0, const bool = true );
00056 
00057   int              shortcutKey(const int) const;
00058   void             setShortcutKey( const int, const int );
00059 
00060   DataObjectList   getSelected() const;
00061   void             getSelected( DataObjectList& ) const;
00062 
00063   void             setSelected( const SUIT_DataObject*, const bool = false );
00064   void             setSelected( const DataObjectList&, const bool = false );
00065 
00066   virtual void     contextMenuPopup( QMenu* );
00067 
00068   void             setAutoSizeFirstColumn( const bool on );
00069   void             setAutoSizeColumns( const bool on );
00070   void             setResizeOnExpandItem( const bool on );
00071 
00072   void             ensureVisible( SUIT_DataObject* );
00073   void             ensureVisible( const DataObjectList& );
00074 
00075 protected:
00076   virtual void     contextMenuEvent( QContextMenuEvent* );
00077 
00078 private:
00079   void             init( SUIT_DataObject* );
00080 
00081 signals:
00082   void             requestUpdate();
00083   void             requestRename();
00084   void             clicked( SUIT_DataObject* );
00085   void             doubleClicked( SUIT_DataObject* );
00086 
00087 private slots:
00088   void             onModelUpdated();
00089   void             onClicked( const QModelIndex& );
00090   void             onDblClicked( const QModelIndex& );
00091   void             onExpanded( const QModelIndex& );
00092   void             onStartEditing();
00093 
00094 private:
00095   typedef          QMap<int, QShortcut*> ShortcutMap;
00096   ShortcutMap      myShortcutMap;
00097 
00098   bool             myAutoSizeFirstColumn;
00099   bool             myAutoSizeColumns;
00100   bool             myResizeOnExpandItem;
00101 };
00102 
00103 #endif // SUIT_BROWSER_H