You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.2 KiB
120 lines
3.2 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "KIvioMapIface.h"
|
||
|
|
||
|
#include "kivio_map.h"
|
||
|
#include "kivio_doc.h"
|
||
|
#include "kivio_page.h"
|
||
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <dcopclient.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
KIvioMapIface::KIvioMapIface( KivioMap* map )
|
||
|
: DCOPObject( map )
|
||
|
{
|
||
|
m_map = map;
|
||
|
}
|
||
|
|
||
14 years ago
|
DCOPRef KIvioMapIface::page( const TQString& name )
|
||
15 years ago
|
{
|
||
|
KivioPage* t = m_map->findPage( name );
|
||
|
if ( !t )
|
||
|
return DCOPRef();
|
||
|
|
||
|
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
|
||
|
}
|
||
|
|
||
|
DCOPRef KIvioMapIface::pageByIndex( int index )
|
||
|
{
|
||
|
KivioPage* t = m_map->pageList().at( index );
|
||
|
if ( !t )
|
||
|
{
|
||
|
kdDebug(43000) << "+++++ No page found at index " << index << endl;
|
||
|
return DCOPRef();
|
||
|
}
|
||
|
|
||
14 years ago
|
kdDebug(43000) << "+++++++ Returning page " << t->TQObject::name() << endl;
|
||
15 years ago
|
|
||
|
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
|
||
|
}
|
||
|
|
||
|
int KIvioMapIface::pageCount() const
|
||
|
{
|
||
|
return m_map->count();
|
||
|
}
|
||
|
|
||
14 years ago
|
TQStringList KIvioMapIface::pageNames() const
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList names;
|
||
15 years ago
|
|
||
14 years ago
|
TQPtrList<KivioPage>& lst = m_map->pageList();
|
||
|
TQPtrListIterator<KivioPage> it( lst );
|
||
15 years ago
|
for( ; it.current(); ++it )
|
||
|
names.append( it.current()->name() );
|
||
|
|
||
|
return names;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQValueList<DCOPRef> KIvioMapIface::pages()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQValueList<DCOPRef> t;
|
||
15 years ago
|
|
||
14 years ago
|
TQPtrList<KivioPage>& lst = m_map->pageList();
|
||
|
TQPtrListIterator<KivioPage> it( lst );
|
||
15 years ago
|
for( ; it.current(); ++it )
|
||
|
t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
|
||
|
|
||
|
return t;
|
||
|
}
|
||
|
|
||
14 years ago
|
DCOPRef KIvioMapIface::insertPage( const TQString& name )
|
||
15 years ago
|
{
|
||
|
if ( m_map->findPage( name ) )
|
||
|
return page( name );
|
||
|
|
||
|
KivioPage* t = new KivioPage( m_map, name );
|
||
|
t->setPageName( name );
|
||
|
m_map->doc()->addPage( t );
|
||
|
|
||
|
return page( name );
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KIvioMapIface::processDynamic(const TQCString &fun, const TQByteArray &/*data*/,
|
||
|
TQCString& replyType, TQByteArray &replyData)
|
||
15 years ago
|
{
|
||
|
// Does the name follow the pattern "foobar()" ?
|
||
|
uint len = fun.length();
|
||
|
if ( len < 3 )
|
||
|
return false;
|
||
|
|
||
|
if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
|
||
|
return false;
|
||
|
|
||
|
KivioPage* t = m_map->findPage( fun.left( len - 2 ).data() );
|
||
|
if ( !t )
|
||
|
return false;
|
||
|
|
||
|
replyType = "DCOPRef";
|
||
14 years ago
|
TQDataStream out( replyData, IO_WriteOnly );
|
||
15 years ago
|
out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
|
||
|
return true;
|
||
|
}
|