summaryrefslogtreecommitdiffstats
path: root/khelpcenter/testmetainfo.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /khelpcenter/testmetainfo.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khelpcenter/testmetainfo.cpp')
-rw-r--r--khelpcenter/testmetainfo.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/khelpcenter/testmetainfo.cpp b/khelpcenter/testmetainfo.cpp
new file mode 100644
index 000000000..65ffd871c
--- /dev/null
+++ b/khelpcenter/testmetainfo.cpp
@@ -0,0 +1,119 @@
+#include <qstringlist.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+
+#include "docmetainfo.h"
+#include "docentrytraverser.h"
+
+using namespace KHC;
+
+class MyTraverser : public DocEntryTraverser
+{
+ public:
+ MyTraverser( const QString &indent = "" ) : mIndent( indent ) {}
+
+ void process( DocEntry *entry )
+ {
+ kdDebug() << mIndent << entry->name() << " - WEIGHT: " << entry->weight()
+ << endl;
+#if 0
+ if ( entry->parent() ) kdDebug() << mIndent << " PARENT: "
+ << entry->parent()->name() << endl;
+ if ( entry->nextSibling() ) kdDebug() << mIndent << " NEXT: "
+ << entry->nextSibling()->name() << endl;
+#endif
+ }
+
+ DocEntryTraverser *createChild( DocEntry * )
+ {
+ return new MyTraverser( mIndent + " " );
+ }
+
+ private:
+ QString mIndent;
+};
+
+class LinearTraverser : public DocEntryTraverser
+{
+ public:
+ void process( DocEntry *entry )
+ {
+ kdDebug() << "PROCESS: " << entry->name() << endl;
+ }
+
+ DocEntryTraverser *createChild( DocEntry * )
+ {
+ return this;
+ }
+
+ DocEntryTraverser *parentTraverser()
+ {
+ return this;
+ }
+
+ void deleteTraverser() {}
+};
+
+class AsyncTraverser : public DocEntryTraverser
+{
+ public:
+ AsyncTraverser( const QString &indent = "" ) : mIndent( indent )
+ {
+// kdDebug() << "AsyncTraverser()" << endl;
+ }
+
+ ~AsyncTraverser()
+ {
+// kdDebug() << "~AsyncTraverser()" << endl;
+ }
+
+ void process( DocEntry *entry )
+ {
+ kdDebug() << mIndent << entry->name() << endl;
+ }
+
+ DocEntryTraverser *createChild( DocEntry * )
+ {
+// kdDebug() << "AsyncTraverser::childTraverser()" << endl;
+ return new AsyncTraverser( mIndent + " " );
+ }
+
+ private:
+ QString mIndent;
+};
+
+int main(int argc,char **argv)
+{
+ KAboutData aboutData("testmetainfo","TestDocMetaInfo","0.1");
+ KCmdLineArgs::init(argc,argv,&aboutData);
+
+ KApplication app;
+
+ kdDebug() << "Scanning Meta Info" << endl;
+
+ QStringList langs;
+ langs << "en";
+// langs << "de";
+
+ DocMetaInfo::self()->scanMetaInfo( langs );
+
+ kdDebug() << "My TRAVERSE start" << endl;
+ MyTraverser t;
+ DocMetaInfo::self()->startTraverseEntries( &t );
+ kdDebug() << "My TRAVERSE end" << endl;
+
+ kdDebug() << "Linear TRAVERSE start" << endl;
+ LinearTraverser l;
+ DocMetaInfo::self()->startTraverseEntries( &l );
+ kdDebug() << "Linear TRAVERSE end" << endl;
+
+ kdDebug() << "Async TRAVERSE start" << endl;
+ AsyncTraverser a;
+ DocMetaInfo::self()->startTraverseEntries( &a );
+ kdDebug() << "Async TRAVERSE end" << endl;
+}
+// vim:ts=2:sw=2:et