Version: 9.16.0
QtxActionMgr.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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
35class QTimer;
36class QAction;
37class QDomNode;
38
39#ifdef WIN32
40#pragma warning( disable:4251 )
41#endif
42
43
45{
46 Q_OBJECT
47
48 class SeparatorAction;
49
50public:
51 class Reader;
52 class XMLReader;
53
54protected:
55 class Creator;
56
57public:
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
85protected:
86 virtual void internalUpdate();
87 int generateId() const;
88
89 void triggerUpdate();
90 virtual void updateContent();
91 virtual void actionChanged( int );
92
93private slots:
94 void onActionChanged();
95 void onUpdateContent();
96
97private:
98 typedef QPointer<QAction> ActionPtr;
99 typedef QMap<int, ActionPtr> ActionMap;
100
101private:
102 bool myUpdate;
104 QTimer* myUpdTimer;
105};
106
107
108QTX_EXPORT typedef QMap<QString, QString> ItemAttributes;
109
111{
112public:
114 virtual ~Creator();
115
116 Reader* reader() const;
117
118 virtual int append( const QString&, const bool,
119 const ItemAttributes&, const int ) = 0;
120 virtual void connect( QAction* ) const;
121
122 virtual bool loadPixmap( const QString&, QPixmap& ) const;
123
124protected:
125 static int intValue( const ItemAttributes&, const QString&, const int );
126 static QString strValue( const ItemAttributes&, const QString&,
127 const QString& = QString() );
128private:
130};
131
133{
134public:
135 Reader();
136 virtual ~Reader();
137
138 QStringList options() const;
139 QString option( const QString&, const QString& = QString() ) const;
140 void setOption( const QString&, const QString& );
141
142 virtual bool read( const QString&, Creator& ) const = 0;
143
144private:
145 QMap< QString, QString > myOptions;
146};
147
149{
150public:
151 XMLReader( const QString&, const QString&, const QString& );
152 virtual ~XMLReader();
153
154 virtual bool read( const QString&, Creator& ) const;
155
156protected:
157 virtual void read( const QDomNode&, const int, Creator& ) const;
158 virtual bool isNodeSimilar( const QDomNode&, const QString& ) const;
159};
160
161
162#endif
QMap< QString, QString > ItemAttributes
attributes map
Definition: QtxActionMgr.h:108
QList< int > QIntList
list of int values
Definition: Qtx.h:57
#define QTX_EXPORT
Definition: Qtx.h:36
For more information see QT documentation.
Generic actions creator class.
Definition: QtxActionMgr.h:111
virtual int append(const QString &, const bool, const ItemAttributes &, const int)=0
Create (and probably append to the action manager) new action.
QtxActionMgr::Reader * myReader
actions reader
Definition: QtxActionMgr.h:129
Generic actions description files reader class.
Definition: QtxActionMgr.h:133
QMap< QString, QString > myOptions
options map
Definition: QtxActionMgr.h:145
virtual bool read(const QString &, Creator &) const =0
Read the file and fill and action manager with actions by using help actions creator.
Separator action class.
Definition: QtxActionMgr.cxx:60
XML file reader.
Definition: QtxActionMgr.h:149
Manages a set of actions accessible by unique identifier.
Definition: QtxActionMgr.h:45
QMap< int, ActionPtr > ActionMap
Actions map.
Definition: QtxActionMgr.h:99
ActionMap myActions
actions map
Definition: QtxActionMgr.h:103
QTimer * myUpdTimer
update timer
Definition: QtxActionMgr.h:104
bool myUpdate
update flag
Definition: QtxActionMgr.h:102
QPointer< QAction > ActionPtr
Action guarded pointer.
Definition: QtxActionMgr.h:98