Version: 6.3.1

src/LightApp/LightApp_ModuleAction.h

Go to the documentation of this file.
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   : 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 
00044 public:
00045   enum { None = 0x00, Buttons = 0x01, ComboItem = 0x02, All = Buttons | ComboItem };
00046 
00047 public:
00048   LightApp_ModuleAction( const QString&, QObject* = 0 );
00049   LightApp_ModuleAction( const QString&, const QIcon&, QObject* = 0 );
00050   virtual ~LightApp_ModuleAction();
00051 
00052   QStringList      modules() const;
00053 
00054   QIcon            moduleIcon( const QString& ) const;
00055   void             setModuleIcon( const QString&, const QIcon& );
00056 
00057   void             insertModule( const QString&, const QIcon&, const int = -1 );
00058   void             removeModule( const QString& );
00059 
00060   QString          activeModule() const;
00061   void             setActiveModule( const QString& );
00062 
00063   void             setMode( const int );
00064   int              mode() const;
00065 
00066 protected:
00067   virtual void     addedTo( QWidget* );
00068   virtual void     removedFrom( QWidget* );
00069 
00070 signals:
00071   void             moduleActivated( const QString& );
00072 
00073 private:
00074   void             init();
00075 
00076   void             update();
00077   void             update( QtxComboBox* );
00078 
00079   QAction*         active() const;
00080   void             activate( int, bool = true );
00081 
00082 private slots:
00083   void             onChanged();
00084   void             onTriggered( int );
00085   void             onComboActivated( int );
00086 
00087 private:
00088   ComboAction*     myCombo;
00089   ActionSet*       mySet;
00090   int              myMode;
00091 };
00092 
00093 class LightApp_ModuleAction::ComboAction : public QtxAction
00094 {
00095   Q_OBJECT
00096 
00097 public:
00098   ComboAction( QObject* parent );
00099 
00100   QList<QtxComboBox*> widgets() const;
00101 
00102 protected:
00103   virtual QWidget*    createWidget( QWidget* );
00104 
00105 signals:
00106   void                activatedId( int );
00107 };
00108 
00109 #endif // LIGHTAPP_MODULEACTION_H
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS