KDEUI
kactioncollection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KACTIONCOLLECTION_H
00027 #define KACTIONCOLLECTION_H
00028
00029 #include <kdeui_export.h>
00030 #include <kstandardaction.h>
00031 #include <kcomponentdata.h>
00032
00033 #include <QtCore/QObject>
00034
00035 class QAction;
00036 class KXMLGUIClient;
00037
00038 class QActionGroup;
00039 class QString;
00040
00056 class KDEUI_EXPORT KActionCollection : public QObject
00057 {
00058 friend class KXMLGUIClient;
00059
00060 Q_OBJECT
00061
00062 Q_PROPERTY( QString configGroup READ configGroup WRITE setConfigGroup )
00063 Q_PROPERTY( bool configIsGlobal READ configIsGlobal WRITE setConfigGlobal )
00064
00065 public:
00070 explicit KActionCollection(QObject *parent, const KComponentData &cData = KComponentData());
00071
00075 virtual ~KActionCollection();
00076
00080 static const QList<KActionCollection*>& allCollections();
00081
00085 void clear();
00086
00094 void associateWidget(QWidget* widget) const;
00095
00104 void addAssociatedWidget(QWidget* widget);
00105
00110 void removeAssociatedWidget(QWidget* widget);
00111
00115 QList<QWidget*> associatedWidgets() const;
00116
00120 void clearAssociatedWidgets();
00121
00125 QString configGroup() const;
00126
00131 bool configIsGlobal() const;
00132
00136 void setConfigGroup( const QString& group );
00137
00142 void setConfigGlobal( bool global );
00143
00151 void readSettings( KConfigGroup* config = 0 );
00152
00160 void importGlobalShortcuts( KConfigGroup* config );
00161
00170 void exportGlobalShortcuts( KConfigGroup* config, bool writeDefaults = false ) const;
00171
00187 void writeSettings( KConfigGroup* config = 0, bool writeDefaults = false, QAction* oneAction = 0 ) const;
00188
00194 int count() const;
00195
00199 bool isEmpty() const;
00200
00206 QAction *action(int index) const;
00207
00215 QAction* action( const QString& name ) const;
00216
00220 QList<QAction*> actions() const;
00221
00225 const QList<QAction*> actionsWithoutGroup() const;
00226
00230 const QList<QActionGroup*> actionGroups() const;
00231
00241 void setComponentData(const KComponentData &componentData);
00242
00244 KComponentData componentData() const;
00245
00249 const KXMLGUIClient *parentGUIClient() const;
00250
00251 Q_SIGNALS:
00255 void inserted( QAction* action );
00256
00261 QT_MOC_COMPAT void removed( QAction* action );
00262
00267 QT_MOC_COMPAT void actionHighlighted(QAction* action);
00268
00272 void actionHovered(QAction* action);
00273
00277 void actionTriggered(QAction* action);
00278
00279 protected Q_SLOTS:
00281 virtual void connectNotify ( const char * signal );
00282
00283 virtual void slotActionTriggered();
00284
00289 QT_MOC_COMPAT virtual void slotActionHighlighted();
00290
00291 private Q_SLOTS:
00292 void slotActionHovered();
00293
00294
00295 public:
00309 QAction *addAction(const QString &name, QAction *action);
00310 KAction *addAction(const QString &name, KAction *action);
00311
00316 void removeAction(QAction *action);
00317
00322 QAction* takeAction(QAction *action);
00323
00331 KAction *addAction(KStandardAction::StandardAction actionType, const QObject *receiver = 0, const char *member = 0);
00338 KAction *addAction(KStandardAction::StandardAction actionType, const QString &name,
00339 const QObject *receiver = 0, const char *member = 0);
00340
00355 KAction *addAction(const QString &name, const QObject *receiver = 0, const char *member = 0);
00356
00362 template<class ActionType>
00363 ActionType *add(const QString &name, const QObject *receiver = 0, const char *member = 0)
00364 {
00365 ActionType *a = new ActionType(this);
00366 if (receiver && member)
00367 connect(a, SIGNAL(triggered()), receiver, member);
00368 addAction(name, a);
00369 return a;
00370 }
00371
00372 private:
00373 Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject *))
00374 Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject*))
00375
00376 KActionCollection( const KXMLGUIClient* parent );
00377
00378 friend class KActionCollectionPrivate;
00379 class KActionCollectionPrivate* const d;
00380 };
00381
00382 #endif