KDEUI
kactioncategory.cpp
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 #include "kactioncategory.h"
00020
00021 #include <QtGui/QAction>
00022
00023 #include "kaction.h"
00024
00025
00026 struct KActionCategoryPrivate
00027 {
00028
00029 KActionCategoryPrivate( KActionCategory *host );
00030
00032 KActionCategory *q;
00033
00035 QString text;
00036
00038 QList<QAction*> actions;
00039
00040 };
00041
00042
00043 KActionCategory::KActionCategory(const QString &text, KActionCollection *parent)
00044 : QObject(parent)
00045 ,d( new KActionCategoryPrivate(this) )
00046 {
00047 d->text = text;
00048 }
00049
00050
00051 KActionCategory::~KActionCategory()
00052 {
00053 delete d;
00054 }
00055
00056
00057 const QList<QAction*> KActionCategory::actions() const
00058 {
00059 return d->actions;
00060 }
00061
00062
00063 QAction * KActionCategory::addAction(const QString &name, QAction *action)
00064 {
00065 collection()->addAction(name, action);
00066 addAction(action);
00067 return action;
00068 }
00069
00070
00071 KAction * KActionCategory::addAction(const QString &name, KAction *action)
00072 {
00073 collection()->addAction(name, action);
00074 addAction(action);
00075 return action;
00076 }
00077
00078
00079 KAction * KActionCategory::addAction(
00080 KStandardAction::StandardAction actionType,
00081 const QObject *receiver,
00082 const char *member)
00083 {
00084 KAction *action = collection()->addAction(actionType, receiver, member);
00085 addAction(action);
00086 return action;
00087 }
00088
00089
00090 KAction * KActionCategory::addAction(
00091 KStandardAction::StandardAction actionType,
00092 const QString &name,
00093 const QObject *receiver,
00094 const char *member)
00095 {
00096 KAction *action = collection()->addAction(actionType, name, receiver, member);
00097 addAction(action);
00098 return action;
00099 }
00100
00101
00102 KAction *KActionCategory::addAction(
00103 const QString &name,
00104 const QObject *receiver,
00105 const char *member)
00106 {
00107 KAction *action = collection()->addAction(name, receiver, member);
00108 addAction(action);
00109 return action;
00110 }
00111
00112
00113 void KActionCategory::addAction(QAction *action)
00114 {
00115
00116 if (!d->actions.contains(action))
00117 {
00118 d->actions.append(action);
00119 }
00120 }
00121
00122
00123 KActionCollection * KActionCategory::collection() const
00124 {
00125 return qobject_cast<KActionCollection*>(parent());
00126 }
00127
00128
00129 QString KActionCategory::text() const
00130 {
00131 return d->text;
00132 }
00133
00134
00135 void KActionCategory::setText(const QString &text)
00136 {
00137 d->text = text;
00138 }
00139
00140
00141 void KActionCategory::unlistAction(QAction *action)
00142 {
00143
00144
00145
00146
00147
00148
00149 int index = d->actions.indexOf(action);
00150
00151
00152 if (index==-1) return;
00153
00154
00155 d->actions.takeAt(index);
00156 }
00157
00158
00159 KActionCategoryPrivate::KActionCategoryPrivate( KActionCategory *host )
00160 : q(host)
00161 {}
00162
00163
00164 #include "moc_kactioncategory.cpp"