Back to index

salome-gui  6.5.0
QtxActionSet.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:      QtxActionSet.h
00021 // Author:    Sergey TELKOV
00022 //
00023 #ifndef QTXACTIONSET_H
00024 #define QTXACTIONSET_H
00025 
00026 #include "QtxAction.h"
00027 
00028 #include <QList>
00029 
00030 #ifdef WIN32
00031 #pragma warning( disable:4251 )
00032 #endif
00033 
00034 class QTX_EXPORT QtxActionSet : public QtxAction
00035 {
00036   Q_OBJECT
00037 
00038 public:
00039   QtxActionSet( QObject* = 0 );
00040   virtual ~QtxActionSet();
00041 
00042   QList<QAction*> actions() const;
00043   void            setActions( const QList<QAction*>& );
00044 
00045   void            insertActions( const QList<QAction*>&, const int = -1 );
00046 
00047   int             insertAction( QAction*, const int id = -1, const int = -1 );
00048   int             insertAction( const QString&, const int id = -1, const int = -1 );
00049   int             insertAction( const QString&, const QIcon&, const int id = -1, const int = -1 );
00050 
00051   void            removeAction( QAction* );
00052   void            removeAction( const int );
00053 
00054   void            clear();
00055 
00056 signals:
00057   void            triggered( int );
00058   void            triggered( QAction* );
00059 
00060 private slots:
00061   void            onChanged();
00062   void            onActionTriggered( bool = false );
00063 
00064 protected:
00065   virtual void    addedTo( QWidget* );
00066   virtual void    removedFrom( QWidget* );
00067 
00068   virtual void    actionAdded( QAction* );
00069   virtual void    actionRemoved( QAction* );
00070 
00071   QAction*        action( int ) const;
00072   int             actionId( QAction* ) const;
00073   void            setActionId( QAction*, const int );
00074 
00075   virtual bool    isEmptyAction() const;
00076 
00077   virtual void    updateAction();
00078   virtual void    updateAction( QWidget* );
00079 
00080 private:
00081   int             generateId() const;
00082 
00083 private:
00084   typedef QList<QAction*> ActionList;
00085 
00086 private:
00087   ActionList      mySet;      
00088 };
00089 
00090 #ifdef WIN32
00091 #pragma warning( default:4251 )
00092 #endif
00093 
00094 #endif