VR-Forces 4.0.4 Class Documentation
include/vrvCoreQt/DtContextTreeWidget.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2009 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtContextTreeWidget.h,v $ $Revision: 1.12 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #ifndef DtContextTreeWidget_H_
00014 #define DtContextTreeWidget_H_
00015 
00016 #include <vrvCoreQt/vrvCoreQt.h>
00017 #include <vrvUtil/signalslib.h>
00018 
00019 #include <QtGui/QTreeWidget>
00020 
00021 class QMenu;
00022 class QMouseEvent;
00023 class QPoint;
00024 class QPushButton;
00025 class QIcon;
00026 
00027 namespace makVrv
00028 {
00032    class DT_DLL_VRVCOREQT DtContextTreeWidget : public QTreeWidget
00033    {
00034       Q_OBJECT
00035 
00036    public:
00037       class ContextMenuItem
00038       {
00039       public:
00040          ContextMenuItem()
00041          : myButton(0)
00042          , myReceiver(0)
00043          , mySlot(0)
00044          {
00045          }
00046 
00047          QPushButton*   myButton;
00048          QObject*       myReceiver;
00049          const char*    mySlot;
00050          QString        myTitle;
00051       };
00052 
00053       typedef std::vector<ContextMenuItem> DtContextMenuItems;
00054 
00055    public:
00056       DtContextTreeWidget(QWidget* parent = 0);
00057 
00058       virtual ~DtContextTreeWidget();
00059 
00060    public:
00061       // \brief Will add a context menu item for the specified button when creating the
00066       virtual void addContextItem(QPushButton* b, QObject* receiver, const char* slot);
00067       virtual void addContextItem(QPushButton* b, const QString& title, QObject* receiver, const char* slot);
00068 
00071       virtual void addContextItem(const QString& item, QObject* receiver, const char* slot,
00072          const QIcon& icon = QIcon());
00073 
00075       virtual void addContextSeparator();
00076 
00079       const DtContextMenuItems& menuItems() const;
00080       virtual void setMenuItems(const DtContextMenuItems&);
00081 
00084       virtual void removeMenuItem(const QString&);
00085 
00087       virtual void removeSeparator(int at = 1);
00088 
00089       bool rightClick() const
00090       {
00091          return myRightClick;
00092       }
00093 
00094    public:
00097       boost::signal<void (DtContextTreeWidget*, QMenu*)> signal_contextMenuAboutToBeShown;
00098 
00099    protected slots:
00100       virtual void onButtonDestroyed();
00101 
00102    protected:
00105       virtual void processContextMenu(const QPoint&);
00106 
00108       virtual void mousePressEvent(QMouseEvent* mouseEvent);
00109 
00111       virtual void mouseReleaseEvent(QMouseEvent* mouseEvent);
00112 
00114       virtual void deleteIfOwned(const ContextMenuItem&);
00115 
00116    protected:
00117       bool                 myRightClick;
00118       DtContextMenuItems   myMenuItems;
00119    };
00120 }
00121 
00122 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)