1 #include <QCoreApplication>
3 #include <kaboutdata.h>
6 #include <kcmdlineargs.h>
8 #include "docmetainfo.h"
9 #include "docentrytraverser.h"
13 class MyTraverser
: public DocEntryTraverser
16 MyTraverser( const QString
&indent
= "" ) : mIndent( indent
) {}
18 void process( DocEntry
*entry
)
20 kDebug() << mIndent
<< entry
->name() << " - WEIGHT: " << entry
->weight()
23 if ( entry
->parent() ) kDebug() << mIndent
<< " PARENT: "
24 << entry
->parent()->name() << endl
;
25 if ( entry
->nextSibling() ) kDebug() << mIndent
<< " NEXT: "
26 << entry
->nextSibling()->name() << endl
;
30 DocEntryTraverser
*createChild( DocEntry
* )
32 return new MyTraverser( mIndent
+ " " );
39 class LinearTraverser
: public DocEntryTraverser
42 void process( DocEntry
*entry
)
44 kDebug() << "PROCESS: " << entry
->name();
47 DocEntryTraverser
*createChild( DocEntry
* )
52 DocEntryTraverser
*parentTraverser()
57 void deleteTraverser() {}
60 class AsyncTraverser
: public DocEntryTraverser
63 AsyncTraverser( const QString
&indent
= "" ) : mIndent( indent
)
65 // kDebug() << "AsyncTraverser()";
70 // kDebug() << "~AsyncTraverser()";
73 void process( DocEntry
*entry
)
75 kDebug() << mIndent
<< entry
->name();
78 DocEntryTraverser
*createChild( DocEntry
* )
80 // kDebug() << "AsyncTraverser::childTraverser()";
81 return new AsyncTraverser( mIndent
+ " " );
88 int main(int argc
,char **argv
)
90 KAboutData
aboutData("testmetainfo", 0,ki18n("TestDocMetaInfo"),"0.1");
91 // KComponentData componentData(&aboutData); doesn't seem to be necessary
92 QCoreApplication
app(argc
,argv
);
94 kDebug() << "Scanning Meta Info";
96 DocMetaInfo::self()->scanMetaInfo( );
98 kDebug() << "My TRAVERSE start";
100 DocMetaInfo::self()->startTraverseEntries( &t
);
101 kDebug() << "My TRAVERSE end";
103 kDebug() << "Linear TRAVERSE start";
105 DocMetaInfo::self()->startTraverseEntries( &l
);
106 kDebug() << "Linear TRAVERSE end";
108 kDebug() << "Async TRAVERSE start";
110 DocMetaInfo::self()->startTraverseEntries( &a
);
111 kDebug() << "Async TRAVERSE end";