lib Library API Documentation

koPartSelectAction.cc

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #include "koPartSelectAction.h" 00020 #include "koPartSelectDia.h" 00021 00022 #include <kdebug.h> 00023 00024 KoPartSelectAction::KoPartSelectAction( const QString& text, QObject* parent, const char* name ) 00025 : KActionMenu( text, parent, name ) 00026 { 00027 init(); 00028 } 00029 00030 KoPartSelectAction::KoPartSelectAction( const QString& text, const QString& icon, 00031 QObject* parent, const char* name ) 00032 : KActionMenu( text, icon, parent, name ) 00033 { 00034 init(); 00035 } 00036 00037 KoPartSelectAction::KoPartSelectAction( const QString& text, const QString& icon, 00038 QObject* receiver, const char* slot, 00039 QObject* parent, const char* name ) 00040 : KActionMenu( text, icon, parent, name ) 00041 { 00042 if (receiver) 00043 connect( this, SIGNAL( activated() ), receiver, slot ); 00044 init(); 00045 } 00046 00047 void KoPartSelectAction::init() 00048 { 00049 // Query for documents 00050 m_lstEntries = KoDocumentEntry::query(); 00051 QValueList<KoDocumentEntry>::Iterator it = m_lstEntries.begin(); 00052 for( ; it != m_lstEntries.end(); ++it ) { 00053 KService::Ptr serv = (*it).service(); 00054 if (!serv->genericName().isEmpty()) { 00055 KAction *action = new KAction( serv->genericName(), serv->icon(), 0, 00056 this, SLOT( slotActionActivated() ), 00057 parentCollection(), serv->name().latin1() ); 00058 insert( action ); 00059 } 00060 } 00061 00062 } 00063 00064 // Called when selecting a part 00065 void KoPartSelectAction::slotActionActivated() 00066 { 00067 QString servName = QString::fromLatin1( sender()->name() ); 00068 KService::Ptr serv = KService::serviceByName( servName ); 00069 m_documentEntry = KoDocumentEntry( serv ); 00070 emit activated(); 00071 } 00072 00073 // Called when activating the toolbar button 00074 void KoPartSelectAction::slotActivated() 00075 { 00076 m_documentEntry = KoPartSelectDia::selectPart( 0L ); 00077 emit activated(); 00078 } 00079 00080 #include "koPartSelectAction.moc"
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:04:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003