00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "KoPartSelectAction.h"
00020 #include "KoPartSelectDia.h"
00021
00022 #include <kdebug.h>
00023
00024 #include <Q3ValueList>
00025 #include <kicon.h>
00026 #warning "KDE4: TODO change argument as kactionmenu (when all will compile)"
00027
00028 KoPartSelectAction::KoPartSelectAction( const QString& text, KActionCollection* parent, const char* name )
00029 : KActionMenu( text, parent, name )
00030 {
00031 init();
00032 }
00033
00034 KoPartSelectAction::KoPartSelectAction( const QString& text, const QString& icon,
00035 KActionCollection* parent, const char* name )
00036 : KActionMenu( KIcon(icon),text, parent, name )
00037 {
00038 init();
00039 }
00040
00041 KoPartSelectAction::KoPartSelectAction( const QString& text, const QString& icon,
00042 QObject* receiver, const char* slot,
00043 KActionCollection* parent, const char* name )
00044 : KActionMenu( KIcon(icon),text, parent, name )
00045 {
00046 if (receiver)
00047 connect( this, SIGNAL( activated() ), receiver, slot );
00048 init();
00049 }
00050
00051 void KoPartSelectAction::init()
00052 {
00053
00054 m_lstEntries = KoDocumentEntry::query();
00055 Q3ValueList<KoDocumentEntry>::Iterator it = m_lstEntries.begin();
00056 for( ; it != m_lstEntries.end(); ++it ) {
00057 KService::Ptr serv = (*it).service();
00058 if (!serv->genericName().isEmpty()) {
00059 KAction *action = new KAction(KIcon(serv->icon()), serv->genericName().replace('&',"&&"), parentCollection(), serv->name().toLatin1());
00060 connect(action, SIGNAL(triggered()), this, SLOT(slotActionActivated()));
00061 addAction( action );
00062 }
00063 }
00064
00065 }
00066
00067
00068 void KoPartSelectAction::slotActionActivated()
00069 {
00070 QString servName = sender()->objectName();
00071 KService::Ptr serv = KService::serviceByName( servName );
00072 m_documentEntry = KoDocumentEntry( serv );
00073 trigger();
00074 }
00075
00076
00077 void KoPartSelectAction::slotActivated()
00078 {
00079 m_documentEntry = KoPartSelectDia::selectPart( 0L );
00080 trigger();
00081 }
00082
00083 #include "KoPartSelectAction.moc"