kivio
KIvioMapIface.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KIvioMapIface.h"
00021
00022 #include "kivio_map.h"
00023 #include "kivio_doc.h"
00024 #include "kivio_page.h"
00025
00026 #include <kapplication.h>
00027 #include <dcopclient.h>
00028 #include <kdebug.h>
00029
00030 KIvioMapIface::KIvioMapIface( KivioMap* map )
00031 : DCOPObject( map )
00032 {
00033 m_map = map;
00034 }
00035
00036 DCOPRef KIvioMapIface::page( const QString& name )
00037 {
00038 KivioPage* t = m_map->findPage( name );
00039 if ( !t )
00040 return DCOPRef();
00041
00042 return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00043 }
00044
00045 DCOPRef KIvioMapIface::pageByIndex( int index )
00046 {
00047 KivioPage* t = m_map->pageList().at( index );
00048 if ( !t )
00049 {
00050 kdDebug(43000) << "+++++ No page found at index " << index << endl;
00051 return DCOPRef();
00052 }
00053
00054 kdDebug(43000) << "+++++++ Returning page " << t->QObject::name() << endl;
00055
00056 return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00057 }
00058
00059 int KIvioMapIface::pageCount() const
00060 {
00061 return m_map->count();
00062 }
00063
00064 QStringList KIvioMapIface::pageNames() const
00065 {
00066 QStringList names;
00067
00068 QPtrList<KivioPage>& lst = m_map->pageList();
00069 QPtrListIterator<KivioPage> it( lst );
00070 for( ; it.current(); ++it )
00071 names.append( it.current()->name() );
00072
00073 return names;
00074 }
00075
00076 QValueList<DCOPRef> KIvioMapIface::pages()
00077 {
00078 QValueList<DCOPRef> t;
00079
00080 QPtrList<KivioPage>& lst = m_map->pageList();
00081 QPtrListIterator<KivioPage> it( lst );
00082 for( ; it.current(); ++it )
00083 t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00084
00085 return t;
00086 }
00087
00088 DCOPRef KIvioMapIface::insertPage( const QString& name )
00089 {
00090 if ( m_map->findPage( name ) )
00091 return page( name );
00092
00093 KivioPage* t = new KivioPage( m_map, name );
00094 t->setPageName( name );
00095 m_map->doc()->addPage( t );
00096
00097 return page( name );
00098 }
00099
00100 bool KIvioMapIface::processDynamic(const QCString &fun, const QByteArray &,
00101 QCString& replyType, QByteArray &replyData)
00102 {
00103
00104 uint len = fun.length();
00105 if ( len < 3 )
00106 return false;
00107
00108 if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
00109 return false;
00110
00111 KivioPage* t = m_map->findPage( fun.left( len - 2 ).data() );
00112 if ( !t )
00113 return false;
00114
00115 replyType = "DCOPRef";
00116 QDataStream out( replyData, IO_WriteOnly );
00117 out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00118 return true;
00119 }
|