Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxActionMgr.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: QtxActionMgr.h
24 // Author: Alexander SOLOVYOV, Sergey TELKOV
25 //
26 #ifndef QTXACTIONMGR_H
27 #define QTXACTIONMGR_H
28 
29 #include "Qtx.h"
30 
31 #include <QMap>
32 #include <QObject>
33 #include <QPointer>
34 
35 class QTimer;
36 class QAction;
37 class QDomNode;
38 
39 #ifdef WIN32
40 #pragma warning( disable:4251 )
41 #endif
42 
43 
45 {
46  Q_OBJECT
47 
48  class SeparatorAction;
49 
50 public:
51  class Reader;
52  class XMLReader;
53 
54 protected:
55  class Creator;
56 
57 public:
58  QtxActionMgr( QObject* parent );
59  virtual ~QtxActionMgr();
60 
61  virtual int registerAction( QAction*, const int = -1 );
62  virtual void unRegisterAction( const int );
63 
64  QAction* action( const int ) const;
65  int actionId( const QAction* ) const;
66  bool contains( const int ) const;
67 
68  int count() const;
69  bool isEmpty() const;
70  QIntList idList() const;
71 
72  bool isUpdatesEnabled() const;
73  virtual void setUpdatesEnabled( const bool );
74 
75  virtual bool isVisible( const int, const int ) const;
76  virtual void setVisible( const int, const int, const bool );
77 
78  void update();
79 
80  virtual bool isEnabled( const int ) const;
81  virtual void setEnabled( const int, const bool );
82 
83  static QAction* separator( const bool = false );
84 
85 protected:
86  virtual void internalUpdate();
87  int generateId() const;
88 
89  void triggerUpdate();
90  virtual void updateContent();
91 
92 private slots:
93  void onUpdateContent();
94 
95 private:
96  typedef QPointer<QAction> ActionPtr;
97  typedef QMap<int, ActionPtr> ActionMap;
98 
99 private:
100  bool myUpdate;
102  QTimer* myUpdTimer;
103 };
104 
105 
106 QTX_EXPORT typedef QMap<QString, QString> ItemAttributes;
107 
109 {
110 public:
112  virtual ~Creator();
113 
114  Reader* reader() const;
115 
116  virtual int append( const QString&, const bool,
117  const ItemAttributes&, const int ) = 0;
118  virtual void connect( QAction* ) const;
119 
120  virtual bool loadPixmap( const QString&, QPixmap& ) const;
121 
122 protected:
123  static int intValue( const ItemAttributes&, const QString&, const int );
124  static QString strValue( const ItemAttributes&, const QString&,
125  const QString& = QString() );
126 private:
128 };
129 
131 {
132 public:
133  Reader();
134  virtual ~Reader();
135 
136  QStringList options() const;
137  QString option( const QString&, const QString& = QString() ) const;
138  void setOption( const QString&, const QString& );
139 
140  virtual bool read( const QString&, Creator& ) const = 0;
141 
142 private:
143  QMap< QString, QString > myOptions;
144 };
145 
147 {
148 public:
149  XMLReader( const QString&, const QString&, const QString& );
150  virtual ~XMLReader();
151 
152  virtual bool read( const QString&, Creator& ) const;
153 
154 protected:
155  virtual void read( const QDomNode&, const int, Creator& ) const;
156  virtual bool isNodeSimilar( const QDomNode&, const QString& ) const;
157 };
158 
159 
160 #endif