lib Library API Documentation

KoApplicationIface.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 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 as published by the Free Software Foundation; either
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 
00021 #include <dcopclient.h>
00022 #include <kdebug.h>
00023 #include <klocale.h>
00024 #include <kmessagebox.h>
00025 
00026 #include "koApplication.h"
00027 #include "KoApplicationIface.h"
00028 #include "koDocument.h"
00029 #include "KoDocumentIface.h"
00030 #include "koMainWindow.h"
00031 #include "koQueryTrader.h"
00032 #include "koView.h"
00033 
00034 KoApplicationIface::KoApplicationIface()
00035  : DCOPObject( "KoApplicationIface" )
00036 {
00037 }
00038 
00039 KoApplicationIface::~KoApplicationIface()
00040 {
00041 }
00042 
00043 DCOPRef KoApplicationIface::createDocument( const QString &nativeFormat )
00044 {
00045     KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( nativeFormat );
00046     if ( entry.isEmpty() )
00047     {
00048         KMessageBox::questionYesNo( 0, i18n( "Unknown KOffice MimeType %s. Check your installation !" ).arg( nativeFormat ) );
00049         return DCOPRef();
00050     }
00051     KoDocument* doc = entry.createDoc( 0 );
00052     return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00053 }
00054 
00055 QValueList<DCOPRef> KoApplicationIface::getDocuments()
00056 {
00057     QValueList<DCOPRef> lst;
00058     QPtrList<KoDocument> *documents = KoDocument::documentList();
00059     if ( documents )
00060     {
00061       QPtrListIterator<KoDocument> it( *documents );
00062       for (; it.current(); ++it )
00063         lst.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00064     }
00065     return lst;
00066 }
00067 
00068 QValueList<DCOPRef> KoApplicationIface::getViews()
00069 {
00070     QValueList<DCOPRef> lst;
00071     QPtrList<KoDocument> *documents = KoDocument::documentList();
00072     if ( documents )
00073     {
00074       QPtrListIterator<KoDocument> it( *documents );
00075       for (; it.current(); ++it )
00076       {
00077           QPtrListIterator<KoView> itview( it.current()->views() );
00078           for ( ; itview.current(); ++itview )
00079               lst.append( DCOPRef( kapp->dcopClient()->appId(), itview.current()->dcopObject()->objId() ) );
00080       }
00081     }
00082     return lst;
00083 }
00084 
00085 QValueList<DCOPRef> KoApplicationIface::getWindows()
00086 {
00087     QValueList<DCOPRef> lst;
00088     QPtrList<KMainWindow> *mainWindows = KMainWindow::memberList;
00089     if ( mainWindows )
00090     {
00091       QPtrListIterator<KMainWindow> it( *mainWindows );
00092       for (; it.current(); ++it )
00093         lst.append( DCOPRef( kapp->dcopClient()->appId(),
00094                              static_cast<KoMainWindow *>(it.current())->dcopObject()->objId() ) );
00095     }
00096     return lst;
00097 }
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Mar 20 14:25:24 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003