00001 // Copyright (C) 2007-2011 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 protected: 00073 virtual void contextMenuEvent( QContextMenuEvent* ); 00074 00075 private: 00076 void init( SUIT_DataObject* ); 00077 00078 signals: 00079 void requestUpdate(); 00080 void requestRename(); 00081 void clicked( SUIT_DataObject* ); 00082 void doubleClicked( SUIT_DataObject* ); 00083 00084 private slots: 00085 void onModelUpdated(); 00086 void onClicked( const QModelIndex& ); 00087 void onDblClicked( const QModelIndex& ); 00088 void onExpanded( const QModelIndex& ); 00089 void onStartEditing(); 00090 00091 private: 00092 typedef QMap<int, QShortcut*> ShortcutMap; 00093 ShortcutMap myShortcutMap; 00094 00095 bool myAutoSizeFirstColumn; 00096 bool myAutoSizeColumns; 00097 bool myResizeOnExpandItem; 00098 }; 00099 00100 #endif // SUIT_BROWSER_H