Back to index

salome-gui  6.5.0
LightApp_ModuleAction.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   : LightApp_ModuleAction.h
00021 // Author : Sergey TELKOV, Vadim SANDLER
00022 //
00023 #ifndef LIGHTAPP_MODULEACTION_H
00024 #define LIGHTAPP_MODULEACTION_H
00025 
00026 #include "LightApp.h"
00027 
00028 #include <QtxAction.h>
00029 
00030 #ifdef WIN32
00031 #pragma warning ( disable:4251 )
00032 #endif
00033 
00034 class QtxComboBox;
00035 
00036 class LIGHTAPP_EXPORT LightApp_ModuleAction : public QtxAction
00037 {
00038   Q_OBJECT
00039 
00040 private:
00041   class ActionSet;
00042   class ComboAction;
00043   class ActivateEvent;
00044 
00045 public:
00046   enum { None = 0x00, Buttons = 0x01, ComboItem = 0x02, All = Buttons | ComboItem };
00047 
00048 public:
00049   LightApp_ModuleAction( const QString&, QObject* = 0 );
00050   LightApp_ModuleAction( const QString&, const QIcon&, QObject* = 0 );
00051   virtual ~LightApp_ModuleAction();
00052 
00053   QStringList      modules() const;
00054 
00055   QIcon            moduleIcon( const QString& ) const;
00056   void             setModuleIcon( const QString&, const QIcon& );
00057 
00058   void             insertModule( const QString&, const QIcon&, const int = -1 );
00059   void             removeModule( const QString& );
00060 
00061   QString          activeModule() const;
00062   void             setActiveModule( const QString& );
00063 
00064   void             setMode( const int );
00065   int              mode() const;
00066 
00067 protected:
00068   virtual void     addedTo( QWidget* );
00069   virtual void     removedFrom( QWidget* );
00070 
00071   virtual bool     event( QEvent* );
00072 
00073 signals:
00074   void             moduleActivated( const QString& );
00075 
00076 private:
00077   void             init();
00078 
00079   void             update();
00080   void             update( QtxComboBox* );
00081 
00082   QAction*         active() const;
00083   void             activate( int, bool = true );
00084 
00085 private slots:
00086   void             onChanged();
00087   void             onTriggered( int );
00088   void             onComboActivated( int );
00089 
00090 private:
00091   ComboAction*     myCombo;
00092   ActionSet*       mySet;
00093   int              myMode;
00094 };
00095 
00096 class LightApp_ModuleAction::ComboAction : public QtxAction
00097 {
00098   Q_OBJECT
00099 
00100 public:
00101   ComboAction( QObject* parent );
00102 
00103   QList<QtxComboBox*> widgets() const;
00104 
00105 signals:
00106   void                activatedId( int );
00107 
00108 protected:
00109   virtual QWidget*    createWidget( QWidget* );
00110 };
00111 
00112 #endif // LIGHTAPP_MODULEACTION_H