1
/* This file is part of the KDE project
2
Copyright (C) 2002 Werner Trobin <trobin@kde.org>
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., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
23
#include <QPluginLoader>
25
#include "KoDocumentEntry.h"
26
#include "KoFilterEntry.h"
27
#include "KoFilterManager.h"
29
#include <MainDebug.h>
31
int main(int /*argc*/, char ** /*argv*/)
33
QByteArray output = "digraph filters {\n";
35
// The following code is shamelessly copied over from Calligra::Graph::buildGraph
36
// It wasn't feasible to do some serious changes in the lib for that tiny bit
37
// of duplicated code in a test file.
39
QList<QString> vertices; // to keep track of already inserted values, not performance critical
41
// Make sure that all available parts are added to the graph
42
const QList<KoDocumentEntry> parts(KoDocumentEntry::query());
43
QList<KoDocumentEntry>::ConstIterator partIt(parts.begin());
44
QList<KoDocumentEntry>::ConstIterator partEnd(parts.end());
46
while (partIt != partEnd) {
47
//kDebug() << ( *partIt ).service()->desktopEntryName();
48
QJsonObject metaData = (*partIt).metaData();
49
QStringList nativeMimeTypes = metaData.value("X-KDE-ExtraNativeMimeTypes").toString().split(',');
50
nativeMimeTypes += metaData.value("X-KDE-NativeMimeType").toString();
51
QStringList::ConstIterator it = nativeMimeTypes.constBegin();
52
QStringList::ConstIterator end = nativeMimeTypes.constEnd();
53
for (; it != end; ++it) {
55
//kDebug() <<"" << key;
58
output += key.toLatin1();
59
output += "\" [shape=box, style=filled, fillcolor=lightblue];\n";
60
if (! vertices.contains(key))
67
const QList<KoFilterEntry::Ptr> filters(KoFilterEntry::query()); // no constraint here - we want *all* :)
68
QList<KoFilterEntry::Ptr>::ConstIterator it = filters.begin();
69
QList<KoFilterEntry::Ptr>::ConstIterator end = filters.end();
71
for (; it != end; ++it) {
72
qDebug() << "import" << (*it)->import << " export" << (*it)->export_;
73
// First add the "starting points"
74
QStringList::ConstIterator importIt = (*it)->import.constBegin();
75
QStringList::ConstIterator importEnd = (*it)->import.constEnd();
76
for (; importIt != importEnd; ++importIt) {
78
if (! vertices.contains(*importIt)) {
79
vertices.append(*importIt);
81
output += (*importIt).toLatin1();
86
QStringList::ConstIterator exportIt = (*it)->export_.constBegin();
87
QStringList::ConstIterator exportEnd = (*it)->export_.constEnd();
89
for (; exportIt != exportEnd; ++exportIt) {
90
// First make sure the export vertex is in place
91
if (! vertices.contains(*exportIt)) {
93
output += (*exportIt).toLatin1();
95
vertices.append(*exportIt);
97
// Then create the appropriate edges
98
importIt = (*it)->import.constBegin();
99
for (; importIt != importEnd; ++importIt) {
101
output += (*importIt).toLatin1();
102
output += "\" -> \"";
103
output += (*exportIt).toLatin1();
104
if (KoFilterManager::filterAvailable(*it))
107
output += "\" [style=dotted];\n";
114
QFile f("graph.dot");
115
if (f.open(QIODevice::WriteOnly))