F:/KPlato/koffice/libs/kofficeui/KoPartSelectAction.cpp

Aller à la documentation de ce fichier.
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., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "KoPartSelectAction.h"
00020 #include "KoPartSelectDia.h"
00021 
00022 #include <kdebug.h>
00023 //Added by qt3to4:
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     // Query for documents
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 // Called when selecting a part
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 // Called when activating the toolbar button
00077 void KoPartSelectAction::slotActivated()
00078 {
00079     m_documentEntry = KoPartSelectDia::selectPart( 0L );
00080     trigger();
00081 }
00082 
00083 #include "KoPartSelectAction.moc"

Généré le Wed Nov 22 23:41:05 2006 pour KPlato par  doxygen 1.5.1-p1