1
/* This file is part of the KDE project
2
Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#include "KIvioMapIface.h"
22
#include "kivio_map.h"
23
#include "kivio_doc.h"
24
#include "kivio_page.h"
26
#include <kapplication.h>
27
#include <dcopclient.h>
30
KIvioMapIface::KIvioMapIface( KivioMap* map )
36
DCOPRef KIvioMapIface::page( const QString& name )
38
KivioPage* t = m_map->findPage( name );
42
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
45
DCOPRef KIvioMapIface::pageByIndex( int index )
47
KivioPage* t = m_map->pageList().at( index );
50
kdDebug(43000) << "+++++ No page found at index " << index << endl;
54
kdDebug(43000) << "+++++++ Returning page " << t->QObject::name() << endl;
56
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
59
int KIvioMapIface::pageCount() const
61
return m_map->count();
64
QStringList KIvioMapIface::pageNames() const
68
QPtrList<KivioPage>& lst = m_map->pageList();
69
QPtrListIterator<KivioPage> it( lst );
70
for( ; it.current(); ++it )
71
names.append( it.current()->name() );
76
QValueList<DCOPRef> KIvioMapIface::pages()
78
QValueList<DCOPRef> t;
80
QPtrList<KivioPage>& lst = m_map->pageList();
81
QPtrListIterator<KivioPage> it( lst );
82
for( ; it.current(); ++it )
83
t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
88
DCOPRef KIvioMapIface::insertPage( const QString& name )
90
if ( m_map->findPage( name ) )
93
KivioPage* t = new KivioPage( m_map, name );
94
t->setPageName( name );
95
m_map->doc()->addPage( t );
100
bool KIvioMapIface::processDynamic(const QCString &fun, const QByteArray &/*data*/,
101
QCString& replyType, QByteArray &replyData)
103
// Does the name follow the pattern "foobar()" ?
104
uint len = fun.length();
108
if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
111
KivioPage* t = m_map->findPage( fun.left( len - 2 ).data() );
115
replyType = "DCOPRef";
116
QDataStream out( replyData, IO_WriteOnly );
117
out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );