X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxActionMgr.h;h=df54e19cb1d168256a7eb0f72e9e180635be92fd;hb=389efae83b99d654509671e60af3eecf11b8278e;hp=e0ba1d0e68dfa19c283879570709cc8f645770a2;hpb=399155730966dfc225fbb24f66204b05664385f2;p=modules%2Fgui.git diff --git a/src/Qtx/QtxActionMgr.h b/src/Qtx/QtxActionMgr.h index e0ba1d0e6..df54e19cb 100644 --- a/src/Qtx/QtxActionMgr.h +++ b/src/Qtx/QtxActionMgr.h @@ -1,47 +1,46 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: QtxActionMgr.h -// Author: Alexander SOLOVYEV, Sergey TELKOV +// File: QtxActionMgr.h +// Author: Alexander SOLOVYOV, Sergey TELKOV +// #ifndef QTXACTIONMGR_H #define QTXACTIONMGR_H #include "Qtx.h" -#include -#include -#include +#include +#include +#include +class QTimer; class QAction; class QDomNode; - #ifdef WIN32 #pragma warning( disable:4251 ) #endif -/*! - \class QtxActionMgr - Contains set of actions accessible by id. - Base class for menu, popup creators and other action containers. -*/ class QTX_EXPORT QtxActionMgr : public QObject { Q_OBJECT @@ -68,7 +67,7 @@ public: int count() const; bool isEmpty() const; - void idList( QIntList& ) const; + QIntList idList() const; bool isUpdatesEnabled() const; virtual void setUpdatesEnabled( const bool ); @@ -87,23 +86,26 @@ protected: virtual void internalUpdate(); int generateId() const; + void triggerUpdate(); + virtual void updateContent(); + +private slots: + void onUpdateContent(); + private: - typedef QGuardedPtr ActionPtr; - typedef QMap ActionMap; + typedef QPointer ActionPtr; //!< Action guarded pointer + typedef QMap ActionMap; //!< Actions map private: - bool myUpdate; - ActionMap myActions; + bool myUpdate; //!< update flag + ActionMap myActions; //!< actions map + QTimer* myUpdTimer; //!< update timer }; -QTX_EXPORT typedef QMap ItemAttributes; +QTX_EXPORT typedef QMap ItemAttributes; //!< attributes map -/*! - \class QtxActionMgr::Creator - Allows to fill automatically action manager with actions created by data from file -*/ -class QtxActionMgr::Creator +class QTX_EXPORT QtxActionMgr::Creator { public: Creator( QtxActionMgr::Reader* ); @@ -111,57 +113,47 @@ public: Reader* reader() const; - virtual int append( const QString&, const bool, - const ItemAttributes&, const int ) = 0; - virtual void connect( QAction* ) const; + virtual int append( const QString&, const bool, + const ItemAttributes&, const int ) = 0; + virtual void connect( QAction* ) const; - virtual bool loadPixmap( const QString&, QPixmap& ) const; + virtual bool loadPixmap( const QString&, QPixmap& ) const; protected: static int intValue( const ItemAttributes&, const QString&, const int ); static QString strValue( const ItemAttributes&, const QString&, - const QString& = QString::null ); + const QString& = QString() ); private: - QtxActionMgr::Reader* myReader; + QtxActionMgr::Reader* myReader; //!< actions reader }; -/*! - \class QtxActionMgr::Reader - This class is used to read files of some format - to create actions and to fill action manager automatically -*/ -class QtxActionMgr::Reader +class QTX_EXPORT QtxActionMgr::Reader { public: - QTX_EXPORT Reader(); - QTX_EXPORT virtual ~Reader(); + Reader(); + virtual ~Reader(); - QTX_EXPORT QStringList options() const; - QTX_EXPORT QString option( const QString&, const QString& = QString::null ) const; - QTX_EXPORT void setOption( const QString&, const QString& ); + QStringList options() const; + QString option( const QString&, const QString& = QString() ) const; + void setOption( const QString&, const QString& ); - QTX_EXPORT virtual bool read( const QString&, Creator& ) const = 0; + virtual bool read( const QString&, Creator& ) const = 0; private: - QMap< QString, QString > myOptions; + QMap< QString, QString > myOptions; //!< options map }; -/*! - \class QtxActionMgr::Reader - This class is used to read files of XML format - to create actions and to fill action manager automatically -*/ -class QtxActionMgr::XMLReader : public Reader +class QTX_EXPORT QtxActionMgr::XMLReader : public Reader { public: - QTX_EXPORT XMLReader( const QString&, const QString&, const QString& ); - QTX_EXPORT virtual ~XMLReader(); + XMLReader( const QString&, const QString&, const QString& ); + virtual ~XMLReader(); - QTX_EXPORT virtual bool read( const QString&, Creator& ) const; + virtual bool read( const QString&, Creator& ) const; protected: - QTX_EXPORT virtual void read( const QDomNode&, const int, Creator& ) const; - QTX_EXPORT virtual bool isNodeSimilar( const QDomNode&, const QString& ) const; + virtual void read( const QDomNode&, const int, Creator& ) const; + virtual bool isNodeSimilar( const QDomNode&, const QString& ) const; };